/* GenAI crash course: shared styles. Colour tokens first; dark mode follows the OS unless toggled. */
:root {
  --bg: #fafaf7; --surface: #ffffff; --ink: #1b1f24; --muted: #5b6470; --line: #e3e5e8;
  --accent: #1f5fbf; --accent-ink: #ffffff; --accent-soft: #e7effb;
  --good: #0b7a4b; --warn: #b4540a; --bad: #b3261e;
  --c1: #0072b2; --c2: #e69f00; --c3: #009e73; --c4: #d55e00; --c5: #cc79a7; --grey: #8a929c;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 14px rgba(0,0,0,.05);
  --r: 12px; --maxw: 1100px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12151a; --surface: #1b2027; --ink: #e8ebef; --muted: #9aa4b1; --line: #2d343d;
    --accent: #6ea8fe; --accent-ink: #0b1220; --accent-soft: #1d2b44;
    --good: #4cc38a; --warn: #f0a15a; --bad: #ff8a80; --grey: #7c8591;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 14px rgba(0,0,0,.3);
  }
}
:root[data-theme="dark"] {
  --bg: #12151a; --surface: #1b2027; --ink: #e8ebef; --muted: #9aa4b1; --line: #2d343d;
  --accent: #6ea8fe; --accent-ink: #0b1220; --accent-soft: #1d2b44;
  --good: #4cc38a; --warn: #f0a15a; --bad: #ff8a80; --grey: #7c8591;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 14px rgba(0,0,0,.3);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
img, canvas, svg { max-width: 100%; }
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 16px; }

/* header */
.site-head { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.site-head .wrap { display: flex; align-items: center; gap: 14px; height: 56px; }
.brand { font-weight: 700; text-decoration: none; color: var(--ink); white-space: nowrap; }
.brand span:not(.long) { color: var(--accent); }
.nav { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; }
.nav a { text-decoration: none; color: var(--muted); padding: 6px 10px; border-radius: 8px; font-size: 15px; }
.nav a:hover, .nav a[aria-current="page"] { color: var(--ink); background: var(--accent-soft); }
.theme-btn { border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 8px; padding: 5px 9px; cursor: pointer; font-size: 14px; }

/* hero + cards */
.hero { padding: 44px 0 18px; }
.hero h1 { font-size: clamp(28px, 5vw, 42px); line-height: 1.15; margin: 0 0 10px; }
.hero p { color: var(--muted); max-width: 62ch; font-size: 18px; margin: 0 0 18px; }
.btn { display: inline-block; padding: 9px 16px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); text-decoration: none; font-weight: 600; font-size: 15px; cursor: pointer; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); margin: 18px 0 30px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 8px; }
.card h3 { margin: 0; font-size: 17px; }
.card .num { font: 600 12px/1 ui-monospace, monospace; color: var(--accent); letter-spacing: .06em; }
.card p { margin: 0; color: var(--muted); font-size: 14.5px; }
.card .row { margin-top: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.chip { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); }
.chip.soon { background: var(--line); color: var(--muted); }

/* lesson page */
.lesson { display: grid; grid-template-columns: 1fr; gap: 24px; padding: 24px 0 60px; }
@media (min-width: 900px) { .lesson { grid-template-columns: 220px minmax(0, 1fr); } }
.lesson article { min-width: 0; }
pre { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; font-size: 13.5px; }
pre code { background: none; padding: 0; }
.toc { position: sticky; top: 72px; align-self: start; font-size: 14px; }
.toc a { display: block; padding: 4px 0; color: var(--muted); text-decoration: none; }
.toc a:hover { color: var(--accent); }
@media (max-width: 899px) { .toc { position: static; } }
.lesson h1 { margin: 0 0 6px; font-size: clamp(26px, 4vw, 34px); }
.lesson h2 { margin-top: 36px; padding-top: 8px; border-top: 1px solid var(--line); font-size: 22px; }
.lede { color: var(--muted); font-size: 18px; }
.box { border: 1px solid var(--line); border-left: 4px solid var(--accent); background: var(--surface); border-radius: 8px; padding: 12px 16px; margin: 14px 0; }
.box.warn { border-left-color: var(--warn); }
.box.good { border-left-color: var(--good); }
.box > :first-child { margin-top: 0; } .box > :last-child { margin-bottom: 0; }
.eq { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; margin: 10px 0; }
.eq .cap { color: var(--muted); font-size: 14px; margin-top: 4px; }
figure { margin: 16px 0; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px; }
figure img { display: block; margin: 0 auto; border-radius: 4px; background: #fff; }
figcaption { color: var(--muted); font-size: 14px; margin-top: 8px; }
.dl { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.dl .btn { text-align: center; }
.dl small { display: block; font-weight: 400; color: var(--muted); }
.dl .btn.primary small { color: var(--accent-ink); opacity: .85; }
details.q { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; margin: 8px 0; }
details.q summary { cursor: pointer; font-weight: 600; }
details.q[open] summary { margin-bottom: 8px; }
table { border-collapse: collapse; width: 100%; font-size: 15px; display: block; overflow-x: auto; }
th, td { border-bottom: 1px solid var(--line); padding: 6px 10px; text-align: left; vertical-align: top; }
th { color: var(--muted); font-weight: 600; }
code { font: 14px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--accent-soft); padding: 1px 5px; border-radius: 4px; }
footer { border-top: 1px solid var(--line); padding: 22px 0 40px; color: var(--muted); font-size: 14px; }

/* playground */
.pg { display: grid; gap: 14px; grid-template-columns: 1fr; padding: 16px 0 50px; }
@media (min-width: 1000px) { .pg { grid-template-columns: 200px minmax(0, 1fr) 300px; align-items: start; } }
.pg-list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 10px; }
.pg-list h4 { margin: 8px 6px 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.pg-list button { display: block; width: 100%; text-align: left; border: 0; background: transparent; color: var(--ink); padding: 7px 8px; border-radius: 8px; cursor: pointer; font: inherit; font-size: 14.5px; }
.pg-list button:hover { background: var(--accent-soft); }
.pg-list button[aria-current="true"] { background: var(--accent); color: var(--accent-ink); }
.pg-main { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; min-width: 0; }
.pg-main h2 { margin: 0 0 2px; font-size: 21px; }
.pg-main .blurb { color: var(--muted); margin: 0 0 10px; }
.stage { width: 100%; aspect-ratio: 4 / 3; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.stage canvas { width: 100%; height: 100%; display: block; }
.explain { display: grid; gap: 10px; margin-top: 12px; }
@media (min-width: 700px) { .explain { grid-template-columns: 1fr 1fr; } }
.explain .box { font-size: 14.5px; }
.explain .box b { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 2px; }
.pg-ctl { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; }
.pg-ctl h3 { margin: 0 0 8px; font-size: 15px; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.ctl { margin: 0 0 14px; }
.ctl label { display: flex; justify-content: space-between; align-items: baseline; font-weight: 600; font-size: 14.5px; gap: 8px; }
.ctl .val.sel { max-width: 55%; overflow: hidden; text-overflow: ellipsis; }
.ctl .val { flex: none; font: 600 13px ui-monospace, monospace; color: var(--accent); background: var(--accent-soft); padding: 1px 7px; border-radius: 6px; white-space: nowrap; }
.ctl input[type=range] { width: 100%; accent-color: var(--accent); margin: 6px 0 0; }
.ctl select, .ctl input[type=text] { width: 100%; padding: 7px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font: inherit; margin-top: 4px; }
.ctl .help { color: var(--muted); font-size: 13px; margin-top: 2px; }
.ctl .ends { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; }
.tools { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; border-top: 1px solid var(--line); padding-top: 12px; }

@media (max-width: 640px) {
  .site-head .wrap { height: auto; min-height: 52px; flex-wrap: wrap; gap: 2px 8px; padding-top: 6px; padding-bottom: 6px; }
  .nav { margin-left: 0; width: 100%; gap: 2px; }
  .nav a { padding: 5px 8px; font-size: 14px; }
  .brand .long { display: none; }
  .hero { padding-top: 24px; }
}

.pg-list summary { display: none; }
@media (max-width: 999px) { .pg-list summary { display: block; cursor: pointer; font-weight: 600; padding: 6px 8px; } .pg-list[open] summary { margin-bottom: 6px; border-bottom: 1px solid var(--line); } }
