/* PHWO mobile layer (1 Oct 2026)
   Responsive fixes only - no redesign. Loaded after the theme sheet on every
   front-end page. Audit + reasons: phwo-mobile/PROGRESS.md. */

/* ---- 1. No sideways scroll ------------------------------------------------ */
html, body { max-width: 100%; }
@supports (overflow: clip) { html, body { overflow-x: clip; } }
img, video, iframe, embed, object { max-width: 100%; }
img, video { height: auto; }
.entry-content, .phwo-content, .phwo-form, .phwo-public-form { overflow-wrap: anywhere; }

/* The footer link lists are a one-track grid; the track took the width of its
   longest link ("Rishta Desk FREE") and pushed the page to 385px on a 360px
   phone. The track may now shrink and long links wrap. */
.phwo-footer-col, .phwo-footer-col ul { min-width: 0; }
.phwo-footer-col ul { grid-template-columns: minmax(0, 1fr); }
.phwo-footer-col ul a { white-space: normal; max-width: 100%; }

/* Tables that are not already wrapped scroll inside their own box
   (mobile.js adds the wrapper). */
.phwo-table-wrap { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.phwo-table-wrap > table { min-width: 100%; }

@media (max-width: 860px) {

	/* ---- 2. Form fields: 16px text (no iOS zoom), full width ------------- */
	html body input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="submit"]):not([type="button"]):not([type="hidden"]),
	html body select,
	html body textarea {
		font-size: 16px !important;
		max-width: 100%;
	}
	.phwo-form input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]),
	.phwo-form select, .phwo-form textarea,
	.phwo-public-form input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]),
	.phwo-public-form select, .phwo-public-form textarea,
	.phwo-acct input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]),
	.phwo-acct select, .phwo-acct textarea {
		width: 100%;
		min-height: 48px;
		box-sizing: border-box;
	}
	.phwo-form textarea, .phwo-public-form textarea { min-height: 110px; }
	.phwo-checkgrid { grid-template-columns: repeat(auto-fit, minmax(min(250px, 100%), 1fr)); }
	.phwo-check { min-height: 44px; }
	.phwo-check input[type="checkbox"], .phwo-check input[type="radio"] { width: 20px; height: 20px; flex: 0 0 auto; }

	/* File and camera inputs: a big, obvious tap area. */
	.phwo-form input[type="file"], .phwo-public-form input[type="file"] {
		width: 100%;
		min-height: 56px;
		padding: 14px 12px;
		font-size: 15px !important;
		line-height: 1.3;
	}
	input[type="file"]::file-selector-button {
		min-height: 40px;
		padding: 8px 14px;
		margin-right: 10px;
		border: 0;
		border-radius: 5px;
		background: #0D5C63;
		color: #fff;
		font: inherit;
		font-weight: 600;
	}
	[data-phwo-live] button, [data-live-box] button { min-height: 48px; }
	[data-live-box] video { width: 100%; max-height: 60vh; object-fit: cover; border-radius: 5px; }
	[data-preview] img { max-width: 100%; height: auto; }

	/* Buttons: full width and 48px tall. */
	.phwo-form [type="submit"], .phwo-public-form [type="submit"], .phwo-submit,
	.phwo-newsletter-fields button {
		width: 100%;
		min-height: 48px;
		font-size: 16px;
	}

	/* ---- 3. Step-by-step forms ------------------------------------------ */
	.phwo-progress ol { gap: 4px; }
	.phwo-progress li { min-width: 0; overflow-wrap: anywhere; hyphens: auto; line-height: 1.25; }
	/* Next/Back stay reachable at the foot of a long step. */
	.phwo-stepper.is-stepped .phwo-stepnav {
		position: sticky;
		bottom: 0;
		z-index: 20;
		margin: 20px -12px 0;
		padding: 10px 12px;
		padding-bottom: max(10px, env(safe-area-inset-bottom));
		background: rgba(255, 255, 255, .97);
		border-top: 1px solid #dde5e6;
		box-shadow: 0 -4px 14px rgba(20, 38, 43, .06);
		flex-wrap: nowrap;
	}
	.phwo-stepnav .phwo-back { flex: 0 0 auto; }
	.phwo-stepnav .phwo-next, .phwo-stepnav .phwo-submit, .phwo-stepnav [type="submit"] { flex: 1 1 auto; width: auto; }
	/* Errors sit next to the field and are never hidden under the header. */
	.phwo-field, .phwo-err-msg, [data-min], .phwo-notice { scroll-margin-top: 110px; scroll-margin-bottom: 90px; }
	.phwo-field.is-invalid::after {
		content: attr(data-err);
		display: block;
		margin-top: 4px;
		color: #b42318;
		font-size: 14px;
		font-weight: 600;
	}
	.phwo-field.is-invalid:not([data-err])::after { content: none; }

	/* ---- 4. Tap targets (44px) ------------------------------------------ */
	.phwo-footer-col ul { gap: 0; }
	.phwo-footer-col ul a { display: inline-flex; align-items: center; min-height: 44px; padding-top: 4px; padding-bottom: 4px; }
	.phwo-footer-col ul a.phwo-footer-rishta { display: block !important; white-space: normal !important; min-height: 44px; padding-top: 11px; padding-bottom: 11px; }
	.phwo-legal-menu a, .phwo-footer-bottom a, .phwo-footer-contact a { display: inline-flex; align-items: center; min-height: 44px; }
	.phwo-nav-more { width: 44px !important; height: 44px !important; top: 4px !important; }
	.phwo-nav-list a { min-height: 44px; }
	.phwo-footer-col ul a.phwo-footer-rishta em { position: static !important; transform: none !important; margin: 0 0 0 .3rem !important; display: inline-block !important; }
	.phwo-crumbs a, .phwo-lc-crumbs a { display: inline-block; padding: 12px 0; margin: -12px 0; }
	.phwo-toc a, .phwo-about-links a { display: inline-block; padding: 10px 0; }
	.phwo-toc li { margin: 0; }
	.phwo-lc-src { display: inline-block; padding: 12px 6px; margin: -12px -6px; }
	.phwo-lc-prov h2 a { display: inline-block; padding: 6px 0; }
	a.phwo-cta, a.phwo-cta-footer, .phwo-badge { min-height: 44px; display: inline-flex; align-items: center; }
	.phwo-lang-pill a { min-height: 40px; display: inline-flex; align-items: center; }
	/* Top bar links keep their slim look but get a 44px hit area. */
	.phwo-topbar a { position: relative; }
	.phwo-topbar a::after { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 44px; transform: translateY(-50%); }

	/* ---- 5. Floating buttons: safe areas and never over a form ---------- */
	.phwo-wa-float { left: max(14px, env(safe-area-inset-left)) !important; margin-bottom: env(safe-area-inset-bottom); }
	.phwo-assist:not(.is-open) { right: max(14px, env(safe-area-inset-right)); margin-bottom: env(safe-area-inset-bottom); }
	body .phwo-lang-pill { margin-bottom: env(safe-area-inset-bottom); }
	.phwo-wa-float, .phwo-assist:not(.is-open), body .phwo-lang-pill, .phwo-stickybar {
		transition: opacity .18s ease, transform .22s ease, visibility .18s;
	}
	/* mobile.js sets this while a form is being filled or its buttons are on
	   screen, so nothing floats over a field or a submit button. */
	body.phwo-floats-off .phwo-wa-float,
	body.phwo-floats-off .phwo-assist:not(.is-open),
	body.phwo-floats-off .phwo-lang-pill,
	body.phwo-floats-off .phwo-stickybar {
		opacity: 0 !important;
		visibility: hidden !important;
		pointer-events: none !important;
	}
	/* The language pill only shows near the top or when scrolling up, so it
	   does not sit over the text people are reading. */
	body.phwo-scroll-down .phwo-lang-pill { opacity: 0; visibility: hidden; pointer-events: none; }
	/* Room at the very end of the page for the floating buttons. */
	.phwo-footer { padding-bottom: calc(90px + env(safe-area-inset-bottom)) !important; }

	/* ---- 6. Media and hero ---------------------------------------------- */
	.phwo-hero h1, .phwo-page-hero h1, .entry-title { overflow-wrap: break-word; hyphens: auto; }
	.entry-content .wp-block-image img, .entry-content figure img { width: 100%; height: auto; }
	.entry-content figure { max-width: 100%; margin-left: 0; margin-right: 0; }
	.entry-content pre { overflow-x: auto; white-space: pre-wrap; }
}

@media (max-width: 640px) {
	/* Two short buttons side by side are fine; anything else stacks. */
	.phwo-stepnav .phwo-back { padding-left: 14px; padding-right: 14px; }
	.phwo-cta-row, .phwo-hero-actions { flex-wrap: wrap; }
	.phwo-cta-row > a, .phwo-hero-actions > a { flex: 1 1 100%; justify-content: center; text-align: center; }

	/* Donation and account lists read as cards when a table is marked as
	   stackable (mobile.js copies each column heading into data-label). */
	table.phwo-stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
	table.phwo-stack, table.phwo-stack tbody, table.phwo-stack tr, table.phwo-stack td { display: block; width: 100%; }
	table.phwo-stack tr { margin: 0 0 12px; padding: 10px 12px; border: 1px solid #dde5e6; border-radius: 5px; background: #fff; }
	table.phwo-stack td { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border: 0; border-bottom: 1px dashed #e6eeee; text-align: end; }
	table.phwo-stack td:last-child { border-bottom: 0; }
	table.phwo-stack td[data-label]::before { content: attr(data-label); font-weight: 600; color: #33454a; text-align: start; flex: 0 0 auto; max-width: 50%; }
}

/* ---- 7. Urdu / RTL ---------------------------------------------------------- */
@media (max-width: 860px) {
	[dir="rtl"] .phwo-footer-col ul a, body.phwo-ur .phwo-footer-col ul a { padding-left: 0; }
	body.phwo-ur .phwo-stepnav .phwo-next, body.phwo-ur .phwo-stepnav .phwo-submit { margin-left: 0; margin-right: auto; }
	body.phwo-ur input[type="tel"], body.phwo-ur input[type="email"], body.phwo-ur input[inputmode="numeric"] { direction: ltr; text-align: right; }
}

@media (prefers-reduced-motion: reduce) {
	.phwo-wa-float, .phwo-assist, .phwo-lang-pill, .phwo-stickybar { transition: none; }
}
