/* K12 interactive pages — shared styles (base copied from Boxi Math play.css).
   Colours match site/src/styles/global.css. Each page sets <body data-subject="physics"> etc.;
   that picks --a (the subject accent). Everything else is the same across subjects. */
:root {
  --bg: #f7f4ee; --surface: #fffdf8; --fg: #1a2822; --muted: #5f675f; --line: #e2ddd2;
  --a: #2f7a56; --b: #966524; --c: #3e5c76; --hl: #d9a441; --no: #b5452f; --h: #c2417a;
  --soft: #efe9dd; --ink-panel: #1f3a30; --on-panel: #f4efe4; --on-panel-muted: #c9d3c8;
  --radius: 14px;
  --font: "Inter", "Noto Sans SC", system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  --serif: "Fraunces", "Noto Serif SC", Georgia, "Songti SC", serif;
  --math: "Cambria Math", "STIX Two Math", "Latin Modern Math", "Times New Roman", serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141a17; --surface: #1c2420; --fg: #ece8df; --muted: #a6ab9f; --line: #2d3832;
    --a: #6fbf91; --b: #d5a463; --c: #8fb0cc; --hl: #e8c27a; --no: #e48b74; --h: #ee88b2;
    --soft: #232d28; --ink-panel: #0e1512; --on-panel: #ece8df; --on-panel-muted: #a6ab9f;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141a17; --surface: #1c2420; --fg: #ece8df; --muted: #a6ab9f; --line: #2d3832;
  --a: #6fbf91; --b: #d5a463; --c: #8fb0cc; --hl: #e8c27a; --no: #e48b74; --h: #ee88b2;
  --soft: #232d28; --ink-panel: #0e1512; --on-panel: #ece8df; --on-panel-muted: #a6ab9f;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.65 var(--font); }
body.embed { background: transparent; }
button, input, select { font: inherit; color: inherit; }
button {
  cursor: pointer; border: 1px solid var(--line); background: var(--surface); border-radius: 9px;
  padding: 7px 13px; transition: background .15s, border-color .15s, transform .1s;
}
button:hover { border-color: var(--a); }
button:active { transform: translateY(1px); }
button.on { background: var(--fg); color: var(--bg); border-color: var(--fg); }
button.small { font-size: 13px; padding: 4px 10px; }
:focus-visible { outline: 3px solid var(--hl); outline-offset: 2px; }
input[type=range] { accent-color: var(--a); min-width: 0; cursor: pointer; }
input[type=checkbox] { accent-color: var(--a); }
a { color: var(--a); }

.play { max-width: 1240px; margin: 0 auto; padding: 24px 20px 28px; }
body.embed .play { padding: 4px 0 8px; }
.topline { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); letter-spacing: .06em; }
.topline .eyebrow { font-weight: 700; color: var(--a); text-transform: uppercase; }
.topline .langs a { text-decoration: none; border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; color: var(--fg); letter-spacing: 0; }
body.embed .topline .langs { display: none; }
.play h1 { font-family: var(--serif); font-size: clamp(22px, 3vw, 32px); line-height: 1.3; margin: 10px 0 6px; letter-spacing: -.01em; }
body.embed .play h1 { display: none; }
.intro { color: var(--muted); font-size: 14px; margin: 0 0 16px; }

.navrow { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.steps { display: flex; gap: 4px; padding: 4px; background: var(--soft); border-radius: 12px; flex-wrap: wrap; }
.steps button { background: transparent; border: 0; font-weight: 650; font-size: 14px; padding: 8px 14px; }
.steps button.on { background: var(--surface); color: var(--fg); box-shadow: 0 1px 6px rgba(0,0,0,.08); }
.steps button .k { color: var(--a); margin-right: 6px; font-variant-numeric: tabular-nums; }
.tools { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.check { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; white-space: nowrap; }

.stage { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(280px, .85fr); background: var(--surface); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; margin-bottom: 16px; }
.stage .visual { position: relative; border-right: 1px solid var(--line); min-width: 0; }
.stage canvas.main { width: 100%; height: 360px; display: block; touch-action: none; cursor: grab; }
.stage canvas.main:active { cursor: grabbing; }
.stage .vtitle { position: absolute; top: 12px; left: 14px; font-size: 12px; font-weight: 650; pointer-events: none; color: var(--muted); }
.stage .vtag { position: absolute; top: 12px; right: 14px; font-size: 11px; color: var(--muted); pointer-events: none; }
.controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 4px 14px 14px; font-size: 13px; color: var(--muted); }
.controls input[type=range] { flex: 1 1 120px; }
.controls .val { font-family: var(--math); color: var(--fg); font-size: 15px; min-width: 3.5em; }
.explain { padding: 20px 22px; display: flex; flex-direction: column; justify-content: center; min-height: 300px; }
.kicker { font-size: 11px; color: var(--a); font-weight: 750; letter-spacing: .12em; text-transform: uppercase; margin-bottom: 6px; }
.explain h2 { font-family: var(--serif); font-size: 20px; line-height: 1.4; margin: 0 0 8px; }
.explain p { font-size: 14px; margin: 0 0 10px; color: var(--muted); }
.explain p strong { color: var(--fg); }
.mathline { margin: 4px 0 10px; font-family: var(--math); font-size: 19px; line-height: 1.9; }
.math { font-family: var(--math); font-size: 1.12em; white-space: nowrap; }
.frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; line-height: 1.05; font-size: .82em; margin: 0 .12em; }
.frac > span:first-child { border-bottom: 1px solid; padding: 0 3px 1px; }
.frac > span:last-child { padding-top: 1px; }
.note { font-size: 12px !important; line-height: 1.7; }
.tag-no { color: var(--no); font-weight: 700; }
.tag-demo { display: inline-block; font-size: 11px; font-weight: 700; color: var(--b); border: 1px solid currentColor; border-radius: 999px; padding: 0 8px; margin-bottom: 8px; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; color: var(--muted); font-size: 12px; margin-top: 4px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: 1px; }
.choices { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 10px; }

.sectionbar { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 4px 0 8px; }
.sectionbar h3 { font-size: 15px; margin: 0; }
.sectionbar span { font-size: 12px; color: var(--muted); text-align: right; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-bottom: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; transition: opacity .2s; }
.card.dim { opacity: .55; border-style: dashed; }
.card header { padding: 12px 14px 4px; display: flex; align-items: center; gap: 9px; }
.badge { height: 28px; width: 28px; border-radius: 8px; display: grid; place-items: center; font-weight: 750; color: var(--surface); background: var(--c-card, var(--a)); flex: none; }
.card h4 { margin: 0; font-size: 14px; }
.card .sub { font-size: 12px; color: var(--muted); font-family: var(--math); }
.card canvas { width: 100%; height: 240px; display: block; touch-action: none; cursor: grab; }
.card .views { display: flex; justify-content: center; gap: 5px; padding: 0 10px 10px; flex-wrap: wrap; }
.card .cnote { border-top: 1px solid var(--line); padding: 10px 14px 12px; font-size: 12px; color: var(--muted); min-height: 64px; }
.card .cnote strong { color: var(--c-card, var(--a)); }

.result { background: var(--ink-panel); color: var(--on-panel); border-radius: 14px; padding: 16px 20px; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.result .rt { font-size: 13px; color: var(--on-panel-muted); margin-bottom: 4px; }
.result .math { font-size: 24px; }
.result .rn { font-size: 13px; color: var(--on-panel-muted); max-width: 440px; }
details.more { margin: 12px 2px 0; font-size: 13px; color: var(--muted); }
details.more summary { cursor: pointer; color: var(--fg); font-weight: 600; }
.foot { font-size: 11px; color: var(--muted); text-align: center; margin-top: 14px; }
body.embed .foot { display: none; }
body.embed .explainit { display: none; } /* the lesson page shows 说一说 / 家里做一做 itself */
[hidden] { display: none !important; }

@media (max-width: 860px) {
  .stage { grid-template-columns: 1fr; }
  .stage .visual { border-right: 0; border-bottom: 1px solid var(--line); }
  .explain { min-height: 0; padding: 16px; }
}
@media (max-width: 560px) {
  .play { padding: 14px 12px 20px; }
  .stage canvas.main { height: 300px; }
  .steps { width: 100%; }
  .steps button { flex: 1 1 auto; padding: 8px 8px; font-size: 13px; }
  .result { display: block; }
  .result .rn { margin-top: 10px; }
  .result .math { font-size: 20px; white-space: normal; overflow-wrap: anywhere; }
}

/* Subject accents (light / dark). --a drives buttons, kickers, focus. */
body[data-subject=chinese]   { --a: #b5452f; } body[data-subject=english]   { --a: #3e5c76; }
body[data-subject=science]   { --a: #2f7a56; } body[data-subject=physics]   { --a: #4a5fb0; }
body[data-subject=chemistry] { --a: #8a4fa3; } body[data-subject=biology]   { --a: #4f8a2f; }
body[data-subject=geography] { --a: #1f7f86; } body[data-subject=history]   { --a: #966524; }
body[data-subject=computing] { --a: #c2417a; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) body[data-subject=chinese]   { --a: #e48b74; }
  :root:not([data-theme="light"]) body[data-subject=english]   { --a: #8fb0cc; }
  :root:not([data-theme="light"]) body[data-subject=science]   { --a: #6fbf91; }
  :root:not([data-theme="light"]) body[data-subject=physics]   { --a: #97a8ec; }
  :root:not([data-theme="light"]) body[data-subject=chemistry] { --a: #c79be0; }
  :root:not([data-theme="light"]) body[data-subject=biology]   { --a: #9fd27a; }
  :root:not([data-theme="light"]) body[data-subject=geography] { --a: #6cc6cc; }
  :root:not([data-theme="light"]) body[data-subject=history]   { --a: #d5a463; }
  :root:not([data-theme="light"]) body[data-subject=computing] { --a: #ee88b2; }
}
:root[data-theme="dark"] body[data-subject=chinese]   { --a: #e48b74; }
:root[data-theme="dark"] body[data-subject=english]   { --a: #8fb0cc; }
:root[data-theme="dark"] body[data-subject=science]   { --a: #6fbf91; }
:root[data-theme="dark"] body[data-subject=physics]   { --a: #97a8ec; }
:root[data-theme="dark"] body[data-subject=chemistry] { --a: #c79be0; }
:root[data-theme="dark"] body[data-subject=biology]   { --a: #9fd27a; }
:root[data-theme="dark"] body[data-subject=geography] { --a: #6cc6cc; }
:root[data-theme="dark"] body[data-subject=history]   { --a: #d5a463; }
:root[data-theme="dark"] body[data-subject=computing] { --a: #ee88b2; }

/* ① 先猜：predict-first box shown on step 1 of every page. */
.predict { background: var(--soft); border-radius: 12px; padding: 12px 14px; margin: 6px 0 12px; }
.predict .q { font-weight: 650; margin-bottom: 8px; font-size: 14px; }
.predict .fb { font-size: 13px; color: var(--muted); margin-top: 8px; min-height: 1.2em; }
.predict button.on.right { background: var(--a); border-color: var(--a); color: var(--surface); }
.predict button.on.wrong { background: var(--no); border-color: var(--no); color: var(--surface); }
/* ④ 说一说 + 家里做一做, under the result bar. */
.explainit { margin-top: 12px; display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.explainit > div { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 16px; font-size: 14px; }
.explainit .kicker { margin-bottom: 4px; }
.stage svg.main { width: 100%; height: 360px; display: block; touch-action: none; }
@media (max-width: 560px) { .stage svg.main { height: 300px; } }
