/* Sprout Classroom website prototype (PRD 08): one brand, two modes (direction B, PRD 07).
   body.mode-primary = 小學模式, body.mode-dse = DSE 模式. Colour pairs are checked for WCAG AA. */

:root {
  --font-head: "Noto Sans TC", "PingFang HK", "Microsoft JhengHei", sans-serif;
  --font-body: "Noto Sans TC", "PingFang HK", "Microsoft JhengHei", sans-serif;
  --radius: 18px;
  --radius-sm: 12px;
  --gutter: 16px;
  --max: 1120px;
  --red-pen: #E5484D;
  --sun: #FFC93C;
  --gold: #F5B301;
}

.mode-primary {
  --font-head: "Huninn", "Noto Sans TC", "PingFang HK", sans-serif;
  --font-body: "Huninn", "Noto Sans TC", "PingFang HK", sans-serif;
  --bg: #FFFDF5;
  --surface: #FFFFFF;
  --tint: #F0FDF4;
  --ink: #1F2937;
  --mute: #4B5563;
  --line: #E5E7EB;
  --brand: #15803D;        /* text and buttons: 5.0:1 on white */
  --brand-bright: #22C55E; /* decoration only */
  --on-brand: #FFFFFF;
  --sky: #4FB6FF;
  --sky-ink: #075985;
  --accent-bg: #FFF4CC;
}

.mode-dse {
  --bg: #0F172A;
  --surface: #1E293B;
  --tint: #172036;
  --ink: #F1F5F9;
  --mute: #CBD5E1;
  --line: #334155;
  --brand: #4ADE80;        /* text on dark */
  --brand-bright: #22C55E;
  --on-brand: #0F172A;
  --sky: #38BDF8;
  --sky-ink: #7DD3FC;
  --accent-bg: #2A2410;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.75 var(--font-body); }
h1, h2, h3 { font-family: var(--font-head); line-height: 1.3; margin: 0 0 .4em; }
.mode-dse h1, .mode-dse h2, .mode-dse h3 { font-weight: 900; letter-spacing: .01em; }
h1 { font-size: clamp(30px, 6vw, 48px); }
h2 { font-size: clamp(22px, 3.6vw, 30px); }
h3 { font-size: 20px; }
p { margin: 0 0 .8em; }
a { color: var(--brand); }
img { max-width: 100%; }
:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; border-radius: 6px; }
.wrap { max-width: var(--max); margin: 0 auto; padding: 0 var(--gutter); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mute { color: var(--mute); }
.small { font-size: 14px; }

/* Header */
.top { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.top .wrap { display: flex; align-items: center; gap: 16px; height: 64px; }
.logo { display: inline-flex; align-items: center; background: #fff; border-radius: 10px; padding: 4px 8px; }
.logo img { height: 26px; width: auto; display: block; }
.nav { display: flex; gap: 4px; margin-left: auto; align-items: center; }
.nav a { color: var(--ink); text-decoration: none; padding: 8px 12px; border-radius: 999px; font-size: 16px; }
.nav a:hover, .nav a[aria-current] { background: var(--tint); color: var(--brand); }
.lang { font-size: 14px; border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; color: var(--mute); background: none; font-family: inherit; }
@media (max-width: 720px) { .nav a:not(.keep) { display: none; } }

/* Breadcrumb */
.crumbs { font-size: 14px; color: var(--mute); padding: 14px 0 0; }
.crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; }
.crumbs li + li::before { content: "›"; margin-right: 6px; }
.crumbs a { color: var(--mute); }

/* Buttons and chips */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 10px 20px; border-radius: 999px; border: 0; background: var(--brand); color: var(--on-brand); font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; }
.btn-ghost { background: transparent; color: var(--brand); border: 2px solid var(--brand); }
.btn-sun { background: var(--sun); color: #1F2937; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 12px; border-radius: 999px; font-size: 14px; background: var(--tint); color: var(--brand); border: 1px solid var(--line); }
.chip-gold { background: var(--gold); color: #1F2937; border: 0; font-weight: 700; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
section { padding: 28px 0; }

/* Home */
.hero { padding: 36px 0 12px; }
.hero .wrap { display: grid; grid-template-columns: 1fr auto; gap: 24px; align-items: center; }
.hero h1 { font-size: clamp(34px, 7vw, 56px); }
.hero h1 em { font-style: normal; background: linear-gradient(transparent 58%, var(--sun) 58%); }
.hero .lead { font-size: 19px; color: var(--mute); max-width: 34em; }
@media (max-width: 640px) { .hero .wrap { grid-template-columns: 1fr; } .hero [data-sprout] { order: -1; } .hero [data-sprout] svg { width: 110px; height: 110px; } }
.picker h2 { margin-bottom: 4px; }
.stage { margin-top: 18px; }
.stage-title { display: flex; align-items: baseline; gap: 10px; margin: 0 0 10px; font-size: 18px; }
.years { display: grid; gap: 12px; grid-template-columns: repeat(6, 1fr); }
.years.three { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 720px) { .years { grid-template-columns: repeat(3, 1fr); } }
.year { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 92px; border-radius: var(--radius); text-decoration: none; font-family: var(--font-head); font-size: 26px; border: 3px solid transparent; transition: transform .15s; }
.year small { font-family: var(--font-body); font-size: 14px; }
.year:hover { transform: translateY(-3px); }
.y-pri { background: #fff; color: #14532D; border-color: #BBF7D0; box-shadow: 0 4px 0 #BBF7D0; }
.y-pri:nth-child(3n+2) { border-color: #FDE68A; box-shadow: 0 4px 0 #FDE68A; color: #713F12; }
.y-pri:nth-child(3n) { border-color: #BAE6FD; box-shadow: 0 4px 0 #BAE6FD; color: #0C4A6E; }
.y-jun { background: #F3F4F6; color: #4B5563; border-style: dashed; border-color: #D1D5DB; }
.y-dse { background: #0F172A; color: #F1F5F9; font-family: var(--font-body); font-weight: 900; box-shadow: 0 4px 0 #F5B301; }
.y-dse small { color: #F5B301; font-weight: 700; }
.feature { display: flex; gap: 14px; align-items: flex-start; }
.feature .ico { flex: none; width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; font-size: 24px; background: var(--accent-bg); }
.demo-dse { background: #0F172A; color: #F1F5F9; border: 0; }
.demo-dse .mute { color: #CBD5E1; }
.demo-dse a.btn { background: #4ADE80; color: #0F172A; }
.footer { border-top: 1px solid var(--line); padding: 24px 0 48px; color: var(--mute); font-size: 14px; margin-top: 24px; }

/* Stage pages */
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0 4px; }
.tab { min-height: 44px; min-width: 64px; padding: 6px 16px; border-radius: 999px; border: 2px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.tab[aria-current] { background: var(--brand); border-color: var(--brand); color: var(--on-brand); font-weight: 700; }
.unit { display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: var(--ink); min-height: 120px; }
.unit .n { font-size: 14px; color: var(--mute); }
.unit h3 { margin: 0; }
.unit.live { border: 2px solid var(--brand); }
.unit.live:hover { transform: translateY(-2px); }
.unit.soon { opacity: .7; border-style: dashed; }
.badge { align-self: flex-start; font-size: 13px; padding: 1px 10px; border-radius: 999px; background: var(--accent-bg); color: var(--ink); }
.empty { display: flex; gap: 16px; align-items: center; }

/* Topic page */
.topic-head { padding: 12px 0 8px; }
.summary { font-size: 20px; max-width: 36em; }
.mode-primary .summary { background: var(--tint); border-radius: var(--radius); padding: 14px 18px; border-left: 6px solid var(--brand-bright); }
.mode-dse .summary { border-left: 4px solid var(--gold); padding-left: 14px; color: var(--ink); }
.steps { list-style: none; margin: 0; padding: 0; counter-reset: s; display: grid; gap: 10px; }
.steps > li { counter-increment: s; position: relative; padding: 12px 52px 12px 56px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.steps > li::before { content: counter(s); position: absolute; left: 14px; top: 12px; width: 30px; height: 30px; border-radius: 50%; background: var(--brand); color: var(--on-brand); font-weight: 700; display: grid; place-items: center; font-size: 16px; }
.work { font-family: "Noto Sans Mono", ui-monospace, Menlo, monospace; background: var(--tint); border-radius: var(--radius-sm); padding: 8px; display: grid; gap: 4px; }
.work > div { position: relative; padding: 8px 52px 8px 12px; border-radius: 10px; }
.work .why { font-family: var(--font-body); font-size: 14px; color: var(--mute); display: block; }
.mistakes li { margin-bottom: 8px; }
.mistakes li::marker { content: "✗  "; color: #B4232A; font-weight: 700; }
.mode-dse .mistakes li::marker { color: #FF8A8E; }
table { border-collapse: collapse; width: 100%; font-size: 16px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--mute); font-weight: 700; }
.table-scroll { overflow-x: auto; }
details { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 16px; margin-bottom: 10px; }
summary { cursor: pointer; font-weight: 700; min-height: 32px; }
details p { margin: 10px 0 0; }

/* DSE goal bar */
.goal { display: grid; grid-template-columns: auto 1fr; gap: 16px; align-items: stretch; }
@media (max-width: 720px) { .goal { grid-template-columns: 1fr; } }
.count { background: #0B1222; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 20px; min-width: 240px; }
.count .num { font-size: 56px; font-weight: 900; color: var(--gold); line-height: 1; }
.count .num span { font-size: 20px; color: var(--ink); margin-left: 6px; }
.levels { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 10px; }
.lvl { min-width: 52px; min-height: 44px; border-radius: 10px; border: 2px solid var(--line); background: transparent; color: var(--ink); font: inherit; font-weight: 900; cursor: pointer; }
.lvl[aria-pressed="true"] { background: var(--gold); border-color: var(--gold); color: #0F172A; }

/* Fractions (primary) */
.frac { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; line-height: 1.1; margin: 0 .15em; font-weight: 700; }
.frac > span:first-child { border-bottom: 3px solid currentColor; padding: 0 .2em; }
.frac.big { font-size: 44px; }
.lesson { display: grid; grid-template-columns: minmax(220px, 340px) 1fr; gap: 20px; align-items: center; }
@media (max-width: 720px) { .lesson { grid-template-columns: 1fr; } }
.stage-visual { background: var(--tint); border-radius: var(--radius); display: grid; place-items: center; padding: 12px; min-height: 260px; }
.stage-visual svg { max-width: 100%; height: auto; }
.step-text { font-size: 20px; min-height: 5.6em; }
.step-nav { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.dots { display: flex; gap: 6px; margin-left: auto; }
.dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
.dots i.on { background: var(--brand-bright); }
.labelled { display: inline-flex; align-items: center; gap: 18px; }
.labelled .tags { display: grid; gap: 22px; font-size: 16px; }
.labelled [data-ask] { position: relative; padding-right: 48px; }
.quiz .opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin: 10px 0; }
.opt { min-height: 72px; border-radius: var(--radius-sm); border: 3px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-size: 22px; cursor: pointer; }
.opt:hover { border-color: var(--sky); }
.opt.right { border-color: var(--brand); background: var(--tint); }
.opt.wrong { border-color: var(--red-pen); }
.mode-dse .opt { font-size: 17px; text-align: left; padding: 10px 14px; }
.feedback { display: flex; gap: 10px; align-items: center; min-height: 72px; }
.stickers { font-size: 28px; letter-spacing: 4px; }

/* Circle to ask */
.ask-bar { position: sticky; bottom: 16px; z-index: 30; display: flex; justify-content: center; pointer-events: none; margin-top: 12px; }
.ask-bar .btn { pointer-events: auto; box-shadow: 0 6px 20px rgba(0,0,0,.25); background: #B4232A; color: #fff; }
.ask-bar .btn[aria-pressed="true"] { background: #fff; color: #B4232A; outline: 3px solid var(--red-pen); }
.ask-canvas { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 40; pointer-events: none; touch-action: none; }
.asking .ask-canvas { pointer-events: auto; cursor: crosshair; }
.asking [data-ask] { outline: 2px dashed rgba(229,72,77,.45); outline-offset: 2px; }
[data-ask] { position: relative; }
.ask-btn { position: absolute; right: 8px; top: 8px; min-width: 36px; height: 32px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: #B4232A; font: inherit; font-size: 14px; font-weight: 700; cursor: pointer; }
.mode-dse .ask-btn { color: #FF8A8E; }
.ask-hit { background: rgba(255, 201, 60, .28) !important; border-radius: 10px; }
.ask-panel { position: fixed; right: 16px; bottom: 16px; z-index: 50; width: min(400px, calc(100vw - 32px)); background: #fff; color: #1F2937; border-radius: 20px; padding: 14px 16px; box-shadow: 0 12px 40px rgba(0,0,0,.3); border: 3px solid #FFC93C; font-family: var(--font-body); }
.ask-head { display: flex; align-items: center; gap: 8px; }
.ask-head b { display: block; font-size: 18px; }
.ask-sub { font-size: 13px; color: #4B5563; }
.ask-close { margin-left: auto; width: 44px; height: 44px; border: 0; background: #F3F4F6; border-radius: 50%; font-size: 18px; cursor: pointer; color: #1F2937; }
.ask-quote { font-size: 14px; color: #4B5563; margin: 8px 0 4px; }
.ask-reply { font-size: 17px; min-height: 3.5em; }
.ask-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.ask-panel .btn { background: #15803D; color: #fff; min-height: 44px; }
.ask-panel .btn-ghost { background: transparent; color: #15803D; border-color: #15803D; }
.ask-note { font-size: 12px; color: #4B5563; margin: 8px 0 0; }

.proto-note { background: var(--accent-bg); border-radius: var(--radius-sm); padding: 8px 14px; font-size: 14px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* Practice board (PRD 10) */
.practice-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.practice-head h1 { margin: 0; }
.practice { display: grid; gap: 16px; grid-template-columns: minmax(300px, 400px) minmax(0, 1fr); grid-template-areas: "q b" "c b" "s b" "f b"; align-items: start; align-content: start; margin-top: 12px; }
.practice > .qcard { grid-area: q; }
.practice > .coach { grid-area: c; }
.practice > .bsteps { grid-area: s; }
.practice > .finish { grid-area: f; }
.practice > .bpanel { grid-area: b; position: sticky; top: 76px; padding: 12px; }
@media (max-width: 900px) {
  .practice { grid-template-columns: minmax(0, 1fr); grid-template-areas: "q" "b" "c" "s" "f"; }
  .practice > .bpanel { position: static; }
}
.qcard h2 { margin: 8px 0 6px; font-size: 22px; }
.qcard p { margin: 0; }
.tools { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; align-items: center; }
.tool { min-height: 44px; min-width: 44px; padding: 0 12px; border-radius: 12px; border: 2px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-size: 15px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.tool[aria-pressed="true"] { border-color: var(--brand); background: var(--tint); color: var(--brand); font-weight: 700; }
.tool.pen { padding: 0; }
.tool.pen i { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); }
.tool-gap { flex: 1; }
.canvas { position: relative; aspect-ratio: 800 / 560; border-radius: 14px; overflow: hidden; border: 2px solid var(--line); }
.canvas canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.canvas canvas:last-child { touch-action: none; cursor: crosshair; }
.bsteps { list-style: none; margin: 0; padding: 0; counter-reset: s; display: grid; gap: 8px; }
.bsteps > li { counter-increment: s; position: relative; padding: 12px 14px 12px 52px; background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius-sm); }
.bsteps > li::before { content: counter(s); position: absolute; left: 12px; top: 12px; width: 28px; height: 28px; border-radius: 50%; background: var(--line); color: var(--ink); font-weight: 700; display: grid; place-items: center; font-size: 15px; }
.bsteps > li.now { border-color: var(--brand); }
.bsteps > li.now::before { background: var(--brand); color: var(--on-brand); }
.bsteps > li.done::before { content: "✓"; background: var(--brand); color: var(--on-brand); }
.bsteps > li.done .say-step { color: var(--mute); }
.bsteps > li.later { opacity: .65; }
.say-step { font-size: 17px; }
.answer { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; margin-top: 10px; }
.answer label { display: grid; gap: 2px; font-size: 14px; color: var(--mute); }
.answer input { width: 112px; min-height: 48px; padding: 6px 10px; border-radius: 12px; border: 2px solid var(--line); background: var(--bg); color: var(--ink); font: inherit; font-size: 20px; }
.answer input:focus { border-color: var(--sky); outline: none; }
.choices { display: grid; gap: 8px; margin-top: 10px; }
.choices .opt { min-height: 52px; font-size: 18px; text-align: left; padding: 8px 14px; }
.step-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.small-btn { min-height: 44px; padding: 6px 16px; font-size: 16px; }
.pulse { animation: pulse 1.1s ease-in-out 3; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(255, 201, 60, .55); } }
.coach { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; align-items: start; padding: 14px 16px; }
.coach .say { font-size: 18px; min-height: 3.2em; }
.coach .live { grid-column: 1 / -1; border-top: 1px solid var(--line); padding-top: 12px; }
.live-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.live-go { background: var(--sun); color: #1F2937; }
.live[data-state="listening"] .live-go, .live[data-state="speaking"] .live-go { background: #B4232A; color: #fff; }
.live[data-state="listening"] .live-go { animation: pulse 1.6s ease-in-out infinite; }
.live-langs { display: inline-flex; border: 2px solid var(--line); border-radius: 999px; overflow: hidden; }
.live-langs button { min-width: 48px; min-height: 44px; border: 0; background: var(--surface); color: var(--ink); font: inherit; cursor: pointer; }
.live-langs button[aria-pressed="true"] { background: var(--brand); color: var(--on-brand); font-weight: 700; }
.live-langs button:disabled { cursor: not-allowed; }
.live-status { margin: 8px 0 0; color: var(--mute); }
.live[data-state="error"] .live-status { color: #B4232A; }
.mode-dse .live[data-state="error"] .live-status { color: #FF8A8E; }
.live-log { max-height: 168px; overflow-y: auto; margin-top: 8px; padding: 8px 12px; border-radius: 12px; background: var(--tint); font-size: 15px; }
.live-log p { margin: 0 0 4px; }
.live-consent { margin-top: 10px; padding: 12px; border-radius: 12px; background: var(--accent-bg); font-size: 15px; }
.finish { text-align: center; }
.finish .stickers { font-size: 34px; }
.tool[hidden] { display: none; }
