/* =====================================================================
   SITE SHELL — header, responsive nav, footer, crisis box, WhatsApp.
   Loaded on every page (base.njk). Mobile-first: the drawer is the
   default; the inline nav + dropdown take over from 1280px (the real IA has
   6 links + a button, so it needs more room than the mockup's 4).
   Look = the approved HTML pack (reference/mockup), #1001659.
   Values come from tokens.css only.
   ===================================================================== */

/* ---- Skip link ---- */
.skip-link {
  position: absolute; left: var(--space-s); top: -100px; z-index: var(--z-skip);
  padding: var(--space-2xs) var(--space-s);
  background: var(--color-primary); color: var(--color-on-primary);
  border-radius: var(--radius-sm);
}
.skip-link:focus { top: var(--space-s); color: var(--color-on-primary); }

/* ---- Wordmark (text logo until #1001621 decides on a designed one) ---- */
.wordmark {
  font-family: var(--font-serif);
  font-size: clamp(1.2rem, 1.05rem + 0.6vw, 1.625rem);
  line-height: 1.1;
  color: var(--color-heading);
  text-decoration: none;
  letter-spacing: -0.01em;
}

/* =====================================================================
   HEADER
   ===================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  border-bottom: var(--border-w) solid var(--color-border);
}
/* Solid ivory bar as in the mockup. Background on a pseudo-element (never
   backdrop-filter on the header: it would trap the fixed drawer inside). */
.site-header::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--color-header-bg);
}
.site-header__inner {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  min-height: var(--header-h);
}

/* Wordmark sits on two lines on a phone so Book + Menu still fit at 360px */
.site-header__brand { display: block; margin-right: auto; font-size: 1.1875rem; }
.site-header__brand .wordmark__title > span { display: block; }
@media (min-width: 600px) {
  .site-header__brand { font-size: clamp(1.2rem, 1.05rem + 0.6vw, 1.625rem); }
  .site-header__brand .wordmark__title > span { display: inline; }
}
/* Small caps name line under the wordmark (Mike, #1001702) — eyebrow styling */
.wordmark__title { display: block; }
.wordmark__sub {
  display: block;
  margin-top: 0.3em;
  font-family: var(--font-body);
  font-size: 0.6875rem;
  line-height: 1;
  font-weight: var(--weight-semi);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}
@media (max-width: 599px) { .wordmark__sub { font-size: 0.75rem; } } /* 11 → 12 on phones (#1001707) */
/* Brian's title under his name (#1002123). Sentence case, no tracking, so the
   long title stays within the wordmark's width. Phones skip it: the 72px bar
   can't take a fourth line, and the hero H1 carries the title right below. */
.wordmark__role {
  display: block;
  margin-top: 0.35em;
  font-family: var(--font-body);
  font-size: 0.75rem;
  line-height: 1.2;
  font-weight: var(--weight-medium);
  color: var(--color-text-muted);
}
@media (max-width: 599px) { .wordmark__role { display: none; } }

.site-header__book {
  flex-shrink: 0;
  min-height: 44px;
  padding-inline: var(--space-s);
  white-space: nowrap;
}
.site-header__book[aria-current="page"] { border-color: var(--color-primary); }
/* Phone: shows "Book", screen readers still hear "Book a free call" */
.site-header__book-long {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
@media (min-width: 600px) {
  .site-header__book { padding-inline: var(--space-m); }
  .site-header__book-short { display: none; }
  .site-header__book-long { position: static; width: auto; height: auto; overflow: visible; clip: auto; }
}

/* ---- Menu button ---- */
.nav-toggle {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2xs);
  min-height: 44px;
  min-width: 44px;
  padding: 0 var(--space-xs);
  background: transparent;
  border: var(--border-w) solid var(--color-border-strong);
  border-radius: var(--radius-md);
  color: var(--color-heading);
  font-size: var(--step--1);
  font-weight: var(--weight-semi);
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
}
.nav-toggle[hidden] { display: none; }
/* Below 600px the label is visually hidden, not display:none, so the button
   keeps its accessible name "Menu" (Lighthouse button-name, #1001627). */
.nav-toggle__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (min-width: 600px) { .nav-toggle__label { position: static; width: auto; height: auto; overflow: visible; clip: auto; } }

.nav-toggle__bars { position: relative; width: 20px; height: 14px; }
.nav-toggle__bars span {
  position: absolute; left: 0; width: 100%; height: 2px; border-radius: 2px;
  background: currentColor;
  transition: transform var(--dur) var(--ease), opacity var(--dur-fast) var(--ease), top var(--dur) var(--ease);
}
.nav-toggle__bars span:nth-child(1) { top: 0; }
.nav-toggle__bars span:nth-child(2) { top: 6px; }
.nav-toggle__bars span:nth-child(3) { top: 12px; }
.nav-toggle[aria-expanded="true"] .nav-toggle__bars span:nth-child(1) { top: 6px; transform: rotate(45deg); }
.nav-toggle[aria-expanded="true"] .nav-toggle__bars span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] .nav-toggle__bars span:nth-child(3) { top: 6px; transform: rotate(-45deg); }

/* =====================================================================
   NAV — mobile drawer (default)
   ===================================================================== */
.js .site-nav {
  position: fixed;
  inset: var(--header-h) 0 0 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--space-m) var(--gutter) calc(var(--space-xl) + env(safe-area-inset-bottom));
  background: var(--color-bg);
  border-top: var(--border-w) solid var(--color-border);
  visibility: hidden;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease), visibility 0s linear var(--dur);
}
.js .site-header.is-open .site-nav {
  visibility: visible;
  opacity: 1;
  transform: none;
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}
html.nav-open { overflow: hidden; }

.site-nav__list { display: flex; flex-direction: column; }
.site-nav__item { border-bottom: var(--border-w) solid var(--color-border); }

.site-nav__link,
.subnav a {
  display: flex;
  align-items: center;
  min-height: 52px;
  color: var(--color-heading);
  text-decoration: none;
}
.site-nav__link { flex: 1; font-family: var(--font-heading); font-size: var(--step-2); }
.site-nav__link[aria-current="page"],
.site-nav__link[aria-current="true"],
.subnav a[aria-current="page"] { color: var(--color-primary); }
.site-nav__link[aria-current="page"]::after,
.subnav a[aria-current="page"]::after {
  content: "";
  width: 6px; height: 6px; margin-left: var(--space-2xs);
  border-radius: 50%;
  background: var(--color-accent);
}

.site-nav__parent { display: flex; align-items: center; gap: var(--space-2xs); }
.subnav-toggle {
  display: inline-grid; place-items: center;
  width: 44px; height: 44px;
  background: transparent;
  border: var(--border-w) solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-heading);
}
.subnav-toggle[hidden] { display: none; }
.subnav-toggle svg { transition: transform var(--dur) var(--ease); }
.has-sub.is-open .subnav-toggle svg { transform: rotate(180deg); }

.site-nav .subnav { padding: 0 0 var(--space-xs) var(--space-s); border-left: 2px solid var(--color-surface-quiet); margin-bottom: var(--space-s); }
.js .has-sub:not(.is-open) .subnav { display: none; }
.subnav a { min-height: 44px; font-size: var(--step-0); }

.site-nav__extra { margin-top: var(--space-l); display: grid; gap: var(--space-m); }
.site-nav__extra .btn { width: 100%; }
.site-nav__crisis {
  padding: var(--space-s);
  border-radius: var(--radius-md);
  background: var(--color-surface-alt);
  color: var(--color-text);
}
.site-nav__crisis a { color: var(--color-heading); font-weight: var(--weight-semi); }

/* No JS: the nav drops below the header as a plain, fully open list */
.no-js .site-header__inner { flex-wrap: wrap; }
.no-js .site-nav { flex-basis: 100%; padding-bottom: var(--space-s); }
.no-js .site-nav__extra { display: none; }

/* =====================================================================
   NAV — desktop (≥1280px): inline links + Counselling dropdown
   ===================================================================== */
@media (min-width: 1280px) {
  :root { --header-h: 96px; }   /* mockup header height */
  .site-header__inner { gap: var(--space-l); }
  .site-header__brand { font-size: clamp(1.375rem, 0.4rem + 1.2vw, 1.625rem); }
  .site-header__brand { margin-right: 0; }
  .site-header__book { order: 3; }
  .nav-toggle { display: none !important; }

  .js .site-nav,
  .no-js .site-nav {
    position: static;
    flex: 1;
    flex-basis: auto;
    padding: 0;
    overflow: visible;
    background: none;
    border: 0;
    visibility: visible;
    opacity: 1;
    transform: none;
    transition: none;
  }
  .site-nav__extra { display: none; }

  .site-nav__list { flex-direction: row; justify-content: flex-end; align-items: center; gap: clamp(1.25rem, -3rem + 5vw, 2.25rem); }
  .site-nav__item { position: relative; border: 0; }
  .site-nav__link {
    min-height: 44px;
    font-family: var(--font-body);
    font-size: clamp(0.9375rem, 0.6rem + 0.42vw, 1rem);
    font-weight: var(--weight-regular);
    white-space: nowrap;
    position: relative;
  }
  /* Current page: short terracotta underline instead of the dot */
  .site-nav__link[aria-current="page"]::after,
  .site-nav__link[aria-current="true"]::after {
    content: "";
    position: absolute; left: 0; right: 0; bottom: 6px;
    width: auto; height: 2px; margin: 0;
    border-radius: 2px;
    background: var(--color-primary);
  }

  .site-nav__parent { gap: 0; }
  .subnav-toggle { width: 32px; height: 44px; border: 0; }

  .site-nav .subnav {
    position: absolute;
    top: calc(100% + var(--space-2xs));
    left: calc(-1 * var(--space-m));
    min-width: 260px;
    margin: 0;
    padding: var(--space-2xs);
    background: var(--color-surface);
    border: var(--border-w) solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lift);
  }
  /* A hover bridge so the pointer can travel from the link to the panel */
  .subnav::before { content: ""; position: absolute; left: 0; right: 0; top: calc(-1 * var(--space-2xs)); height: var(--space-2xs); }
  .no-js .has-sub:not(:hover):not(:focus-within) .subnav,
  .js .has-sub:not(.is-open) .subnav { display: none; }
  @media (hover: hover) {
    .js .has-sub:hover .subnav { display: block; }
  }
  .subnav a {
    min-height: 40px;
    padding: 0 var(--space-s);
    border-radius: var(--radius-sm);
    font-size: var(--text-note);
  }
  .subnav__overview { border-bottom: var(--border-w) solid var(--color-border); margin-bottom: var(--space-3xs); padding-bottom: var(--space-3xs); }
  .subnav__overview a { font-weight: var(--weight-semi); }
}

/* =====================================================================
   FOOTER — the design pack's near-black footer: CTA row, link grid,
   crisis bar, oversized serif wordmark with arcs, bottom bar.
   ===================================================================== */
.site-footer {
  position: relative;
  overflow: hidden;
  background: var(--color-night-bg);
  color: var(--color-night-muted);
  padding-top: var(--section-y);
  font-size: var(--text-note);
  --color-focus: var(--color-night-accent);
}
.site-footer a { color: var(--color-night-text); text-underline-offset: 0.2em; }
.site-footer .wordmark { color: var(--color-night-text); font-size: var(--step-3); }
.footer-eyebrow {
  font-size: var(--step--1); font-weight: var(--weight-semi);
  letter-spacing: var(--tracking-eyebrow); text-transform: uppercase;
  color: var(--color-night-accent);
}

/* Button variants for dark bands (footer + dark sections) */
.btn--light { background: var(--color-night-accent); color: var(--color-on-light-btn); }
.btn--ghost-light { border-color: var(--color-night-stroke); color: var(--color-night-text); }
.btn .icon-wa { width: 18px; height: 18px; }
.site-footer .btn--light, .site-footer .btn--light:hover, .site-footer .btn--light:focus-visible { color: var(--color-on-light-btn); }

/* ---- CTA row ---- */
.footer-cta {
  display: grid;
  gap: var(--space-l);
  padding-bottom: var(--space-xl);
  border-bottom: var(--border-w) solid var(--color-night-border);
}
@media (min-width: 900px) { .footer-cta { padding-bottom: 3.5rem; } }
.footer-cta__text > * + * { margin-top: var(--space-s); }
.footer-cta__line {
  font-family: var(--font-serif);
  font-size: clamp(2rem, 1.5rem + 2.2vw, 2.75rem);
  line-height: 1.18;
  letter-spacing: var(--tracking-heading);
  color: var(--color-night-text);
  text-wrap: balance;
  max-width: 620px;
}
.footer-cta__line em { color: var(--color-night-accent); }
.footer-cta__actions .btn { flex: 1 1 auto; min-height: 56px; padding-inline: 1.75rem; }
@media (min-width: 900px) {
  .footer-cta { grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: var(--space-2xl); }
  .footer-cta__actions .btn { flex: 0 0 auto; }
}

/* ---- Link grid ---- */
.footer-grid {
  display: grid;
  gap: var(--space-xl) var(--space-l);
  grid-template-columns: minmax(0, 1fr);
  padding-block: var(--space-2xl) var(--space-xl);
}
.footer-brand > * + * { margin-top: var(--space-m); }
.footer-brand p { max-width: 36ch; }
.footer-col__title {
  font-family: var(--font-body);
  font-size: var(--step--1);
  font-weight: var(--weight-semi);
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  color: var(--color-night-accent);
  margin-bottom: var(--space-s);
}
.footer-col ul { display: grid; gap: var(--space-2xs); }
.footer-col li { overflow-wrap: anywhere; font-size: var(--step-0); color: var(--color-night-text); }
.footer-col a { text-decoration: none; display: inline-block; padding-block: 2px; }
.footer-col .small { margin-top: var(--space-s); }
.footer-col--contact li { display: flex; gap: var(--space-xs); align-items: flex-start; }
.footer-col--contact li > svg { flex: none; width: 18px; height: 18px; margin-top: 5px; color: var(--color-night-accent); fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.footer-col--contact li > .icon-wa { fill: currentColor; stroke: none; }
.footer-col--contact li > a { padding-block: 0; }
@media (min-width: 600px) {
  .footer-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .footer-brand { grid-column: 1 / -1; }
}
@media (min-width: 1200px) {
  .footer-grid { grid-template-columns: 1.5fr 1fr 1fr 1.4fr; }
  .footer-brand { grid-column: auto; padding-right: var(--space-xl); }
}

/* ---- Crisis box — must appear on every page (R8). Do not hide. ----
   Styled as the design pack's "Not an emergency service" bar. */
.crisis-box {
  display: grid;
  gap: var(--space-s);
  padding: var(--space-m);
  background: var(--color-night-raised);
  border-radius: var(--radius-md);
  color: var(--color-night-text);
}
.crisis-box__icon { color: var(--terra-400); }
.crisis-box__body > * + * { margin-top: var(--space-xs); }
.crisis-box__title {
  font-family: var(--font-body);
  font-size: var(--step-0);
  font-weight: var(--weight-semi);
  letter-spacing: 0;
  color: var(--color-night-text);
}
.crisis-box__title span { font-weight: var(--weight-regular); color: var(--color-night-muted); }
.crisis-box__list { display: grid; gap: var(--space-2xs); }
.crisis-box__list li { padding-left: var(--space-s); position: relative; }
.crisis-box__list li::before {
  content: ""; position: absolute; left: 0; top: 0.7em;
  width: 6px; height: 6px; border-radius: 50%; background: var(--terra-400);
}
.crisis-box a { color: var(--color-night-text); text-decoration-color: var(--terra-400); }
@media (min-width: 600px) { .crisis-box { grid-template-columns: auto minmax(0, 1fr); gap: var(--space-m); padding: var(--space-m) var(--space-l); } }
@media (min-width: 900px) {
  .crisis-box__list { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-m); }
}

/* ---- Oversized wordmark + arcs (decorative) ---- */
.footer-sign { position: relative; min-height: clamp(120px, 14vw, 220px); display: flex; align-items: flex-end; margin-top: var(--space-xl); }
.footer-sign .container { position: relative; }
.footer-sign__word {
  display: block;
  margin-bottom: -0.2em;
  font-family: var(--font-serif);
  font-size: clamp(1.5rem, 7.6vw, 7.25rem);
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--color-night-decor);
  white-space: nowrap;
}
/* Drawn from a pseudo-element: it's decoration, not text to read or contrast-check */
.footer-sign__word::before { content: attr(data-word); }

/* ---- Bottom bar ---- */
.footer-bar {
  position: relative;
  background: var(--color-night-deep);
  padding-block: 1.375rem;
  /* Room so the floating WhatsApp button never covers the legal links */
  padding-bottom: calc(1.375rem + 64px + env(safe-area-inset-bottom));
  font-size: var(--text-fine);
}
.footer-bar__inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--space-xs) var(--space-l); }
.footer-bar .cluster { --cluster-gap: 1.75rem; }
.footer-bar a { color: var(--color-night-muted); }
@media (min-width: 900px) { .footer-bar { padding-bottom: 1.375rem; } }

/* =====================================================================
   FLOATING WHATSAPP BUTTON (kickoff 7.14)
   ===================================================================== */
.wa-float {
  position: fixed;
  right: max(var(--space-s), env(safe-area-inset-right));
  bottom: max(var(--space-s), env(safe-area-inset-bottom));
  z-index: var(--z-float);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2xs);
  width: 56px;
  height: 56px;
  border-radius: var(--radius-pill);
  background: var(--color-primary);
  color: var(--color-on-primary);
  box-shadow: var(--shadow-lift);
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  text-decoration: none;
  font-weight: var(--weight-semi);
  font-size: var(--step--1);
  transition: background-color var(--dur-fast) var(--ease), transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.wa-float .icon-wa { width: 26px; height: 26px; flex-shrink: 0; }
.wa-float__label { display: none; }
@media (min-width: 900px) {
  .wa-float { width: auto; border-radius: var(--radius-md); padding: 0 var(--space-m) 0 var(--space-s); right: var(--space-l); bottom: var(--space-l); }
  .wa-float__label { display: inline; }
}
html.nav-open .wa-float { display: none; }
/* Phones/tablets (#1002130): the button waits until the hero has scrolled clear of its
   footprint, so it never sits on the opening paragraph. site-nav.js adds .is-shown;
   no JS = always visible. Desktop is unaffected (button sits in the gutter). */
@media (max-width: 899.98px) {
  html.js .wa-float {
    transition: background-color var(--dur-fast) var(--ease), transform var(--dur) var(--ease),
      opacity var(--dur) var(--ease), visibility 0s linear 0s;
  }
  html.js .wa-float:not(.is-shown) {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(var(--space-s));
    transition: transform var(--dur) var(--ease), opacity var(--dur) var(--ease), visibility 0s linear var(--dur);
  }
}

@media print {
  .site-header { position: static; }
  .wa-float, .nav-toggle, .subnav-toggle, .footer-cta .cluster { display: none !important; }
}
