/* Lessons and crew dialogue: the learn track's lesson step (js/story/lesson.js), the standalone
   speech scenes (talkScene / hostDialog in js/story/companions.js), the track-choice screen, the big
   finger-zone keyboard (.kb-big) and the faded auto-filled characters in campaign typing.
   Prefixes: .talk- .dlg- .lesson- .lp- .hand .kb-big (+ .cmp-track).
   Tokens only (style.css / storybook.css), no hex colors. Light = sunny shallows, dark = night dive.
   Every animation is decoration: reduced motion keeps every beat and drops the motion. */

/* finger zones, shared by the keyboard, the keycaps and the gloves (css/hands.css) */
.lesson,
.kb-big {
  --z1: var(--sb-pink);
  --z2: var(--sb-orange);
  --z3: var(--sb-kelp);
  --z4: var(--sb-sea);
  --zt: var(--sb-grape);
}

/* ---------- the talk scene: a portrait and a big cartoon speech bubble ---------- */

.talk {
  --badge: clamp(72px, 14vw, 112px);
  --who: var(--sb-sea);
  --who-ink: var(--sb-outline);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: end;
  /* room for the bubble's tail plus the portrait's ring as it swells while speaking */
  gap: clamp(28px, 3.4vw, 34px);
  padding-top: 14px;
  position: relative;
}
.talk[data-who="ned"] { --who: var(--sb-orange); }
.talk[data-who="nemo"] { --who: var(--sb-sun); }
.talk[data-who="aronnax"] { --who: var(--sb-pink); }

.talk-portrait {
  width: var(--badge);
  height: var(--badge);
  margin: 0 0 8px 6px;
  flex: none;
}
.talk-portrait .comp-badge { display: block; }
.talk-portrait .comp-badge.is-speaking { transform: scale(1.1); }
.talk-portrait .comp-medal {
  border: var(--sb-outline-w) solid var(--sb-outline);
  box-shadow: 0 0 0 4px var(--who), var(--sb-pop);
}

.talk-bubble {
  position: relative;
  padding: 24px clamp(16px, 3vw, 24px) 18px;
  color: var(--sb-card-ink);
  background: var(--sb-card);
  border: var(--sb-outline-w) solid var(--sb-outline);
  border-radius: 28px;
  box-shadow: var(--sb-pop);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: clamp(1.1rem, 2.4vw, 1.4rem);
  line-height: 1.38;
  text-wrap: pretty;
}
/* the tail points at the portrait */
.talk-bubble::before {
  content: '';
  position: absolute;
  left: -13px;
  bottom: 26px;
  width: 22px;
  height: 22px;
  background: var(--sb-card);
  border-left: var(--sb-outline-w) solid var(--sb-outline);
  border-bottom: var(--sb-outline-w) solid var(--sb-outline);
  border-bottom-left-radius: 6px;
  transform: rotate(45deg);
}
.talk-who {
  position: absolute;
  top: -17px;
  left: 18px;
  padding: 2px 14px 3px;
  color: var(--who-ink);
  background: var(--who);
  border: 2.5px solid var(--sb-outline);
  border-radius: 999px;
  box-shadow: 0 2px 0 var(--sb-outline);
  font: 600 0.95rem/1.35 var(--font-display);
  letter-spacing: 0.03em;
  white-space: nowrap;
}
/* every line the bubble may show is laid out invisibly in the same cell: the bubble never resizes */
.talk-text { display: grid; }
.talk-ghost,
.talk-line { grid-area: 1 / 1; display: block; }
.talk-ghost { visibility: hidden; pointer-events: none; }
.talk-line.is-in { animation: sb-pop 0.32s var(--ease-spring); }
.talk-bubble[data-mood="worried"] { border-color: var(--sb-danger); }
.talk-bubble[data-mood="worried"]::before { border-color: var(--sb-danger); }
.talk-tap {
  display: block;
  margin-top: 8px;
  color: var(--sb-card-muted);
  font: 700 0.9rem var(--font-body);
}
.talk-tap kbd {
  padding: 0 6px;
  color: var(--sb-card-ink);
  background: var(--sb-card-2);
  border: 1.5px solid var(--sb-card-line);
  border-radius: 6px;
  font: inherit;
}
.lesson:is(.is-compact, .is-done) .talk-tap { visibility: hidden; }
@media (hover: none) { .talk-tap kbd { display: none; } }
.lesson.is-intro .talk-tap { visibility: visible; }

/* ---------- the host's dialogue (chapter intro and outro) ---------- */

.dlg {
  --badge: clamp(92px, 20vw, 150px);
  position: relative;
  max-width: 860px;
  min-height: min(56vh, 420px);
  margin: clamp(8px, 3vh, 28px) auto 0;
  padding: 64px clamp(14px, 3vw, 34px) 30px;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(circle at 12% 22%, color-mix(in srgb, #fff 30%, transparent) 0 12px, transparent 13px),
    radial-gradient(circle at 84% 34%, color-mix(in srgb, #fff 26%, transparent) 0 9px, transparent 10px),
    radial-gradient(circle at 70% 14%, color-mix(in srgb, #fff 22%, transparent) 0 6px, transparent 7px),
    radial-gradient(circle at 30% 60%, color-mix(in srgb, #fff 18%, transparent) 0 5px, transparent 6px),
    linear-gradient(180deg, var(--sb-sky) 0%, color-mix(in srgb, var(--sb-sea) 62%, var(--sb-sky)) 100%);
  border: var(--sb-outline-w) solid var(--sb-outline);
  border-radius: var(--radius-lg);
  box-shadow: var(--sb-pop), var(--sb-shadow-lg);
  cursor: pointer;
}
.dlg .talk { width: 100%; }
.dlg .talk-bubble { min-height: 7.5rem; padding-bottom: 28px; }
.dlg-skip {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  min-height: 40px;
  color: var(--sb-card-ink);
  background: var(--sb-card);
  border: 2.5px solid var(--sb-outline);
  border-radius: 999px;
  font-family: var(--font-display);
  font-weight: 600;
}
.talk-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
}
.dlg-dots { display: flex; gap: 6px; }
.dlg-dot {
  width: 11px;
  height: 11px;
  border: 2px solid var(--sb-outline);
  border-radius: 50%;
  background: var(--sb-card-2);
  transition: background-color 0.2s ease, transform 0.25s var(--ease-spring);
}
.dlg-dot.is-on { background: var(--sb-sun); transform: scale(1.2); }
.dlg-next { color: var(--sb-card-muted); font: 700 0.9rem var(--font-body); }
.dlg-next kbd {
  padding: 0 6px;
  color: var(--sb-card-ink);
  background: var(--sb-card-2);
  border: 1.5px solid var(--sb-card-line);
  border-radius: 6px;
  font: inherit;
}
@media (hover: none) { .dlg-next kbd { display: none; } }
/* a thin bar empties while the line waits to move on by itself */
.dlg-timer {
  position: absolute;
  left: 22px;
  right: 22px;
  bottom: 9px;
  height: 5px;
  border-radius: 999px;
  background: var(--sb-card-line);
  overflow: hidden;
}
.dlg-timer::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--who, var(--sb-sea));
  transform-origin: 0 50%;
}
.dlg-timer.is-running::after { animation: dlg-drain var(--dlg-ms, 4s) linear forwards; }
@keyframes dlg-drain { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* ---------- a lesson ---------- */

.lesson {
  display: flex;
  flex-direction: column;
  gap: clamp(8px, 1.5vh, 16px);
  position: relative;
  max-width: 920px;
  margin: clamp(6px, 2vh, 22px) auto 0;
  padding: 0 0 10px;
}
.lesson .talk { --badge: clamp(64px, 9vw, 96px); }
.lesson .talk-bubble { min-height: 4.6rem; }
/* once the player is typing, the coach steps back so the keyboard stays on screen */
.lesson:is(.is-compact, .is-done) .talk { --badge: clamp(56px, 9vw, 80px); padding-top: 4px; }
.lesson:is(.is-compact, .is-done) .talk-bubble { min-height: 0; padding: 18px 20px 12px; font-size: clamp(1rem, 2vw, 1.2rem); }

.lesson-play {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: clamp(150px, 19vh, 190px);
  padding: 12px 14px 10px;
  color: var(--sb-card-ink);
  background: var(--sb-card);
  border: var(--sb-outline-w) solid var(--sb-outline);
  border-radius: var(--radius-lg);
  box-shadow: inset 0 -6px 0 var(--sb-card-2), var(--sb-pop);
}
.lesson.is-drill .lesson-play {
  align-items: stretch;
  min-height: 0;
  padding: 0;
  background: none;
  border: 0;
  box-shadow: none;
}
.lesson-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: clamp(100px, 13.5vh, 124px);
}
.lesson.is-drill .lesson-stage { align-items: stretch; justify-content: flex-start; min-height: 0; }
.lesson-view { width: 100%; }
/* a drill is a warm-up, not a test: two lines, no stat chips, no restart hint */
main[data-screen="campaign"] .lesson :is(.tv-stats, .tv-hints) { display: none; }
main[data-screen="campaign"] .lesson .tv-text { height: calc(1.95em * 2); }
.lesson-hint {
  min-height: 1.6em;
  margin: 0;
  color: var(--sb-card-muted);
  font: 700 1rem var(--font-body);
  text-align: center;
}
.lesson-dots { display: flex; gap: 6px; min-height: 12px; justify-content: center; flex-wrap: wrap; }
.lesson-dot {
  width: 10px;
  height: 10px;
  border: 2px solid var(--sb-outline);
  border-radius: 50%;
  background: var(--sb-card-2);
  transition: background-color 0.2s ease, transform 0.25s var(--ease-spring);
}
.lesson-dot.is-on { background: var(--sb-sun); transform: scale(1.15); }
.lesson.is-drill .lesson-hint,
.lesson.is-drill .lesson-dots { display: none; }

/* getting ready: the pictures need the room, the keyboard waits for the roll call */
.lesson.is-posture :is(.lesson-kb, .lesson-hint) { display: none; }

/* a finished lesson no longer needs its keyboard: room for the Continue button */
.lesson.is-done :is(.lesson-kb, .lesson-guide) { display: none; }

/* skip, on the panels of a replay and on the hands-home check */
.lesson-skip { position: absolute; top: 8px; right: 8px; z-index: 2; }
.lesson-skip[hidden] { display: none; }

/* keycaps: the prompt, big and friendly */
.lesson-prompt,
.lesson-seq,
.lesson-meet {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: center;
  gap: clamp(8px, 2vw, 16px);
}
.lp-cap {
  --cap: var(--sb-card-2);
  --cap-size: clamp(60px, min(17vw, 13vh), 108px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--cap-size);
  height: var(--cap-size);
  padding: 0 14px;
  color: var(--sb-card-ink);
  background: color-mix(in srgb, var(--cap) 40%, var(--sb-card));
  border: var(--sb-outline-w) solid var(--sb-outline);
  border-radius: 22px;
  box-shadow: 0 6px 0 var(--sb-outline);
  font: 700 clamp(2.2rem, 9vw, 4rem)/1 var(--font-display);
  transition: background-color 0.15s ease, transform 0.15s var(--ease-spring);
}
.lp-cap.is-single { --cap-size: clamp(64px, min(26vw, 10.5vh), 100px); border-radius: 24px; font-size: clamp(2.6rem, min(14vw, 8vh), 4.2rem); box-shadow: 0 7px 0 var(--sb-outline); }
.lp-cap.is-wide { font-size: clamp(1.4rem, 5vw, 2.4rem); min-width: calc(var(--cap-size) * 2); }
.z-1 { --cap: var(--z1); }
.z-2 { --cap: var(--z2); }
.z-3 { --cap: var(--z3); }
.z-4 { --cap: var(--z4); }
.z-t { --cap: var(--zt); }
.lp-cap:not(.is-now):not(.is-done):not(.lp-meet) { opacity: 0.55; }
.lp-cap.is-now {
  --cap: var(--sb-primary);
  background: var(--sb-primary);
  color: var(--sb-primary-ink);
  transform: translateY(-4px);
  box-shadow: 0 10px 0 var(--sb-outline), 0 0 0 7px var(--sb-glow-color);
  animation: lp-bounce 1.1s ease-in-out infinite;
}
.lp-cap.is-done { background: color-mix(in srgb, var(--sb-kelp) 55%, var(--sb-card)); opacity: 1; }
.lesson-prompt.is-fresh { animation: sb-pop 0.28s var(--ease-spring); }
.lp-cap.is-pop { animation: sb-pop 0.32s var(--ease-spring); }
.lp-cap.is-wiggle { animation: sb-wiggle 0.28s ease-in-out 2; background: color-mix(in srgb, var(--sb-danger) 40%, var(--sb-card)); }
@keyframes lp-bounce { 0%, 100% { transform: translateY(-4px); } 50% { transform: translateY(-12px); } }

.lesson-seq .lp-cap { --cap-size: clamp(40px, min(9vw, 11vh), 72px); padding: 0 8px; font-size: clamp(1.5rem, 5vw, 2.6rem); border-radius: 16px; }
.lesson-seq .lp-cap.is-wide { min-width: calc(var(--cap-size) * 2.4); font-size: clamp(1.1rem, 3.6vw, 1.7rem); }
.lesson-seq .lp-cap:not(.is-now):not(.is-done) { opacity: 0.7; }

/* "Did master peek?" */
.lesson-peek { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: clamp(12px, 3vw, 24px); }
.lesson-peek-btn { min-width: 9.5rem; font-family: var(--font-display); }
.lesson-peek-key { margin-left: 10px; padding: 0 7px; font: 700 0.85rem var(--font-body); background: color-mix(in srgb, var(--sb-outline) 12%, transparent); border: 1.5px solid color-mix(in srgb, var(--sb-outline) 40%, transparent); border-radius: 6px; }
@media (hover: none) { .lesson-peek-key { display: none; } }

.lesson-meet {
  /* room above for the "Your new keys" tag, and between rows for the keys' bounce (up to 12px) */
  padding-top: 40px;
  row-gap: 22px;
}
/* a big batch (the number row: eleven keys) gets smaller keycaps, so it stays two or three rows */
.lesson-meet.is-many { column-gap: clamp(6px, 1.4vw, 12px); }
.lesson-meet.is-many .lp-meet { --cap-size: clamp(46px, min(10vw, 7vh), 64px); font-size: clamp(1.6rem, min(6vw, 4.6vh), 2.4rem); border-radius: 16px; }
.lesson-meet.is-many .lesson-meet-finger { padding: 1px 9px; font-size: 0.82rem; }
.lesson-meet-key {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  animation: sb-pop 0.45s var(--ease-spring) both;
  animation-delay: calc(var(--i, 0) * 0.12s);
}
.lp-meet { --cap-size: clamp(54px, min(14vw, 9vh), 78px); font-size: clamp(1.9rem, min(8vw, 6vh), 3rem); animation: lp-bounce 1.6s ease-in-out infinite; animation-delay: calc(var(--i, 0) * -0.3s); }
.lesson-meet-finger {
  padding: 2px 12px;
  color: var(--sb-card-ink);
  background: var(--sb-card-2);
  border: 2px solid var(--sb-outline);
  border-radius: 999px;
  font: 600 0.95rem var(--font-display);
}

/* the finger label above the keyboard: "Left middle finger" */
.lesson-guide {
  --zc: var(--sb-sun);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}
.lesson-guide[data-zone="1"] { --zc: var(--z1); }
.lesson-guide[data-zone="2"] { --zc: var(--z2); }
.lesson-guide[data-zone="3"] { --zc: var(--z3); }
.lesson-guide[data-zone="4"] { --zc: var(--z4); }
.lesson-guide[data-zone="t"] { --zc: var(--zt); }

.lesson-finger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  max-width: 100%;
  padding: 6px 16px 6px 10px;
  color: var(--sb-chip-ink);
  background: var(--sb-chip);
  border: var(--sb-outline-w) solid var(--sb-outline);
  border-radius: 999px;
  box-shadow: 0 3px 0 var(--sb-outline);
  font: 600 clamp(1rem, 2.6vw, 1.2rem)/1.2 var(--font-display);
}
.lesson-finger-icon {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: none;
  color: var(--sb-outline);
  background: var(--zc);
  border: 2.5px solid var(--sb-outline);
  border-radius: 50%;
}
.lesson-finger-icon svg { width: 18px; height: 18px; }
.lesson-finger-key { color: var(--sb-card-muted); font-weight: 600; }
.lesson-finger :is(.lesson-finger-key, .lesson-finger-cap, .lesson-finger-icon)[hidden] { display: none; }
/* the key to press, as a little keycap */
.lesson-finger-cap {
  display: inline-grid;
  place-items: center;
  min-width: 34px;
  height: 32px;
  padding: 0 9px;
  color: var(--sb-outline);
  background: var(--zc);
  border: 2.5px solid var(--sb-outline);
  border-radius: 9px;
  box-shadow: 0 3px 0 var(--sb-outline);
  font: 700 1.05rem/1 var(--font-display);
  white-space: nowrap;
}
.lesson-guide.is-enter .lesson-finger-cap { background: var(--sb-sun); animation: lesson-enter-bob 1.6s ease-in-out infinite; }
@keyframes lesson-enter-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
.lesson-guide.is-nudge .lesson-finger { animation: lesson-nudge 0.45s ease; }
@keyframes lesson-nudge {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px) rotate(-1.5deg); }
  45% { transform: translateX(6px) rotate(1deg); }
  70% { transform: translateX(-3px); }
}
.reduced-motion .lesson-guide .lesson-finger-cap,
.reduced-motion .lesson-guide.is-nudge .lesson-finger { animation: none; }
/* meet-the-keys: these are to look at, not to type yet */
.lesson-meet-tag {
  position: absolute;
  top: 10px;
  left: 12px;
  margin: 0;
  padding: 1px 12px 2px;
  color: var(--sb-card-ink);
  background: var(--sb-card-2);
  border: 2px solid var(--sb-outline);
  border-radius: 999px;
  font: 600 0.9rem/1.3 var(--font-display);
  transform: rotate(-2deg);
}

/* ---------- the big keyboard ---------- */

.lesson-kb { padding: 0 2px 2px; }
.hide-keyboard .kb.kb-big { display: block; }
.kb-big {
  --kb-gap: clamp(3px, 0.8vw, 8px);
  max-width: 880px;
}
.kb-big .kb-row { margin-bottom: calc(var(--kb-gap) + 3px); }
.kb-big .kb-key {
  height: clamp(30px, min(7.4vw, 5.2vh), 56px);
  border-width: 2.5px;
  border-radius: clamp(7px, 1.5vw, 14px);
  box-shadow: 0 clamp(3px, 0.6vw, 6px) 0 var(--sb-outline);
  font-size: clamp(0.78rem, 2.8vw, 1.55rem);
  font-weight: 700;
}
.kb-big .kb-f1 { --kb-bg: color-mix(in srgb, var(--z1) 38%, var(--sb-card)); }
.kb-big .kb-f2 { --kb-bg: color-mix(in srgb, var(--z2) 38%, var(--sb-card)); }
.kb-big .kb-f3 { --kb-bg: color-mix(in srgb, var(--z3) 38%, var(--sb-card)); }
.kb-big .kb-f4 { --kb-bg: color-mix(in srgb, var(--z4) 38%, var(--sb-card)); }
.kb-big .kb-thumb { --kb-bg: color-mix(in srgb, var(--zt) 38%, var(--sb-card)); }
.kb-big .kb-mod { --kb-bg: var(--sb-card-2); color: var(--sb-card-muted); }
/* the raised home-row marks */
.kb-big .kb-bump::after {
  content: '';
  position: absolute;
  bottom: 18%;
  left: 32%;
  right: 32%;
  height: 3px;
  border-radius: 3px;
  background: currentColor;
  opacity: 0.55;
}
/* keys not in play yet fade back */
.kb-big .kb-off { opacity: 0.42; filter: saturate(0.55); }
.kb-big .kb-off.kb-next { opacity: 1; filter: none; } /* Enter, lit while the lesson waits for it */
/* keys being taught: glow and bounce */
.kb-big .kb-new {
  --kb-bg: color-mix(in srgb, var(--sb-glow-color) 62%, var(--sb-card));
  border-color: var(--sb-outline);
  box-shadow: 0 clamp(3px, 0.6vw, 6px) 0 var(--sb-outline), 0 0 0 clamp(2px, 0.5vw, 4px) var(--sb-glow-color);
  animation: kb-bounce 1.3s ease-in-out infinite;
  z-index: 1;
}
@keyframes kb-bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
/* the next key to press */
.kb-big .kb-key.kb-next {
  background: var(--sb-primary);
  color: var(--sb-primary-ink);
  transform: translateY(-3px);
  box-shadow: 0 clamp(4px, 0.8vw, 8px) 0 var(--sb-outline), 0 0 0 clamp(3px, 0.7vw, 6px) var(--sb-glow-color);
  animation: kb-ping 0.9s ease-in-out infinite;
  z-index: 2;
}
@keyframes kb-ping {
  0%, 100% { box-shadow: 0 clamp(4px, 0.8vw, 8px) 0 var(--sb-outline), 0 0 0 clamp(3px, 0.7vw, 6px) var(--sb-glow-color); }
  50% { box-shadow: 0 clamp(4px, 0.8vw, 8px) 0 var(--sb-outline), 0 0 0 clamp(6px, 1.2vw, 11px) color-mix(in srgb, var(--sb-glow-color) 40%, transparent); }
}
.kb-big .kb-key.kb-flash-good { animation: kb-good 0.22s ease-out; }
.kb-big .kb-key.kb-flash-bad { animation: kb-bad 0.26s ease-out; }
.kb-big .kb-top { display: none; }

/* ---------- finishing ---------- */

.lesson-continue { align-self: center; min-width: 11rem; font-family: var(--font-display); }
.lesson-continue[hidden] { display: none; }
.lesson-burst {
  position: absolute;
  left: 50%;
  top: 140px;
  width: 0;
  height: 0;
  pointer-events: none;
  z-index: 3;
}
.lesson-burst span {
  position: absolute;
  left: -9px;
  top: -9px;
  width: 18px;
  height: 18px;
  background: var(--sb-sun);
  clip-path: polygon(50% 0, 62% 36%, 100% 38%, 70% 60%, 80% 100%, 50% 76%, 20% 100%, 30% 60%, 0 38%, 38% 36%);
  animation: lesson-burst 1.3s ease-out both;
}
.lesson-burst span:nth-child(3n) { background: var(--sb-pink); }
.lesson-burst span:nth-child(3n + 1) { background: var(--sb-sea); }
@keyframes lesson-burst {
  from { opacity: 1; transform: rotate(calc(var(--i) * 25.7deg)) translateY(-10px) scale(0.5); }
  to { opacity: 0; transform: rotate(calc(var(--i) * 25.7deg)) translateY(-150px) scale(1.4); }
}

/* ---------- the track choice ---------- */

.lesson-choose { gap: clamp(18px, 3.2vh, 30px); margin-top: clamp(14px, 4vh, 40px); }
.lesson-choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(16px, 3vw, 28px);
  margin-top: 6px;
}
.lesson-choice {
  position: relative;
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 132px;
  padding: 24px 64px 24px 24px; /* the right side holds the keycap */
  color: var(--sb-card-ink);
  background: var(--sb-card);
  border: var(--sb-outline-w) solid var(--sb-outline);
  border-radius: var(--radius-lg);
  box-shadow: var(--sb-pop);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform 0.15s var(--ease-spring), box-shadow 0.15s ease, background-color 0.15s ease;
}
.lesson-choice:hover { transform: translateY(-3px) rotate(-0.6deg); }
.lesson-choice:active, .lesson-choice.is-pressed { transform: translateY(3px); box-shadow: 0 1px 0 var(--sb-outline); }
.lesson-choice:focus-visible { outline: 4px solid var(--accent); outline-offset: 4px; }
.lesson-choice.is-suggested { background: color-mix(in srgb, var(--sb-sun) 28%, var(--sb-card)); box-shadow: var(--sb-pop), 0 0 0 5px var(--sb-glow-color); }
.lesson-choice-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 64px;
  height: 64px;
  color: var(--sb-outline);
  background: var(--sb-sun);
  border: var(--sb-outline-w) solid var(--sb-outline);
  border-radius: 50%;
  box-shadow: 0 3px 0 var(--sb-outline);
}
.lesson-choice.is-sail .lesson-choice-icon { background: var(--sb-sea); }
.lesson-choice-icon .sb-icon { width: 34px; height: 34px; stroke-width: 2.1; }
.lesson-choice-text { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
/* a little keycap with the home-key bump: F picks the left card, J the right */
.lesson-choice-key {
  position: absolute;
  right: 16px;
  top: 50%;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  margin-top: -18px;
  color: var(--sb-card-ink);
  background: var(--sb-card-2);
  border: 2.5px solid var(--sb-outline);
  border-radius: 9px;
  box-shadow: 0 3px 0 var(--sb-outline);
  font: 700 1.05rem/1 var(--font-display);
}
.lesson-choice-key::after {
  content: '';
  position: absolute;
  bottom: 5px;
  left: 50%;
  width: 10px;
  height: 2.5px;
  margin-left: -5px;
  border-radius: 2px;
  background: currentColor;
  opacity: 0.6;
}
.lesson-choice.is-pressed .lesson-choice-key { transform: translateY(2px); box-shadow: 0 1px 0 var(--sb-outline); }
.lesson-keys-hint { margin: -4px 0 0; text-align: center; color: var(--ink); font: 700 0.95rem var(--font-body); }
.lesson-keys-hint kbd {
  padding: 0 7px;
  color: var(--sb-card-ink);
  background: var(--sb-card-2);
  border: 1.5px solid var(--sb-card-line);
  border-radius: 6px;
  font: inherit;
}
@media (hover: none) { .lesson-choice-key, .lesson-keys-hint { display: none; } }
.lesson-choice-title { font: 700 clamp(1.25rem, 3.4vw, 1.7rem)/1.15 var(--font-display); }
.lesson-choice-blurb { color: var(--sb-card-muted); font: 600 1rem/1.35 var(--font-body); }
.lesson-choice-flag {
  position: absolute;
  top: -14px;
  right: 16px;
  padding: 1px 12px 2px;
  color: var(--sb-outline);
  background: var(--sb-pink);
  border: 2.5px solid var(--sb-outline);
  border-radius: 999px;
  font: 600 0.9rem/1.4 var(--font-display);
}
.lesson-test { margin: 0; text-align: center; }
.lesson-link {
  min-height: 40px;
  padding: 6px 10px;
  color: inherit;
  background: none;
  border: 0;
  font: 700 1rem var(--font-body);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.lesson-link:hover { text-decoration-thickness: 2px; }
.lesson-link:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.lesson-test .lesson-link { color: var(--ink); }

/* "Track: Learning the keys · change" under the chapter card's buttons */
.cmp-track {
  margin: 10px 0 0;
  color: var(--sb-card-muted);
  font: 600 0.95rem var(--font-body);
  text-align: center;
}
.cmp-track strong { color: var(--sb-card-ink); }
.cmp-track .lesson-link { color: var(--sb-card-ink); }

/* ---------- learn track: characters that fill in by themselves ---------- */

main[data-screen="campaign"] .tv-char.is-auto { font-size: 0.82em; opacity: 0.6; }
main[data-screen="campaign"] .tv-char.is-auto.is-correct { color: var(--sb-card-muted); }
main[data-screen="campaign"] .tv-char.is-auto.is-current::before { display: none; }

/* ---------- small screens ---------- */

@media (max-width: 640px) {
  .talk { gap: 22px; }
  .talk-bubble { border-radius: 22px; padding: 22px 14px 14px; }
  .talk-bubble::before { left: -11px; bottom: 20px; width: 18px; height: 18px; }
  .dlg { padding: 56px 12px 24px; }
  .lesson-choices { grid-template-columns: 1fr; }
  .lesson-choice { min-height: 96px; padding: 16px 56px 16px 16px; }
  .lesson-choice-key { right: 12px; }
  .lesson-choice-icon { width: 54px; height: 54px; }
  .lesson-play { min-height: 140px; padding: 10px 8px 6px; gap: 6px; }
  .lesson-hint { min-height: 1.2em; font-size: 0.92rem; }
  .lesson-stage { min-height: 92px; }
  .lesson-finger { padding: 4px 12px 4px 8px; }
  .lesson-meet { gap: 20px 12px; }
  .lesson-meet.is-many { column-gap: 8px; }
  .lesson-meet-finger { padding: 1px 8px; font-size: 0.82rem; }
  .lesson-meet .lp-cap.is-wide { min-width: calc(var(--cap-size) * 1.8); }
}

/* ---------- reduced motion: every beat stays, the motion goes ---------- */

.reduced-motion .talk-line.is-in,
.reduced-motion .lesson-meet-key,
.reduced-motion .lp-meet,
.reduced-motion .lp-cap.is-now,
.reduced-motion .lp-cap.is-pop,
.reduced-motion .lesson-prompt.is-fresh,
.reduced-motion .lp-cap.is-wiggle,
.reduced-motion .kb-big .kb-new,
.reduced-motion .kb-big .kb-key.kb-next,
.reduced-motion .dlg-timer.is-running::after { animation: none; }
.reduced-motion .lp-cap.is-now { transform: translateY(-4px); }
.reduced-motion .lesson-choice:hover { transform: none; }
.reduced-motion .lesson-burst { display: none; }

/* ---------- learn track: a "Your keys" sticker in the stage's top-right corner ---------- */
.cmp-keys {
  position: absolute;
  z-index: 4;
  top: 12px;
  right: 12px;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
  max-width: calc(100% - 24px);
  margin: 0;
  padding: 6px 8px 6px 12px;
  border: 2px solid var(--sb-outline);
  border-radius: 20px;
  background: var(--sb-chip);
  color: var(--sb-chip-ink);
  box-shadow: 0 3px 0 var(--sb-outline);
  font: 600 0.9rem/1 var(--font-display);
  pointer-events: none;
}
.cmp-keys-label { margin-right: 2px; }
.cmp-keys kbd {
  display: inline-grid;
  place-items: center;
  min-width: 30px;
  height: 30px;
  padding: 0 7px;
  border: 2px solid var(--sb-outline);
  border-radius: 8px;
  background: var(--sb-sun);
  color: var(--sb-outline);
  box-shadow: 0 2px 0 var(--sb-outline);
  font: 700 0.95rem/1 var(--font-display);
}
.cmp-keys kbd.is-wide { min-width: 64px; font-size: 0.85rem; }
@media (max-width: 719px) {
  .cmp-keys { top: 8px; right: 8px; max-width: calc(100% - 132px); padding: 4px 5px; gap: 4px; font-size: 0.8rem; } /* clear of the depth gauge */
  .cmp-keys-label { display: none; } /* the keycaps speak for themselves on a phone; the aria-label keeps the words */
  .cmp-keys kbd { min-width: 24px; height: 24px; padding: 0 5px; font-size: 0.8rem; border-radius: 6px; }
  .cmp-keys kbd.is-wide { min-width: 48px; font-size: 0.72rem; }
}

/* touch screens have no F and J to press: no keycaps, so the cards take their room back */
@media (hover: none) { .lesson .lesson-choice { padding-right: 16px; } }
