/* Akshar lesson player. Kid first: one thing per screen, huge type on the slate, big round buttons, the tutor's
   voice does the talking. One column from 320px phones to tablets and laptops; the slate takes the height there is.
   Solid fills only. The script font comes from the lesson file (--script-font, set by learn.js). */
:root {
  --paper: #F5EDE0;
  --ink: #1E2452;
  --ink-soft: #4B4F72;
  --slate: #1B2048;
  --chalk: #F3EBDD;
  --chalk-soft: #C9C6D6;
  --marigold: #E9A23B;
  --marigold-deep: #D48C22;
  --terracotta: #B5532F;
  --terracotta-ink: #A4482A;
  --wood: #8E4B2E;
  --rule: #DCCFB9;
  --serif: "Young Serif", Georgia, "Times New Roman", serif;
  --sans: "Hind", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --script-font: serif;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; height: 100%; }
body.learn {
  margin: 0;
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
  touch-action: manipulation;
  overscroll-behavior-y: none;
  font-variant-numeric: lining-nums;
}
p { margin: 0; }
.script { font-family: var(--script-font); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--marigold); outline-offset: 4px; }

.app {
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 780px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: max(12px, env(safe-area-inset-top)) 16px max(8px, env(safe-area-inset-bottom));
}

/* Top: progress along today's lesson, and the stars so far */
.top { display: flex; align-items: center; gap: 14px; flex: 0 0 auto; }
.bar { flex: 1 1 auto; height: 8px; border-radius: 4px; background: var(--rule); overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--marigold); border-radius: 4px; transition: width 0.35s ease; }
.stars-count { display: flex; align-items: center; gap: 6px; font-family: var(--serif); font-size: 20px; line-height: 1; color: var(--ink); }
.stars-count svg { width: 24px; height: 24px; overflow: visible; }
.stars-count path { fill: var(--marigold); stroke: var(--wood); stroke-width: 9; stroke-linejoin: round; }
.stars-count.bump { animation: bump 0.5s ease; }
@keyframes bump { 40% { transform: scale(1.25); } }

/* The stage: a label, the slate in its wooden frame, a caption. The slate takes the height that is left. */
.stage { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; justify-content: center; padding-top: 12px; }
.label { flex: 0 0 auto; text-align: center; font-family: var(--serif); font-size: 22px; line-height: 1.2; color: var(--ink); margin-bottom: 10px; }
.label:empty { display: none; }
.app[data-step="gp"] .label { color: var(--terracotta); }
.board {
  position: relative;
  flex: 1 1 auto;
  min-height: 190px;
  max-height: min(540px, 104vw);
  display: flex;
  background: var(--wood);
  border-radius: 18px;
  padding: 9px;
}
.slate {
  position: relative;
  flex: 1 1 auto;
  min-height: 172px;
  background: var(--slate);
  border-radius: 11px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  container-type: size;
}
.rule { position: absolute; left: 0; right: 0; height: 1px; background: var(--chalk); opacity: 0.14; }
.rule.r1 { top: 14%; }
.rule.r2 { bottom: 14%; }
.slate-text {
  position: relative;
  width: 90%;
  color: var(--chalk);
  text-align: center;
  line-height: 1.25;
  font-size: 40px;
}
.slate-text[data-kind="letter"], .slate-text[data-kind="letters"], .slate-text[data-kind="word"], .slate-text[data-nowrap] { white-space: nowrap; line-height: 1.15; }
.slate-text[data-kind="letter"] { line-height: 1; }
.slate-text[data-kind="line"] { word-break: keep-all; overflow-wrap: normal; }
.slate-text .hl { color: var(--marigold); }
.slate-text .sep { color: var(--chalk-soft); opacity: 0.6; }
.slate-text[data-kind="letters"] span + span { margin-left: 0.32em; opacity: 0.55; }

/* Greeting: the child's name, big, and today's first line */
.greet { position: relative; width: 90%; text-align: center; color: var(--chalk); }
.greet-name { font-family: var(--serif); line-height: 1.1; white-space: nowrap; }
.greet-line { margin-top: 0.5em; line-height: 1.3; color: var(--chalk-soft); }

/* The letter game: three big chalk cards on the slate */
.cards { width: 90%; max-height: 76%; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4%; align-items: center; }
.card {
  display: grid;
  place-items: center;
  padding: 0;
  border: 3px solid var(--chalk);
  border-radius: 16px;
  background: transparent;
  color: var(--chalk);
  font-family: var(--script-font);
  aspect-ratio: 3 / 4;
  max-height: 76cqh;
  font-size: min(30cqh, 19cqw);
  line-height: 1;
  cursor: pointer;
  transition: opacity 0.2s, background-color 0.2s, border-color 0.2s;
}
.card:active { transform: scale(0.97); }
.card.right { background: var(--marigold); border-color: var(--marigold); color: var(--slate); }
.card.dim { opacity: 0.28; }
.card.hint { border-color: var(--marigold); animation: breathe 1.6s ease-in-out infinite; }
@supports not (font-size: 1cqh) { .card { font-size: 64px; } }

/* Praise: a drawn star on the frame's corner */
.star { position: absolute; top: 18px; right: 18px; width: 78px; height: 78px; overflow: visible; z-index: 2; }
.star path, .big-star path { fill: var(--marigold); stroke: var(--wood); stroke-width: 6; stroke-linejoin: round; }
.star.pop { animation: pop 0.5s cubic-bezier(0.2, 1.4, 0.4, 1) both; }
@keyframes pop {
  from { transform: scale(0.3) rotate(-25deg); opacity: 0; }
  to { transform: scale(1) rotate(0deg); opacity: 1; }
}

.caption { flex: 0 0 auto; text-align: center; min-height: 54px; padding: 10px 8px 0; }
.cap-tr { font-size: 20px; line-height: 1.3; color: var(--ink); }
.cap-en { font-size: 16px; line-height: 1.35; color: var(--ink-soft); margin-top: 2px; }
.dots { display: flex; justify-content: center; gap: 8px; padding-top: 4px; }
.dots span { width: 12px; height: 12px; border-radius: 50%; background: var(--rule); }
.dots span.on { background: var(--marigold); }
.dots span.now { background: var(--ink); }

/* What the tutor is doing, for the grown-up watching */
.cue { flex: 0 0 auto; text-align: center; min-height: 56px; padding: 4px 8px 0; }
.cue-script { font-size: 23px; line-height: 1.3; color: var(--ink); }
.cue-en { font-family: var(--serif); font-size: 22px; line-height: 1.25; color: var(--ink); }
.cue-script:not(:empty) + .cue-en { font-family: var(--sans); font-size: 16px; color: var(--ink-soft); margin-top: 1px; }
.app[data-phase="ready"] .cue-en, .app[data-phase="gp"] .cue-en { color: var(--terracotta); }

/* Big round buttons: the main one centered, "hear it again" to its left, "skip" to its right */
.controls {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 24px;
  padding: 14px 0 16px;
}
#btn-hear { grid-column: 1; grid-row: 1; justify-self: end; }
#btn-main { grid-column: 2; grid-row: 1; }
#btn-skip { grid-column: 3; grid-row: 1; justify-self: start; }
.round {
  position: relative;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  font: inherit;
  -webkit-user-select: none;
  user-select: none;
}
.round.main { width: 112px; height: 112px; background: var(--marigold); color: var(--slate); }
.round.small { width: 72px; height: 72px; background: transparent; color: var(--ink); box-shadow: inset 0 0 0 3px var(--ink); }
.round svg { grid-area: 1 / 1; }
.round .i { width: 46px; height: 46px; display: none; }
.round.small svg { width: 34px; height: 34px; }
.round .fill { fill: currentColor; }
.round .stroke { fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.round[data-icon="play"] .i-play, .round[data-icon="next"] .i-next, .round[data-icon="mic"] .i-mic,
.round[data-icon="stop"] .i-stop, .round[data-icon="dots"] .i-dots, .round[data-icon="speaker"] .i-speaker { display: block; }
.round[data-icon="play"] .i-play { margin-left: 6px; }
.round:active:not([disabled]) { transform: scale(0.96); }
.round[disabled] { cursor: default; }
.round.small[disabled] { color: var(--rule); box-shadow: inset 0 0 0 3px var(--rule); }
.round.main[disabled] { background: var(--rule); color: var(--ink-soft); }
.round.main[data-icon="dots"][disabled] { background: var(--marigold); color: var(--slate); }
.i-dots .d1, .i-dots .d2, .i-dots .d3 { animation: blink 1.2s infinite ease-in-out; }
.i-dots .d2 { animation-delay: 0.2s; }
.i-dots .d3 { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

/* Listening: terracotta, with a soft ring that breathes. No countdown: the child takes the time they need. */
.ring { position: absolute; inset: -13px; width: calc(100% + 26px); height: calc(100% + 26px); display: none; overflow: visible; }
.ring circle { fill: none; stroke: var(--terracotta); stroke-width: 4; }
.app[data-phase="recording"] .round.main { background: var(--terracotta); color: var(--chalk); }
.app[data-phase="recording"] .ring { display: block; animation: listen 1.6s ease-in-out infinite; }
@keyframes listen { 0%, 100% { opacity: 0.25; transform: scale(0.96); } 50% { opacity: 1; transform: scale(1.02); } }
/* A soft pulse on what to tap next */
.app[data-phase="ready"] .round.main, .app[data-phase="try"] .round.main, .app[data-phase="gp"] .round.main,
.round.main.nudge { animation: breathe 2.2s ease-in-out infinite; }
.round.small.nudge { animation: breathe 1.6s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }
.app[data-speaking] #btn-hear:not([disabled]) { background: var(--ink); color: var(--chalk); }

.mode-note { flex: 0 0 auto; text-align: center; font-size: 15px; line-height: 1.5; color: var(--ink-soft); padding: 4px 8px 0; }
.mode-note .link-btn { line-height: inherit; padding: 2px 2px; }
.link-btn {
  display: inline;
  padding: 4px 2px;
  border: 0;
  background: none;
  color: var(--ink);
  font-family: var(--sans);
  font-size: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.foot-link { flex: 0 0 auto; text-align: center; padding: 8px 0 2px; font-size: 15px; }
.foot-link a { color: var(--ink-soft); text-underline-offset: 3px; }

/* Celebration */
.done { flex: 1 1 auto; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 8px 0 0; }
.app[data-step="done"] .stage, .app[data-step="done"] .cue, .app[data-step="done"] .controls, .app[data-step="done"] .mode-note { display: none; }
.big-star { width: min(44vw, 190px); height: min(44vw, 190px); overflow: visible; animation: rise 0.8s cubic-bezier(0.2, 1.3, 0.4, 1) both; }
@keyframes rise {
  from { transform: scale(0.4) rotate(-40deg); opacity: 0; }
  to { transform: scale(1) rotate(0deg); opacity: 1; }
}
.done-title { font-family: var(--serif); font-weight: 400; font-size: 38px; line-height: 1.1; margin: 14px 0 0; }
.done-sub { font-size: 18px; color: var(--ink-soft); margin-top: 6px; max-width: 24em; }
.mini-stars { margin-top: 12px; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; max-width: 340px; }
.mini-stars svg { width: 26px; height: 26px; overflow: visible; }
.mini-stars path, .badge-art .mark { fill: var(--marigold); stroke: var(--wood); stroke-width: 9; stroke-linejoin: round; }
.done-stars { margin-top: 8px; font-family: var(--serif); font-size: 19px; color: var(--ink); }
.week { margin-top: 16px; }
.week-dots { display: flex; justify-content: center; gap: 8px; margin: 0; padding: 0; list-style: none; }
.week-dots li { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 13px; color: var(--ink-soft); }
.week-dots i { display: block; width: 22px; height: 22px; border-radius: 50%; box-shadow: inset 0 0 0 2px var(--rule); }
.week-dots li.on i { background: var(--marigold); box-shadow: none; }
.week-dots li.today i { box-shadow: inset 0 0 0 2px var(--ink); }
.week-dots li.today.on i { box-shadow: inset 0 0 0 2px var(--wood); }
.week-text { margin-top: 8px; font-size: 16px; color: var(--ink); }
.week-text span { display: block; }
.badge-won { margin-top: 16px; display: grid; grid-template-columns: auto auto; grid-template-rows: auto auto; column-gap: 12px; align-items: center; text-align: left; }
.badge-art { grid-row: 1 / 3; width: 64px; height: 75px; overflow: visible; }
.badge-art .ribbon { fill: var(--terracotta); }
.badge-art .disc { fill: var(--wood); }
.badge-art .ring2 { fill: var(--slate); }
.badge-art .mark { stroke-width: 3; }
.badge-title { font-family: var(--serif); font-size: 22px; line-height: 1.1; }
.badge-sub { font-size: 15px; color: var(--ink-soft); }
.done-next { margin-top: 14px; font-size: 16px; color: var(--ink-soft); max-width: 22em; }
.done .link-btn { margin-top: 8px; font-size: 16px; }

/* For the grown-up: microphone help */
.scrim { position: fixed; inset: 0; background: rgba(27, 32, 72, 0.5); z-index: 10; }
.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 11;
  max-width: 720px;
  margin: 0 auto;
  max-height: 88vh;
  overflow-y: auto;
  padding: 22px 20px max(18px, env(safe-area-inset-bottom));
  background: var(--paper);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -6px 24px rgba(27, 32, 72, 0.2);
}
.sheet-kicker { font-size: 15px; font-weight: 600; color: var(--terracotta-ink); }
.sheet-title { font-family: var(--serif); font-weight: 400; font-size: 26px; line-height: 1.2; margin: 6px 0 0; }
.sheet-body { margin-top: 10px; font-size: 17px; color: var(--ink); }
.sheet-steps { margin: 12px 0 0; padding-left: 1.3em; font-size: 17px; }
.sheet-steps li { padding: 3px 0; }
.sheet-steps:empty { display: none; }
.sheet-btn {
  display: block;
  width: 100%;
  min-height: 58px;
  margin-top: 18px;
  border: 0;
  border-radius: 12px;
  background: var(--marigold);
  color: var(--slate);
  font-family: var(--sans);
  font-weight: 600;
  font-size: 18px;
  cursor: pointer;
}
.sheet-skip { display: block; margin: 12px auto 0; font-size: 17px; }
.noscript { padding: 24px 16px; font-size: 18px; }

/* Tablets and laptops: more room, the same one column */
@media (min-width: 700px) {
  .app { padding-left: 28px; padding-right: 28px; padding-top: max(18px, env(safe-area-inset-top)); }
  .board { border-radius: 22px; padding: 12px; max-height: 560px; }
  .slate { border-radius: 13px; }
  .round.main { width: 124px; height: 124px; }
  .round.small { width: 80px; height: 80px; }
  .label { font-size: 26px; margin-bottom: 14px; }
  .cue-en { font-size: 24px; }
  .cue-script { font-size: 26px; }
  .cap-tr { font-size: 22px; }
  .cap-en { font-size: 17px; }
  .stars-count { font-size: 24px; }
  .stars-count svg { width: 28px; height: 28px; }
  .done-title { font-size: 46px; }
  .big-star { width: 210px; height: 210px; }
}
@media (hover: hover) {
  .round.main:not([disabled]):hover { background: var(--marigold-deep); }
  .app[data-phase="recording"] .round.main:hover { background: var(--terracotta-ink); }
  .sheet-btn:hover { background: var(--marigold-deep); }
  .card:not(.right):not(.dim):hover { border-color: var(--marigold); }
}
@media (prefers-reduced-motion: reduce) {
  .star.pop, .big-star, .i-dots circle, .round.main, .round.small.nudge, .card.hint, .stars-count.bump, .ring { animation: none !important; }
  .bar span { transition: none; }
}
