/**
 * Small-screen corrections.
 *
 * Loaded last, sitewide. Everything here exists for one reason: the site
 * carries eleven years of pasted markup — hand-written tables, images with
 * width attributes, embedded maps, page-builder sections with fixed pixel
 * widths — and any one of those can push the document wider than the screen.
 * A single overflowing element makes every page on the phone scroll sideways,
 * which is both the most common mobile usability failure and one Google
 * measures directly.
 *
 * The rules are defensive rather than decorative. They constrain what the
 * content can do; they do not restyle it.
 */

/* ==========================================================================
   Document-level containment
   ========================================================================== */

/*
 * "clip" rather than "hidden" is deliberate.
 *
 * overflow-x: hidden on <body> turns the body into a scroll container, and a
 * scroll container between a position: sticky element and the viewport stops
 * the stickiness working — which would silently break the consultation card on
 * every article. overflow-x: clip prevents the sideways scroll without
 * creating a scroll container, so the card still sticks.
 *
 * The hidden declaration stays first as the fallback for anything that does
 * not support clip.
 */
html,
body {
	overflow-x: hidden;
}

@supports (overflow: clip) {
	html,
	body {
		overflow-x: clip;
	}
}

body {
	max-width: 100%;
}

/* Long unbroken strings — company numbers, URLs pasted as text, sort codes —
   wrap instead of setting the page width. */
body,
.entry-content,
.lpa-article__body,
.lpa-panel,
.lpa-cardpage {
	overflow-wrap: break-word;
}

/* ==========================================================================
   Media and embeds
   ========================================================================== */

img,
video,
canvas {
	max-width: 100%;
	height: auto;
}

/* Inline icons are sized by their own width/height attributes; only the
   ceiling is imposed, never the height. */
svg {
	max-width: 100%;
}

iframe,
embed,
object {
	max-width: 100%;
}

/* Maps and video embeds pasted with width="600" height="450". */
.entry-content iframe,
.lpa-article__body iframe,
.lpa-cardpage iframe {
	width: 100%;
}

/* ==========================================================================
   Tables
   ========================================================================== */

/*
 * A table with more columns than the screen can hold has to scroll inside its
 * own box. Making it a block with overflow-x gives it that scrollport without
 * needing a wrapper element around markup we do not control: the rows and cells
 * still lay out as a table inside the anonymous table box the block generates.
 *
 * Scoped to the content area rather than .entry-content, because the page
 * builder renders its widgets outside that wrapper — the pricing tables on the
 * package pages live in .elementor-widget-container and were the one thing on
 * the site still forcing a 570px document on a 320px screen.
 */
.site-content table {
	display: block;
	width: 100%;
	max-width: 100%;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
}

/* A scrollable table needs to look scrollable. */
@media (max-width: 782px) {
	.site-content table {
		scrollbar-width: thin;
	}
}

/* ==========================================================================
   Legacy and builder markup
   ========================================================================== */

/*
 * Widths written straight into the markup as attributes or inline styles.
 * These are the single most common source of sideways scroll on this site.
 */
[width],
[style*="width:"],
[style*="width :"] {
	max-width: 100%;
}

/* Class names inherited from the pre-builder pages, still present inside
   Elementor HTML widgets on the posts and the contact page. */
.entry-content .container,
.lpa-article__body .container,
.lpa-cardpage .container {
	width: auto;
	max-width: 100%;
	margin-inline: 0;
}

.lpa-article__body .hero,
.lpa-article__body .section {
	padding-inline: 0;
}

/* Elementor columns must be allowed to shrink below their content width. */
.elementor-column,
.elementor-widget-wrap,
.elementor-widget-container {
	min-width: 0;
	max-width: 100%;
}

/*
 * Top bar contact row.
 *
 * At 320px the support badges, the phone link and the contact link measured
 * 292px against a 288px content box — a four-pixel overhang that was enough to
 * make the whole document scroll sideways. It has to be allowed to wrap.
 */
.lpa-topbar__contact {
	flex-wrap: wrap;
	min-width: 0;
	max-width: 100%;
	row-gap: 0.35rem;
}

.lpa-topbar__contact > * {
	min-width: 0;
}

@media (max-width: 480px) {
	.lpa-topbar__contact {
		gap: 0.35rem 0.75rem;
	}

	/* The bar is a utility strip; the availability claims repeat in the hero. */
	.lpa-topbar .lpa-support--bar {
		width: 100%;
	}
}

/* Grid and flex children default to min-width:auto, which lets a wide child
   stretch the track. */
.lpa-postgrid > *,
.lpa-panels > *,
.lpa-channels > *,
.lpa-single__wrap > *,
.lpa-localtrust__grid > * {
	min-width: 0;
}

/* ==========================================================================
   Phones: 320px to 414px
   ========================================================================== */

@media (max-width: 480px) {
	/* Full-bleed bands must measure against the same 100% the body does; on a
	   phone with no scrollbar 100vw and 100% agree, but the negative margin
	   still needs the clip above to be safe on desktop. */
	.lpa-pagehero,
	.lpa-pageoutro,
	.lpa-localtrust,
	.lpa-articlehero,
	.lpa-home {
		padding-inline: 16px;
	}

	/* A call to action the thumb can hit without aiming. */
	.lpa-pagehero__actions .lpa-btn,
	.lpa-pageoutro__actions .lpa-btn,
	.lpa-article-cta__actions .lpa-btn,
	.lpa-localtrust__call .lpa-btn {
		flex: 1 1 100%;
		justify-content: center;
		min-height: 48px;
	}

	/* Headline sizes that clamp against vw can still overshoot at 320px. */
	.lpa-articlehero__title {
		font-size: clamp(1.45rem, 7vw, 2rem);
	}

	.lpa-pagehero__title {
		font-size: clamp(1.5rem, 7.5vw, 2.1rem);
	}

	/* Cards lose their side padding before they lose their content. */
	.lpa-article__body,
	.lpa-panel,
	.lpa-formcard,
	.lpa-cardpage .elementor-top-section {
		padding-inline: 16px;
	}

	.lpa-postcard__body {
		padding: 1rem 1.05rem 1.15rem;
	}

	/* Two-up meta rows stack rather than squeeze. */
	.lpa-nap__row,
	.lpa-postnav {
		grid-template-columns: 1fr;
	}

	.lpa-postnav__link--next {
		text-align: left;
	}

	/* The switcher's pill track is the intended horizontal scroller; make sure
	   nothing around it inherits that. */
	.lpa-locswitch {
		padding: 0.8rem;
	}

	/* Pagination wraps to as many rows as it needs. */
	.lpa-pagination ul {
		gap: 0.3rem;
	}
}

/* The narrowest phones still in use. */
@media (max-width: 360px) {
	:root {
		--lpa-gap: 1rem;
	}

	.lpa-articlehero__meta {
		font-size: 0.78rem;
	}

	.lpa-cred,
	.lpa-channel {
		padding: 0.9rem 1rem;
	}
}

/* ==========================================================================
   Touch targets and form controls
   ========================================================================== */

/*
 * The top bar is a dense utility strip, so its links are not 48px tall and
 * should not be — but they measured 22px, under the 24px minimum WCAG 2.5.8
 * sets for a target that is not inline in a sentence.
 */
@media (max-width: 782px) {
	.lpa-topbar__link,
	.lpa-topbar__contact a {
		min-height: 28px;
		padding-block: 0.3rem;
	}
}

@media (pointer: coarse) {
	.lpa-btn,
	.lpa-home__btn,
	.lpa-sidecard__btn,
	.lpa-postcard__link,
	.lpa-locswitch__pill,
	.wpcf7 input[type="submit"],
	.wpcf7 button[type="submit"] {
		min-height: 48px;
	}
}

/*
 * iOS zooms the whole page in when a focused control's text is under 16px, and
 * the layout does not always zoom back out afterwards. Sizing the controls at
 * 16px is the fix.
 */
@media (max-width: 782px) {
	.wpcf7 input[type="text"],
	.wpcf7 input[type="email"],
	.wpcf7 input[type="tel"],
	.wpcf7 input[type="number"],
	.wpcf7 input[type="date"],
	.wpcf7 select,
	.wpcf7 textarea {
		width: 100%;
		max-width: 100%;
		font-size: 16px;
	}
}
