/* Markdown Coach theme, November 2026. Replaces the September charcoal palette (SPEC 1.3 §8.1.1).
   Big idea: the child is an explorer on Markdown Island. Survey-map paper with faint contour
   lines, fern green for actions, flag orange used sparingly, amber for stars. The island map in
   Field School is the one bold element; everything else stays quiet so reading and writing stay easy.
   Dino theme = Jungle survey. Car theme (unlocked at 80 stars) = Rally map. Fonts are bundled (OFL). */
@font-face { font-family: "Grandstander"; src: url("./fonts/grandstander-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Grandstander"; src: url("./fonts/grandstander-latin-800-normal.woff2") format("woff2"); font-weight: 800; font-display: swap; }
@font-face { font-family: "Lexend"; src: url("./fonts/lexend-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Lexend"; src: url("./fonts/lexend-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("./fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("./fonts/ibm-plex-mono-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; }

:root, .theme-dino {
  color-scheme: light;
  --paper: #e8f1ea; --card: #fbfdfb; --ink: #17352e; --muted: #4d6a61;
  --primary: #2f7a4d; --primary-deep: #245f3c; --on-primary: #ffffff; --selected: #dcefe2;
  --flag: #d9541e; --flag-text: #b8430f; --lagoon: #2a7fa8; --lagoon-text: #1f6a8f;
  --amber: #f2b632; --amber-pale: #fff6dc; --amber-line: #e5c66f; --bone: #f3e9cf;
  --line: #c9dacf; --control-border: #6e8a80; --code-bg: #f1f5ef; --code-ink: #7a2e0b;
  --sea: #bfe0ea; --sea-deep: #86c3d6; --sand: #efe2bf; --jungle: #7fb58b; --jungle-deep: #3f7a52; --rock: #cdb98a;
  --danger: #a8321b;
}
.theme-car {
  --paper: #e6ebef; --card: #fbfcfd; --ink: #1c2a36; --muted: #4f5f6c;
  --primary: #b8322a; --primary-deep: #8f2620; --selected: #f6dfdc;
  --line: #ccd5dd; --control-border: #71808c; --code-bg: #f0f3f6;
  --sea: #c5dbe8; --sea-deep: #8fb6cf; --sand: #ead9bd; --jungle: #9db39a; --jungle-deep: #5f7d5c; --rock: #c7b08c;
}
/* Names the base stylesheet still uses; declared on the theme element so they follow the theme. */
:root, .theme-dino, .theme-car {
  --bg-start: var(--paper); --bg-end: var(--paper); --panel: var(--card); --surface-code: var(--code-bg);
  --text-strong: var(--ink); --text-muted: var(--muted); --accent: var(--primary); --accent-2: var(--flag-text);
  --surface-selected: var(--selected); --surface-action: var(--primary); --ok: var(--primary);
  --button-text: var(--on-primary); --shadow: none;
}

body {
  background-color: var(--paper);
  background-image: url("./contours.svg");
  background-size: 720px 720px;
  color: var(--ink);
  font-family: "Lexend", "Avenir Next", system-ui, sans-serif;
  line-height: 1.55;
}
#app { min-height: 100vh; color: var(--ink); background-color: var(--paper); background-image: url("./contours.svg"); background-size: 720px 720px; }
h1, h2, h3, legend, summary, .tab-btn, .action, .lesson-choice, .kind-choice, .page-choice, .avatar-card {
  font-family: "Grandstander", "Avenir Next", system-ui, sans-serif;
}
h1 { font-weight: 800; font-size: 42px; letter-spacing: -0.01em; color: var(--ink); }
h2 { font-weight: 800; font-size: 30px; color: var(--ink); }
h3 { font-weight: 700; color: var(--primary-deep); }
strong { color: var(--ink); }
.subtitle, .local-label, .helper, .lesson-choice small, .avatar-card small, .kind-choice small, .page-choice small { color: var(--muted); }
.subtitle { font-size: 19px; }

/* Header: a footprint mark beside the title, and stat chips like specimen labels. */
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark { width: 54px; height: 54px; flex: none; }
.badge {
  background: var(--card); border: 1.5px solid var(--line); border-radius: 999px;
  padding: 8px 16px; font-size: 18px; color: var(--ink); box-shadow: none;
}
.badge-stars::before { content: "★"; color: var(--amber); margin-right: 6px; -webkit-text-stroke: 1px var(--ink); }
.badge-stars, #stars-value { color: var(--flag-text); }
.avatar-chip { border-radius: 10px; }

/* Tabs */
.tabbar { gap: 8px; border-bottom: 2px solid var(--line); padding-bottom: 12px; }
.tab-btn {
  background: var(--card); color: var(--ink); border: 2px solid var(--control-border);
  border-radius: 999px; padding: 10px 20px; font-size: 21px; font-weight: 700;
}
.tab-btn.active { background: var(--primary); color: var(--on-primary); border-color: var(--primary-deep); }

/* Surfaces */
.card, .quick-group, .playground-cheatsheet, .stat-box, .playground-guide-row, .badge-pill, .list-item {
  background: var(--card); border: 1.5px solid var(--line); border-radius: 14px; color: var(--ink); box-shadow: none;
}
.card { padding: 18px 20px; }

/* Buttons */
.action {
  background: var(--primary); color: var(--on-primary); border: 2px solid var(--primary-deep);
  border-radius: 12px; font-weight: 700; padding: 10px 18px;
}
.action:hover { background: var(--primary-deep); transform: none; }
.action.ghost { background: var(--card); color: var(--ink); border-color: var(--control-border); }
.action.ghost:hover { background: var(--selected); }
button:not(:disabled):hover { border-color: var(--primary-deep); }
.lesson-choice, .kind-choice, .page-choice, .avatar-card {
  background: var(--card); color: var(--ink); border: 2px solid var(--control-border); border-radius: 14px;
}
.lesson-choice.selected, .kind-choice.selected, .page-choice.selected, .avatar-card.selected {
  background: var(--selected); color: var(--primary-deep); border-color: var(--primary); box-shadow: inset 6px 0 0 var(--primary);
}
.lesson-choice small, .kind-choice small, .page-choice small, .avatar-card small { font-family: "Lexend", system-ui, sans-serif; }
.key-guide {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 22px; margin: 10px 0; padding: 10px 14px;
  background: var(--card); border: 1.5px dashed var(--control-border); border-radius: 12px;
}
.key-guide .key-lead { font-family: "Grandstander", system-ui, sans-serif; font-weight: 700; color: var(--primary-deep); font-size: 17px; }
.key-guide .key-item { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.key-guide .key-symbol { font-size: 22px; font-weight: 600; padding: 0 6px; margin-right: 4px; background: var(--code-bg); }
.key-guide kbd {
  font-family: "Lexend", system-ui, sans-serif; font-size: 15px; line-height: 1; min-width: 28px; text-align: center;
  padding: 5px 8px 4px; background: var(--card); color: var(--ink);
  border: 1.5px solid var(--control-border); border-bottom-width: 3px; border-radius: 6px;
}
.key-guide .key-join, .key-guide .key-note { color: var(--muted); font-size: 15px; }
.key-guide .key-note { flex-basis: 100%; margin-top: -2px; }

/* Writing surfaces: field-notebook ruling in the editors. */
textarea, input, select {
  background-color: var(--card); color: var(--ink); border: 2px solid var(--control-border); border-radius: 10px;
  caret-color: var(--flag); accent-color: var(--primary); font-family: "Lexend", system-ui, sans-serif;
}
textarea {
  font-family: "IBM Plex Mono", Menlo, monospace; font-size: 20px; line-height: 1.7;
  /* Rules sit under each line of text; the first layer is clipped to the text area so no rule shows above line one. */
  background-image: linear-gradient(to bottom, transparent calc(1.7em - 1px), var(--line) calc(1.7em - 1px)), linear-gradient(var(--card), var(--card));
  background-size: 100% 1.7em, auto; background-position: 0 0, 0 0; background-repeat: repeat, no-repeat;
  background-origin: content-box, padding-box; background-clip: content-box, padding-box; background-attachment: local, local;
}
textarea::placeholder, input::placeholder { color: var(--muted); opacity: 1; }
pre, code, .markdown-preview pre, .playground-guide-row code {
  background: var(--code-bg); color: var(--code-ink); border-color: var(--line);
  font-family: "IBM Plex Mono", Menlo, monospace; font-variant-ligatures: none;
}
pre { color: var(--ink); border: 0; border-left: 4px solid var(--flag); border-radius: 0 10px 10px 0; }
code { border-radius: 5px; padding: 2px 6px; overflow-wrap: anywhere; }
pre code { padding: 0; }
.playground-guide-desc { color: var(--muted); font-weight: 400; }

/* The page a child makes: rendered with the display face so it feels like their own. */
.markdown-preview, .target-page { background: var(--card); color: var(--ink); border: 1.5px solid var(--line); border-radius: 12px; }
.markdown-preview :is(h1, h2, h3, h4, h5, h6) { color: var(--ink); font-family: "Grandstander", system-ui, sans-serif; font-weight: 800; }
.markdown-preview :is(th, td) { border-color: var(--control-border); }
.markdown-preview blockquote { margin-left: 0; border-left: 3px solid var(--lagoon); padding-left: 16px; color: var(--muted); }
.markdown-preview hr { border: 0; border-top: 2px dashed var(--line); }
.target-page { border: 2px dashed var(--control-border); }
#lesson-content .markdown-preview, .target-page { min-height: 150px; }
.inert-link { color: var(--lagoon-text); }
.image-placeholder { color: var(--muted); border-color: var(--control-border); }

/* Feedback */
.learning-feedback { background: var(--selected); border: 2px solid var(--primary); color: var(--ink); }
.feedback { color: var(--flag-text); }
.feedback.good { color: var(--primary-deep); }
.feedback.bad { color: var(--danger); }
.answer-choice, details { border-color: var(--line); }
.answer-choice:has(input:checked) { background: var(--selected); border-color: var(--primary); }
summary { color: var(--ink); min-height: 44px; font-weight: 700; }
.test-mode-banner, #save-status:not(:empty) { background: #fff1e6; color: #7a2e0b; border: 2px solid var(--flag); border-radius: 12px; }
.writer-box, .writer-star { background: var(--amber-pale); border: 1.5px solid var(--amber-line); }
.writer-box h3 { color: var(--ink); }
.site-news { font-family: "Grandstander", system-ui, sans-serif; font-weight: 800; font-size: 22px; color: var(--primary-deep); margin-top: 0; }
.save-label.bad { color: var(--danger); }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible,
summary:focus-visible, a:focus-visible, [tabindex="-1"]:focus-visible {
  outline: 3px solid var(--flag); outline-offset: 3px;
}

/* Markdown Island map (Field School) */
.island-map { margin: 0 0 16px; border: 1.5px solid var(--line); border-radius: 18px; overflow: hidden; background: var(--sea); }
.island-map svg { display: block; width: 100%; height: auto; }
.island-map .sea { fill: var(--sea); }
.island-map .wave { fill: none; stroke: var(--sea-deep); stroke-width: 3; stroke-linecap: round; }
.island-map .shore { fill: var(--sand); stroke: var(--ink); stroke-width: 2.5; }
.island-map .jungle { fill: var(--jungle); }
.island-map .contour { fill: none; stroke: var(--ink); stroke-opacity: .16; stroke-width: 1.5; }
.island-map .trail { fill: none; stroke: var(--ink); stroke-width: 4; stroke-linecap: round; stroke-dasharray: 1 12; }
.island-map .land-dark { fill: var(--jungle-deep); stroke: var(--ink); stroke-width: 2; stroke-linejoin: round; }
.island-map .snow { fill: #ffffff; }
.island-map .rock { fill: var(--rock); stroke: var(--ink); stroke-width: 2; stroke-linejoin: round; }
.island-map .water { fill: var(--sea-deep); }
.island-map .falls { stroke: #ffffff; stroke-width: 3; stroke-linecap: round; }
.island-map .site { cursor: pointer; }
.island-map .marker { fill: var(--card); stroke: var(--ink); stroke-width: 3; }
.island-map .marker.unknown { stroke-dasharray: 5 5; stroke: var(--control-border); }
.island-map .here { fill: none; stroke: var(--flag); stroke-width: 4; stroke-dasharray: 8 6; }
.island-map .label { font-family: "Grandstander", system-ui, sans-serif; font-weight: 800; font-size: 21px; fill: var(--ink);
  paint-order: stroke; stroke: var(--card); stroke-width: 6px; stroke-linejoin: round; }
.island-map .status { font-family: "Lexend", system-ui, sans-serif; font-size: 15px; fill: var(--ink);
  paint-order: stroke; stroke: var(--card); stroke-width: 5px; stroke-linejoin: round; }
.island-map .title { font-family: "Grandstander", system-ui, sans-serif; font-weight: 800; font-size: 26px; fill: var(--ink); }
.island-map .ink { fill: var(--ink); }
.island-map .ink-line { fill: none; stroke: var(--ink); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.island-map .flag { fill: var(--flag); }
.island-map .tent { fill: var(--primary); stroke: var(--ink); stroke-width: 2; stroke-linejoin: round; }
.island-map .lens { fill: var(--sea); stroke: var(--lagoon-text); stroke-width: 3; }
.island-map .found { fill: var(--amber); stroke: var(--ink); stroke-width: 3; }
.island-map .bone, .museum .bone { fill: var(--bone); stroke: var(--ink); stroke-width: 2.5; stroke-linejoin: round; }
.island-map .unknown-mark { font-family: "Grandstander", system-ui, sans-serif; font-weight: 800; font-size: 24px; fill: var(--muted); }

/* Fossil museum (rewards) */
.museum svg { display: block; width: 100%; height: auto; }
.museum .plinth { fill: var(--selected); stroke: var(--ink); stroke-width: 2; }
.museum .plinth-label { font-family: "Grandstander", system-ui, sans-serif; font-weight: 700; font-size: 18px; fill: var(--ink); }
.museum .missing { fill: none; stroke: var(--control-border); stroke-width: 2; stroke-dasharray: 4 6; }
.museum .bone-line-out { fill: none; stroke: var(--ink); stroke-width: 15; stroke-linecap: round; stroke-linejoin: round; }
.museum .bone-line { fill: none; stroke: var(--bone); stroke-width: 9; stroke-linecap: round; stroke-linejoin: round; }
.museum .bone-line-out.rib { stroke-width: 10; }
.museum .bone-line.rib { stroke-width: 5; }
.museum .missing-line { fill: none; stroke: var(--control-border); stroke-width: 3; stroke-linecap: round; stroke-dasharray: 4 8; }
.museum .eye { fill: var(--ink); }
.museum-caption { font-size: 18px; margin: 8px 0 0; }
.museum .new { animation: dig-up 900ms cubic-bezier(.2, 1.4, .4, 1) both; transform-box: fill-box; transform-origin: center; }
@keyframes dig-up { from { opacity: 0; transform: translateY(14px) scale(.6); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .museum .new { animation: none; } }

/* Read Aloud bar: shown only while reading, kept in view at the bottom of the window. */
.speech-controls {
  position: sticky; bottom: 12px; z-index: 15; width: fit-content; max-width: 100%;
  margin: 12px 0 0; padding: 8px 10px 8px 16px; gap: 10px;
  background: var(--card); border: 1.5px solid var(--primary); border-radius: 999px;
}
.speech-controls #speech-state { font-family: "Grandstander", system-ui, sans-serif; font-weight: 700; color: var(--primary-deep); }
.speech-controls .action { border-radius: 999px; }

/* ---------- Web edition additions ---------- */
:root { --cjk: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", "Source Han Sans SC"; }
html:lang(zh-CN) body, html:lang(zh-CN) button, html:lang(zh-CN) input, html:lang(zh-CN) select, html:lang(zh-CN) textarea { font-family: "Lexend", var(--cjk), system-ui, sans-serif; }
html:lang(zh-CN) h1, html:lang(zh-CN) h2, html:lang(zh-CN) h3, html:lang(zh-CN) .island-map .label, html:lang(zh-CN) .island-map .title { font-family: "Grandstander", var(--cjk), system-ui, sans-serif; }
.island-map .ferry { fill: none; stroke: var(--ink); stroke-width: 3; stroke-linecap: round; stroke-dasharray: 2 10; }
.island-map .cave { fill: var(--ink); }
.island-map .code-mark { font-family: "IBM Plex Mono", Menlo, monospace; font-weight: 600; font-size: 15px; fill: var(--ink); }
.lesson-group { margin: 6px 0 4px; font-size: 18px; color: var(--primary-deep); }
.lang-switch { margin-left: 4px; }
.markdown-preview table { border-collapse: collapse; margin: 10px 0; }
.markdown-preview th, .markdown-preview td { border: 1.5px solid var(--line); padding: 6px 12px; text-align: left; }
.markdown-preview th { background: var(--selected); }
.markdown-preview blockquote { margin: 10px 0; padding: 6px 14px; border-left: 5px solid var(--primary); background: var(--selected); border-radius: 0 10px 10px 0; }
.markdown-preview code { font-family: "IBM Plex Mono", Menlo, monospace; background: var(--selected); padding: 1px 6px; border-radius: 6px; }
.markdown-preview pre code { background: none; padding: 0; }
.markdown-preview a, .markdown-preview .inert-link { color: var(--primary-deep); text-decoration: underline; text-underline-offset: 3px; }
.about-card p, .about-card li { font-size: 18px; line-height: 1.6; max-width: 72ch; }
.about-card ol { padding-left: 1.4em; }
.data-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.data-actions input[type=file] { font-size: 16px; }
.mission-lang-note { font-size: 15px; }
.island-map .ink-line.thin, .museum .ink-line.thin { fill: none; stroke: var(--ink); stroke-width: 2; }
.island-map .status.strong { font-weight: 600; }
.island-map .hit { fill: transparent; }
