/* =============================================================================
   COOKIE CONSENT -- banner + preferences modal
   Uses design tokens from style.css (:root). First-party CMP.
   ============================================================================= */

/* Banner --------------------------------------------------------------------- */

.hz-cc {
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 9999;
	background: var(--hz-bg-surface);
	border-top: 1px solid var(--hz-border);
	box-shadow: var(--hz-shadow-lg);
	color: var(--hz-text);
	font-family: var(--hz-font-body);
}

.hz-cc[hidden] { display: none; }

.hz-cc__inner {
	max-width: var(--hz-content-max);
	margin: 0 auto;
	padding: 1.25rem 1.5rem;
	display: flex;
	align-items: center;
	gap: 1.5rem;
	flex-wrap: wrap;
}

.hz-cc__copy { flex: 1 1 420px; min-width: 0; }

.hz-cc__title {
	margin: 0 0 0.35rem;
	font-family: var(--hz-font-display);
	font-size: var(--hz-text-xl);
	font-weight: 600;
	color: var(--hz-text);
}

.hz-cc__text {
	margin: 0;
	font-size: var(--hz-text-sm);
	line-height: 1.6;
	color: var(--hz-text-muted);
}

.hz-cc__text a,
.hz-cc-modal a {
	color: var(--hz-primary-light);
	text-decoration: underline;
}

.hz-cc__actions {
	display: flex;
	gap: 0.6rem;
	flex-wrap: wrap;
	align-items: center;
}

/* Banner variants (HORIZON-20261117-003): hz-consent.js shows "consent" or "notice" by setting
   [hidden]; the display rules above would otherwise override it. */
.hz-cc [data-hz-variant][hidden],
.hz-cc-modal [data-hz-variant][hidden] { display: none; }

/* Buttons (shared) ----------------------------------------------------------- */

.hz-cc__btn {
	appearance: none;
	cursor: pointer;
	border-radius: 0; /* house style: sharp corners */
	font-family: var(--hz-font-body);
	font-size: var(--hz-text-sm);
	font-weight: 600;
	padding: 0.7rem 1.25rem;
	line-height: 1;
	transition: background var(--hz-transition), border-color var(--hz-transition), color var(--hz-transition);
}

.hz-cc__btn--primary {
	background: var(--hz-primary);
	border: 1px solid var(--hz-primary);
	color: #00171a;
}

.hz-cc__btn--primary:hover { background: var(--hz-primary-light); border-color: var(--hz-primary-light); }

.hz-cc__btn--ghost {
	background: transparent;
	border: 1px solid var(--hz-border);
	color: var(--hz-text);
}

.hz-cc__btn--ghost:hover { border-color: var(--hz-primary); color: var(--hz-primary-light); }

.hz-cc__btn:focus-visible,
.hz-cookie-settings:focus-visible {
	outline: 2px solid var(--hz-primary-light);
	outline-offset: 2px;
}

/* Modal ---------------------------------------------------------------------- */

.hz-cc-modal {
	position: fixed;
	inset: 0;
	z-index: 10000;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 1.5rem;
}

.hz-cc-modal[hidden] { display: none; }

.hz-cc-modal__backdrop {
	position: absolute;
	inset: 0;
	background: var(--hz-bg-overlay);
}

.hz-cc-modal__panel {
	position: relative;
	width: 100%;
	max-width: 560px;
	max-height: 90vh;
	overflow-y: auto;
	background: var(--hz-bg-surface);
	border: 1px solid var(--hz-border);
	border-radius: 0; /* house style: sharp corners */
	box-shadow: var(--hz-shadow-lg);
	padding: 1.75rem;
	color: var(--hz-text);
	font-family: var(--hz-font-body);
}

.hz-cc-modal__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 0.75rem;
}

.hz-cc-modal__title {
	margin: 0;
	font-family: var(--hz-font-display);
	font-size: var(--hz-text-2xl);
	font-weight: 600;
}

.hz-cc-modal__close {
	appearance: none;
	background: transparent;
	border: 0;
	color: var(--hz-text-muted);
	font-size: 1.75rem;
	line-height: 1;
	cursor: pointer;
	padding: 0.25rem 0.5rem;
}

.hz-cc-modal__close:hover { color: var(--hz-text); }

.hz-cc-modal__intro {
	margin: 0 0 1rem;
	font-size: var(--hz-text-sm);
	line-height: 1.6;
	color: var(--hz-text-muted);
}

.hz-cc-gpc {
	margin: 0 0 1.25rem;
	padding: 0.85rem 1rem;
	border: 1px solid var(--hz-border-primary);
	border-radius: 0; /* house style: sharp corners */
	background: var(--hz-primary-alpha-10);
	font-size: var(--hz-text-sm);
	line-height: 1.55;
	color: var(--hz-text);
}

.hz-cc-gpc[hidden] { display: none; }

/* Category rows -------------------------------------------------------------- */

.hz-cc-cat {
	padding: 1rem 0;
	border-top: 1px solid var(--hz-border-alpha);
}

.hz-cc-cat__row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
}

.hz-cc-cat__label { display: flex; align-items: baseline; gap: 0.6rem; flex-wrap: wrap; }

.hz-cc-cat__name {
	font-size: var(--hz-text-base);
	font-weight: 600;
	color: var(--hz-text);
}

.hz-cc-cat__always {
	font-size: var(--hz-text-xs);
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var(--hz-primary-light);
}

.hz-cc-cat__desc {
	margin: 0.5rem 0 0;
	font-size: var(--hz-text-sm);
	line-height: 1.55;
	color: var(--hz-text-muted);
}

/* Toggle switch -------------------------------------------------------------- */

.hz-cc-switch {
	position: relative;
	flex: 0 0 auto;
	width: 44px;
	height: 24px;
	display: inline-block;
}

.hz-cc-switch input {
	position: absolute;
	opacity: 0;
	width: 100%;
	height: 100%;
	margin: 0;
	cursor: pointer;
}

.hz-cc-switch__track {
	position: absolute;
	inset: 0;
	background: var(--hz-bg-raised);
	border: 1px solid var(--hz-border);
	border-radius: var(--hz-radius-full);
	transition: background var(--hz-transition), border-color var(--hz-transition);
	pointer-events: none;
}

.hz-cc-switch__track::before {
	content: "";
	position: absolute;
	top: 50%;
	left: 3px;
	transform: translateY(-50%);
	width: 16px;
	height: 16px;
	border-radius: 50%;
	background: var(--hz-text-muted);
	transition: transform var(--hz-transition), background var(--hz-transition);
}

.hz-cc-switch input:checked + .hz-cc-switch__track {
	background: var(--hz-primary);
	border-color: var(--hz-primary);
}

.hz-cc-switch input:checked + .hz-cc-switch__track::before {
	transform: translateY(-50%) translateX(20px);
	background: #00171a;
}

.hz-cc-switch input:focus-visible + .hz-cc-switch__track {
	outline: 2px solid var(--hz-primary-light);
	outline-offset: 2px;
}

.hz-cc-switch--locked { opacity: 0.85; }
.hz-cc-switch--locked input { cursor: not-allowed; }

/* Modal actions -------------------------------------------------------------- */

.hz-cc-modal__actions {
	display: flex;
	gap: 0.6rem;
	flex-wrap: wrap;
	justify-content: flex-end;
	margin-top: 1.5rem;
	padding-top: 1.25rem;
	border-top: 1px solid var(--hz-border-alpha);
}

/* Footer "Cookie settings" trigger styled like a footer link ----------------- */

.hz-cookie-settings {
	appearance: none;
	background: none;
	border: 0;
	padding: 0;
	cursor: pointer;
	font: inherit;
	color: inherit;
	text-align: left;
}

/* Match footer link styling when used inside the footer Legal column */
.hz-footer .hz-footer__col ul li button.hz-cookie-settings {
	font-family: var(--hz-font-body);
	font-size: var(--hz-text-sm);
	color: var(--hz-text-muted);
	line-height: 1.4;
	transition: color var(--hz-transition);
}

.hz-footer .hz-footer__col ul li button.hz-cookie-settings:hover {
	color: var(--hz-text);
}

body.hz-cc-open { overflow: hidden; }

/* Responsive ----------------------------------------------------------------- */

/* Mobile ---------------------------------------------------------------------
   RC-016 (HORIZON-20260910-011). Measured 2026-09-10 the banner stood 294.9px tall,
   36.3% of a 375x812 fold, with its top edge at y=517 and BOTH hero CTAs
   ("Book a Call" y=669-719, "Start Free" y=735-785) entirely inside it. RC-016's PASS
   condition is "primary CTA bounding box inside the fold with the banner present", so
   the banner was not merely large, it was covering the route that bills.

   Two changes, and neither touches the consent system itself. The full first-layer text,
   the Cookie Policy link and all three button labels are unchanged, because shortening
   "Reject non-essential" or demoting it to the modal would trade a layout defect for a
   compliance one: rejecting must stay one click at the first layer and as prominent as
   accepting.

     1. TIGHTEN. Smaller type and padding bring the three buttons onto ONE row, which is
        where most of the height went. 294.9px -> 149.3px, 36.3% -> 18.4%.
     2. RESERVE. The banner is position:fixed, so it cannot reflow the page. `:has()` lets
        the hero react to it with no JS at all: while #hz-cc is not [hidden], the hero
        reserves bottom padding and the copy and CTAs sit above the banner.
        ⚠️ SUPERSEDED IN PART by HORIZON-20260919-006 - see "The RESERVE, corrected" below.
        This shipped as `.hz-hero__actions { padding-bottom }` at `max-width: 640px`, which
        matched nothing on the two pages that pass no `actions`, and stopped 220px short of
        the hero's own 860px breakpoint. The reserve now sits on `.hz-hero__grid` at 860px.
        ⛔ The TIGHTEN half below is untouched and still correct.

   ⛔ Do NOT re-tune this by eye or by the coverage percentage. A banner can shrink from
   36% to 20% and still sit squarely on the button, so `consentOverlay.coversFoldPct` is
   NOT the acceptance test. Re-measure with the probe, which reports the actual overlap:
     node docs/seo-war-room/scripts/cmp-cta-overlap.mjs --url <url>
   Verified primary-CTA-clear at 320/360/375/414 wide and 667/740/812 tall. ⚠️ Recorded
   residual: the SECONDARY CTA is still covered at 320 wide and at 667 tall. The primary
   is the acceptance bar; the secondary is not, and chasing it would push the H1 off the
   top on the shortest viewports.
   ---------------------------------------------------------------------------- */
@media ( max-width: 640px ) {
	.hz-cc__inner { flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: 0.45rem; padding: 0.6rem 0.85rem; }
	.hz-cc__copy { flex: 0 0 auto; }
	.hz-cc__title { font-size: 0.9rem; margin: 0 0 0.1rem; }
	.hz-cc__text { font-size: 0.72rem; line-height: 1.4; }
	.hz-cc__actions { justify-content: flex-start; gap: 0.35rem; }
	.hz-cc__actions .hz-cc__btn { flex: 1 1 auto; text-align: center; padding: 0.55rem 0.4rem; font-size: 0.74rem; }

	.hz-cc-modal__actions { justify-content: flex-start; }
	.hz-cc-modal__actions .hz-cc__btn { flex: 1 1 auto; text-align: center; }
}

/* The RESERVE, corrected (HORIZON-20260919-006) -------------------------------
   RC-016's reserve above was `.hz-hero__actions { padding-bottom: 33vh }` inside
   `@media (max-width: 640px)`. It worked wherever it applied. It had two gaps, and both
   are the same mistake: THE RESERVE'S CONDITIONS DID NOT MATCH THE LAYOUT'S CONDITIONS.

     1. IT HUNG OFF AN OPTIONAL ELEMENT. `hz_render_hero()` takes `actions` and /about/
        and /client/ pass none, so `.hz-hero__actions` is not in the DOM on those pages
        and the rule matched nothing. Measured at 390x844: the sub-copy sat at y=692-800
        against a banner whose top edge is y=695, so the entire hero paragraph was behind
        the banner on a first visit - on two nav-level pages, neither of which has a CTA
        either, leaving a headline and a cookie dialogue.
     2. IT STOPPED AT 640px. The hero's phone layout - `.hz-hero--copy-bottom`, which is
        `align-content: end` against a `100svh` grid - runs to 860px. Between 641 and 860
        the copy was still bottom-pinned with nothing reserved. Measured at 768x1024 the
        banner is 210px and BOTH the h1 and the sub were behind it.

   So the reserve now sits on `.hz-hero__grid`, at the hero's own breakpoint:

   - ON THE GRID, not the copy or the actions. The grid always exists, so no page can opt
     out of it by omitting a part. ⛔ It must NOT go on `.hz-hero__copy`: that element
     carries the contrast scrim (`::before`, inset -28px -24px, HORIZON-20260919-002), and
     padding there would stretch the scrim 33vh below the text as a dark slab.
   - `border-box` means the grid's `min-height` includes padding, so a larger
     padding-bottom shrinks the content box and the end-aligned content rises by exactly
     that much. This is why it lifts the copy rather than just making the hero taller.
   - 33vh against the 32vh ceiling below, so the reserve is provably a full viewport
     percent clear of the tallest the banner may be. The ceiling moved out of the 640px
     block with it - at 768 the banner measures 210px (20.5vh) so it is inert there today,
     and it must stay paired with the reserve or that guarantee is lost.

   Measured, banner present, occlusion by elementFromPoint at each element's own centre:
   fixed at 390x844, 390x667, 768x1024, 360x740 and 414x896. /client/ is fixed at 320x568
   too, and nothing regressed anywhere.

   ⚠️ RECORDED RESIDUAL, unchanged by this and pre-existing: at 320x568 /about/'s sub and
   both stores' CTAs are still covered, and the secondary CTA is still covered at 360x740
   and 390x667. A 568px viewport leaves ~281px for the whole hero once the header and a
   32vh banner are taken, which the four-line H1 alone does not fit in. RC-016 declined to
   chase this for the same reason - it would push the H1 off the top - and that still holds.

   ⛔ Do NOT re-tune by eye or by coverage percentage; a banner can shrink and still sit on
   the text. Re-measure:
     node docs/research/hero-handset-review-2026-09-16/cmp-reserve.mjs --width 390 --height 844 \
       about=https://dev.automatehorizon.com/about/
   ---------------------------------------------------------------------------- */
@media ( max-width: 860px ) {
	/* A hard ceiling, so the banner can never exceed the space the hero reserves for it.
	   If a device ever needs more, it scrolls inside the banner rather than growing over
	   the copy. */
	.hz-cc { max-height: 32vh; overflow-y: auto; }

	/* `.hz-cc-pending` (set in <head>, HORIZON-20260925-003) applies the reserve from the FIRST
	   paint. :has() alone only matched once the footer banner was parsed and un-hidden, so the
	   copy painted low and then jumped up: CLS 0.26-0.28 on first visits. Both selectors stay. */
	.hz-cc-pending .hz-hero--copy-bottom .hz-hero__grid,
	body:has( #hz-cc:not([hidden]) ) .hz-hero--copy-bottom .hz-hero__grid {
		/* 1.5rem is the phone grid's own padding-bottom; the reserve is added to it. */
		padding-bottom: calc(1.5rem + 33vh);
	}
}
