/*
 * Atlas. Calm paper and ink (after the HighGrain/AMBIT tokens), one colour per line of the map, big tap targets.
 * Themes: auto (follows the device), light, dark, calm (soft, low glare), contrast. Body classes carry the learner's
 * font, size, spacing and motion settings.
 */
:root, .theme-light {
  --paper: #F7F5F0; --paper2: #EFEDE7; --card: #FFFFFF; --border: #E0DDD5; --border2: #C8C5BC;
  --head: #1A1916; --body: #3A3832; --mid: #5E5C56; --green: #2D7A4F; --greenbg: rgba(45,122,79,.10);
  --bad: #A13A2F; --badbg: rgba(180,69,58,.10); --warn: #8A5A00; --focus: #2F6FB2; --shadow: 0 1px 2px rgba(26,25,22,.06), 0 6px 18px rgba(26,25,22,.05);
}
.theme-dark {
  --paper: #0F0F0D; --paper2: #161614; --card: #1C1C19; --border: #2C2B27; --border2: #3B3A35;
  --head: #EDEAE2; --body: #D3D0C7; --mid: #A9A69D; --green: #4FBF80; --greenbg: rgba(79,191,128,.14);
  --bad: #E58A7F; --badbg: rgba(229,138,127,.14); --warn: #E2B45A; --focus: #8AB8F0; --shadow: none;
}
.theme-calm {
  --paper: #EEF0EA; --paper2: #E4E7DF; --card: #F7F8F3; --border: #D3D8CC; --border2: #BCC3B4;
  --head: #2A2F2A; --body: #3E443E; --mid: #5F665F; --green: #3B7A57; --greenbg: rgba(59,122,87,.10);
  --bad: #9A4A3F; --badbg: rgba(154,74,63,.10); --warn: #7A5A10; --focus: #3E6E9E; --shadow: none;
}
.theme-contrast {
  --paper: #FFFFFF; --paper2: #FFFFFF; --card: #FFFFFF; --border: #000000; --border2: #000000;
  --head: #000000; --body: #000000; --mid: #1A1A1A; --green: #005A2B; --greenbg: #E6F4EC;
  --bad: #8B0000; --badbg: #FCE8E8; --warn: #5A3A00; --focus: #0033CC; --shadow: none;
}
@media (prefers-color-scheme: dark) {
  .theme-auto {
    --paper: #0F0F0D; --paper2: #161614; --card: #1C1C19; --border: #2C2B27; --border2: #3B3A35;
    --head: #EDEAE2; --body: #D3D0C7; --mid: #A9A69D; --green: #4FBF80; --greenbg: rgba(79,191,128,.14);
    --bad: #E58A7F; --badbg: rgba(229,138,127,.14); --warn: #E2B45A; --focus: #8AB8F0; --shadow: none;
  }
}

* { box-sizing: border-box; }
html { background: var(--paper); }
body { margin: 0; background: var(--paper); color: var(--body); font-family: "Source Sans 3", "Source Sans Pro", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 18px; line-height: 1.6; -webkit-font-smoothing: antialiased; }
body.font-readable { font-family: "Atkinson Hyperlegible", "Atkinson Hyperlegible Next", Verdana, Tahoma, sans-serif; letter-spacing: .01em; }
body.font-dyslexia { font-family: "OpenDyslexic", "Lexend", "Comic Sans MS", Verdana, sans-serif; letter-spacing: .03em; word-spacing: .12em; }
body.size-s { font-size: 16px; } body.size-l { font-size: 21px; } body.size-xl { font-size: 24px; }
body.space-wide { line-height: 1.95; } body.space-wide p, body.space-wide li { margin-bottom: 1em; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }
body.calm-motion * { transition: none !important; animation: none !important; }

a { color: var(--focus); text-underline-offset: 3px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { color: var(--head); line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: clamp(1.8rem, 4.2vw, 2.6rem); font-weight: 900; margin: .2em 0 .4em; }
h2 { font-size: 1.3rem; font-weight: 800; }
h3 { font-size: 1.08rem; font-weight: 700; }
.section { margin-top: 2rem; }
.lede { font-size: 1.1em; max-width: 65ch; }
.muted { color: var(--mid); } .small { font-size: .88em; } .tiny { font-size: .85em; margin: .6rem 0 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; } .skip:focus { left: 12px; top: 8px; background: var(--card); padding: .5rem 1rem; z-index: 9; }

/* frame */
.top { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: .4rem 1.4rem; padding: .7rem clamp(16px, 3vw, 32px);
  background: var(--paper); border-bottom: 1px solid var(--border); }
.brand { font-weight: 900; font-size: 1.2rem; color: var(--head); text-decoration: none; display: inline-flex; gap: .4rem; align-items: center; }
.logo { color: var(--green); font-size: 1.3em; }
.top nav { display: flex; flex-wrap: wrap; gap: .2rem .9rem; flex: 1; }
.top nav a { color: var(--mid); text-decoration: none; padding: .35rem .1rem; border-bottom: 3px solid transparent; font-weight: 600; }
.top nav a:hover, .top nav a[aria-current="page"] { color: var(--head); border-bottom-color: var(--green); }
.top nav a.leave { color: var(--head); }
.count { display: inline-block; min-width: 1.4em; padding: 0 .35em; border-radius: 999px; background: var(--green); color: #fff; font-size: .8em; text-align: center; }
.who { color: var(--mid); font-size: .88em; }
@media (max-width: 760px) {
  .top { position: static; padding-bottom: 0; }
  .who { margin-left: auto; font-size: .8em; }
  .top nav { order: 3; flex: 1 0 100%; flex-wrap: nowrap; overflow-x: auto; gap: 1.1rem; padding-bottom: .2rem; scrollbar-width: none; }
  .top nav a { white-space: nowrap; }
}
body.in-focus .who { display: none; }
main { max-width: 1180px; margin: 0 auto; padding: clamp(16px, 3vw, 36px) clamp(16px, 3vw, 32px) 64px; }
.foot { max-width: 1180px; margin: 0 auto; padding: 18px clamp(16px, 3vw, 32px) 40px; color: var(--mid); font-size: .85em; border-top: 1px solid var(--border); }
.flash { max-width: 1180px; margin: 1rem auto 0; padding: .7rem 1rem; background: var(--greenbg); color: var(--head); border-left: 5px solid var(--green); border-radius: 8px; }
form.page { margin: 0; }

/* parts */
.card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: clamp(16px, 2.4vw, 26px); box-shadow: var(--shadow); margin: 0 0 1rem; }
.eyebrow { font: 600 .74rem/1.3 "Source Code Pro", ui-monospace, Menlo, monospace; letter-spacing: .12em; text-transform: uppercase; color: var(--green); margin: 0 0 .4rem; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 48px; padding: .6rem 1.25rem; border-radius: 12px; border: 2px solid var(--head);
  background: var(--card); color: var(--head); font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; }
.btn:hover { border-color: var(--accent, var(--green)); }
.btn.primary { background: var(--head); color: var(--paper); }
.btn.primary:hover { background: var(--accent, var(--green)); border-color: var(--accent, var(--green)); color: #fff; }
.btn.big { min-height: 56px; font-size: 1.08em; padding: .7rem 1.6rem; }
.btn.quiet { border-color: transparent; background: transparent; color: var(--mid); }
.row { display: flex; flex-wrap: wrap; gap: .7rem; align-items: center; margin-top: 1rem; }
.field { display: grid; gap: .3rem; margin: .8rem 0; font-weight: 600; color: var(--head); }
.field input, textarea { font: inherit; font-weight: 400; color: var(--body); background: var(--paper); border: 2px solid var(--border2); border-radius: 10px; padding: .65rem .8rem; width: 100%; }
textarea { line-height: 1.55; resize: vertical; }
.problem { background: var(--badbg); color: var(--bad); border-radius: 10px; padding: .6rem .9rem; font-weight: 600; }
.note { padding: .7rem 1rem; border-radius: 10px; background: var(--paper2); } .note.good { background: var(--greenbg); } .note.warn { background: var(--badbg); }
.tag { display: inline-block; margin: 0 .35rem .4rem 0; padding: .15rem .6rem; border-radius: 999px; background: var(--paper2); border: 1px solid var(--border); font-size: .82em; }
.dots { display: inline-flex; gap: 4px; vertical-align: middle; } .dots i { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--border2); display: inline-block; }

/* welcome */
.hero { display: grid; grid-template-columns: 1.3fr 1fr; gap: 2rem; align-items: start; }
.hero h1 { font-size: clamp(2.2rem, 6vw, 3.6rem); }
.promises { padding-left: 1.1rem; } .promises li { margin: .4rem 0; }
@media (max-width: 820px) { .hero { grid-template-columns: 1fr; } }

/* today */
.greet { margin-bottom: .2rem; }
.today { display: grid; grid-template-columns: 2fr 1fr; gap: 1.2rem; align-items: stretch; margin-top: 1.2rem; }
@media (max-width: 820px) { .today { grid-template-columns: 1fr; } }
.next { border-left: 8px solid var(--accent); } .next h2 { font-size: 1.7rem; margin: .2rem 0 .5rem; }
.week { display: flex; gap: 1rem; align-items: center; } .week h2 { margin: 0 0 .3rem; }
.ring { width: 120px; flex: none; } .ring-back { fill: none; stroke: var(--paper2); stroke-width: 12; } .ring-fill { fill: none; stroke: var(--green); stroke-width: 12; stroke-linecap: round; }
.ring-big { fill: var(--head); font-weight: 900; font-size: 24px; } .ring-small { fill: var(--mid); font-size: 11px; }
.cue { font-weight: 600; color: var(--head); } .cue.big { font-size: 1.25em; padding: .8rem 1rem; background: var(--greenbg); border-radius: 12px; }
.nudge { padding: .7rem 1rem; background: var(--paper2); border-radius: 10px; }

/* map */
.mapwrap { padding: 8px; overflow-x: auto; }
.map { width: 100%; min-width: 640px; height: auto; display: block; }
.map-line { fill: none; stroke-width: 12; stroke-linecap: round; opacity: .9; }
.map-linename { font-weight: 800; font-size: 15px; letter-spacing: .02em; }
.map-dot { stroke-width: 6; } .map-next { fill: none; stroke-width: 3; stroke-dasharray: 5 5; }
.map-num { font-weight: 900; font-size: 18px; fill: var(--head); } .map-num.on { fill: #fff; }
.map-name { font-size: 13px; fill: var(--body); font-weight: 600; }
.map-cap { stroke: #7A3EA0; stroke-width: 6; fill: var(--card); } .map-cap.passed, .map-cap.mastered { fill: #7A3EA0; }
.map-stop:hover .map-dot, .map-stop:focus .map-dot { stroke-width: 9; }
.legend { display: flex; flex-wrap: wrap; gap: 1.2rem; list-style: none; padding: 0; color: var(--mid); font-size: .9em; }
.lg { display: inline-block; width: 16px; height: 16px; border-radius: 50%; border: 3px solid var(--mid); margin-right: .4rem; vertical-align: -3px; font-style: normal; font-size: 10px; text-align: center; line-height: 10px; }
.lg.half { background: linear-gradient(0deg, var(--mid) 50%, transparent 50%); } .lg.full, .lg.done { background: var(--mid); color: var(--paper); }
.lines { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; }
.line h3 { color: var(--accent); border-bottom: 4px solid var(--accent); padding-bottom: .3rem; }
.line ol { list-style: none; padding: 0; } .line li { margin: 0 0 .9rem; } .line .q { color: var(--mid); font-size: .88em; }

/* station */
.station-head { border-left: 10px solid var(--accent); padding-left: 1.2rem; margin-bottom: 1.5rem; }
.big-q { font-size: 1.35em; font-weight: 700; color: var(--accent); margin: 0 0 .5rem; }
.state { display: inline-block; padding: .2rem .7rem; border-radius: 999px; border: 2px solid var(--accent); font-weight: 700; font-size: .88em; }
.cols { display: grid; grid-template-columns: 1.6fr 1fr; gap: 1.5rem; } @media (max-width: 900px) { .cols { grid-template-columns: 1fr; } }
.stops { list-style: none; padding: 0; }
.stop { display: grid; grid-template-columns: auto 1fr auto; gap: 1rem; align-items: center; border-left: 6px solid var(--accent); }
.stop .n { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; border: 3px solid var(--accent); font-weight: 900; color: var(--head); }
.stop.passed .n { background: var(--accent); color: #fff; }
.stop h3 { margin: 0 0 .2rem; } .stop h3 a { color: var(--head); text-decoration: none; } .stop p { margin: .1rem 0; }
@media (max-width: 600px) { .stop { grid-template-columns: auto 1fr; } .stop .btn { grid-column: 1 / -1; } }
.mission { border-top: 6px solid var(--accent); }
.outcomes li { margin: .35rem 0; }
.method { background: var(--greenbg); border-radius: 10px; padding: .6rem .8rem; }

/* the player */
.player { max-width: 820px; margin: 0 auto; }
.stop-title { margin-top: 0; }
.steps { display: flex; gap: .4rem; list-style: none; padding: 0; margin: 0 0 1.2rem; }
.steps li { flex: 1; text-align: center; padding: .35rem .2rem; border-radius: 999px; background: var(--paper2); color: var(--mid); font-size: .8em; font-weight: 700; }
.steps li.done { background: var(--accent); color: #fff; } .steps li.now { background: var(--card); color: var(--head); outline: 3px solid var(--accent); }
.lesson-top { display: flex; justify-content: space-between; align-items: center; gap: 1rem; } .lesson-top h2 { margin: 0; font-size: 1.5rem; }
.listen { border: 2px solid var(--border2); background: var(--paper); color: var(--head); border-radius: 999px; padding: .4rem .9rem; font: inherit; font-weight: 700; cursor: pointer; min-height: 44px; }
.listen.speaking { border-color: var(--accent); }
.picture { margin: 1rem 0; padding: .5rem; background: var(--paper); border-radius: 12px; }
.words { font-size: 1.12em; color: var(--head); max-width: 62ch; }
.words strong { background: linear-gradient(transparent 60%, color-mix(in srgb, var(--accent) 28%, transparent) 60%); }
.analogy { background: var(--paper2); border-radius: 12px; padding: .8rem 1rem; }
.small-h { font-size: 1rem; text-transform: uppercase; letter-spacing: .08em; color: var(--mid); margin: 0 0 .5rem; }
.choices { border: 0; padding: 0; margin: 0; display: grid; gap: .55rem; }
.choices legend.q { font-weight: 700; color: var(--head); font-size: 1.08em; margin-bottom: .7rem; padding: 0; }
.choice { display: flex; gap: .7rem; align-items: flex-start; padding: .75rem .9rem; border: 2px solid var(--border2); border-radius: 12px; cursor: pointer; background: var(--card); min-height: 48px; }
.choice:hover { border-color: var(--accent); } .choice input { width: 1.25em; height: 1.25em; margin-top: .2em; accent-color: var(--accent); flex: none; }
.choice:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--card)); }
.choice.right { border-color: var(--green); background: var(--greenbg); } .choice.right::after { content: "✓"; margin-left: auto; color: var(--green); font-weight: 900; }
.choice.wrong { border-color: var(--bad); background: var(--badbg); } .choice.wrong::after { content: "✗"; margin-left: auto; color: var(--bad); font-weight: 900; }
.confidence, .days, .opt { border: 0; padding: 0; margin: .9rem 0 0; display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.confidence legend, .days legend, .opt legend { font-weight: 700; color: var(--head); margin-bottom: .4rem; width: 100%; padding: 0; }
.pill { display: inline-flex; align-items: center; gap: .4rem; padding: .45rem .9rem; border: 2px solid var(--border2); border-radius: 999px; cursor: pointer; min-height: 44px; background: var(--card); }
.pill:has(input:checked) { border-color: var(--green); background: var(--greenbg); color: var(--head); font-weight: 700; }
.pill input { accent-color: var(--green); }
.feedback { margin-top: 1rem; padding: .85rem 1rem; border-radius: 12px; border-left: 6px solid; }
.feedback.good { background: var(--greenbg); border-color: var(--green); } .feedback.nope { background: var(--badbg); border-color: var(--bad); }
.flag { display: inline-block; margin-top: .4rem; font-weight: 700; color: var(--warn); }
.question { margin-bottom: 1.1rem; }
.result { text-align: center; } .result.good { border-top: 8px solid var(--green); } .result.nope { border-top: 8px solid var(--warn); }
.score { font-size: 3rem; font-weight: 900; color: var(--head); margin: 0; }
.timer { position: sticky; top: 70px; float: right; font: 700 1.2rem "Source Code Pro", ui-monospace, monospace; background: var(--card); border: 2px solid var(--border2); border-radius: 10px; padding: .2rem .7rem; }

/* missions */
.mission-page { max-width: 900px; margin: 0 auto; }
.brief { border-left: 8px solid var(--accent); font-size: 1.05em; }
.step label { display: flex; gap: .7rem; font-weight: 700; color: var(--head); margin-bottom: .5rem; }
.step .n { flex: none; width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; }
details summary { cursor: pointer; color: var(--focus); font-weight: 600; margin: .3rem 0; }
.rubric table { width: 100%; border-collapse: separate; border-spacing: 6px; }
.rubric th[scope=row] { text-align: left; color: var(--head); width: 22%; vertical-align: top; }
.rubric thead th { font-size: .8em; color: var(--mid); text-transform: uppercase; letter-spacing: .06em; }
.lvl { display: block; height: 100%; padding: .55rem; border: 2px solid var(--border); border-radius: 10px; cursor: pointer; font-size: .86em; }
.lvl:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--card)); }
.lvl input { display: block; margin-bottom: .3rem; accent-color: var(--accent); }
@media (max-width: 760px) { .rubric thead { display: none; } .rubric tr, .rubric th, .rubric td { display: block; width: 100% !important; } }

/* plan, record, settings, about */
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 1rem; }
.tips li { margin: .45rem 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .8rem; margin: 1rem 0 1.5rem; }
.stats div { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 1rem; font-size: 1.1em; color: var(--mid); }
.stats b { font-size: 2.1rem; color: var(--head); } .stats span { display: block; font-size: .8em; }
.tablewrap { overflow-x: auto; }
table.record { width: 100%; border-collapse: collapse; background: var(--card); border-radius: 14px; overflow: hidden; }
table.record th, table.record td { text-align: left; padding: .65rem .8rem; border-bottom: 1px solid var(--border); }
table.record th a { color: var(--head); text-decoration: none; } .sw { display: inline-block; width: 10px; height: 22px; border-radius: 4px; background: var(--accent); margin-right: .6rem; vertical-align: middle; }
.ok { color: var(--green); font-weight: 700; }
.cols2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; margin-top: 1.5rem; }
.coverage table { width: 100%; border-collapse: collapse; } .coverage td, .coverage th { text-align: left; padding: .35rem .5rem; border-bottom: 1px solid var(--border); }
.certificate { text-align: center; border: 4px double var(--green); padding: 2rem; }
.outcomes-all { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: .5rem 1.5rem; text-align: left; font-size: .9em; }
.wheels-list { list-style: none; padding: 0; display: grid; gap: .5rem; } .wheels-list .pill { border-radius: 12px; width: 100%; }
.evidence { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; }
.evidence h3 { margin-top: 0; color: var(--green); }
.loop li { margin: .4rem 0; }
.answer { background: var(--paper); border-radius: 10px; padding: .7rem 1rem; white-space: normal; }

/* the pictures (Diagrams.java) */
.dg { width: 100%; height: auto; display: block; font-family: inherit; }
.dg-box { fill: var(--card); stroke: var(--accent); stroke-width: 3; }
.dg-key { fill: var(--accent); }
.dg-alt { fill: var(--paper2); stroke-dasharray: 6 4; }
.dg-soft { fill: var(--paper2); stroke: var(--border2); stroke-width: 1.5; }
.dg-label { fill: var(--head); font-size: 17px; font-weight: 700; }
.dg-on-key { fill: #fff; }
.dg-axis, .dg-vs { fill: var(--mid); font-size: 15px; font-weight: 700; }
.dg-arrow, .dg-line { stroke: var(--mid); stroke-width: 3; fill: none; }
.dg-head { fill: var(--mid); }
.dg-ring { fill: none; stroke: var(--border2); stroke-width: 3; stroke-dasharray: 8 6; }
.dg-dot { fill: var(--card); stroke: var(--accent); stroke-width: 4; }
.dg-g0 { stop-color: var(--paper2); } .dg-g1 { stop-color: var(--accent); }
.theme-contrast .dg-box { stroke: #000; } .theme-contrast .dg-key { fill: #000; }
@media (max-width: 600px) { .picture { margin-left: -10px; margin-right: -10px; padding: 2px; } .dg-label { font-size: 20px; } .dg-axis, .dg-vs { font-size: 18px; } }

@media print {
  .top, .foot, .row, .btn, .flash, .skip { display: none !important; }
  body { background: #fff; color: #000; } .card { box-shadow: none; }
}
