/* The lesson player around the board: top bar, caption, timeline, controls, side board and check cards. */
.player {
  --chalk-font: "Kalam", "Chalkboard SE", "Segoe Print", cursive;
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto auto;
  grid-template-columns: minmax(0, 1fr);
  height: 100dvh;
  overflow: hidden;
  background: var(--board);
  padding-bottom: env(safe-area-inset-bottom);
}

/* Top bar */
.topbar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: calc(4px + env(safe-area-inset-top)) 6px 6px;
}
.titles { flex: 1; min-width: 0; }
.titles p { margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lesson-title { font-size: 15px; font-weight: 600; letter-spacing: -.005em; }
.lesson-chapter { font-size: 12px; color: var(--chalk-dim); min-height: 1.3em; }

/* Buttons */
.icon-btn, .text-btn, .ask-btn, .chip, .talk-btn, .jump-latest, .tap-start {
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--chalk);
}
.icon-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; padding: 0; flex: none; }
.icon-btn:hover, .text-btn:hover { background: var(--board-raised); }
.text-btn { padding: 0 10px; min-width: 44px; min-height: 44px; font-size: 14px; font-weight: 600; flex: none; }
.text-btn.primary { background: var(--yellow); color: #17171a; }
.text-btn.primary:hover { background: #fae38f; }
#app .text-btn[data-testid="captions-toggle"] { color: var(--chalk-dim); text-decoration: line-through; }
#app .text-btn[data-testid="captions-toggle"].on { color: var(--chalk); text-decoration: none; }

.tap-start { position: absolute; inset: auto 16px 24px; z-index: 3; display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 56px; background: var(--yellow); color: #17171a; font-size: 18px; font-weight: 700; }
.toast { position: absolute; left: 16px; right: 16px; bottom: 96px; padding: 10px 14px; border-radius: var(--radius); background: var(--board-raised); border: 1px solid var(--hairline); box-shadow: 0 8px 24px rgb(0 0 0 / .4); font-size: 14px; text-align: center; overflow-wrap: anywhere; z-index: 12; }

/* Caption */
.caption { margin: 0; padding: 8px 16px 4px; font-size: 15px; line-height: 1.4; min-height: 2.9em; max-height: 8.6em; overflow-y: auto; position: relative; color: var(--chalk-dim); }
.caption.empty { visibility: hidden; }
.caption .said { color: var(--chalk); }
.caption .now { color: var(--yellow); }

/* Timeline */
.scrub { --played: 0%; --arrived: 0%; position: relative; height: 28px; padding: 0 12px; }
.scrub-range { position: absolute; inset: 0 12px; width: calc(100% - 24px); height: 28px; margin: 0; background: transparent; appearance: none; -webkit-appearance: none; touch-action: none; cursor: pointer; }
.scrub-range::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--yellow) var(--played), rgb(255 255 255 / .3) var(--played) var(--arrived), rgb(255 255 255 / .1) var(--arrived));
}
.scrub-range::-moz-range-track { height: 4px; border-radius: 2px; background: linear-gradient(90deg, var(--yellow) var(--played), rgb(255 255 255 / .3) var(--played) var(--arrived), rgb(255 255 255 / .1) var(--arrived)); }
.scrub-range::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; margin-top: -6px; border-radius: 50%; background: var(--yellow); box-shadow: 0 0 0 3px var(--board); }
.scrub-range::-moz-range-thumb { width: 16px; height: 16px; border: 0; border-radius: 50%; background: var(--yellow); box-shadow: 0 0 0 3px var(--board); }
.scrub-marks { position: absolute; inset: 0 20px; pointer-events: none; }
.scrub-marks i { position: absolute; top: 9px; width: 2px; height: 10px; margin-left: -1px; border-radius: 1px; background: var(--chalk); opacity: .3; }
.scrub-tip { position: absolute; left: 12px; bottom: 28px; z-index: 2; max-width: calc(100% - 24px); margin: 0; padding: 4px 10px; border-radius: 6px; background: var(--board-raised); border: 1px solid var(--hairline); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Controls */
.controls { display: flex; align-items: center; gap: 2px; padding: 2px 8px 4px; }
.controls .play { color: var(--yellow); }
.ask-btn { flex: 1 1 auto; min-width: 72px; min-height: 44px; margin-left: 4px; padding: 0 16px; background: var(--yellow); color: #17171a; font-size: 15px; font-weight: 650; line-height: 1.1; }
.ask-btn:hover { background: #fae38f; }
@media (max-width: 520px) {
  .controls.read-only { flex-wrap: wrap; justify-content: space-between; }
  .controls.read-only .ask-btn { flex: 1 0 100%; margin: 2px 0 0; }
}

/* Side board: a sheet under the whiteboard on phones, a column beside it on laptops */
.side { position: fixed; inset: 38dvh 0 0; z-index: 10; display: flex; flex-direction: column; background: var(--board); border-top: 1px solid var(--hairline); border-radius: 14px 14px 0 0; padding: 8px 0 env(safe-area-inset-bottom); box-shadow: 0 -8px 24px rgb(0 0 0 / .45); }
.side-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 8px 6px 16px; }
.side-title { flex: 1; min-width: 0; margin: 0; font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.talk-btn { display: flex; flex: none; align-items: center; justify-content: center; gap: 8px; min-height: 52px; margin: 0 12px 8px; background: var(--board-raised); border: 1px solid var(--hairline); font-size: 16px; font-weight: 600; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.talk-btn.live { background: var(--yellow); border-color: var(--yellow); color: #17171a; }
.side-form { display: flex; flex: none; gap: 6px; padding: 0 12px 8px; }
.side-input { flex: 1; min-width: 0; min-height: 44px; padding: 0 12px; border: 1px solid var(--hairline); border-radius: var(--radius); background: var(--board-raised); font-size: 16px; }
.quick { display: flex; flex: none; flex-wrap: wrap; gap: 6px; padding: 0 12px 8px; }
.chip { min-height: 44px; padding: 0 14px; border: 1px solid var(--hairline); border-radius: 999px; color: var(--chalk-dim); font-size: 14px; }
.chip:hover { color: var(--chalk); }
.chip:hover { background: var(--board-raised); }
.side-asked { flex: none; margin: 0; padding: 4px 16px 8px; color: var(--yellow); font-size: 14px; overflow-wrap: anywhere; }
.side-again { color: var(--chalk-dim); font-weight: 500; }
.side:not(.asked) .side-again { display: none; }
.side.asked { top: 22dvh; }
.side.asked .talk-btn, .side.asked .side-form, .side.asked .quick { display: none; }
.side.asked .side-asked { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-bottom: 4px; }
.side-paused { margin: 0; padding: 12px 16px; color: var(--chalk-dim); font-size: 14px; line-height: 1.45; }
.side .caption { flex: none; max-height: none; }
.side.returning [data-testid="side-return"] { background: linear-gradient(90deg, #fae38f 50%, var(--yellow) 50%) 100% 0 / 200% 100%; animation: side-return 5s linear forwards; }
@keyframes side-return { to { background-position: 0 0; } }
.stage:has(.code-dock[data-compute-open]) .side { top: 16dvh; bottom: 40dvh; }
.stage:has(.side) .code-dock[data-compute-open] { position: fixed; left: 0; right: 0; bottom: 0; height: 40dvh; z-index: 11; background: var(--board); }

/* Check moment and end quiz. Marks are never green: blue with a check, red with a cross. */
.check { font-size: 15px; line-height: 1.3; }
/* Docked over the caption and controls, so the board it asks about stays readable. */
.player > .check { position: absolute; left: 0; right: 0; bottom: 0; z-index: 9; max-height: 62%; overflow-y: auto; padding: 16px 14px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--hairline); border-radius: 14px 14px 0 0; background: var(--board-raised); box-shadow: 0 -8px 24px rgb(0 0 0 / .45); }
.check-timer { position: absolute; top: 0; left: 0; width: 100%; height: 3px; background: var(--yellow); transform-origin: 0 50%; animation: check-time 30s linear forwards; }
@keyframes check-time { to { transform: scaleX(0); } }
.player:is([data-state="paused"], [data-state="side"]) .check-timer { animation-play-state: paused; }
.check-q { margin: 0 0 12px; font-weight: 600; text-wrap: pretty; }
.check-choices { display: grid; gap: 8px; }
.check-choices.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.check-choice { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 48px; padding: 8px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: transparent; color: var(--chalk); text-align: left; font: inherit; }
.check-choice:hover:not(:disabled) { background: rgb(255 255 255 / .05); border-color: var(--chalk-dim); }
.check-choice:disabled { opacity: .7; }
.check-choice.right { opacity: 1; border-color: var(--blue); color: var(--blue); }
.check-choice.right::after { content: "\2713"; font-weight: 700; }
.check-choice.wrong { opacity: 1; border-color: var(--danger); color: var(--danger); }
.check-choice.wrong::after { content: "\2717"; font-weight: 700; }
.check-why { margin: 10px 0 0; color: var(--chalk-dim); text-wrap: pretty; }
.check-skip { display: block; margin: 6px 0 0 auto; color: var(--chalk-dim); }
.quiz-score { margin: 10px 0 0; color: var(--yellow); font-family: var(--font-ui); font-size: 15px; font-weight: 600; }

@media (min-width: 900px) {
  .caption { padding: 10px max(24px, calc((100% - 860px) / 2)) 6px; font-size: 17px; text-align: center; text-wrap: balance; min-height: 2.4em; }
  .controls { justify-content: center; gap: 6px; }
  .ask-btn { flex: 0 0 auto; min-width: 150px; }
  .scrub { padding: 0 24px; }
  .scrub-range { inset: 0 24px; width: calc(100% - 48px); }
  .scrub-marks { inset: 0 32px; }
  .scrub-tip { left: 24px; }
  .side { position: relative; inset: auto; z-index: 1; flex: 0 0 380px; border-top: 0; border-left: 1px solid var(--hairline); border-radius: 0; padding: 0; box-shadow: none; }
  .side .board { font-size: 20px; }
  .side .b-section { padding: 12px 14px 14px 22px; }
  .stage:has(.code-dock[data-compute-open]) .side { top: auto; bottom: auto; }
  .stage:has(.side) .code-dock[data-compute-open] { position: relative; height: auto; z-index: auto; }
  .player > .check { left: 50%; right: auto; width: min(680px, calc(100% - 32px)); padding-inline: 18px; transform: translateX(-50%); }
  .side.asked { top: auto; }
  .toast { left: 50%; right: auto; transform: translateX(-50%); }
  .tap-start { inset: auto auto 32px 50%; transform: translateX(-50%); padding: 0 32px; }
}

@media (prefers-reduced-motion: reduce) {
  .side.returning [data-testid="side-return"] { animation: none; }
  .check-timer { display: none; }
}
