/* CarKinematiX Academy — reading styles.
   Separate from the app's Tailwind build on purpose: this is a page you read,
   not a tool you operate, and it should not wait on a 1.4 MB bundle to render a
   paragraph. Palette echoes the app so the two feel related. */

:root {
  --bg: #070b14;
  --surface: #0e1420;
  --line: #1e2939;
  --ink: #e8edf6;
  --ink-dim: #9aa8bd;
  --accent: #5eead4;
  --accent-ink: #0b1220;
  --link: #7dd3fc;
  --warn: #fbbf24;
  --measure: 43rem;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #fbfcfe; --surface: #f2f5fa; --line: #dde4ee;
    --ink: #131a26; --ink-dim: #56637a;
    --accent: #0d9488; --accent-ink: #ffffff;
    --link: #0369a1;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.7 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ── chrome ─────────────────────────────────────────────────────────────── */

header.site, footer.site {
  border-bottom: 1px solid var(--line);
  padding: 1rem 1.5rem;
  display: flex; flex-wrap: wrap; gap: 1rem;
  align-items: center; justify-content: space-between;
}
footer.site { border-bottom: 0; border-top: 1px solid var(--line); margin-top: 4rem; display: block; }
footer.site p { margin: .35rem 0; color: var(--ink-dim); font-size: .9rem; }
footer.site .fine { font-size: .82rem; opacity: .8; max-width: var(--measure); }

.brand { font-weight: 650; letter-spacing: -.01em; text-decoration: none; color: var(--ink); }
.brand span { color: var(--accent); }
.app-link {
  text-decoration: none; font-size: .9rem; font-weight: 600;
  color: var(--accent-ink); background: var(--accent);
  padding: .45rem .8rem; border-radius: 6px;
}

main { max-width: var(--measure); margin: 0 auto; padding: 2.5rem 1.5rem 0; }
main.hub { max-width: 52rem; }

.crumbs { font-size: .85rem; color: var(--ink-dim); margin-bottom: 1.5rem; }
.crumbs a { color: var(--ink-dim); }

/* ── prose ──────────────────────────────────────────────────────────────── */

h1 { font-size: clamp(1.9rem, 5vw, 2.6rem); line-height: 1.15; letter-spacing: -.02em; margin: 0 0 .75rem; }
h2 { font-size: 1.45rem; line-height: 1.25; letter-spacing: -.01em; margin: 3rem 0 .75rem; }
h3 { font-size: 1.1rem; margin: 2rem 0 .5rem; }

.standfirst { font-size: 1.15rem; color: var(--ink-dim); margin: 0 0 2.5rem; line-height: 1.55; }

a { color: var(--link); text-underline-offset: 2px; }

strong { color: var(--ink); font-weight: 650; }

blockquote {
  margin: 1.75rem 0; padding: 1.1rem 1.3rem;
  background: var(--surface); border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
}
blockquote p:first-child { margin-top: 0; }
blockquote p:last-child { margin-bottom: 0; }

code {
  font-family: ui-monospace, "JetBrains Mono", SFMono-Regular, Menlo, monospace;
  font-size: .88em; background: var(--surface);
  padding: .12em .38em; border-radius: 4px;
}
pre { background: var(--surface); padding: 1rem 1.1rem; border-radius: 8px; overflow-x: auto; }
pre code { background: none; padding: 0; }

table { border-collapse: collapse; width: 100%; margin: 1.75rem 0; font-size: .93rem; }
th, td { text-align: left; padding: .55rem .7rem; border-bottom: 1px solid var(--line); }
th { color: var(--ink-dim); font-weight: 600; font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; }

/* Wide content scrolls inside its own box — the page body never does. */
.table-wrap, .math-block { overflow-x: auto; }
.math-block { margin: 1.75rem 0; padding: .35rem 0; }

hr { border: 0; border-top: 1px solid var(--line); margin: 3rem 0; }

/* ── the interactive callout ────────────────────────────────────────────────
   The centerpiece of every chapter: go and look at the thing. Given real visual
   weight because it is the part that teaches, not an aside from the part that
   teaches. Authored as `> **Go look at it**` blockquotes with a class hook. */

.try {
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 10%, var(--surface)), var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line));
  border-left: 3px solid var(--accent);
  border-radius: 8px; padding: 1.25rem 1.4rem; margin: 2rem 0;
}
.try h3, .try h4 { margin-top: 0; color: var(--accent); font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; }
.try ol { margin: .5rem 0 0; padding-left: 1.2rem; }
.try li { margin: .45rem 0; }
.try li::marker { color: var(--accent); font-weight: 700; }

.rule-of-thumb { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 1.1rem 1.3rem; margin: 2rem 0; }
.rule-of-thumb h3, .rule-of-thumb h4 { margin-top: 0; font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--warn); }

/* ── listings ───────────────────────────────────────────────────────────── */

.module { margin: 3rem 0; }
.module h2 { margin-bottom: .25rem; }
.module h2 a { color: var(--ink); text-decoration: none; }
.module > p { color: var(--ink-dim); margin-top: 0; }

ol.chapters { list-style: none; counter-reset: ch; padding: 0; margin: 1.25rem 0 0; }
ol.chapters li { counter-increment: ch; border-top: 1px solid var(--line); }
ol.chapters li:last-child { border-bottom: 1px solid var(--line); }
ol.chapters a, ol.chapters li.soon { display: grid; gap: .15rem; padding: .9rem .5rem .9rem 2.6rem; position: relative; text-decoration: none; color: var(--ink); }
ol.chapters a::before, ol.chapters li.soon::before {
  content: counter(ch, decimal-leading-zero);
  position: absolute; left: .5rem; top: .95rem;
  font: 600 .78rem/1 ui-monospace, monospace; color: var(--accent); opacity: .75;
}
ol.chapters a:hover { background: var(--surface); }
ol.chapters span { color: var(--ink-dim); font-size: .9rem; line-height: 1.5; }
ol.chapters li.soon { color: var(--ink-dim); opacity: .55; }
ol.chapters li.soon::before { color: var(--ink-dim); }

/* ── pager ──────────────────────────────────────────────────────────────── */

.pager { display: flex; gap: 1rem; justify-content: space-between; margin: 4rem 0 0; }
.pager a {
  flex: 1 1 0; display: grid; gap: .2rem; padding: .9rem 1.1rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  text-decoration: none; color: var(--ink); font-weight: 600; font-size: .95rem;
}
.pager a:hover { border-color: var(--accent); }
.pager .next { text-align: right; }
.pager span { font-size: .75rem; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-dim); font-weight: 500; }

@media (max-width: 34rem) {
  body { font-size: 16px; }
  main { padding: 1.75rem 1.15rem 0; }
  .pager { flex-direction: column; }
  .pager .next { text-align: left; }
}

/* ── diagrams ───────────────────────────────────────────────────────────────
   Hand-drawn schematics, inlined so they inherit the variables above and render
   correctly in both themes from one file. They replaced screenshots of the app:
   a screenshot shows every line the tool draws, and a chapter is usually talking
   about two of them. The simulator link below each one supplies the real version. */

figure.dg {
  margin: 2.25rem 0;
  padding: 1rem 1rem .25rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}
figure.dg svg { display: block; width: 100%; height: auto; overflow: visible; }
figure.dg figcaption {
  padding: .5rem .2rem 0;
  color: var(--ink-dim);
  font-size: .89rem;
  line-height: 1.55;
}
.dg-cta {
  display: inline-block;
  margin: .6rem .2rem 1rem;
  font-size: .9rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  padding-bottom: 1px;
}
.dg-cta:hover { border-bottom-color: var(--accent); }

@media (max-width: 34rem) {
  figure.dg { padding: .6rem .6rem .1rem; }
}

/* ── standing caveat ────────────────────────────────────────────────────────
   Deliberately quieter than the .try callout but impossible to skim past: it
   qualifies every number on the page, so it must not read as decoration. */
aside.note {
  margin: 2rem 0;
  padding: 1rem 1.2rem;
  border: 1px solid color-mix(in srgb, var(--warn) 30%, var(--line));
  border-left: 3px solid var(--warn);
  border-radius: 8px;
  background: color-mix(in srgb, var(--warn) 6%, var(--surface));
  font-size: .93rem;
  line-height: 1.6;
}
aside.note p { margin: 0; color: var(--ink-dim); }
aside.note strong { color: var(--ink); }
