/* UNTRAPD shared shell v1 — PLAN_2026-09.md §13.8. Standalone: no dependency on
   main.css, no webfont request (Inter where present, else system). Namespaced
   ush- (header) usr- (rail) usf- (footer) uss- (strip). Theme-aware: the stamper
   writes ush--light or ush--dark (etc.) from pages.json so the shell matches the
   page instead of stamping a white bar onto a dark page. */
.ush, .usr, .usf, .uss {
  all: revert;
  box-sizing: border-box;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
}
.ush *, .usr *, .usf *, .uss * { box-sizing: border-box; }

/* ---- shared tokens ---- */
.ush--light, .usr--light, .usf--light, .uss--light {
  --sh-bg: #ffffff;
  --sh-ink: #1a1d23;
  --sh-muted: #5b6472;
  --sh-line: #e3e7ee;
  --sh-primary: #0066ff;
  --sh-primary-ink: #ffffff;
  --sh-chip-bg: transparent;
  --sh-chip-line: #c6cdd8;
}
.ush--dark, .usr--dark, .usf--dark, .uss--dark {
  --sh-bg: #0b1220;
  --sh-ink: #f2f5fa;
  --sh-muted: #c3cfe0;
  --sh-line: rgba(255, 255, 255, .14);
  --sh-primary: #0066ff;
  --sh-primary-ink: #ffffff;
  --sh-chip-bg: rgba(255, 255, 255, .06);
  --sh-chip-line: rgba(255, 255, 255, .28);
}

/* ---- header ---- */
.ush {
  background: var(--sh-bg);
  color: var(--sh-ink);
  border-bottom: 1px solid var(--sh-line);
}
.ush-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 20px;
}
.ush-brand {
  color: var(--sh-ink);
  text-decoration: none;
  font-weight: 800;
  letter-spacing: .08em;
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  margin: 0;
}
.ush-tagline {
  font-weight: 400;
  letter-spacing: 0;
  font-size: .85rem;
  color: var(--sh-muted);
}
.ush-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 16px;
  margin: 0;
}
.ush-link {
  color: var(--sh-ink);
  text-decoration: none;
  font-weight: 500;
  padding: 6px 2px;
  margin: 0;
}
.ush-link:hover { text-decoration: underline; }
.ush-link[aria-current="page"] { text-decoration: underline; text-underline-offset: 4px; }
.ush-side {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}
.ush-lang {
  color: var(--sh-muted);
  text-decoration: none;
  font-size: .85rem;
  padding: 6px 8px;
  border: 1px solid var(--sh-line);
  border-radius: 8px;
  margin: 0;
}
.ush-cta {
  background: #0066ff;
  color: #fff !important;
  border-radius: 8px;
  padding: 8px 16px;
  font-weight: 600;
  text-decoration: none;
  margin: 0;
  white-space: nowrap;
}
.ush-cta:hover { background: #0052cc; }

/* ---- urgent rail ---- */
.usr {
  background: var(--sh-bg);
  color: var(--sh-muted);
  border-bottom: 1px solid var(--sh-line);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 14px;
  padding: 9px 16px;
  font-size: .92rem;
  margin: 0;
}
.usr-label { color: var(--sh-ink); font-weight: 600; margin: 0; }
.usr-link {
  color: var(--sh-ink);
  text-decoration: none;
  padding: 4px 12px;
  border: 1px solid var(--sh-chip-line);
  border-radius: 999px;
  background: var(--sh-chip-bg);
  font-weight: 500;
  margin: 0;
  white-space: nowrap;
}

/* ---- footer ---- */
.usf {
  background: var(--sh-bg);
  color: var(--sh-ink);
  border-top: 1px solid var(--sh-line);
  margin-top: 48px;
}
.usf-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 16px;
  display: grid;
  grid-template-columns: 1.4fr repeat(5, 1fr);
  gap: 24px 20px;
}
.usf-brand-text { font-weight: 800; letter-spacing: .08em; }
.usf-brand-statement { color: var(--sh-muted); font-size: .9rem; margin: 8px 0 0; }
.usf-social { margin: 12px 0 0; display: flex; gap: 12px; }
.usf-social a { color: var(--sh-ink); text-decoration: none; }
.usf-col { margin: 0; }
.usf-col strong { display: block; margin: 0 0 10px; font-size: .85rem; }
.usf-col a { display: block; color: var(--sh-muted); text-decoration: none; font-size: .9rem; padding: 3px 0; margin: 0; }
.usf-col a:hover { text-decoration: underline; }
@media (max-width: 900px) {
  .usf-inner { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .ush-side { margin-left: 0; }
  .usf-inner { grid-template-columns: 1fr; }
}

/* ---- minimal strip (C8 exception pages) ---- */
.uss {
  background: var(--sh-bg);
  color: var(--sh-muted);
  border-bottom: 1px solid var(--sh-line);
  text-align: center;
  padding: 8px 16px;
  font-size: .85rem;
  margin: 0;
}
.uss a { color: var(--sh-ink); text-decoration: none; font-weight: 600; }
.uss-by { margin: 0 4px; }

/* ---- legibility guard ----
   Page stylesheets carry high-specificity anchor rules that beat single-class
   shell selectors (measured 2026-09-10: `a:not(...[class*="btn"])` = 0,1,1 >
   `.ush-link` = 0,1,0 turned header links #6ac4e0-on-white). These !important
   declarations are scoped to ush-/usr-/usf-/uss- classes only — no page
   content outside the shell is affected. Site-wide audit same day: the only
   `!important` color rules in page stylesheets are page-scoped classes that
   never match shell markup, so this guard is deterministic. */
.ush, .usr, .usf, .uss {
  background-color: var(--sh-bg) !important;
  border-color: var(--sh-line) !important;
}
.ush-brand, .ush-brand-text, .ush-link, .ush-lang,
.usr-label, .usr-link, .usf-brand-text, .usf-col strong,
.uss a {
  color: var(--sh-ink) !important;
  -webkit-text-fill-color: var(--sh-ink) !important;
}
.ush .ush-tagline.ush-tagline, .usf .usf-brand-statement.usf-brand-statement,
.usf .usf-col.usf-col a, .usf .usf-social.usf-social a {
  color: var(--sh-muted) !important;
  -webkit-text-fill-color: var(--sh-muted) !important;
}
/* Above the page arms race: neural-background.css carries
   `section a:not(...):not(...):not(...):not(...)` at 0,1,2 with !important
   (plus -webkit-text-fill-color, which is what Blink actually paints —
   measure contrast on the PAINTED fill, not getComputedStyle().color).
   Doubled-class + root scope = 0,3,0, strictly above it. */
.ush .ush-brand.ush-brand, .ush .ush-brand-text.ush-brand-text,
.ush .ush-link.ush-link, .ush .ush-lang.ush-lang,
.usr .usr-label.usr-label, .usr .usr-link.usr-link,
.usf .usf-brand-text.usf-brand-text, .usf .usf-col.usf-col strong,
.usf .usf-col.usf-col a, .usf .usf-social.usf-social a,
.uss .uss-product.uss-product, .uss .uss-brand.uss-brand {
  color: var(--sh-ink) !important;
  -webkit-text-fill-color: var(--sh-ink) !important;
}
.ush .ush-cta.ush-cta {
  background-color: #0066ff !important;
  color: #fff !important;
  -webkit-text-fill-color: #fff !important;
  border-color: transparent !important;
}
.usr-link { background-color: var(--sh-chip-bg) !important; border-color: var(--sh-chip-line) !important; }

/* ---- phone layout (added 2026-09-23, operator-approved hybrid) ----
   Measured on a Note20-size viewport (412x915): the wrapped header was 146px, the rail 94px,
   and main.css still reserved an 80px body offset for the old fixed .main-header — 320px
   (35% of the screen) before any content. Now: one header row (brand · Get FINDERR · menu),
   the three nav links + language switch behind a native <details> menu (no JS), and the
   urgent rail kept visible and compact (one row, or two where labels don't fit) — urgent
   links are never hidden. */
.ush-menu { display: none; }
.ush-inner { position: relative; }
/* Pages that lay <body> out as a full-height flex column (/counselor/, /stories/) would shrink
   the shell; with overflow-x:auto the rail's min-height becomes 0 and it collapsed to 13px
   (measured 2026-09-23). Shell pieces keep their natural height. */
.ush, .usr, .usf, .uss { flex-shrink: 0 !important; }

/* The shell header is static, so main.css's fixed-header offset is dead space on shelled
   pages. Scoped with :has() to pages that carry the shell header — held-back pages (F2) keep
   theirs. Browsers without :has() simply keep the old offset. */
body:has(> header.ush) { padding-top: 0 !important; margin-top: 0 !important; }

@media (max-width: 640px) {
  .ush-inner { flex-wrap: nowrap; gap: 10px; padding: 8px 12px; }
  .ush-tagline, .ush-nav, .ush-side .ush-lang { display: none !important; }
  .ush-side { margin-left: auto; gap: 8px; }
  .ush-cta { padding: 8px 14px; font-size: .95rem; }

  .ush-menu { display: block; margin: 0; }
  .ush-menu-btn {
    list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: center;
    width: 44px; height: 44px; margin: 0; border-radius: 8px; border: 1px solid var(--sh-line);
  }
  .ush-menu-btn::-webkit-details-marker { display: none; }
  .ush-menu-btn::marker { content: ""; }
  .ush-menu-btn:focus-visible { outline: 2px solid var(--sh-primary); outline-offset: 2px; }
  .ush-burger, .ush-burger::before, .ush-burger::after {
    display: block; width: 20px; height: 2px; background: var(--sh-ink); border-radius: 2px; position: relative; content: "";
  }
  .ush-burger::before { position: absolute; top: -6px; }
  .ush-burger::after { position: absolute; top: 6px; }
  .ush-menu[open] .ush-burger { background: transparent; }
  .ush-menu[open] .ush-burger::before { top: 0; transform: rotate(45deg); }
  .ush-menu[open] .ush-burger::after { top: 0; transform: rotate(-45deg); }

  .ush-menu-panel {
    position: absolute; left: 0; right: 0; top: 100%; z-index: 1000;
    display: flex; flex-direction: column; margin: 0; padding: 6px 12px 12px;
    background: var(--sh-bg); border-bottom: 1px solid var(--sh-line);
    box-shadow: 0 10px 24px rgba(0, 0, 0, .18);
  }
  .ush-menu-link {
    display: block; padding: 13px 4px; margin: 0; font-weight: 600; font-size: 1.05rem;
    text-decoration: none; border-bottom: 1px solid var(--sh-line);
  }
  .ush-menu-link[aria-current="page"] { text-decoration: underline; text-underline-offset: 5px; }
  .ush-menu-panel .ush-lang { align-self: flex-start; margin-top: 12px; padding: 8px 12px; }

  /* Wraps rather than scrolls: a scrolling row hid the third urgent chip on screens <=390px
     and on every FR page (measured 2026-09-23). Urgent links stay visible; the rail is one
     row (42px) where it fits, two (80px) where it doesn't. */
  .usr { flex-wrap: wrap; justify-content: center; gap: 6px 8px; padding: 6px 12px; font-size: .84rem; line-height: 1.3; }
  .usr-label { display: none !important; }
  .usr-link { padding: 5px 11px; line-height: 1.3; }
}
.ush .ush-menu-link.ush-menu-link {
  color: var(--sh-ink) !important;
  -webkit-text-fill-color: var(--sh-ink) !important;
}
