/* ===========================================================================
 * styles.css — Olympiad Class 4, Unit 1.
 *
 * Deep indigo ground with warm amber accents: the Kannada apps are bright and
 * pastel because they teach a five-to-eight-year-old to read. This one is for a
 * nine-year-old preparing for a competitive exam and is deliberately a shade
 * more grown-up, without turning into a spreadsheet.
 * =========================================================================== */

:root {
  --ink:        #12263f;
  --ink-2:      #1c3557;
  --paper:      #f7f5ef;
  --card:       #ffffff;
  --line:       #dfd9cc;
  --muted:      #6b7a8f;

  --amber:      #f0a02c;
  --amber-dk:   #cf8113;
  --green:      #2f9e56;
  --green-dk:   #248244;
  --red:        #d1495b;
  --red-soft:   #fdecee;
  --green-soft: #e8f6ed;

  --r:  16px;
  --r-s: 10px;
  --shadow: 0 2px 0 rgba(18,38,63,.14), 0 8px 22px rgba(18,38,63,.07);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Nunito", "Trebuchet MS", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 17px;
  line-height: 1.45;
  overscroll-behavior-y: contain;
}

button { font: inherit; color: inherit; cursor: pointer; }

/* ---------------------------------------------------------------- screens */
.screen { display: none; min-height: 100vh; min-height: 100dvh; }
.screen.show { display: block; }
#learn.show, #exam.show { display: flex; flex-direction: column; }

/* =============================================================== HOME ==== */
.hero {
  display: flex; align-items: center; gap: 14px;
  padding: 18px 18px 14px;
  background: linear-gradient(160deg, var(--ink) 0%, var(--ink-2) 100%);
  color: #fff;
}
.hero-owl { width: 74px; flex: 0 0 74px; }
.hero-text { flex: 1 1 auto; min-width: 0; }
.kicker {
  margin: 0 0 2px; font-size: 12px; letter-spacing: .09em;
  text-transform: uppercase; color: #a9c0dd; font-weight: 700;
}
.hero h1 { margin: 0; font-size: 27px; line-height: 1.1; font-weight: 800; }
.hero .sub { margin: 4px 0 0; font-size: 14px; color: #b9cbe2; }

.icon-btn {
  background: rgba(255,255,255,.14); border: 0; color: inherit;
  width: 40px; height: 40px; border-radius: 50%; font-size: 19px;
  display: grid; place-items: center; flex: 0 0 auto;
}
.icon-btn.off { opacity: .45; }
#learn .icon-btn, #exam .icon-btn { background: rgba(18,38,63,.08); color: var(--ink); }

/* progress bar (shared) */
.bar-wrap { padding: 14px 18px 4px; display: flex; align-items: center; gap: 12px; }
.bar {
  flex: 1 1 auto; height: 13px; border-radius: 99px;
  background: #e4dfd3; overflow: hidden;
}
.bar.small { height: 9px; margin: 8px 0 6px; background: rgba(255,255,255,.22); }
.bar-fill {
  height: 100%; width: 0%; border-radius: 99px;
  background: linear-gradient(90deg, var(--amber), #ffc766);
  transition: width .45s cubic-bezier(.3,1.4,.5,1);
}
.bar.exam .bar-fill { background: linear-gradient(90deg, var(--ink-2), #4b7bb5); }
.bar-label { font-size: 13px; color: var(--muted); font-weight: 700; white-space: nowrap; }

/* unit tabs — the course has several units and none of them are locked, so
   these are a selector, never a ladder */
.units { display: flex; gap: 8px; padding: 12px 18px 2px; flex-wrap: wrap; }
.unit-tab {
  flex: 1 1 160px; text-align: left;
  border: 2px solid var(--line); background: var(--card);
  border-radius: var(--r); padding: 10px 13px; box-shadow: var(--shadow);
}
.unit-tab.on { border-color: var(--ink-2); background: #eef3f9; }
.unit-tab.done { border-color: var(--green); background: var(--green-soft); }
.unit-tab .ut {
  display: block; font-weight: 800; font-size: 15px; line-height: 1.2;
}
.unit-tab .un {
  display: block; font-size: 12px; font-weight: 800; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em; margin-bottom: 3px;
}
.unit-tab .up { display: block; font-size: 12.5px; color: var(--muted); font-weight: 700; margin-top: 4px; }

/* quick-action chips */
.quick { display: flex; gap: 10px; padding: 10px 18px 4px; flex-wrap: wrap; }
.chip {
  border: 2px solid var(--line); background: var(--card); border-radius: 99px;
  padding: 9px 16px; font-size: 14px; font-weight: 800; box-shadow: var(--shadow);
}
.chip:disabled { opacity: .45; box-shadow: none; cursor: default; }
.chip .n { color: var(--red); }

.section-head {
  margin: 20px 18px 10px; font-size: 14px; font-weight: 800;
  color: var(--muted); letter-spacing: .02em;
}

/* the round map */
.map {
  display: grid; gap: 12px; padding: 0 18px;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
}
.round {
  position: relative; text-align: left;
  background: var(--card); border: 2px solid var(--line); border-radius: var(--r);
  padding: 13px 13px 11px; box-shadow: var(--shadow);
  transition: transform .12s ease;
}
.round:active { transform: translateY(2px); }
.round.passed { border-color: var(--green); background: var(--green-soft); }
.round .emo { font-size: 27px; line-height: 1; }
.round .rt { display: block; font-weight: 800; font-size: 15px; margin: 7px 0 3px; }
.round .rn { display: block; font-size: 12.5px; color: var(--muted); font-weight: 700; }
.round .star {
  position: absolute; top: 10px; right: 11px; font-size: 19px;
}
.round .best {
  position: absolute; top: 12px; right: 11px;
  font-size: 12px; font-weight: 800; color: var(--muted);
}

/* final exam card */
.final-card {
  display: flex; gap: 14px; align-items: flex-start;
  margin: 22px 18px; padding: 16px; border-radius: var(--r);
  background: linear-gradient(160deg, var(--ink) 0%, var(--ink-2) 100%);
  color: #fff; box-shadow: var(--shadow);
}
.final-lock { font-size: 30px; }
.final-body { flex: 1 1 auto; }
.final-card h3 { margin: 0 0 3px; font-size: 19px; }
.final-card p { margin: 0; font-size: 13.5px; color: #b9cbe2; }
.final-req { font-weight: 700; }
.final-card:not(.locked) { background: linear-gradient(160deg, var(--green-dk), var(--green)); }

.foot { padding: 8px 18px 34px; text-align: center; }
.link-btn {
  background: none; border: 0; color: var(--muted);
  font-size: 13px; text-decoration: underline; padding: 8px;
}

/* ==================================================== LEARN / EXAM shell = */
.top {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; flex: 0 0 auto;
}
.hearts { display: flex; gap: 3px; font-size: 17px; flex: 0 0 auto; }
.hearts .h.gone { opacity: .2; }
.qcount { font-size: 14px; font-weight: 800; color: var(--muted); flex: 0 0 auto; }

.stage {
  flex: 1 1 auto; padding: 4px 18px 18px;
  max-width: 620px; width: 100%; margin: 0 auto;
}
.foot-bar {
  flex: 0 0 auto; padding: 14px 18px calc(20px + env(safe-area-inset-bottom));
  border-top: 2px solid var(--line); background: var(--card);
}
.foot-bar.right  { background: var(--green-soft); border-top-color: #bfe4cd; }
.foot-bar.wrong  { background: var(--red-soft);   border-top-color: #f5c8ce; }

.btn {
  display: block; width: 100%; max-width: 584px; margin: 0 auto;
  border: 0; border-radius: 14px; padding: 14px;
  font-weight: 800; font-size: 16.5px;
  background: #e6e1d6; color: var(--ink);
  box-shadow: 0 3px 0 #cfc8b8;
}
.btn.primary { background: var(--amber); color: #2b1a02; box-shadow: 0 3px 0 var(--amber-dk); }
.btn.go      { background: var(--green); color: #fff;  box-shadow: 0 3px 0 var(--green-dk); }
.btn.ghost   { background: none; box-shadow: none; color: var(--muted); }
.btn:disabled { opacity: .45; box-shadow: none; }
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: none; }
.btn + .btn { margin-top: 9px; }

/* ------------------------------------------------------------- questions */
.prompt {
  font-size: 13px; font-weight: 800; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted); margin: 6px 0 10px;
}
.ask {
  font-size: 22px; font-weight: 800; line-height: 1.28; margin: 0 0 18px;
  display: flex; align-items: flex-start; gap: 10px;
}
.ask .txt { flex: 1 1 auto; }

.opts { display: grid; gap: 10px; }
.opt {
  text-align: left; background: var(--card);
  border: 2px solid var(--line); border-radius: 14px;
  padding: 14px 15px; font-size: 16.5px; font-weight: 700;
  box-shadow: 0 3px 0 #e7e2d7;
}
.opt:active { transform: translateY(3px); box-shadow: none; }
.opt.sel   { border-color: var(--ink-2); background: #eef3f9; }
.opt.right { border-color: var(--green); background: var(--green-soft); }
.opt.wrong { border-color: var(--red);   background: var(--red-soft); }
.opt:disabled { cursor: default; }

/* flashcard */
.flash {
  background: var(--card); border: 2px solid var(--line); border-radius: var(--r);
  padding: 26px 22px; text-align: center; box-shadow: var(--shadow);
}
.flash .q { font-size: 19px; font-weight: 700; color: var(--muted); }
.flash .a {
  font-size: 30px; font-weight: 800; margin: 14px 0 4px;
  line-height: 1.2; color: var(--ink);
}
.flash .emo { font-size: 42px; }

/* typing */
.type-in {
  width: 100%; font: inherit; font-size: 20px; font-weight: 800;
  padding: 14px 15px; border: 2px solid var(--line); border-radius: 14px;
  background: var(--card); color: var(--ink);
}
.type-in:focus { outline: none; border-color: var(--ink-2); }
.type-in.right { border-color: var(--green); background: var(--green-soft); }
.type-in.wrong { border-color: var(--red);   background: var(--red-soft); }
.hint-btn {
  margin-top: 10px; background: none; border: 0; color: var(--muted);
  font-size: 14px; font-weight: 700; text-decoration: underline; padding: 6px 0;
}

/* match */
.match { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.match .col { display: grid; gap: 10px; align-content: start; }
.match .m {
  text-align: left; background: var(--card); border: 2px solid var(--line);
  border-radius: 12px; padding: 12px; font-size: 15px; font-weight: 700;
  box-shadow: 0 3px 0 #e7e2d7; min-height: 56px;
}
.match .m.sel   { border-color: var(--ink-2); background: #eef3f9; }
.match .m.done  { border-color: var(--green); background: var(--green-soft); opacity: .55; }
.match .m.miss  { border-color: var(--red);   background: var(--red-soft); }

/* order the dates */
.order-pool, .order-slots { display: grid; gap: 9px; margin-bottom: 14px; }
.order-slots { min-height: 8px; }
.ord {
  text-align: left; background: var(--card); border: 2px solid var(--line);
  border-radius: 12px; padding: 12px 14px; font-weight: 700; font-size: 15.5px;
  box-shadow: 0 3px 0 #e7e2d7;
}
.ord.placed { background: #eef3f9; border-color: var(--ink-2); }
.ord.right  { border-color: var(--green); background: var(--green-soft); }
.ord.wrong  { border-color: var(--red);   background: var(--red-soft); }

/* feedback banner in the footer */
.fb { display: flex; align-items: flex-start; gap: 11px; margin-bottom: 12px; }
.fb .fb-owl { width: 46px; flex: 0 0 46px; }
.fb .fb-t { font-weight: 800; font-size: 16px; }
.fb .fb-a { font-weight: 800; }
.fb .fb-note {
  font-size: 13.5px; color: var(--ink); opacity: .8; margin-top: 5px;
  border-left: 3px solid var(--amber); padding-left: 9px; line-height: 1.4;
}

/* ============================================================= RESULT ==== */
.result-wrap {
  position: relative; max-width: 620px; margin: 0 auto;
  padding: 26px 18px calc(30px + env(safe-area-inset-bottom)); text-align: center;
}
.confetti { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.result-owl { width: 96px; margin: 0 auto 6px; }
.score-ring {
  width: 132px; height: 132px; margin: 6px auto 12px; border-radius: 50%;
  display: grid; place-items: center;
  background: conic-gradient(var(--amber) var(--pct, 0%), #e4dfd3 0);
  position: relative;
}
.score-ring::after {
  content: ""; position: absolute; inset: 11px; border-radius: 50%; background: var(--paper);
}
.score-ring.pass { background: conic-gradient(var(--green) var(--pct, 0%), #e4dfd3 0); }
.score-ring span { position: relative; z-index: 1; font-size: 31px; font-weight: 800; }
#resultTitle { margin: 4px 0 2px; font-size: 25px; }
#result .sub { margin: 0 0 16px; color: var(--muted); font-weight: 700; }

.review { text-align: left; display: grid; gap: 9px; margin: 4px 0 20px; }
.rev {
  background: var(--card); border: 2px solid var(--line); border-left-width: 6px;
  border-radius: var(--r-s); padding: 11px 13px;
}
.rev.bad { border-left-color: var(--red); }
.rev .rq { font-weight: 800; font-size: 15px; }
.rev .ra { font-size: 14px; margin-top: 4px; }
.rev .ra b { color: var(--green-dk); }
.rev .rw { color: var(--red); text-decoration: line-through; }
.rev .rnote {
  font-size: 13px; color: var(--muted); margin-top: 6px;
  border-left: 3px solid var(--amber); padding-left: 8px; line-height: 1.4;
}
.result-actions { display: grid; gap: 9px; }

/* ------------------------------------------------- lessons and the check-up */
.lessons { padding: 4px 18px 0; }
.checkup-card {
  display: flex; gap: 14px; align-items: center; margin: 12px 0 4px;
  background: var(--card); border: 2px solid var(--amber); border-radius: var(--r);
  padding: 15px; box-shadow: var(--shadow);
}
.cu-owl { width: 66px; flex: 0 0 66px; }
.checkup-card h3 { margin: 0 0 4px; font-size: 18px; }
.checkup-card p { margin: 0 0 11px; font-size: 14px; color: var(--muted); font-weight: 700; }
.checkup-card .btn { max-width: 260px; margin: 0; }

.lesson-row { display: grid; gap: 9px; }
.lesson {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--card); border: 2px solid var(--line); border-radius: var(--r-s);
  padding: 9px 12px;
}
.lesson.ok { border-color: var(--green); background: var(--green-soft); }
.lesson .le { font-size: 20px; }
.lesson .lt { font-weight: 800; font-size: 15px; }
.lesson .ls {
  font-size: 12px; font-weight: 800; color: var(--muted);
  text-transform: uppercase; letter-spacing: .05em; flex: 1 1 auto;
}
.chip.sm { padding: 6px 11px; font-size: 13px; box-shadow: none; }
.chip.sm.vid { text-decoration: none; color: var(--ink-2); border-color: var(--ink-2); }

.round.needs { border-color: var(--amber); }
.round .learn-first {
  display: block; margin-top: 6px; font-size: 11.5px; font-weight: 800;
  color: var(--amber-dk); text-transform: uppercase; letter-spacing: .05em;
}
.teach-flag { font-size: 14px; font-weight: 700; color: var(--amber-dk); margin: 6px 0 0; }
.teach-flag.ok { color: var(--green-dk); }

/* ---------------------------------------------------------- a lesson page */
.teach {
  background: var(--card); border: 2px solid var(--line); border-radius: var(--r);
  padding: 18px; box-shadow: var(--shadow);
}
.teach h3 { margin: 0 0 12px; font-size: 20px; line-height: 1.25; }
.teach p { margin: 0 0 8px; font-size: 16px; line-height: 1.5; }
.teach p:last-child { margin-bottom: 0; }
.art { display: block; margin: 4px 0 14px; max-width: 340px; }
.art-t { font: 800 17px/1 inherit; fill: var(--ink); }
.art-d { font: 800 20px/1 inherit; fill: var(--ink); }
.art-s { font: 700 12px/1 inherit; fill: var(--muted); }

.steps { margin: 0; padding-left: 24px; }
.steps li { font-size: 16px; line-height: 1.5; margin-bottom: 7px; }
.steps li.fresh { animation: stepIn .3s ease; font-weight: 800; }
.steps li.gap {
  list-style: none; margin-left: -24px; padding: 9px 13px;
  border: 2px dashed var(--amber); border-radius: 10px;
  color: var(--amber-dk); font-weight: 800; background: #fff8ee;
}
@keyframes stepIn { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; } }

/* --------------------------------------------------------- the exam clock */
.clock {
  flex: 0 0 auto; font-size: 14px; font-weight: 800; color: var(--muted);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.clock.low { color: var(--red); animation: clockPulse 1s ease infinite; }
@keyframes clockPulse { 0%,100% { opacity: 1; } 50% { opacity: .45; } }

/* the written question */
.write-in {
  width: 100%; font: inherit; font-size: 16.5px; line-height: 1.5;
  padding: 13px 14px; border: 2px solid var(--line); border-radius: 14px;
  background: var(--card); color: var(--ink); resize: vertical;
}
.write-in:focus { outline: none; border-color: var(--ink-2); }
.rev.written { border-left-color: var(--ink-2); }
.rev.written .ra { font-size: 15px; line-height: 1.5; margin-top: 6px; }

/* the final-exam card, once it opens */
.final-card.open { cursor: pointer; }
.final-card.open:active { transform: translateY(2px); }

/* ------------------------------------------------------------ lesson video */
.video { margin: 2px 0 12px; }
.video-frame {
  position: relative; width: 100%; padding-top: 56.25%;   /* 16:9 */
  background: #000; border-radius: 12px; overflow: hidden;
  border: 2px solid var(--ink-2);
}
.video-frame iframe {
  position: absolute; inset: 0; width: 100%; height: 100%; border: 0;
}
.video-list { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.video-list .chip.on { border-color: var(--ink-2); background: #eef3f9; }
.video-cap, .video-note {
  font-size: 13.5px; color: var(--muted); font-weight: 700; margin: 9px 0 0;
}
.video-blocked {
  border: 2px dashed var(--red); border-radius: 12px;
  padding: 14px; background: var(--red-soft);
}
.video-blocked h4 { margin: 0 0 7px; font-size: 16px; }
.video-blocked p { margin: 0 0 8px; font-size: 14px; line-height: 1.45; }
.video-blocked ul { margin: 0 0 8px; padding-left: 20px; }
.video-blocked li { font-size: 14px; margin-bottom: 3px; }
.video-blocked code {
  font: 700 13.5px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  background: #fff; padding: 2px 6px; border-radius: 5px; border: 1px solid var(--line);
}

/* --------------------------------------------------- maths: why and work */
/* The named mistake gets the loudest treatment on the card. For a maths
   question it is the most useful sentence the app can show. */
.fb-why {
  font-size: 14px; font-weight: 800; margin-top: 6px; line-height: 1.4;
  border-left: 3px solid var(--red); padding-left: 9px; color: var(--ink);
}
.work { margin-top: 8px; }
.work summary {
  font-size: 13.5px; font-weight: 800; color: var(--muted);
  cursor: pointer; padding: 3px 0; list-style: none;
}
.work summary::-webkit-details-marker { display: none; }
.work summary::before { content: "▸ "; }
.work[open] summary::before { content: "▾ "; }
.work ol { margin: 5px 0 0; padding-left: 22px; }
.work li { font-size: 14px; line-height: 1.5; margin-bottom: 3px; }
.rwhy {
  font-size: 13px; margin-top: 6px; font-weight: 700;
  border-left: 3px solid var(--red); padding-left: 8px; line-height: 1.4;
}

/* ---------------------------------------------------------------- combo */
/* The app makes no speech, so the streak counter is doing the job an
   encouraging voice would: telling him something is going well, right now. */
.combo {
  flex: 0 0 auto; font-size: 14px; font-weight: 800; min-width: 44px;
  text-align: center; color: var(--amber-dk); letter-spacing: -.01em;
}
.combo.hot2 { font-size: 16px; }
.combo.hot3 { font-size: 18px; color: var(--red); }
.combo.pop  { animation: comboPop .32s cubic-bezier(.3,1.6,.5,1); }
@keyframes comboPop { 0% { transform: scale(1); } 40% { transform: scale(1.35); } 100% { transform: scale(1); } }

/* ------------------------------------------------------------ build word */
.build-slot {
  min-height: 62px; border: 2px dashed var(--line); border-radius: 14px;
  background: var(--card); padding: 8px; margin-bottom: 16px;
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
}
.build-slot.right { border-style: solid; border-color: var(--green); background: var(--green-soft); }
.build-slot.wrong { border-style: solid; border-color: var(--red);   background: var(--red-soft); }
.slot-empty { color: var(--muted); font-size: 14px; font-weight: 700; padding-left: 6px; }
.tiles { display: flex; flex-wrap: wrap; gap: 8px; }
.tile {
  min-width: 42px; height: 46px; padding: 0 11px;
  border: 2px solid var(--line); border-radius: 11px; background: var(--card);
  font-size: 20px; font-weight: 800; text-transform: uppercase;
  box-shadow: 0 3px 0 #e7e2d7;
}
.tile:active:not(:disabled) { transform: translateY(3px); box-shadow: none; }
.tile.used { opacity: .22; pointer-events: none; box-shadow: none; }
.tile.placed { background: #eef3f9; border-color: var(--ink-2); box-shadow: none; height: 42px; }
.hint-line { color: var(--muted); font-size: 13.5px; font-weight: 700; margin: 14px 0 0; }

/* --------------------------------------------------------- sort two bins */
.tray {
  display: flex; flex-wrap: wrap; gap: 8px; min-height: 50px;
  padding: 8px; margin-bottom: 14px;
  border: 2px dashed var(--line); border-radius: 14px;
}
.chip-a {
  border: 2px solid var(--line); background: var(--card); border-radius: 11px;
  padding: 9px 12px; font-size: 14.5px; font-weight: 800; box-shadow: 0 3px 0 #e7e2d7;
}
.chip-a.sel { border-color: var(--ink-2); background: #eef3f9; }
.chip-a.ok  { border-color: var(--green); background: var(--green-soft); box-shadow: none; }
.chip-a.no  { border-color: var(--red);   background: var(--red-soft);   box-shadow: none; }
.bins { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.bin {
  border: 2px solid var(--line); border-radius: 14px; background: var(--card);
  padding: 10px; min-height: 140px;
}
.bin h4 {
  margin: 0 0 8px; font-size: 13px; line-height: 1.25;
  color: var(--muted); font-weight: 800;
}
.bin-in { display: flex; flex-wrap: wrap; gap: 7px; align-content: start; }

/* ------------------------------------------------------------- odd one out */
.ask b { color: var(--amber-dk); }

/* --------------------------------------------------------------- desktop */
@media (min-width: 700px) {
  .hero { padding: 24px 30px 20px; }
  .hero h1 { font-size: 32px; }
  .map, .bar-wrap, .quick, .units, .lessons, .section-head, .final-card, .foot { padding-left: 30px; padding-right: 30px; }
  .final-card { margin-left: 30px; margin-right: 30px; }
}
