/* learning.<DOMAIN>'s one stylesheet (routes/learning.ts serves it,
   versioned by its content). The brand is the portal's: concept 5a, square
   corners, the tokens below copied from packages/ui/src/tokens.ts
   (andomirTokens), which stays the source: learning-css.test.ts fails when
   one drifts. No hex below the token block, no radius but 0. The fonts are
   named as the portal names them and fall back to the system's: this host
   loads nothing from a third party. */
:root {
  --color-bg: #2A1518;
  --color-surface: #381D21;
  --color-surface-2: #3A1F23;
  --color-accent: #D9A227;
  --color-accent-hover: #B8871C;
  --color-accent-muted: rgba(217,162,39,0.14);
  --color-inverse-text: #2A1518;
  --color-text: #F2E8DA;
  --color-text-muted: #B08A78;
  --color-text-dim: #A98876;
  --color-border: #4A2C30;
  --color-border-subtle: #3A2126;
  --color-error: #D98A80;
  --color-error-muted: rgba(168,68,60,0.18);
  --color-success: #7FB08A;
  --color-success-muted: rgba(78,122,82,0.18);
  --color-warning: #E8833A;
  --color-warning-muted: rgba(232,131,58,0.14);
  --font-display: 'Space Grotesk', Helvetica, Arial, sans-serif;
  --font-body: 'IBM Plex Sans', Helvetica, Arial, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;
  --font-size-micro: 10.5px;
  --radius: 0px;
  --focus-ring: 0 0 0 2px #2A1518, 0 0 0 4px #D9A227;
  --side: 264px;
  --toc: 220px;
  --measure: 72ch;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font: 16px/1.6 var(--font-body);
}
a { color: var(--color-accent); text-underline-offset: 2px; }
a:hover { color: var(--color-accent-hover); }
:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--color-accent); color: var(--color-inverse-text); padding: 8px 12px; }
.skip:focus { left: 8px; z-index: 10; }

.eyebrow {
  margin: 0 0 8px;
  font: 500 var(--font-size-micro)/1.4 var(--font-mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-text-dim);
}

/* ── The top bar ─────────────────────────────────────────────────────── */
.top {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
  position: sticky;
  top: 0;
  z-index: 5;
}
.brand { display: flex; align-items: center; gap: 10px; font: 600 17px/1 var(--font-display); color: var(--color-text); text-decoration: none; white-space: nowrap; }
.mark { display: inline-grid; place-items: center; width: 28px; height: 28px; background: var(--color-accent); color: var(--color-inverse-text); font: 700 15px/1 var(--font-display); border-radius: var(--radius); }
.search { flex: 1; display: flex; max-width: 520px; margin-left: auto; }
.search input {
  flex: 1; min-width: 0; padding: 8px 12px;
  background: var(--color-bg); color: var(--color-text);
  border: 1px solid var(--color-border); border-right: 0; border-radius: var(--radius);
  font: inherit; font-size: 14px;
}
.search button, .signout button, .button {
  padding: 8px 14px; border: 1px solid var(--color-accent); border-radius: var(--radius);
  background: var(--color-accent); color: var(--color-inverse-text);
  font: 600 14px/1.2 var(--font-body); cursor: pointer; text-decoration: none; display: inline-block;
}
.signout { margin: 0; }
.signout button { background: transparent; color: var(--color-text-muted); border-color: var(--color-border); }
.lang { font-size: 14px; color: var(--color-text-muted); white-space: nowrap; }

/* ── The three columns ───────────────────────────────────────────────── */
.frame {
  display: grid;
  grid-template-columns: var(--side) minmax(0, 1fr) var(--toc);
  gap: 40px;
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
}
.side { position: sticky; top: 76px; align-self: start; max-height: calc(100vh - 96px); overflow-y: auto; font-size: 14px; }
.toc { position: sticky; top: 76px; align-self: start; font-size: 13px; }
.phone-nav { display: none; }
main { min-width: 0; max-width: var(--measure); }

.tree, .tree ul, .toc ol { list-style: none; margin: 0 0 20px; padding: 0; }
.tree ul { margin: 2px 0 8px 12px; padding-left: 10px; border-left: 1px solid var(--color-border-subtle); }
.tree summary { cursor: pointer; padding: 4px 0; list-style-position: outside; }
.tree a, .toc a { display: block; padding: 4px 0; color: var(--color-text-muted); text-decoration: none; }
.tree a:hover, .toc a:hover { color: var(--color-text); }
.tree a[aria-current="page"] { color: var(--color-accent); font-weight: 600; }
.toc li.toc-3 { padding-left: 12px; }
.toc ol { border-left: 1px solid var(--color-border); padding-left: 12px; }

/* ── Content ─────────────────────────────────────────────────────────── */
h1, h2, h3 { font-family: var(--font-display); line-height: 1.25; text-wrap: balance; }
h1 { font-size: 32px; margin: 8px 0 12px; }
h2 { font-size: 22px; margin: 36px 0 12px; scroll-margin-top: 80px; }
h3 { font-size: 17px; margin: 24px 0 8px; scroll-margin-top: 80px; }
.lead { font-size: 18px; color: var(--color-text-muted); margin: 0 0 20px; }
.meta { font-size: 13px; color: var(--color-text-dim); margin: 0 0 12px; }
.prose p, .prose li { max-width: var(--measure); }
.prose code, code { font: 0.92em var(--font-mono); background: var(--color-surface-2); padding: 1px 5px; border-radius: var(--radius); }
.prose figure { margin: 20px 0; }
.prose img { display: block; max-width: 100%; height: auto; border: 1px solid var(--color-border); border-radius: var(--radius); }
.table-wrap { overflow-x: auto; margin: 16px 0; }
table { border-collapse: collapse; font-size: 14px; min-width: 100%; }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--color-border); vertical-align: top; }
th { font: 500 var(--font-size-micro)/1.4 var(--font-mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--color-text-dim); }

.crumbs ol { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 0 0 8px; padding: 0; font-size: 13px; color: var(--color-text-dim); }
.crumbs li + li::before { content: '/'; margin-right: 6px; color: var(--color-border); }
.crumbs a { color: var(--color-text-muted); }

.tags { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 20px; }
.tag {
  font: 500 var(--font-size-micro)/1.4 var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase;
  padding: 3px 8px; border: 1px solid var(--color-border); color: var(--color-text-muted); border-radius: var(--radius);
}
.tag-flag { border-color: var(--color-warning); color: var(--color-warning); background: var(--color-warning-muted); }
.tag-addon { border-color: var(--color-accent); color: var(--color-accent); background: var(--color-accent-muted); }

.callout { margin: 20px 0; padding: 12px 16px; border-left: 3px solid var(--color-accent); background: var(--color-surface-2); }
.callout p { margin: 4px 0 0; }
.callout-label { font: 500 var(--font-size-micro)/1.4 var(--font-mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--color-accent); }
.callout-important { border-left-color: var(--color-error); }
.callout-important .callout-label { color: var(--color-error); }
.callout-tip { border-left-color: var(--color-success); }
.callout-tip .callout-label { color: var(--color-success); }

.cards { list-style: none; padding: 0; margin: 12px 0 32px; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.card a, .steps a {
  display: flex; flex-direction: column; gap: 6px; height: 100%; padding: 16px;
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius);
  color: var(--color-text); text-decoration: none;
}
.card a:hover, .steps a:hover { border-color: var(--color-accent); }
.card-title { font: 600 16px/1.3 var(--font-display); }
.card-text { font-size: 14px; color: var(--color-text-muted); }
.card-meta { margin-top: auto; font: 500 var(--font-size-micro)/1.4 var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--color-text-dim); }

.steps { counter-reset: step; list-style: none; padding: 0; display: grid; gap: 10px; }
.steps li { counter-increment: step; display: grid; grid-template-columns: 36px 1fr; gap: 12px; align-items: stretch; }
.steps li::before { content: counter(step); display: grid; place-items: center; background: var(--color-accent); color: var(--color-inverse-text); font: 700 16px/1 var(--font-display); }

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 40px 0 0; padding-top: 20px; border-top: 1px solid var(--color-border); }
.pager a { display: flex; flex-direction: column; gap: 4px; padding: 12px 16px; border: 1px solid var(--color-border); color: var(--color-text); text-decoration: none; }
.pager a:hover { border-color: var(--color-accent); }
.pager .next { text-align: right; grid-column: 2; }

.results { list-style: none; padding: 0; }
.results li { padding: 14px 0; border-bottom: 1px solid var(--color-border); }
.results li a { font: 600 17px/1.3 var(--font-display); }
.results .card-meta { display: block; margin-top: 4px; }
.results p { margin: 6px 0 0; color: var(--color-text-muted); font-size: 14px; }

/* ── The sign-in page ────────────────────────────────────────────────── */
.gate { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.gate-card { width: 100%; max-width: 440px; padding: 32px; background: var(--color-surface); border: 1px solid var(--color-border); }
.gate-card .brand { margin: 0 0 20px; }
.small { font-size: 14px; color: var(--color-text-muted); }

/* ── Narrower screens ────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .frame { grid-template-columns: var(--side) minmax(0, 1fr); }
  .toc { display: none; }
}
@media (max-width: 800px) {
  .frame { grid-template-columns: minmax(0, 1fr); padding: 16px; gap: 0; }
  .side { display: none; }
  .phone-nav { display: block; margin: 0 0 16px; padding: 10px 12px; border: 1px solid var(--color-border); background: var(--color-surface); }
  .phone-nav summary { cursor: pointer; font-weight: 600; }
  .phone-nav nav { margin-top: 12px; font-size: 14px; }
  .top { flex-wrap: wrap; gap: 10px; padding: 10px 16px; }
  .search { order: 5; flex-basis: 100%; max-width: none; }
  h1 { font-size: 26px; }
  .pager { grid-template-columns: 1fr; }
  .pager .next { grid-column: 1; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
