/* ============================================================
   Documentation shell — sidebar + content
   Altris cream-ground aesthetic
   ============================================================ */

.shell {
  /* sidebar is a fixed overlay drawer (below), so the only in-flow child
     is .content — block layout lets it center with auto margins */
  display: block;
  min-height: 100vh;
  background: var(--bg);
}

/* ---- Sidebar — overlay drawer ---- */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  width: var(--sidebar-w);
  height: 100vh;
  overflow-y: auto;
  background: var(--bg);
  border-right: 1px solid var(--rule);
  padding: var(--s-16) 0 var(--s-12);
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform .26s cubic-bezier(.4, 0, .2, 1);
  z-index: 60;
}

/* ---- Collapsible nav drawer (pure-CSS; default collapsed) ----
   A visually-hidden checkbox placed before .sidebar drives open/closed.
   The hamburger and the full-screen scrim are <label>s for it — no JS. */
.nav-cb { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.nav-cb:checked ~ .sidebar { transform: translateX(0); box-shadow: 0 0 48px rgba(11, 13, 15, 0.22); }

.nav-toggle {
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 70;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  background: var(--bg);
  border: 1px solid var(--rule);
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  transition: background .15s, border-color .15s;
}
.nav-toggle:hover { border-color: var(--rule-bold); }
.nav-toggle span,
.nav-toggle span::before,
.nav-toggle span::after {
  content: "";
  display: block;
  width: 18px;
  height: 2px;
  background: var(--ink);
  transition: transform .22s ease, opacity .12s;
}
.nav-toggle span { position: relative; }
.nav-toggle span::before { position: absolute; left: 0; top: -6px; }
.nav-toggle span::after  { position: absolute; left: 0; top: 6px; }
.nav-cb:checked ~ .nav-toggle { background: transparent; border-color: transparent; }
.nav-cb:checked ~ .nav-toggle span { background: transparent; }
.nav-cb:checked ~ .nav-toggle span::before { transform: translateY(6px) rotate(45deg); }
.nav-cb:checked ~ .nav-toggle span::after  { transform: translateY(-6px) rotate(-45deg); }
.nav-cb:focus-visible ~ .nav-toggle { outline: 2px solid var(--ink); outline-offset: 2px; }

.nav-scrim {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgba(11, 13, 15, 0.42);
  opacity: 0;
  visibility: hidden;
  transition: opacity .26s ease, visibility .26s ease;
  cursor: pointer;
}
.nav-cb:checked ~ .nav-scrim { opacity: 1; visibility: visible; }

.brand {
  padding: 0 var(--s-6) var(--s-8);
  border-bottom: 1px solid var(--rule);
  margin-bottom: var(--s-6);
}
.brand-link {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-decoration: none;
  color: var(--deep-70);
}
.brand-wordmark {
  width: 132px;
  --wm-w: 132px;
  color: var(--deep-70);
}
.brand-placeholder {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 3px 7px 3px 6px;
  border: 1px dashed var(--accent-terra);
  background: rgba(240, 146, 96, 0.08);
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 9.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-terra);
  align-self: flex-start;
  white-space: nowrap;
}
.brand-placeholder::before {
  content: "";
  width: 4px;
  height: 4px;
  background: var(--accent-terra);
  border-radius: 50%;
}
.brand-sub {
  font-family: var(--font-sans);
  font-size: 11px;
  color: var(--ink-muted);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 500;
}
/* legacy brand text styles kept harmless in case any page still uses them */
.brand-mark {
  width: 32px; height: 32px;
  background: var(--deep-70);
  color: var(--bg);
  display: grid; place-items: center;
  font-weight: 900;
  font-size: 16px;
  letter-spacing: -0.02em;
}
.brand-name {
  display: flex; flex-direction: column; line-height: 1.1;
}
.brand-name b {
  font-weight: 900;
  font-size: 15px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}
.brand-name span {
  font-size: 10px;
  color: var(--ink-muted);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 500;
  margin-top: 3px;
}

.nav-section {
  padding: 0 var(--s-6);
  margin-bottom: var(--s-5);
}
.nav-section h4 {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 0 0 var(--s-2);
}
.nav-list { list-style: none; padding: 0; margin: 0; }
.nav-list a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 12px;
  margin: 0 -12px;
  border: 0;
  color: var(--ink);
  font-size: 14px;
  font-weight: 400;
}
.nav-list a:hover { background: rgba(37,38,36,0.05); color: var(--ink); }
.nav-list a.active {
  background: var(--deep-70);
  color: var(--bg);
  font-weight: 700;
}
.nav-list .nav-dead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 12px;
  margin: 0 -12px;
  color: var(--ink-faint);
  font-size: 14px;
  font-weight: 400;
  cursor: default;
}
.nav-list .status {
  font-family: var(--font-sans);
  font-size: 10px;
  color: var(--ink-faint);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 500;
}
.nav-list a.active .status { color: var(--terra-30); }

.sidebar-foot {
  margin-top: auto;
  padding: var(--s-6) var(--s-6) 0;
  border-top: 1px solid var(--rule);
  font-size: 11px;
  color: var(--ink-faint);
  font-family: var(--font-sans);
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  display: flex; justify-content: space-between;
}

/* ---- Content ---- */
.content {
  padding: var(--s-12) var(--content-pad) var(--s-24);
  max-width: calc(var(--content-max) + var(--content-pad) * 2);
  margin-inline: auto; /* centered, responsive — fills width up to max-width then centers */
}

.crumbs {
  display: flex; gap: var(--s-2); align-items: center;
  font-family: var(--font-sans); font-size: 11px; font-weight: 500;
  color: var(--ink-faint); letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: var(--s-6);
}
.crumbs a { color: var(--ink-faint); border: 0; }
.crumbs a:hover { color: var(--ink); }
.crumbs .sep { opacity: 0.5; }

.page-head {
  padding-bottom: var(--s-10);
  border-bottom: 1px solid var(--rule);
  margin-bottom: var(--s-12);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--s-8);
  align-items: end;
}
.page-head h1 { margin: 0 0 var(--s-4); }
.page-head p { margin: 0; max-width: 62ch; color: var(--ink-muted); }
.page-head .meta {
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-faint);
  text-align: right;
  line-height: 2;
}
.page-head .meta .tag {
  display: inline-block;
  padding: 3px 8px;
  background: rgba(37,38,36,0.08);
  color: var(--ink);
  margin-left: 6px;
}
.page-head .meta .tag.live  { background: var(--deep-70); color: var(--bg); }
.page-head .meta .tag.draft { background: var(--terra-30); color: var(--terra-90); }
.page-head .meta .tag.wip   { background: var(--terra-50); color: #fff; }

section.doc-section {
  padding: var(--s-12) 0;
  border-top: 1px solid var(--rule);
  scroll-margin-top: var(--s-10);
}
section.doc-section:first-of-type { border-top: 0; padding-top: 0; }

.section-head {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: var(--s-10);
  margin-bottom: var(--s-8);
}
.section-head .label {
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding-top: 10px;
}
.section-head h2 { margin: 0 0 var(--s-3); }
.section-head p { margin: 0; color: var(--ink-muted); max-width: 58ch; }

/* Page footer nav */
.page-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-4);
  margin-top: var(--s-16);
  padding-top: var(--s-8);
  border-top: 1px solid var(--rule);
}
.page-nav a {
  display: block;
  padding: var(--s-5) var(--s-6);
  border: 1px solid var(--rule);
  color: var(--ink);
  background: transparent;
  transition: background .12s, border-color .12s;
}
.page-nav a:hover { background: var(--bg-paper); border-color: var(--rule-bold); }
.page-nav a .dir {
  font-family: var(--font-sans); font-weight: 500; font-size: 11px;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink-faint);
  display: block;
  margin-bottom: 4px;
}
.page-nav a .ttl { font-weight: 700; font-size: 17px; }
.page-nav a.next { text-align: right; }

/* Callout */
.callout {
  border-left: 2px solid var(--deep-70);
  padding: var(--s-4) var(--s-6);
  background: var(--bg-paper);
  font-size: 14px;
}
.callout b { font-weight: 700; }

/* Pill */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 8px;
  background: rgba(37,38,36,0.08);
  font-family: var(--font-sans); font-weight: 500; font-size: 10px;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ink-muted);
}
.pill .dot { width: 6px; height: 6px; background: var(--deep-70); border-radius: 50%; }
.pill.warn .dot { background: var(--s-warn); }
.pill.ok   .dot { background: var(--s-success); }
.pill.draft .dot { background: var(--terra-50); }

/* ============================================================
   Mobile — stack the chrome and collapse multi-column grids
   (loaded on every page, so this is the site-wide responsive pass)
   ============================================================ */
@media (max-width: 768px) {
  /* clear the fixed hamburger so it doesn't sit on top of the breadcrumbs */
  .content { padding-top: var(--s-16); }
  .page-head { grid-template-columns: 1fr; gap: var(--s-5); align-items: start; }
  .page-head .meta { text-align: left; }
  .section-head { grid-template-columns: 1fr; gap: var(--s-3); margin-bottom: var(--s-6); }
  .section-head .label { padding-top: 0; }
  .page-nav { grid-template-columns: 1fr; }
  .page-nav a.next { text-align: left; }
  .crumbs { flex-wrap: wrap; }

  /* Collapse content grids to a single column. Listed by class so it
     reaches each page's own stylesheet; !important beats the page rule
     (page <style> loads after this file). Chart internals (.bars .axis)
     and the auto-fit .hero-meta are intentionally left alone. */
  /* minmax(0,1fr) — single column with no min-content floor, so cells
     can't expand past the viewport (e.g. fixed-width logo lockups). */
  .principles, .convictions, .foundations, .pillars,
  .hero-strip, .pair-grid, .dont-grid, .ax-grid,
  .axia-hero, .rules, .dd-row, .directions,
  .explorations, .sizes, .variants, .misuse, .mock-grid,
  .space-row, .bp-grid, .tpl-grid, .tpl-hero .bot,
  .ease-grid, .pat-grid, .chart-grid, .stats, .pie-wrap,
  .legend, .size-row, .misuse-row, .rgrid {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  .icon-grid { grid-template-columns: repeat(3, 1fr) !important; }

  /* Wide tables become horizontally scrollable rather than overflowing. */
  .scale-table, .data-table { display: block; overflow-x: auto; max-width: 100%; }

  /* Typography weight specimens: let the specimen column shrink + wrap. */
  .weights { grid-template-columns: 80px minmax(0, 1fr) !important; }

  /* Components: tab strip wraps instead of overflowing. */
  .tabs { flex-wrap: wrap; }

  /* Color page: keep the 10-step tonal ramps as a swipeable strip
     instead of collapsing; tighten the role rows. */
  .scale { overflow-x: auto; }
  .scale-row { grid-template-columns: repeat(10, 50px) !important; height: 84px; }
  .role-row { grid-template-columns: 34px 1fr auto !important; }
  .role-row .use { display: none; }

  /* Grid page: keep all 12 columns but let them shrink to fit
     (covers the inline-styled column-label row too). */
  .grid-cols, .comp-row,
  .grid-demo > div[style*="repeat(12"] { grid-template-columns: repeat(12, minmax(0, 1fr)) !important; }
  .col-label { font-size: 8px; letter-spacing: 0; overflow: hidden; text-align: center; }
  .grid-rule { flex-wrap: wrap; height: auto; row-gap: 4px; }
  .comp-row .ph { min-width: 0; overflow: hidden; }
}

@media print {
  @page { size: A4 landscape; margin: 12mm 11mm; }

  html, body {
    background: #ffffff !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* hide interactive chrome that has no place in a static document */
  .nav-toggle, .nav-scrim, .sidebar, .nav-cb { display: none !important; }
  .page-nav { display: none !important; }

  /* let the content column fill the printable page width */
  .shell { display: block; }
  .content {
    max-width: none !important;
    width: auto !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  /* ===== print pagination — keep blocks whole, stop grids collapsing ===== */

  /* reset over-tall aspect-ratio / fixed-height boxes so they fit a page */
  [class*="stage"] { aspect-ratio: auto !important; height: auto !important; min-height: 140px !important; }
  [class*="cell"]  { aspect-ratio: auto !important; min-height: 0 !important; }
  .hero-strip, .grid-demo, .grid-cols, .comp-row,
  .product-card .img-stub { aspect-ratio: auto !important; height: auto !important; min-height: 0 !important; }
  .pie-wrap svg { max-height: 170px !important; }
  .curve { max-height: 120px !important; }
  [class*="scroll"] { overflow: visible !important; }

  /* re-assert columns so multi-col grids don't collapse to one column when paginated */
  .hero-strip { grid-template-columns: repeat(6, minmax(0,1fr)) !important; }
  .ax-grid    { grid-template-columns: 1.4fr 1fr 1fr 1fr 1fr !important; font-size: 10px; }
  .ax-grid > div { padding: 6px 8px; }
  .dont-grid, .icon-grid, .tpl-grid, .principles { grid-template-columns: repeat(3, minmax(0,1fr)) !important; }
  .grid-cols, .comp-row { grid-template-columns: repeat(12, minmax(0,1fr)) !important; }
  .size-row   { grid-template-columns: repeat(5, minmax(0,1fr)) !important; }
  .misuse-row { grid-template-columns: repeat(2, minmax(0,1fr)) !important; }
  .stats      { grid-template-columns: repeat(4, minmax(0,1fr)) !important; }

  /* never split an atomic content block across a page */
  [class*="-card"], [class*="cell"], [class*="-row"], [class*="stage"],
  .page-head, .crumbs, .section-head, .scale-head,
  .scale-row, .role-row, .pair, .pairing, .weights, .swatch, .card, .tile,
  .specimen, .callout, .quote, .hero-strip, .grid-demo, .principle, .pillar,
  .status-row, .conv, .found-card, .axia-hero, .dd, .variant, .mis, .mock,
  .pat, .lab, .comp-block, .stat, .pmf, .sizes, .ph, .tpl, .rgrid, .dont > div,
  .ax-grid, .dont-grid, .chart-card, .chart-stage, .pie-wrap,
  figure, blockquote, table tr { break-inside: avoid; }

  /* but allow genuinely tall grids to break BETWEEN rows (columns forced above) */
  .icon-grid, .size-row, .misuse-row { break-inside: auto; }

  /* ---- round 2: more page-unique grids to re-assert + sizing tweaks ---- */
  .sizes     { grid-template-columns: repeat(4, minmax(0,1fr)) !important; }
  .variants  { grid-template-columns: repeat(4, minmax(0,1fr)) !important; }
  .misuse    { grid-template-columns: repeat(3, minmax(0,1fr)) !important; }
  .ease-grid { grid-template-columns: repeat(4, minmax(0,1fr)) !important; break-inside: avoid; }
  .principles { break-inside: avoid; }
  /* cap the oversized Axia hero wordmark so it doesn't eat a whole page */
  .axia-hero { padding: var(--s-10) var(--s-8) !important; margin-bottom: var(--s-8) !important; }
  .axia-hero .mega { font-size: 150px !important; line-height: 0.9 !important; }
  /* cap the line-chart SVG so its card fits one page */
  .line-wrap svg { max-height: 210px !important; }
  /* keep the three direction-treatment cards together on one page */
  .directions { grid-template-columns: repeat(3, minmax(0,1fr)) !important; break-inside: avoid; }
  /* let the contrast matrix fill the page (break between rows, protect cells) */
  .ax-grid { break-inside: auto !important; }
  .ax-grid > div { break-inside: avoid; }
  /* keep the small button-rule callout with the block above it */
  .alert { break-before: avoid; }
  /* heat-map cells are revealed by JS (no-op in static print) — force visible */
  .pmf__cell { transform: none !important; }
  /* give each long-form type composition its own page region */
  .pairing + .pairing { break-before: page; }

  /* keep a heading attached to the content that follows it */
  h2, h3, h4, .section-head, .scale-head { break-after: avoid; }

  a { color: inherit; }
}
