/* =============================================================================
   OnSiteSafety TrustID — Frame (Header + Footer)  · Phase 2
   Builds on field-document.css tokens. "Hi-vis tape" header + passport-stamp
   footer. Borders over shadows. WCAG-AA, keyboard-first, no-hover menus.
   ========================================================================== */

:root { --hi-vis: var(--brand); }            /* alias once (review N1) */

/* ---- 0. Two-tone focus ring (WCAG 2.2 SC 1.4.11) ---------------------------
   A bare 2px brand ring on white is ~1.9:1 and FAILS. Stack an --ink ring with
   a --brand ring so the indicator contrasts both the surface AND itself.
   On carbon surfaces the ink ring would vanish, so flip ink -> paper there. */
.oss-header :is(a, button, [tabindex]):focus-visible,
.oss-footer :is(a, button, [tabindex]):focus-visible,
.oss-btn:focus-visible,
.skip-link:focus {
  outline: none;
  box-shadow:
    0 0 0 2px var(--paper),
    0 0 0 4px var(--ink),
    0 0 0 6px var(--brand);
  border-radius: 3px;
}
.oss-footer :is(a, button, [tabindex]):focus-visible {
  box-shadow:
    0 0 0 2px var(--carbon),
    0 0 0 4px var(--paper),
    0 0 0 6px var(--brand);
}

/* Visually-hidden helper (matches WP core .screen-reader-text contract). */
.screen-reader-text {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  clip: rect(0 0 0 0); clip-path: inset(50%);
  overflow: hidden; white-space: nowrap;
}

/* ---- 1. Skip-link (reuse Kadence's first-focusable a.skip-link -> #main) ---- */
.skip-link.screen-reader-text {
  background: var(--paper);
}
.skip-link:focus {
  position: fixed !important;
  top: 8px; left: 8px;
  z-index: 1000;
  width: auto; height: auto;
  margin: 0; padding: 0.6rem 1rem;
  clip: auto; clip-path: none;
  font-family: var(--font-body); font-weight: 700;
  color: var(--ink); background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 4px;
  text-decoration: none;
}

/* ---- 2. Header shell -------------------------------------------------------
   Sticky via CSS only (no scroll listener). 2px hi-vis top keyline reads as
   tape; 1px steel/20% bottom hairline. 64px -> 52px condense via .is-stuck
   (toggled by an IntersectionObserver sentinel, not a scroll handler). */
.oss-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--paper);
  border-top: 2px solid var(--hi-vis);
  border-bottom: 1px solid var(--hair);
  transition: box-shadow 160ms var(--ease);
}
.oss-header.is-stuck {
  box-shadow: 0 1px 0 var(--hair), 0 6px 18px -14px rgba(31,41,51,0.5);
}
.oss-header__inner {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 clamp(1rem, 3vw, 2rem);
  height: 64px;
  transition: height 160ms var(--ease);
}
.oss-header.is-stuck .oss-header__inner { height: 52px; }

/* ---- 3. Logo lockup --------------------------------------------------------
   Nunito 800 name + JetBrains Mono model-number sub (design language locks the
   brand faces; the blueprint's "Archivo" is stale). */
.oss-logo {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  line-height: 1;
  text-decoration: none;
  background: none;                 /* cancel the global link underline-grow */
  flex: 0 0 auto;
}
.oss-logo__name {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.2rem;
  letter-spacing: -0.01em;
  color: var(--ink);
}
/* Brand mark (the official OnSiteSafety wordmark, 250x75 PNG). Sized by height
   so it condenses with the sticky header; width auto keeps the lockup crisp. */
.oss-logo__img {
  display: block;
  height: 1.9rem;
  width: auto;
  transition: height 160ms var(--ease);
}
.oss-header.is-stuck .oss-logo__img { height: 1.55rem; }
.oss-logo__sub {
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  color: var(--steel);
  margin-top: 2px;
}

/* ---- 4. Primary nav (desktop inline) --------------------------------------- */
.oss-nav { display: flex; }
.oss-nav__list {
  display: flex;
  align-items: center;
  gap: clamp(1rem, 2.4vw, 2rem);
  margin: 0; padding: 0;
  list-style: none;
}
.oss-nav__list a,
.oss-nav__link {
  position: relative;
  display: inline-block;
  padding: 0.4rem 0;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.98rem;
  color: var(--ink);
  text-decoration: none;
  background: none;                 /* use the custom underline below */
}
/* Hi-vis underline grows from the left on hover/focus; locked on current. */
.oss-nav__list a::after,
.oss-nav__link::after {
  content: "";
  position: absolute;
  left: 0; bottom: -2px;
  height: 2px; width: 100%;
  background: var(--hi-vis);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 160ms var(--ease);
}
.oss-nav__list a:hover::after,
.oss-nav__list a:focus-visible::after,
.oss-nav__link:hover::after,
.oss-nav__link:focus-visible::after,
.oss-nav__list a[aria-current="page"]::after,
.oss-nav__link[aria-current="page"]::after { transform: scaleX(1); }
.oss-nav__list a[aria-current="page"],
.oss-nav__link[aria-current="page"] { color: var(--ink); font-weight: 700; }

/* ---- 4a. Dropdown submenus (CLICK-toggled disclosure, never hover-only) ----
   No-JS: submenus + their links are plain, always-visible indented lists and
   the toggle button is hidden (progressive enhancement). With JS (.oss-js):
   the disclosure button shows, submenus collapse, and open only on click. */
.oss-nav__list > li { position: relative; }

.oss-subtoggle {
  display: none;                       /* shown only when JS is on */
  align-items: center;
  justify-content: center;
  width: 1.9rem; height: 1.9rem;
  margin-left: 0.1rem;
  padding: 0;
  background: none;
  border: 0;
  border-radius: 6px;
  color: var(--ink);
  cursor: pointer;
  vertical-align: middle;
}
html.oss-js .oss-subtoggle { display: inline-flex; }
.oss-subtoggle__caret { font-size: 0.8em; line-height: 1; transition: transform 160ms var(--ease); }
.oss-subtoggle[aria-expanded="true"] .oss-subtoggle__caret { transform: rotate(180deg); }

/* The submenu list. Default (no-JS): static indented block, always visible. */
.oss-nav__sub {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.oss-nav__sub a {
  display: block;
  white-space: nowrap;
  font-weight: 600;
  font-size: 0.95rem;
}

/* With JS: collapse submenus; reveal only the open one (set by frame.js). */
html.oss-js .oss-nav__list .menu-item-has-children > .oss-nav__sub { display: none; }
html.oss-js .oss-nav__list .menu-item-has-children.is-open > .oss-nav__sub { display: flex; }

/* JS + desktop: open submenu is an absolutely-positioned dropdown card. */
@media (min-width: 880px) {
  html.oss-js .oss-nav__sub {
    position: absolute;
    top: calc(100% + 0.4rem);
    left: 0;
    z-index: 120;
    min-width: 15rem;
    padding: 0.5rem;
    gap: 0.05rem;
    background: var(--paper);
    border: 1px solid var(--rule, rgba(31,41,51,0.14));
    border-radius: 10px;
    box-shadow: 0 12px 28px -10px rgba(31,41,51,0.28);
  }
  html.oss-js .oss-nav__sub a {
    padding: 0.5rem 0.65rem;
    border-radius: 6px;
  }
  html.oss-js .oss-nav__sub a:hover,
  html.oss-js .oss-nav__sub a:focus-visible { background: rgba(31,41,51,0.06); }
  /* Suppress the hi-vis underline inside the dropdown card (it has hover fill). */
  html.oss-js .oss-nav__sub a::after { content: none; }
}

/* ---- 5. Utility cluster ----------------------------------------------------- */
.oss-header__collapse {
  display: flex;
  align-items: center;
  gap: clamp(1rem, 2.4vw, 2rem);
  flex: 1 1 auto;
  justify-content: flex-end;
}
.oss-util {
  display: flex;
  align-items: center;
  gap: clamp(0.6rem, 1.6vw, 1.1rem);
}

/* Verify — hi-vis ghost + mono. Border/label use --brand-text (AA + >=3:1
   boundary; bare --brand on white would fail 3:1). */
/* Label text is --ink (14.8:1 AA). NOTE: --brand-text (#B5700A) measures only
   3.97:1 on white (axe-verified) — it fails normal-text AA despite the design
   token's stated purpose, so it is used here ONLY as the >=3:1 UI-component
   border, never as the readable label. (Flagged to Diego: --brand-text token
   does not meet its AA contract.) */
.oss-verify {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  padding: 0.5rem 0.85rem;
  color: var(--ink);
  background: transparent;
  border: 2px solid var(--brand-text);   /* 3.97:1 >= 3:1 UI-component floor */
  border-radius: 6px;
}
.oss-verify:hover { background: rgba(181,112,10,0.08); color: var(--ink); border-color: var(--brand-deep); }
.oss-verify__caret { font-size: 0.7em; color: var(--brand-text); }

/* Login — quiet text link (--ink; the hi-vis lives in the hover underline). */
.oss-login {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--ink);
  text-decoration: none;
  background: none;
}
.oss-login:hover { text-decoration: underline; }

/* Get a TrustID — the one solid brand button; label LOCKED to --ink (~8.4:1). */
.oss-cta {
  background: var(--brand);
  color: var(--ink);
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0.6rem 1.1rem;
  font-weight: 700;
  white-space: nowrap;
}
.oss-cta:hover { background: var(--brand-deep); color: var(--ink); }

/* EN·FR·ES — non-interactive slot until WPML (Phase 8). No dead links. */
.oss-lang {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  padding-left: 0.4rem;
  border-left: 1px solid var(--hair);
}
.oss-lang__opt.is-active { color: var(--ink); font-weight: 700; }
.oss-lang__opt.is-disabled { color: var(--steel); opacity: 0.6; cursor: default; }
.oss-lang__sep { color: var(--steel); }

/* ---- 6. Hamburger toggle + overlay close (shown via JS on mobile) ---------- */
.oss-nav__toggle {
  display: none;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
  padding: 0.5rem 0.7rem;
  background: transparent;
  border: 1px solid var(--hair);
  border-radius: 6px;
  font-family: var(--font-body);
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
}
.oss-nav__toggle-bars,
.oss-nav__toggle-bars::before,
.oss-nav__toggle-bars::after {
  content: "";
  display: block;
  width: 20px; height: 2px;
  background: var(--ink);
  position: relative;
}
.oss-nav__toggle-bars::before { position: absolute; top: -6px; }
.oss-nav__toggle-bars::after  { position: absolute; top: 6px; }
.oss-overlay__close {
  position: absolute;
  top: 1rem; right: 1rem;
  width: 44px; height: 44px;
  font-size: 1.5rem; line-height: 1;
  background: transparent;
  border: 1px solid var(--hair);
  border-radius: 6px;
  color: var(--ink);
  cursor: pointer;
}

/* =============================================================================
   7. MOBILE  (< 880px)
   With JS (.oss-js on <html>): hamburger -> full-screen --paper overlay, body
   scroll-locked, background inert, CTA pinned to bottom safe-area, ✕ refocuses
   the hamburger. WITHOUT JS: the collapse region degrades to plain visible
   links (progressive enhancement — review S6).
   ========================================================================== */
@media (max-width: 879.98px) {

  /* No-JS fallback: everything stacks and stays visible & operable. */
  .oss-header__inner { flex-wrap: wrap; height: auto; padding-top: 0.6rem; padding-bottom: 0.6rem; }
  .oss-header.is-stuck .oss-header__inner { height: auto; }
  .oss-header__collapse { flex-basis: 100%; flex-direction: column; align-items: stretch; gap: 1rem; justify-content: flex-start; }
  .oss-nav__list { flex-direction: column; align-items: flex-start; gap: 0.25rem; }
  .oss-util { flex-wrap: wrap; gap: 0.75rem; }

  /* JS present: hide the collapse behind the hamburger, reveal as overlay. */
  html.oss-js .oss-nav__toggle { display: inline-flex; }
  html.oss-js .oss-overlay__close { display: block; }

  html.oss-js .oss-header__collapse {
    position: fixed;
    inset: 0;
    z-index: 200;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 1.25rem;
    padding: 4.5rem 1.5rem calc(1.5rem + env(safe-area-inset-bottom));
    background: var(--paper);
    overflow-y: auto;
    transform: translateY(-8px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 180ms var(--ease), transform 180ms var(--ease), visibility 0s linear 180ms;
  }
  html.oss-js .oss-header.is-open .oss-header__collapse {
    transform: none;
    opacity: 1;
    visibility: visible;
    transition: opacity 180ms var(--ease), transform 180ms var(--ease);
  }
  html.oss-js .oss-header.is-open .oss-nav__list { gap: 0.25rem; }
  html.oss-js .oss-header.is-open .oss-nav__link,
  html.oss-js .oss-header.is-open .oss-nav__list > li > a { font-size: 1.25rem; padding: 0.6rem 0; }

  /* Mobile overlay: parent row = link + inline disclosure button on one line. */
  html.oss-js .oss-header.is-open .oss-nav__list > li { display: flex; flex-wrap: wrap; align-items: center; width: 100%; }
  html.oss-js .oss-header.is-open .oss-nav__list > li > a { flex: 1 1 auto; }
  html.oss-js .oss-header.is-open .oss-subtoggle { width: 2.75rem; height: 2.75rem; }

  /* Submenu expands inline within the overlay (no absolute dropdown card). */
  html.oss-js .oss-header.is-open .oss-nav__sub {
    flex-basis: 100%;
    position: static;
    border: 0;
    box-shadow: none;
    padding: 0.1rem 0 0.4rem 1rem;
    border-left: 2px solid var(--rule, rgba(31,41,51,0.14));
    margin: 0 0 0.5rem;
  }
  html.oss-js .oss-header.is-open .oss-nav__sub a { font-size: 1.05rem; padding: 0.45rem 0; }

  /* CTA pinned to the bottom safe-area; gloves-friendly 48px target. */
  html.oss-js .oss-header.is-open .oss-util {
    margin-top: auto;
    flex-direction: column;
    align-items: stretch;
  }
  html.oss-js .oss-header.is-open .oss-cta {
    order: 3;
    text-align: center;
    padding: 0.95rem 1.1rem;
    min-height: 48px;
  }
  html.oss-js .oss-header.is-open .oss-verify { order: 1; justify-content: center; min-height: 48px; }
  html.oss-js .oss-header.is-open .oss-login { order: 2; }
  html.oss-js .oss-header.is-open .oss-lang { order: 4; border-left: 0; padding-left: 0; justify-content: center; margin-top: 0.5rem; }

  /* Body scroll-lock while the overlay is open. */
  html.oss-js body.oss-nav-open { overflow: hidden; touch-action: none; }
}

/* Desktop: ensure the toggle/close never show. */
@media (min-width: 880px) {
  .oss-nav__toggle, .oss-overlay__close { display: none !important; }
}

/* =============================================================================
   8. FOOTER
   ========================================================================== */
.oss-footer { color: var(--paper); }
.oss-footer a { color: var(--paper); background: none; }
.oss-footer a:hover { text-decoration: underline; }

/* MRZ stamp — carbon band, mono, " · " separators. Horizontally scrollable as
   one unbroken line (reads as a real document edge). Keyboard-scrollable
   (tabindex=0) and labeled (review N3). */
.oss-footer__mrz {
  border-radius: 0;
  border-top: 1px solid rgba(255,255,255,0.10);
  border-bottom: 1px solid rgba(255,255,255,0.10);
  overflow-x: auto;
  white-space: nowrap;
  padding: 0.7rem clamp(1rem, 3vw, 2rem);
}
.oss-footer__mrz-text { display: inline-block; }

.oss-footer__inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: clamp(2.5rem, 6vw, 4rem) clamp(1rem, 3vw, 2rem) 2rem;
}

.oss-footer__cols {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: clamp(1.25rem, 3vw, 2.25rem);
}
.oss-footer__heading {
  color: var(--brand);
  margin: 0 0 0.85rem;
}
.oss-footer__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
.oss-footer__list a { font-family: var(--font-body); font-weight: 400; font-size: 0.95rem; color: var(--paper); opacity: 0.92; }

.oss-footer__legend {
  margin-top: clamp(2rem, 5vw, 3rem);
  padding-top: 1.5rem;
  border-top: 1px solid rgba(255,255,255,0.14);
  color: rgba(255,255,255,0.85);
}
.oss-footer__legend-row { margin: 0 0 0.5rem; font-size: 0.82rem; letter-spacing: 0.02em; display: flex; flex-wrap: wrap; align-items: center; gap: 0.15rem; }
.oss-footer__legend-states { display: inline-flex; align-items: center; gap: 0.4rem; margin-left: 0.6rem; }
.oss-dot { width: 0.6em; height: 0.6em; border-radius: 50%; display: inline-block; }
.oss-dot--verified { background: var(--verified); }
.oss-dot--checking  { background: var(--checking); }
.oss-dot--expired { background: var(--expired); }

.oss-footer__base {
  margin-top: clamp(2rem, 5vw, 3rem);
  padding-top: 1.5rem;
  border-top: 1px solid rgba(255,255,255,0.14);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
/* Inverse (white) wordmark on the carbon footer. */
.oss-footer__brand { display: inline-block; background: none; margin-bottom: 0.6rem; }
.oss-footer__logo { display: block; height: 2.1rem; width: auto; }
.oss-footer__meta { font-size: 0.82rem; color: rgba(255,255,255,0.8); margin: 0; }
.oss-footer__compliance { font-family: var(--font-body); font-size: 0.85rem; color: rgba(255,255,255,0.7); margin: 0; }

@media (max-width: 1100px) {
  .oss-footer__cols { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 767.98px) {
  .oss-footer__cols { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 439.98px) {
  .oss-footer__cols { grid-template-columns: 1fr; }
}

/* ---- 9. Reduced motion: collapse condense + overlay transitions ------------ */
@media (prefers-reduced-motion: reduce) {
  .oss-header__inner,
  .oss-header,
  .oss-nav__list a::after,
  .oss-nav__link::after,
  html.oss-js .oss-header__collapse { transition: none !important; }
}
