/* ===========================================================================
   THRESHOLDS — Production Bible shared chrome
   Single source for nav, footer, skip link and the left TOC rail.
   Loaded by every Bible page. Edit HERE, never in a page.

   Why this exists: the nav and footer were copy-pasted into 9 pages, which
   produced 9 different navs, 9 different footers and 5 disagreeing version
   stamps. Every fix had to be applied 9 times by hand, and three times it
   landed in the wrong media query. One file removes the whole class of bug.
   =========================================================================== */

:root {
  --gold:     #F2B705;
  --gold-d:   #C9940A;
  --dark:     #0D0D0D;
  --text:     #1A1A1A;
  --text-mid: #555555;
  --text-dim: #888888;
  --rule:     #E0E0E0;
  --bg:       #FFFFFF;
  --bg-2:     #F7F6F4;
  --bg-3:     #EFECE8;
  --steel:    #334053;
  --asset-ink: #1855A3;
  --shot-ink:  #17702F;
  --danger:    #C0392B;
}

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .hero-bg-wrap { animation: none !important; }
  .hero-bg-img { transition: none !important; }
}
[id] { scroll-margin-top: 80px; }
h1, h2, h3, h4 { font-weight: 400; }

/* ── Skip link ── */
.skip-link {
  position: fixed; top: 8px; left: 50%;
  transform: translateX(-50%) translateY(-160%);
  z-index: 300; background: var(--gold); color: var(--dark);
  font-family: 'DM Sans', sans-serif; font-size: 11px; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase; text-decoration: none;
  padding: 7px 16px; transition: transform 0.18s ease;
}
.skip-link:focus { transform: translateX(-50%) translateY(0); outline: 2px solid var(--dark); outline-offset: 2px; }

/* ── Nav ── */
.nav {
  position: sticky; top: 0; z-index: 100;
  background: var(--dark); border-bottom: 2px solid var(--gold);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 48px; height: 56px;
}
.nav-logo { display: flex; align-items: center; }
.nav-logo img { height: 24px; display: block; flex-shrink: 0; }
.nav-label { font-family: 'Bebas Neue', sans-serif; font-size: 13px; letter-spacing: 0.22em; color: var(--gold); text-transform: uppercase; white-space: nowrap; }
.nav-menu { display: flex; gap: 2px; align-items: center; }
.nm-item {
  font-size: 10px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase;
  color: rgba(255,255,255,0.4); text-decoration: none; padding: 5px 10px;
  transition: color 0.2s; white-space: nowrap;
}
.nm-item:hover { color: rgba(255,255,255,0.85); }
.nm-item.active { color: var(--gold); }
.nm-item:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }
.nav-burger { display: none; background: none; border: none; cursor: pointer; padding: 6px; flex-direction: column; gap: 5px; }
.nav-burger span { display: block; width: 22px; height: 2px; background: rgba(255,255,255,0.65); border-radius: 1px; }

/* The 9 nav items need ~811px, the logo 144px and the padding 96px. The page
   label adds up to 201px on top of that ("08 — Delivery Specs"), which pushed
   the nav past the viewport between 1101px and ~1252px. The label is redundant
   with the highlighted nav item, so it goes first; the burger only comes in
   later, at 1100px, where the items themselves stop fitting. */
@media (max-width: 1300px) { .nav-label { display: none; } }

/* 9 nav items — collapse to the burger before they can crowd or wrap. */
@media (max-width: 1100px) {
  .nav-burger { display: flex; }
  .nav-menu {
    display: none !important; position: fixed; top: 56px; left: 0; right: 0;
    z-index: 200; background: var(--dark); flex-direction: column;
    border-bottom: 2px solid var(--gold); padding: 6px 0;
    max-height: calc(100vh - 56px); overflow-y: auto;
  }
  .nav-menu.open { display: flex !important; }
  .nm-item { padding: 13px 24px; border-bottom: 1px solid rgba(255,255,255,0.06); }
}
@media (max-width: 600px) { .nav { padding: 0 20px; } }

/* ── Left TOC rail ── */
.page-wrap {
  max-width: 1280px; margin: 0 auto; padding: 0 64px;
  display: grid; grid-template-columns: 220px 1fr; gap: 56px; align-items: start;
}
.page-wrap > .page, .page-wrap > .main { max-width: none; margin: 0; padding: 48px 0 80px; min-width: 0; }
.toc-rail {
  position: sticky; top: 72px; max-height: calc(100vh - 88px); overflow-y: auto;
  padding: 0 0 32px 20px; border-left: 3px solid var(--gold); margin-top: 48px;
  scrollbar-width: thin; scrollbar-color: var(--rule) transparent;
}
.toc-rail::-webkit-scrollbar { width: 4px; }
.toc-rail::-webkit-scrollbar-thumb { background: var(--rule); }
.toc-rail::-webkit-scrollbar-track { background: transparent; }
.toc-label {
  background: none; border: 0; width: 100%; text-align: left; font-family: inherit; cursor: pointer;
  font-size: 10px; font-weight: 700; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--gold); margin: 0 0 14px; display: block; padding: 0;
}
.toc-rail ol { list-style: none; margin: 0; padding: 0; counter-reset: toc; }
.toc-rail ol li { counter-increment: toc; }
.toc-rail a {
  display: flex; gap: 9px; align-items: baseline; color: var(--text-dim);
  padding: 5px 0; line-height: 1.4; text-decoration: none; font-size: 12px; transition: color 0.15s;
}
.toc-rail a::before {
  content: counter(toc, decimal-leading-zero);
  font: 600 9px ui-monospace, SFMono-Regular, Menlo, monospace;
  color: rgba(136,136,136,0.45); flex-shrink: 0;
}
.toc-rail a:hover { color: var(--dark); }
.toc-rail a:hover::before { color: var(--text-dim); }
.toc-rail a.is-active { color: var(--dark); font-weight: 600; }
.toc-rail a.is-active::before { color: var(--gold-d); }

@media (max-width: 900px) {
  .page-wrap { grid-template-columns: 1fr; gap: 0; padding: 0 24px; }
  .page-wrap > .page, .page-wrap > .main { padding: 32px 0 60px; }
  .toc-rail {
    position: sticky; top: 56px; z-index: 80; margin: 0 -24px;
    border-left: none; border-bottom: 1px solid var(--rule);
    background: var(--bg-2); padding: 0; max-height: none; overflow: visible;
  }
  .toc-label { display: flex; align-items: center; justify-content: space-between; padding: 0 24px; margin: 0; min-height: 44px; }
  .toc-label::after {
    content: ''; display: block; width: 0; height: 0; border-style: solid;
    border-width: 4px 4px 0; border-color: var(--text-dim) transparent transparent; transition: transform 0.2s;
  }
  .toc-rail.toc-open .toc-label::after { transform: rotate(180deg); }
  .toc-rail ol { display: none; padding: 8px 24px 16px; columns: 2; column-gap: 24px; }
  .toc-rail.toc-open ol { display: block; }
}
@media (max-width: 600px) {
  .page-wrap { padding: 0 20px; }
  .toc-rail { margin: 0 -20px; }
  .toc-label { padding: 0 20px; }
  /* padding must be restated, not just `columns` — the ≤900px block above sets
     24px and would otherwise leak down, sitting the TOC entries 4px right of
     their own label. */
  .toc-rail ol { padding: 8px 20px 16px; columns: 1; }
}

/* ── Footer ── */
.footer {
  background: var(--dark); border-top: 2px solid var(--gold);
  padding: 22px 64px; display: flex; align-items: center;
  justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.footer-left, .footer-right { font-size: 11px; color: #6A6A6A; letter-spacing: 0.06em; }
.footer-left { text-transform: uppercase; }
.footer-right { text-align: right; }
.footer-sep { color: #3A3A3A; padding: 0 6px; }
@media (max-width: 600px) {
  .footer { padding: 20px 24px; flex-direction: column; align-items: flex-start; gap: 8px; }
  .footer-right { text-align: left; }
}

/* ── Overflow guards ──
   Grid/flex children default to min-width:auto and refuse to shrink below
   their intrinsic content width. This is NOT a narrow-viewport concern: it is
   unconditional grid/flex correctness. Scoping it to max-width:900px is what
   left folder-structure.html rendering 2201px wide in a 1440px viewport — the
   mobile fix looked like it worked because nobody re-checked the desktop.

   Keep this list to containers only. `.anatomy-row > *` also belongs here on
   paper, but it ties with the page's own `.anatomy-folder { min-width: 140px }`
   on specificity and — loading later — silently collapsed that column to 77px.
   `.anatomy-desc` below is the only child that actually needs to shrink. */
.page-wrap > *, .anatomy-grid > *, .stage-block > *, .principles > * { min-width: 0; }

/* Long path/token strings (assets/<type>/<name>/_review/<versionId>/) cannot
   break at any normal opportunity, so they punch out of their container at
   every width. `anywhere` only breaks a word that would otherwise overflow, so
   short inline code is untouched. */
code, .cc-code, .ex-filename { overflow-wrap: anywhere; }

/* .anatomy-desc is a flex row whose text is an anonymous flex item — that item
   keeps min-width:auto and is unreachable from CSS, so the trailing badge gets
   pushed out of the viewport. Wrapping is the only lever available here. */
.anatomy-desc { min-width: 0; flex-wrap: wrap; }

@media (max-width: 600px) {
  code, .cc-code, .ex-filename { word-break: break-word; }
  .tree, .folder-tree, pre { overflow-x: auto; max-width: 100%; }
  .cc-tools { flex-wrap: wrap; justify-content: flex-end; }
  .cc-tool-chip { height: 26px; padding: 3px 5px; }
  .cc-tool-chip img { height: 16px; }
}

/* ── Print ──
   Navigation and decoration are not content. Without the nav/hero rules the
   first third of printed page 1 is a solid black bar and a 260px photo. */
@media print {
  .toc-rail, .nav, .skip-link, .hero { display: none; }
  .page-wrap { display: block; }
}
