/* React Ride School: Tempershift Labs look (dark, cyan), lessons on the left, a code bench under each lesson. */
:root {
  --bg: #071015; --surface: #0b1219; --surface-2: #101a23; --ink: #eef5f8; --muted: #8d9aa8;
  --line: rgba(255, 255, 255, .1); --cyan: #6fe7ff; --cyan-ink: #04161c; --ticket: #ffc861;
  --good: #5fdc9b; --bad: #ff8a7a; --code-bg: #050b0f;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "Cascadia Code", "JetBrains Mono", Consolas, ui-monospace, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; } /* hidden must win over any display rule, or the word pop-up can't close */
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.6 var(--sans); }
a { color: var(--cyan); }
code { font-family: var(--mono); font-size: .9em; background: rgba(111, 231, 255, .08); padding: .1em .35em; border-radius: 5px; }
button { font: inherit; }
/* learners must see => and !== exactly as typed, not joined into one symbol */
code, pre, textarea { font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

/* top bar */
.top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px; min-height: 64px;
  padding: env(safe-area-inset-top, 0px) max(16px, env(safe-area-inset-right, 0px)) 0 max(16px, env(safe-area-inset-left, 0px));
  background: rgba(7, 16, 21, .94); border-bottom: 1px solid var(--line); backdrop-filter: blur(8px);
}
.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; min-width: 0; }
.brand img { height: 28px; width: auto; }
.brand span { font-weight: 800; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-left: 12px; border-left: 1px solid var(--line); }
.menu { display: none; background: none; border: 1px solid var(--line); color: var(--ink); border-radius: 8px; width: 40px; height: 40px; cursor: pointer; }
.progress { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.progress b { color: var(--ink); }
.progress i { display: block; width: 110px; height: 6px; border-radius: 6px; background: var(--line); overflow: hidden; }
.progress em { display: block; height: 100%; width: 0; background: var(--ticket); transition: width .3s; }

/* layout */
.layout { display: grid; grid-template-columns: 290px minmax(0, 1fr); }
.side { position: sticky; top: 64px; align-self: start; height: calc(100vh - 64px); overflow: auto; padding: 20px 14px 40px max(16px, env(safe-area-inset-left, 0px)); border-right: 1px solid var(--line); }
.side h2, .mod h2 { margin: 18px 0 8px; font-size: .78rem; font-weight: 800; color: var(--ink); }
.side h2 span, .mod h2 span { display: block; color: var(--cyan); font-size: .64rem; letter-spacing: .18em; text-transform: uppercase; }
.side ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.side a { display: grid; grid-template-columns: 26px 1fr 16px; gap: 6px; align-items: baseline; padding: 6px 8px; border-radius: 8px; color: #b7c4cf; text-decoration: none; font-size: .88rem; line-height: 1.35; }
.side a:hover { background: var(--surface-2); color: var(--ink); }
.side a.on { background: rgba(111, 231, 255, .1); color: var(--ink); }
.side .num { font-family: var(--mono); font-size: .75rem; color: var(--muted); }
.side a.done .num, .side .tick { color: var(--good); }
main { min-width: 0; padding: 36px max(16px, env(safe-area-inset-right, 0px)) 80px max(16px, env(safe-area-inset-left, 0px)); }
.loading { color: var(--muted); padding: 40px 16px; }

/* home */
.home, .lesson { max-width: 1100px; margin: 0 auto; }
.eyebrow { margin: 0 0 12px; color: var(--cyan); font-size: .67rem; font-weight: 900; letter-spacing: .18em; }
.home h1 { margin: 0; font-size: clamp(2.2rem, 6vw, 4.4rem); line-height: .98; letter-spacing: -.05em; max-width: 14ch; text-wrap: balance; }
.lede { max-width: 62ch; color: var(--muted); font-size: 1.05rem; line-height: 1.75; margin: 20px 0 0; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 26px 0 8px; }
.how { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin: 34px 0 10px; }
.how div { padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.how p { margin: 6px 0 0; color: var(--muted); font-size: .92rem; }
.mod { margin-top: 30px; }
.tickets { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
/* each lesson is a ride ticket: a numbered stub, a perforation, then the ride */
.ticket { display: flex; min-height: 74px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); color: var(--ink); text-decoration: none; overflow: hidden; }
.ticket:hover { border-color: rgba(111, 231, 255, .45); }
.ticket .stub { flex: 0 0 58px; display: grid; place-items: center; font: 800 1.15rem var(--mono); color: var(--ticket); border-right: 2px dashed var(--line); background: var(--surface-2); }
.ticket.done .stub { color: var(--good); }
.ticket .body { padding: 12px 14px; display: grid; gap: 2px; align-content: center; min-width: 0; }
.ticket .t { font-weight: 700; line-height: 1.3; }
.ticket .meta { color: var(--muted); font-size: .8rem; }
.small { color: var(--muted); font-size: .85rem; margin-top: 30px; }

/* buttons (same shape as the main site) */
.button { display: inline-flex; min-height: 44px; padding: 0 18px; align-items: center; justify-content: center; border-radius: 10px; background: #eef3fb; color: #071015; font-weight: 800; text-decoration: none; border: 0; cursor: pointer; }
.button.secondary { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.button:disabled { opacity: .6; cursor: wait; }
.mini { margin-left: auto; background: none; border: 1px solid var(--line); color: var(--muted); border-radius: 6px; padding: 2px 10px; font-size: .78rem; cursor: pointer; }

/* lesson text */
.lesson h1 { margin: 0 0 18px; font-size: clamp(1.9rem, 4.5vw, 3rem); line-height: 1.05; letter-spacing: -.04em; text-wrap: balance; }
.prose { max-width: 70ch; }
.prose p, .prose li { color: #c9d4dc; }
.prose h2 { font-size: 1.25rem; margin: 30px 0 8px; letter-spacing: -.02em; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li { margin: 6px 0; }
.snippet { margin: 16px 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--code-bg); }
.snippet figcaption { padding: 6px 12px; font: .75rem var(--mono); color: var(--muted); border-bottom: 1px solid var(--line); }
.snippet pre, .cmd pre { margin: 0; padding: 14px; overflow-x: auto; }
.snippet code, .cmd code { background: none; padding: 0; font-size: .86rem; line-height: 1.6; color: #d6e6ee; }
.tip { margin: 20px 0; padding: 14px 16px; border-left: 3px solid var(--ticket); background: rgba(255, 200, 97, .06); border-radius: 0 10px 10px 0; }
.tip strong { color: var(--ticket); font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; }
.tip p { margin: 4px 0 0; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 700; }

/* code bench */
.bench { margin-top: 30px; display: grid; gap: 16px; }
.mission { padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.mission h2 { margin: 0 0 10px; font-size: 1rem; }
#tasks { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
#tasks li { display: grid; grid-template-columns: 22px 1fr; gap: 8px; color: #c9d4dc; }
#tasks .st { width: 18px; height: 18px; margin-top: 3px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; font-size: .7rem; font-weight: 900; }
#tasks li.checking .st { border-color: var(--cyan); border-top-color: transparent; animation: spin .8s linear infinite; }
#tasks li.pass .st { background: var(--good); border-color: var(--good); color: #062014; }
#tasks li.pass .st::after { content: "✓"; }
#tasks li.fail .st { background: var(--bad); border-color: var(--bad); color: #2a0703; }
#tasks li.fail .st::after { content: "!"; }
#tasks li.fail { color: var(--ink); }
@keyframes spin { to { transform: rotate(360deg); } }
.bench-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.hint { margin: 14px 0 0; padding: 12px 14px; border-radius: 10px; background: rgba(255, 200, 97, .08); color: #f3e2bd; font-size: .92rem; }
.result { margin: 12px 0 0; font-weight: 700; min-height: 1em; }
.result.good, .why.good { color: var(--good); }
.result.bad, .why.bad { color: var(--bad); }
.panes { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 16px; }
.pane { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--code-bg); display: flex; flex-direction: column; min-width: 0; }
.bar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--surface); font: .78rem var(--mono); color: var(--muted); }
.dots { display: flex; gap: 5px; }
.dots i { width: 9px; height: 9px; border-radius: 50%; background: var(--line); }
.url { flex: 1; padding: 2px 10px; border-radius: 6px; background: var(--bg); }

/* the preview is the learner's own page, styled like a plain light browser page */
.preview { flex: 1; min-height: 260px; padding: 18px; background: #f7fafc; color: #13202a; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; overflow: auto; }
.preview h1 { font-size: 1.5rem; margin: 0 0 .5em; line-height: 1.2; }
.preview h3 { margin: 0 0 .2em; font-size: 1.05rem; }
.preview p { margin: .4em 0; }
.preview .card { border: 1px solid #d5e0e8; background: #fff; border-radius: 12px; padding: 14px; margin-bottom: 10px; }
.preview button { padding: .4em .9em; margin: 3px 6px 3px 0; border-radius: 8px; border: 1px solid #0a7e95; background: #0a7e95; color: #fff; cursor: pointer; }
.preview input { font: inherit; padding: .4em .6em; margin: 3px 6px 3px 0; border: 1px solid #b9c8d3; border-radius: 8px; background: #fff; color: #13202a; }
.preview ul { padding-left: 1.2em; }
.preview li { margin: .35em 0; }
.preview li.fav { font-weight: 700; }
.preview .badge { display: inline-block; margin-left: .5em; padding: .05em .55em; border-radius: 99px; background: #e7f3f7; color: #0d4a58; font-size: .8em; }
.preview .badge.long { background: #ffe6df; color: #8a2414; }
.preview .crash { color: #a4210f; font-weight: 600; }
.console { margin: 0; max-height: 160px; overflow: auto; padding: 10px 12px; border-top: 1px solid var(--line); font: .8rem/1.5 var(--mono); white-space: pre-wrap; }
.console .err { color: var(--bad); }
.console .warn { color: var(--ticket); }
.console .log { color: #b7c4cf; }

/* steps + quiz */
.steps { list-style: none; counter-reset: s; padding: 0; margin: 24px 0; display: grid; gap: 12px; max-width: 80ch; }
.steps li { padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.steps label, .quiz label { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.steps input, .quiz input { margin-top: 5px; accent-color: var(--cyan); width: 18px; height: 18px; flex: 0 0 auto; }
.steps li:has(input:checked) span { color: var(--muted); text-decoration: line-through; }
.cmd { display: flex; align-items: stretch; margin-top: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--code-bg); overflow: hidden; }
.cmd pre { flex: 1; min-width: 0; padding: 10px 12px; }
.copy { border: 0; border-left: 1px solid var(--line); background: var(--surface-2); color: var(--cyan); padding: 0 14px; cursor: pointer; font-weight: 700; font-size: .82rem; }
.quiz { margin-top: 30px; max-width: 80ch; }
.quiz fieldset { margin: 0 0 14px; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.quiz legend { padding: 0 6px; font-weight: 700; }
.quiz label { padding: 6px 0; }
.why { margin: 8px 0 0; font-size: .92rem; }
.finish { margin-top: 26px; }
.done-banner { margin-top: 24px; padding: 14px 16px; border-radius: 12px; background: rgba(95, 220, 155, .1); border: 1px solid rgba(95, 220, 155, .35); color: var(--good); font-weight: 800; }
.pager { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; margin-top: 40px; padding-top: 24px; border-top: 1px solid var(--line); }

/* ── Color for code: the same colors everywhere, with a key under the editor ── */
:root { --k-keyword: #c792ea; --k-string: #c3e88d; --k-number: #f78c6c; --k-function: #82aaff; --k-tag: #ff7a90; --k-attr: #ffcb6b; --k-comment: #7f8c98; --k-punct: #89ddff; }
.token.keyword { color: var(--k-keyword); }
.token.string, .token.template-string, .token.attr-value { color: var(--k-string); }
.token.number, .token.boolean { color: var(--k-number); }
.token.function { color: var(--k-function); }
.token.tag, .token.tag .class-name { color: var(--k-tag); }
.token.attr-name { color: var(--k-attr); }
.token.comment { color: var(--k-comment); }
.token.punctuation, .token.operator { color: var(--k-punct); }
.token.interpolation-punctuation, .token.script-punctuation { color: var(--k-keyword); }
.token.plain-text, .token.interpolation, .token.script { color: #d6e6ee; }
.mission .small { margin: 0 0 12px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 8px 12px; border-top: 1px solid var(--line); background: var(--surface); font: .74rem var(--mono); }

/* the editor: a colored copy sits behind a see-through text box, lined up exactly */
.editor { position: relative; flex: 1; min-height: 420px; background: var(--code-bg); }
.editor textarea, .editor pre { position: absolute; inset: 0; margin: 0; padding: 14px; border: 0; font: .86rem/1.6 var(--mono); tab-size: 2; white-space: pre; overflow: auto; letter-spacing: 0; }
.editor pre { overflow: hidden; pointer-events: none; color: #d6e6ee; }
.editor pre code { font: inherit; background: none; padding: 0; }
.editor textarea { z-index: 1; resize: none; background: transparent; color: transparent; -webkit-text-fill-color: transparent; caret-color: #fff; min-height: 0; }
.editor textarea::selection { background: rgba(111, 231, 255, .28); }
#code:focus-visible { outline: none; box-shadow: inset 0 0 0 2px rgba(111, 231, 255, .4); }

/* ── Lesson cards: one small idea at a time, colored by what they are ── */
.prose { display: grid; gap: 14px; }
.card-step { --tone: #b69cff; position: relative; padding: 16px 18px 18px; border: 1px solid var(--line); border-left: 4px solid var(--tone); border-radius: 14px; background: var(--surface); }
.card-step.kind-example { --tone: var(--cyan); }
.card-step.kind-tip { --tone: var(--ticket); background: rgba(255, 200, 97, .05); }
.card-step.current { box-shadow: 0 0 0 1px var(--tone), 0 12px 34px rgba(0, 0, 0, .35); }
.card-step:not(.current) { opacity: .78; }
.card-step > header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.chip { display: inline-flex; padding: 3px 10px; border-radius: 99px; font-size: .74rem; font-weight: 800; letter-spacing: .04em; color: var(--tone); background: color-mix(in srgb, var(--tone) 14%, transparent); }
.count { color: var(--muted); font-size: .78rem; font-variant-numeric: tabular-nums; }
.card-step > p:first-of-type { margin-top: 6px; }
.card-step > :last-child { margin-bottom: 0; }
.next-card { margin-top: 14px; }
.reading-help { margin: 0 0 12px; }
.linklike { background: none; border: 0; padding: 0; color: var(--cyan); text-decoration: underline; cursor: pointer; font-size: inherit; }

/* mission: the step to work on stands out; later steps wait quietly */
#tasks li { padding: 8px 10px; border-radius: 10px; border: 1px solid transparent; }
#tasks li.current { border-color: rgba(111, 231, 255, .45); background: rgba(111, 231, 255, .06); color: var(--ink); }
#tasks li.later { opacity: .5; }
#tasks .st { color: var(--muted); }
#tasks li.current .st { border-color: var(--cyan); color: var(--cyan); }
#tasks li.pass .st, #tasks li.fail .st { font-size: 0; }
#tasks li.pass .st::after, #tasks li.fail .st::after { font-size: .7rem; }
#tasks li.pass { opacity: .85; }

/* JavaScript rides: the Console is the output */
.console.big { flex: 1; min-height: 260px; max-height: none; border-top: 0; font-size: .86rem; }
.console .empty { color: var(--muted); font-style: italic; }

/* help under a step that isn't working yet */
.step-help { grid-column: 2; margin: 2px 0 4px; padding: 10px 12px; border-radius: 10px; background: rgba(255, 200, 97, .08); color: #f3e2bd; font-size: .9rem; font-family: var(--mono); line-height: 1.55; overflow-wrap: anywhere; }

/* tap-to-explain words */
.term { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: help; text-decoration: underline dotted var(--cyan); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.term:hover { color: var(--cyan); }
.word-sheet { position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; padding: 0 max(16px, env(safe-area-inset-right, 0px)) calc(16px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); pointer-events: none; }
.word-card { pointer-events: auto; width: min(560px, 100%); padding: 18px 20px; border-radius: 16px; border: 1px solid rgba(111, 231, 255, .35); background: var(--surface-2); box-shadow: 0 18px 50px rgba(0, 0, 0, .55); }
.word-card h2 { margin: 0 0 6px; font-size: 1.2rem; color: var(--cyan); }
.word-card p { margin: 0; color: #d4dee5; }
.word-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; }
.words { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; margin: 24px 0 0; }
.words div { padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.words dt { font-weight: 800; color: var(--cyan); }
.words dd { margin: 4px 0 0; color: #c9d4dc; font-size: .93rem; }
.lesson .lede { margin-top: 0; }

@media (max-width: 1080px) { .panes { grid-template-columns: minmax(0, 1fr); } .editor { min-height: 320px; } }
@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .menu { display: block; }
  .side { display: none; position: fixed; inset: 64px 0 0; height: auto; z-index: 15; background: var(--bg); border: 0; padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  body.nav-open .side { display: block; }
  .how { grid-template-columns: minmax(0, 1fr); }
  .progress i { width: 60px; }
  .brand img { display: none; }
  .brand span { border: 0; padding: 0; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
