/* Learning screens: course covers, the path through a course, the round player, the end of a round.
   Same Dusk tokens as nia.css. Each class has a hue (set by the learn_tags `hue` filter); every
   tint is derived from it with color-mix against the theme's own surface and ink, so dark mode
   follows without a second palette. White text on every hue passes AA (4.5:1). */

.hue-violet { --h: #5B45D6; }
.hue-teal   { --h: #0F7C75; }
.hue-green  { --h: #2F7A3E; }
.hue-rose   { --h: #C2386A; }
.hue-amber  { --h: #9A5B00; }
.hue-sky    { --h: #1D6FB8; }
.hue-orange { --h: #C0441B; }
.hue-plum   { --h: #8A3F9E; }
.hue-slate  { --h: #475467; }
[class*="hue-"] {
  --h-soft: color-mix(in srgb, var(--h) 11%, var(--surface));
  --h-line: color-mix(in srgb, var(--h) 28%, var(--surface));
  --h-ink: color-mix(in srgb, var(--h) 62%, var(--ink));
}

/* ---------- greeting, streak, XP ---------- */
.hello { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px var(--gutter) 4px; max-width: 640px; margin: 0 auto; }
.hello h1 { font-size: 1.7rem; margin: 0; }
.hello .sub { color: var(--ink-3); font-size: .9rem; margin: 2px 0 0; }
.fx { display: flex; gap: 6px; flex: 0 0 auto; }
.fx-chip {
  display: inline-flex; align-items: center; gap: 5px; height: 36px; padding: 0 11px;
  border-radius: 999px; background: var(--surface); border: 1px solid var(--line);
  font-weight: 800; font-size: .92rem; font-family: var(--font-display); color: var(--ink);
}
.fx-chip .ico { color: var(--accent); }
.fx-chip.is-lit { background: var(--accent-soft); border-color: var(--accent-line); }
.fx-chip.is-lit .ico { fill: var(--accent); }

.level-bar { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--line); }
.level-bar i { display: block; height: 100%; width: calc(var(--p, 0) * 100%); background: var(--accent); border-radius: 999px; }

/* ---------- round hero card ---------- */
.hero {
  position: relative; overflow: hidden; display: block; text-decoration: none;
  background: var(--h); color: #fff; border-radius: var(--radius-lg); padding: 18px 18px 16px;
  box-shadow: 0 10px 28px color-mix(in srgb, var(--h) 30%, transparent);
}
.hero .glyph { position: absolute; right: -14px; bottom: -18px; width: 132px; height: 132px; opacity: .18; stroke-width: 1.4; }
.hero .kicker { font-size: .74rem; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; opacity: .88; margin: 0 0 4px; }
.hero h2 { color: #fff; font-size: 1.35rem; margin: 0 0 6px; max-width: 80%; }
.hero .meta { font-size: .9rem; opacity: .92; margin: 0 0 14px; }
.hero .go {
  display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 18px; border-radius: 999px;
  background: #fff; color: var(--h); font-weight: 800; font-size: .98rem;
}
.hero.is-building { background: var(--surface); color: var(--ink); border: 1px dashed var(--line-2); box-shadow: none; }
.hero.is-building h2 { color: var(--ink); }
.hero.is-building .go { display: none; }

.shelf-x { display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 2px var(--gutter) 8px; margin: 0 calc(var(--gutter) * -1); }
.shelf-x > * { scroll-snap-align: start; flex: 0 0 78%; max-width: 330px; }

/* ---------- course covers ---------- */
.covers { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.cover {
  position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end;
  min-height: 128px; padding: 14px; border-radius: var(--radius); text-decoration: none;
  background: var(--h); color: #fff;
}
.cover .glyph { position: absolute; right: -8px; top: -8px; width: 84px; height: 84px; opacity: .22; stroke-width: 1.5; }
.cover .name { font-family: var(--font-display); font-weight: 800; font-size: 1.08rem; line-height: 1.2; letter-spacing: -.01em; }
.cover .words { font-size: .78rem; opacity: .92; margin-top: 3px; }
.cover .dots { display: flex; gap: 3px; margin-top: 8px; flex-wrap: wrap; }
.cover .dots i { width: 8px; height: 8px; border-radius: 3px; background: rgba(255, 255, 255, .32); }
.cover .dots i.st-learning { background: rgba(255, 255, 255, .7); }
.cover .dots i.st-got_it { background: #fff; }
.cover:hover { filter: brightness(1.06); }

/* ---------- course page ---------- */
.course-head {
  position: relative; overflow: hidden; background: var(--h); color: #fff;
  padding: 18px var(--gutter) 22px; margin-bottom: 18px;
}
.course-head .inner { max-width: 640px; margin: 0 auto; position: relative; }
.course-head .glyph { position: absolute; right: -20px; top: -10px; width: 140px; height: 140px; opacity: .18; stroke-width: 1.3; }
.course-head a.back { color: #fff; text-decoration: none; font-weight: 700; font-size: .9rem; opacity: .9; }
.course-head h1 { color: #fff; font-size: 1.9rem; margin: 10px 0 4px; }
.course-head p { opacity: .92; margin: 0 0 14px; }
.course-head .btn-on-hue { background: #fff; color: var(--h); border: 0; min-height: 50px; border-radius: 999px; padding: 0 22px; font-weight: 800; }

.unit { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.unit + .unit { margin-top: 12px; }
.unit-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 13px 14px; }
.unit-head h3 { margin: 0; font-size: 1.02rem; }
.unit-tag { font-size: .72rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.unit-tag.now { background: var(--h); color: #fff; }
.unit-tag.done { background: var(--h-soft); color: var(--h-ink); }
.unit-tag.later { background: var(--surface-2); color: var(--ink-3); }
.unit.is-later { background: var(--sunken); }
.unit.is-later .unit-head h3 { color: var(--ink-3); }

.path { list-style: none; margin: 0; padding: 0 0 6px; }
.path li { position: relative; }
.path a, .path .locked {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px; min-height: 56px;
  text-decoration: none; color: var(--ink);
}
.path a:hover { background: var(--h-soft); }
.node {
  flex: 0 0 auto; width: 30px; height: 30px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center;
  border: 2px solid var(--h-line); background: var(--surface); color: var(--h-ink); position: relative; z-index: 1;
}
.node.st-learning { border-color: var(--h); background: var(--h-soft); }
.node.st-learning::after { content: ""; width: 10px; height: 10px; border-radius: 999px; background: var(--h); }
.node.st-got_it { border-color: var(--h); background: var(--h); color: #fff; }
.path li:not(:last-child) .node::before {
  content: ""; position: absolute; left: 50%; top: 28px; width: 2px; height: 30px; background: var(--h-line); transform: translateX(-50%);
}
.path .t-title { font-weight: 700; line-height: 1.3; }
.path .t-state { font-size: .78rem; color: var(--ink-3); }
.path .locked { color: var(--ink-3); cursor: default; }

.pill { display: inline-flex; align-items: center; gap: 5px; font-size: .76rem; font-weight: 800; padding: 3px 10px; border-radius: 999px; }
.pill.st-new { background: var(--surface-2); color: var(--ink-2); }
.pill.st-learning { background: var(--h-soft); color: var(--h-ink); }
.pill.st-got_it { background: var(--h); color: #fff; }

/* ---------- topic page ---------- */
.topic-actions { display: grid; gap: 10px; }
.act {
  display: flex; align-items: center; gap: 14px; padding: 14px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); text-decoration: none; color: var(--ink);
  font: inherit; text-align: left; width: 100%; cursor: pointer; box-shadow: var(--shadow);
}
.act:hover { border-color: var(--h-line); background: var(--h-soft); }
.act .badge { flex: 0 0 auto; width: 46px; height: 46px; border-radius: 14px; background: var(--h-soft); color: var(--h-ink); display: inline-flex; align-items: center; justify-content: center; }
.act.is-main .badge { background: var(--h); color: #fff; }
.act b { display: block; font-size: 1.02rem; }
.act span.small { display: block; }
.act form { display: contents; }
.objectives { margin: 0; padding-left: 1.1em; }
.objectives li { margin-bottom: 4px; }

/* ---------- the round player ---------- */
body.playing { padding-bottom: 0; }
body.playing .tabs { display: none; }
.player { min-height: 100dvh; display: flex; flex-direction: column; max-width: 640px; margin: 0 auto; padding: 0 var(--gutter); }
.player-top { display: flex; align-items: center; gap: 12px; padding: 14px 0 10px; }
.player-top .icon-btn { width: 42px; height: 42px; }
.segs { flex: 1 1 auto; display: flex; gap: 4px; }
.segs i { flex: 1 1 0; height: 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); transition: background .25s; }
.segs i.is-now { background: var(--h-line); border-color: var(--h-line); }
.segs i.v-yes { background: var(--h); border-color: var(--h); }
.segs i.v-partly, .segs i.v-self { background: color-mix(in srgb, var(--h) 55%, var(--surface)); border-color: transparent; }
.segs i.v-no { background: var(--ink-3); border-color: var(--ink-3); opacity: .55; }

.qcard { flex: 1 1 auto; display: flex; flex-direction: column; gap: 14px; padding: 6px 0 16px; }
.q-topic { display: inline-flex; align-self: flex-start; align-items: center; gap: 6px; font-size: .78rem; font-weight: 800; color: var(--h-ink); background: var(--h-soft); padding: 4px 10px; border-radius: 999px; }
.q-prompt { font-family: var(--font-display); font-weight: 800; font-size: 1.38rem; line-height: 1.32; letter-spacing: -.01em; margin: 0; }
.q-tools { display: flex; gap: 8px; flex-wrap: wrap; }
.q-tools .btn { min-height: 40px; border-radius: 999px; font-size: .88rem; padding: 0 14px; }
.q-tools .is-busy { opacity: .6; }
.hint-box { background: var(--second-soft); border-radius: 14px; padding: 12px 14px; font-size: .96rem; }

.opts { display: flex; flex-direction: column; gap: 10px; }
.opt {
  display: flex; align-items: center; gap: 12px; text-align: left; min-height: 58px; padding: 12px 14px;
  border-radius: 16px; background: var(--surface); border: 2px solid var(--line); box-shadow: 0 2px 0 var(--line);
  font: inherit; color: var(--ink); cursor: pointer; transition: transform .08s, border-color .15s, background .15s;
}
.opt .key { flex: 0 0 auto; width: 30px; height: 30px; border-radius: 9px; border: 2px solid var(--line-2); display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: .85rem; color: var(--ink-3); }
.opt:hover { border-color: var(--h-line); }
.opt:active { transform: translateY(1px); box-shadow: none; }
.opt[aria-pressed="true"] { border-color: var(--h); background: var(--h-soft); }
.opt[aria-pressed="true"] .key { border-color: var(--h); background: var(--h); color: #fff; }
.opt.is-right { border-color: var(--ok); background: var(--ok-soft); }
.opt.is-right .key { border-color: var(--ok); background: var(--ok); color: var(--surface); }
.opt.is-off { opacity: .5; }
.tf { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tf .opt { justify-content: center; font-weight: 800; font-size: 1.05rem; }

.answer-in { font-size: 1.15rem; min-height: 58px; border-radius: 16px; border-width: 2px; }
.answer-in:focus { border-color: var(--h); outline: none; box-shadow: 0 0 0 3px var(--h-soft); }
textarea.answer-in { min-height: 130px; }
.unit-after { display: flex; align-items: center; gap: 10px; }
.unit-after span { font-weight: 700; color: var(--ink-2); }

.player-foot { position: sticky; bottom: 0; padding: 12px 0 calc(14px + env(safe-area-inset-bottom, 0px)); background: linear-gradient(to top, var(--bg) 70%, transparent); }
.player-foot .btn-primary { background: var(--h); border-color: var(--h); color: #fff; box-shadow: 0 4px 14px color-mix(in srgb, var(--h) 32%, transparent); border-radius: 16px; }
.player-foot .btn-primary:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }

.verdict {
  border-radius: var(--radius-lg); padding: 16px; margin-bottom: 12px; border: 1px solid var(--line);
  background: var(--surface); box-shadow: var(--shadow-lift); animation: rise .22s ease-out;
}
.verdict h3 { display: flex; align-items: center; gap: 8px; font-size: 1.2rem; margin: 0 0 6px; }
.verdict.v-yes { border-color: var(--ok); background: var(--ok-soft); }
.verdict.v-yes h3 { color: var(--ok); }
.verdict.v-partly, .verdict.v-self { border-color: var(--second); background: var(--second-soft); }
.verdict.v-no { border-color: var(--line-2); }
.verdict p { margin: 0 0 8px; }
.verdict .right { font-weight: 700; }
.verdict .row { flex-wrap: wrap; gap: 6px; }
.verdict .btn { min-height: 38px; border-radius: 999px; font-size: .86rem; }
@keyframes rise { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

.pop { animation: pop .35s ease-out; }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.03); } 100% { transform: scale(1); } }

.building { flex: 1 1 auto; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 10px; padding: 40px 10px; }

/* ---------- end of a round ---------- */
.finish { text-align: center; padding: 34px 0 10px; }
.finish .burst {
  width: 96px; height: 96px; margin: 0 auto 16px; border-radius: 999px; background: var(--h); color: #fff;
  display: flex; align-items: center; justify-content: center; box-shadow: 0 0 0 10px var(--h-soft);
  animation: pop .5s ease-out;
}
.finish h1 { font-size: 1.8rem; margin-bottom: 6px; }
.gain { display: flex; justify-content: center; gap: 8px; margin: 12px 0 4px; }
.topic-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.topic-chips a { text-decoration: none; }
.tchip { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 12px; font-weight: 700; font-size: .9rem; }
.tchip.good { background: var(--h-soft); color: var(--h-ink); }
.tchip.again { background: var(--surface); border: 1px solid var(--line-2); color: var(--ink); }

#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 50; }

/* ---------- lesson extras ---------- */
.lesson-check { border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 16px; background: var(--surface); }
.lesson-check .opts { margin-top: 10px; }
.lesson-done { text-align: center; }

@media (min-width: 560px) {
  .covers { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .shelf-x > * { flex-basis: 46%; }
}
@media (prefers-reduced-motion: reduce) {
  .verdict, .pop, .finish .burst { animation: none; }
}
