/* The brand hub's own layout and documentation styles.
   Colors and sizes come from tokens/colors.css and tokens/foundations.css. */

@font-face { font-family: 'Jost'; src: url('../fonts/Jost%5Bwght%5D.ttf') format('truetype'); font-weight: 100 900; font-display: swap; }

:root {
  /* Short names used throughout the chapter markup. Each one points at a role. */
  --navy: var(--surface-0);
  --card: var(--surface-1);
  --line: var(--stroke-subtle);
  --grid: var(--navy-700);
  --blue: var(--blue-500);
  --blue-text: var(--text-link);
  --lime: var(--lime-300);
  --orange: var(--orange-500);
  --ink: var(--text-primary);
  --gray: var(--text-secondary);
  --side: 264px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 5rem; }
body { margin: 0; background: var(--surface-0); color: var(--text-primary); font-family: var(--font-body); font-size: var(--type-body-size); line-height: var(--type-body-line); -webkit-font-smoothing: antialiased; }
img, svg { max-width: 100%; }
a { color: var(--text-link); text-underline-offset: 3px; }
a:hover { color: var(--text-link-hover); }

/* ---------------------------------------------------------------- shell */
.shell { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); max-width: 1440px; margin: 0 auto; }
.side { position: sticky; top: 0; align-self: start; height: 100vh; z-index: 30; display: flex; flex-direction: column; background: var(--surface-0); border-right: 1px solid var(--line); overflow-y: auto; scrollbar-width: none; }
.side::-webkit-scrollbar { display: none; }
.side-brand { display: flex; align-items: center; min-height: 64px; padding: 0 20px; flex: none; }
.side-brand img { height: 24px; display: block; }
.side-back { display: block; flex: none; margin: 0 12px 12px; padding: 9px 12px; font-family: var(--font-mono); font-size: 12px; color: var(--text-primary); text-decoration: none; border: 1px solid var(--stroke-default); border-radius: var(--radius-control); }
.side-back:hover { border-color: var(--stroke-accent); color: var(--text-link); }
.top-back { margin-left: auto; margin-right: 12px; font-family: var(--font-mono); font-size: 12px; color: var(--text-secondary); text-decoration: none; }
.top-back:hover { color: var(--text-primary); }
.side nav { padding: 4px 8px 12px; flex: 1; }
.side details { border-top: 1px solid var(--line); }
.side summary { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 12px; cursor: pointer; list-style: none; font-family: var(--font-head); font-weight: 500; font-size: 11px; letter-spacing: 0.22em; text-transform: uppercase; color: var(--text-secondary); border-radius: var(--radius-control); }
.side summary::-webkit-details-marker { display: none; }
.side summary::after { content: ''; width: 6px; height: 6px; border-right: 1.5px solid var(--text-muted); border-bottom: 1.5px solid var(--text-muted); transform: rotate(-45deg); transition: transform var(--duration-fast) var(--ease-out); flex: none; }
.side details[open] > summary::after { transform: rotate(45deg); }
.side summary:hover { color: var(--text-primary); }
.side summary:focus-visible { outline: 2px solid var(--stroke-focus); outline-offset: -2px; }
.side details[open] > summary { color: var(--text-primary); }
.side ul { list-style: none; margin: 0; padding: 0 0 10px; }
.side li a { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 12px; font-size: 0.875rem; color: var(--text-secondary); text-decoration: none; border-radius: var(--radius-control); }
.side li a:hover { background: var(--state-hover); color: var(--text-primary); }
.side li a[aria-current='page'] { background: var(--state-selected); color: var(--text-primary); box-shadow: inset 3px 0 0 var(--stroke-accent); }
.side i.dot { display: inline-block; width: 7px; height: 7px; flex: none; }
.side i.dot.draft { background: var(--orange-400); }
.side i.dot.todo { border: 1px solid var(--text-muted); }
.side-foot { padding: 14px 20px 18px; border-top: 1px solid var(--line); flex: none; display: flex; flex-direction: column; gap: 10px; }
.side-foot span { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.switch { display: flex; border: 1px solid var(--stroke-default); border-radius: var(--radius-control); overflow: hidden; }
.switch button { flex: 1; font-family: var(--font-mono); font-size: 11px; color: var(--text-secondary); background: transparent; border: 0; padding: 7px 0; cursor: pointer; }
.switch button[aria-pressed='true'] { background: var(--state-selected); color: var(--text-primary); }
.switch button:focus-visible { outline: 2px solid var(--stroke-focus); outline-offset: -2px; }

.topbar { display: none; position: sticky; top: 0; z-index: 25; align-items: center; justify-content: space-between; height: 56px; padding: 0 16px; background: var(--surface-0); border-bottom: 1px solid var(--line); }
.topbar img { height: 22px; display: block; }
.topbar button { font-family: var(--font-mono); font-size: 12px; color: var(--text-primary); background: transparent; border: 1px solid var(--stroke-default); border-radius: var(--radius-control); padding: 8px 12px; cursor: pointer; }

.main { min-width: 0; }
.wrap { max-width: var(--page-max); margin: 0; padding: 0 48px; }
.page-head { padding: 64px 0 40px; border-bottom: 1px solid var(--line); }
.page-head .kicker { font-family: var(--font-mono); font-size: 12px; color: var(--text-secondary); display: block; margin-bottom: 14px; }
.page-head .kicker b { color: var(--text-link); font-weight: 500; }
.page-head .lede { margin: 18px 0 0; }
.page-body { padding: 16px 0 72px; }
.page-foot { display: flex; justify-content: space-between; gap: 16px; padding: 28px 0 72px; border-top: 1px solid var(--line); font-family: var(--font-head); font-weight: 600; }
.page-foot a { text-decoration: none; }
.page-foot small { display: block; font-family: var(--font-mono); font-weight: 400; font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.page-foot .next { text-align: right; margin-left: auto; }

@media (max-width: 980px) {
  .shell { display: block; }
  .side { position: fixed; inset: 0 auto 0 0; width: var(--side); height: auto; transform: translateX(-100%); transition: transform var(--duration-base) var(--ease-out); box-shadow: none; }
  body.menu-open .side { transform: none; box-shadow: var(--shadow-3); }
  .topbar { display: flex; }
  .wrap { padding: 0 20px; }
  .page-head { padding: 40px 0 28px; }
}

/* ---------------------------------------------------------------- type */
h1, h2, h3 { font-family: var(--font-head); font-weight: 600; margin: 0; }
h1 { font-size: var(--type-h1-size); line-height: var(--type-h1-line); letter-spacing: var(--type-h1-track); }
h2 { font-size: var(--type-h2-size); line-height: var(--type-h2-line); letter-spacing: var(--type-h2-track); }
h3 { font-size: var(--type-h3-size); line-height: var(--type-h3-line); margin-bottom: 0.5rem; }
p { margin: 0 0 1rem; max-width: var(--measure); }
.lede { font-size: var(--type-lede-size); line-height: var(--type-lede-line); color: var(--text-primary); max-width: 58ch; }
.muted { color: var(--text-secondary); }
.label { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.04em; color: var(--text-secondary); }
.label b { color: var(--text-link); font-weight: 500; }
.caps { font-family: var(--font-head); font-weight: 500; font-size: var(--type-label-size); letter-spacing: var(--type-label-track); text-transform: uppercase; color: var(--text-secondary); }
code { font-family: var(--font-mono); font-size: 0.86em; color: var(--text-primary); background: var(--surface-1); padding: 0.1em 0.4em; }
ul.plain { margin: 0 0 1rem; padding-left: 1.15rem; max-width: var(--measure); }
ul.plain li { margin-bottom: 0.4rem; }
ul.plain li::marker { color: var(--blue-500); }

/* ---------------------------------------------------------------- documentation blocks */
.sub { margin-top: 56px; }
.sub > .caps { display: block; margin-bottom: 16px; }
.cols { display: grid; gap: 16px; }
.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.c6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.tile { background: var(--surface-1); border: 1px solid var(--line); padding: 28px; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.tile.center { align-items: center; justify-content: center; text-align: center; }
.tile.white { background: #FFFFFF; border-color: #FFFFFF; color: #5F5E5A; }
.tile.flush { padding: 0; overflow: hidden; }
.tile .label, .tile .caps { margin-top: auto; }
.stage { display: flex; align-items: center; justify-content: center; min-height: 150px; width: 100%; }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.facts > div { background: var(--surface-0); padding: 22px 24px; }
.facts .caps { display: block; margin-bottom: 8px; }
.facts p { margin: 0; }

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.94rem; }
th { text-align: left; font-family: var(--font-head); font-weight: 500; font-size: 12px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--text-secondary); padding: 0 16px 10px 0; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px 16px 12px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
td.mono, .mono { font-family: var(--font-mono); font-size: 0.8125rem; }
.pass { color: var(--lime-300); }
.warn { color: var(--orange-500); }

.swatch { min-height: 150px; padding: 18px; display: flex; flex-direction: column; justify-content: flex-end; font-family: var(--font-mono); font-size: 12px; line-height: 1.5; }
.swatch strong { font-family: var(--font-head); font-weight: 600; font-size: 1.05rem; letter-spacing: 0.01em; }
.ratio { display: flex; height: 44px; border: 1px solid var(--line); }
.ratio div { display: flex; align-items: center; padding-left: 12px; font-family: var(--font-mono); font-size: 11px; white-space: nowrap; overflow: hidden; }

.dont { position: relative; }
.dont::after { content: ''; position: absolute; left: 14px; top: 14px; width: 14px; height: 14px; background: linear-gradient(45deg, transparent 43%, var(--orange-500) 43% 57%, transparent 57%), linear-gradient(-45deg, transparent 43%, var(--orange-500) 43% 57%, transparent 57%); }

.spec { border-top: 1px solid var(--line); padding: 22px 0; display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 20px; align-items: baseline; }
.spec:last-child { border-bottom: 1px solid var(--line); }
.spec .label { line-height: 1.6; }
.giant { font-family: var(--font-head); font-weight: 600; font-size: clamp(3rem, 9vw, 6rem); line-height: 1; letter-spacing: -0.02em; }

.swap { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.swap > div { background: var(--surface-0); padding: 16px 20px; }
.swap .no { color: var(--text-secondary); text-decoration: line-through; text-decoration-color: var(--orange-500); }
blockquote { margin: 0; padding: 24px 28px; background: var(--surface-1); border-left: 4px solid var(--blue-500); font-family: var(--font-head); font-size: 1.3rem; line-height: 1.4; font-weight: 500; }
blockquote + blockquote { margin-top: 12px; }
blockquote cite { display: block; margin-top: 12px; font-family: var(--font-mono); font-style: normal; font-size: 12px; color: var(--text-secondary); }

.pat { min-height: 140px; background-color: var(--surface-0); background-repeat: repeat; border: 1px solid var(--line); position: relative; }
.pat span { position: absolute; left: 0; bottom: 0; background: var(--surface-0); padding: 6px 10px; }

/* Home page */
.hero { padding: 72px 0 56px; border-bottom: 1px solid var(--line); background: url('../elements/pattern-steps.svg') repeat; background-size: 88px; }
.hero .plate { background: var(--surface-0); padding: 56px 56px 52px; }
.hero .lock { height: 52px; display: block; margin-bottom: 40px; }
.hero h1 { font-size: var(--type-display-size); line-height: var(--type-display-line); letter-spacing: var(--type-display-track); }
.chapters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.chapter { display: flex; flex-direction: column; gap: 6px; padding: 20px; background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--radius-card); text-decoration: none; color: inherit; transition: border-color var(--duration-fast) var(--ease-out), background-color var(--duration-fast) var(--ease-out); }
.chapter:hover { border-color: var(--stroke-accent); background: var(--surface-2); color: inherit; }
.chapter strong { font-family: var(--font-head); font-weight: 600; font-size: 1.125rem; }
.chapter span { font-size: 0.875rem; color: var(--text-secondary); }
.chapter i { font-style: normal; font-family: var(--font-mono); font-size: 10px; align-self: flex-start; padding: 2px 7px; border-radius: var(--radius-tag); margin-top: 6px; }
.chapter i.built { background: var(--fill-accent-quiet); color: var(--text-link); }
.chapter i.draft { background: var(--orange-900); color: var(--orange-200); }
.chapter i.todo { border: 1px solid var(--line); color: var(--text-muted); }
.stub { border: 1px dashed var(--stroke-default); padding: 32px; margin-top: 40px; }

/* Color chapter */
.ramp { margin-top: 44px; }
.ramp-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.ramp-head h3 { text-transform: capitalize; margin: 0; }
.ramp-head span { color: var(--text-secondary); font-size: 0.94rem; }
.swatches { display: grid; grid-template-columns: repeat(11, minmax(0, 1fr)); }
.sw { position: relative; height: 104px; padding: 10px 8px 8px; border: 0; text-align: left; font-family: var(--font-mono); font-size: 11px; line-height: 1.4; cursor: pointer; display: flex; flex-direction: column; justify-content: flex-end; min-width: 0; }
.sw b { font-family: var(--font-head); font-weight: 600; font-size: 14px; }
.sw .hex { overflow: hidden; white-space: nowrap; }
.sw.base::before { content: 'BASE'; position: absolute; left: 8px; top: 9px; font-family: var(--font-head); font-weight: 600; font-size: 9px; letter-spacing: 0.18em; }
.sw.used::after { content: ''; position: absolute; right: 8px; top: 10px; width: 7px; height: 7px; background: currentColor; }
.sw:focus-visible { outline: 2px solid var(--stroke-focus); outline-offset: 2px; z-index: 1; }
.sw:hover { z-index: 1; box-shadow: 0 0 0 2px var(--surface-0), 0 0 0 4px var(--stroke-focus); }
.used-by { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-family: var(--font-mono); font-size: 11px; color: var(--text-secondary); border: 1px solid var(--line); padding: 2px 8px; }
.legend { display: flex; gap: 22px; flex-wrap: wrap; margin-top: 18px; color: var(--text-secondary); font-size: 0.875rem; }
.legend i { display: inline-block; width: 7px; height: 7px; background: var(--text-secondary); margin-right: 8px; vertical-align: 1px; }
.role { background: var(--surface-1); border: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; }
.role .sample { height: 84px; display: flex; align-items: center; justify-content: center; border-bottom: 1px solid var(--line); font-family: var(--font-head); font-weight: 600; font-size: 28px; }
.role .body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.role .name { font-family: var(--font-mono); font-size: 13px; color: var(--text-primary); overflow-wrap: anywhere; }
.role .ref { font-family: var(--font-mono); font-size: 11px; color: var(--text-secondary); }
.role .use { font-size: 0.875rem; color: var(--text-secondary); margin-top: 4px; }
.badge { align-self: flex-start; margin-top: 8px; font-family: var(--font-mono); font-size: 11px; padding: 2px 8px; }
.badge.pass { background: var(--lime-300); color: var(--navy-950); }
.badge.large { background: var(--orange-500); color: var(--navy-950); }
.badge.fail { background: var(--red-500); color: var(--navy-950); }
.float-stage { background: var(--surface-1); border: 1px solid var(--line); padding: 36px 28px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 28px; }
.float { padding: 18px 18px 16px; border-radius: var(--radius-card); min-height: 110px; display: flex; flex-direction: column; justify-content: flex-end; gap: 4px; }

/* Component and token demos */
.demo { background: var(--surface-1); border: 1px solid var(--line); padding: 28px; display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.demo.on-page { background: var(--surface-0); }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.scale { display: flex; flex-direction: column; gap: 10px; }
.scale div { display: flex; align-items: center; gap: 16px; }
.scale i { display: block; height: 16px; background: var(--blue-500); flex: none; }
.scale span { font-family: var(--font-mono); font-size: 12px; color: var(--text-secondary); white-space: nowrap; }
.shape-box { height: 96px; background: var(--surface-2); border: 1.5px solid var(--stroke-strong); display: flex; align-items: flex-end; padding: 10px 12px; font-family: var(--font-mono); font-size: 11px; color: var(--text-secondary); }
.mover { height: 44px; background: var(--surface-0); border: 1px solid var(--line); position: relative; overflow: hidden; }
.mover i { position: absolute; left: 6px; top: 6px; width: 32px; height: 32px; background: var(--blue-500); transition: transform var(--d, 200ms) var(--ease-out); }
.mover.go i { transform: translateX(calc(var(--travel, 300px))); }

/* Downloads */
.files { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.file { display: flex; flex-direction: column; text-decoration: none; color: inherit; border: 1px solid var(--line); min-width: 0; }
.file:hover { border-color: var(--stroke-accent); color: inherit; }
.file .thumb { height: 96px; display: flex; align-items: center; justify-content: center; padding: 14px; background: var(--surface-1); }
.file .thumb.white { background: #FFFFFF; }
.file .thumb.blue { background: var(--blue-500); }
.file .thumb img { max-height: 100%; max-width: 100%; }
.file span { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-secondary); padding: 8px 10px; border-top: 1px solid var(--line); overflow-wrap: anywhere; }

/* Fixed helpers */
.to-top { position: fixed; right: 24px; bottom: 24px; z-index: 20; width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; background: var(--surface-1); border: 1px solid var(--stroke-default); opacity: 0; pointer-events: none; transition: opacity var(--duration-base) var(--ease-out), border-color var(--duration-fast) var(--ease-out); }
.to-top.show { opacity: 1; pointer-events: auto; }
.to-top:hover, .to-top:focus-visible { border-color: var(--stroke-accent); outline: none; }
.to-top svg { width: 20px; height: 20px; fill: var(--blue-500); }
.to-top:hover svg { fill: var(--lime-300); }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); background: var(--surface-inverse); color: var(--text-on-inverse); font-family: var(--font-mono); font-size: 12px; padding: 8px 14px; opacity: 0; transition: opacity var(--duration-fast) var(--ease-out); pointer-events: none; z-index: 40; }
.toast.show { opacity: 1; }

@media (max-width: 1180px) {
  .chapters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .swatches { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .sw { height: 88px; }
}
@media (max-width: 820px) {
  .c3, .c4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .c6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .spec { grid-template-columns: 1fr; gap: 6px; }
  .float-stage { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero { padding: 40px 0; }
  .hero .plate { padding: 32px 24px 28px; }
}
@media (max-width: 560px) {
  .c2, .facts, .swap, .chapters { grid-template-columns: 1fr; }
  .tile, .demo { padding: 20px; }
  .swatches { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
