/* Layout: one cinema-style column; 16:9 stage on top, transport bar, then chapter chips. Single dark look by design. */
:root {
  --ink: #0b1424;          /* page */
  --panel: #121f35;        /* bars, cards */
  --line: #24365a;
  --text: #eef3fb;
  --muted: #9fb0c8;
  --life: #5ee0a0;         /* living things / correct */
  --cell: #4fd1c5;
  --energy: #ffc857;
  --alert: #ff6b6b;
  --sky: #5bc0eb;
  --violet: #b59cff;
  --display: "Noto Kufi Arabic", "Segoe UI", Tahoma, sans-serif;
  --body: "Readex Pro", "Segoe UI", Tahoma, sans-serif;
  color-scheme: dark;
}
html, body { height: 100%; }
[hidden] { display: none !important; }
body {
  background: var(--ink); color: var(--text); font-family: var(--body);
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 16px;
}
.app { max-width: 1280px; margin: 0 auto; display: grid; gap: 12px; }
.head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.head h1 { font-family: var(--display); font-size: clamp(18px, 2.4vw, 26px); margin: 0; font-weight: 800; text-wrap: balance; }
.head .tag { color: var(--muted); font-size: 14px; }
.head .by { color: var(--life); font-size: 14px; font-weight: 600; }
.head .home { margin-inline-start: auto; color: var(--sky); font-size: 14px; text-decoration: none; border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; }
.head .home:hover { background: #1a2a46; }
.head .home:focus-visible { outline: 2px solid var(--sky); outline-offset: 2px; }

.player { display: grid; background: var(--panel); border-radius: 14px; overflow: hidden; border: 1px solid var(--line); }
.screen { position: relative; aspect-ratio: 16 / 9; max-width: 100%; container-type: inline-size; background: #0d1a2e; overflow: hidden; }
.screen svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.screen svg text { font-family: var(--body); }

/* Subtitles. Soft (default): a plain one-or-two-line cue in a dark box, switchable with CC.
   Hard (burned into the hard-subbed MP4): a short word group on a dark pill; the spoken word gets a yellow chip,
   upcoming words are dimmed. Motion is set from the lesson clock in player.js (no CSS transitions), so renders match. */
.caption {
  position: absolute; inset-inline: 0; bottom: 3.6cqw; display: flex; justify-content: center; pointer-events: none; padding-inline: 6cqw;
}
.hs.soft {
  max-width: 78cqw; padding: .22em .75em .3em; border-radius: .38em; background: rgba(6, 10, 20, .8);
  font: 600 clamp(14px, 2.45cqw, 38px)/1.55 var(--body); color: #fff; text-align: center; text-wrap: balance;
  box-shadow: 0 .15em .6em rgba(0, 0, 0, .35);
}
.hs.hard {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: .12em .16em; max-width: 80cqw;
  padding: .16em .32em; border-radius: .7em; background: rgba(8, 12, 26, .62);
  box-shadow: 0 .25em .9em rgba(0, 0, 0, .35), inset 0 0 0 1px rgba(255, 255, 255, .08);
  font: 800 clamp(18px, 3.7cqw, 58px)/1.25 var(--display); color: #fff; text-align: center;
  text-shadow: 0 .05em .12em rgba(0, 0, 0, .55); transform-origin: 50% 100%;
}
.hs.hard span { display: inline-block; padding: .06em .26em .12em; border-radius: .32em; }
.hs.hard span.fut { color: rgba(255, 255, 255, .5); }
.hs.hard span.key { color: #8ff5c3; }
.hs.hard span.key.fut { color: rgba(143, 245, 195, .5); }
.hs.hard span.on { background: #ffd23f; color: #141826; text-shadow: none; box-shadow: 0 .09em 0 #c9971a, 0 .2em .45em rgba(0, 0, 0, .3); }
.caption.off { display: none; }
.chapter-chip {
  display: none; /* scenes carry their own headings; kept in the DOM for the scene-title logic */
  position: absolute; top: 2.2cqw; right: 2.4cqw; font-family: var(--display); font-weight: 700;
  font-size: clamp(11px, 1.55cqw, 22px); background: rgba(6, 12, 24, .55); border: 1px solid rgba(255,255,255,.12);
  padding: .3em .9em; border-radius: 999px; color: var(--text);
}

.start {
  position: absolute; inset: 0; display: grid; place-items: center; background: radial-gradient(circle at 50% 45%, rgba(18,40,70,.55), rgba(5,10,20,.85));
}
.start button {
  font-family: var(--display); font-weight: 800; font-size: clamp(16px, 2.6cqw, 34px); color: #062014;
  background: var(--life); border: 0; border-radius: 999px; padding: .6em 1.6em; cursor: pointer;
  box-shadow: 0 0 0 .35em rgba(94,224,160,.22);
}
.start small { display: block; color: var(--muted); font-size: clamp(11px, 1.4cqw, 18px); margin-top: .8em; text-align: center; font-family: var(--body); }

.bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; flex-wrap: wrap; border-top: 1px solid var(--line); }
.bar button, .bar label.btn {
  font: inherit; font-size: 14px; color: var(--text); background: #1a2a46; border: 1px solid var(--line);
  border-radius: 8px; height: 36px; min-width: 36px; padding: 0 10px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.bar button:hover, .bar label.btn:hover { background: #22365a; }
.bar button:focus-visible, .bar label.btn:focus-within, .chips button:focus-visible, .quiz button:focus-visible { outline: 2px solid var(--sky); outline-offset: 2px; }
.bar button[aria-pressed="false"] { opacity: .55; }
.bar .play { background: var(--life); color: #062014; border-color: transparent; font-weight: 700; }
.bar svg { width: 16px; height: 16px; fill: currentColor; }
.track { flex: 1 1 200px; min-width: 120px; height: 36px; position: relative; cursor: pointer; display: flex; align-items: center; }
.track .rail { position: absolute; inset-inline: 0; height: 6px; border-radius: 3px; background: #23375c; overflow: hidden; }
.track .fill { position: absolute; inset-block: 0; right: 0; width: 0; background: var(--life); }
.track .tick { position: absolute; top: 9px; width: 2px; height: 18px; background: #0b1424; }
.time { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; min-width: 88px; text-align: center; direction: ltr; }
.bar input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.note { font-size: 12px; color: var(--muted); padding: 0 12px 10px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; margin: 0; padding: 0; }
.chips button {
  font: inherit; font-size: 13px; color: var(--muted); background: transparent; border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 12px; cursor: pointer;
}
.chips button.on { color: #062014; background: var(--life); border-color: transparent; }
.chips button.quiz-chip { border-color: var(--energy); color: var(--energy); }

/* Quiz overlay */
.quiz { position: absolute; inset: 0; background: radial-gradient(circle at 70% 20%, #1b3156, #0b1424 70%); display: grid; align-content: center; justify-items: center; padding: 3cqw 5cqw; gap: 1.6cqw; overflow: auto; }
.quiz .qhead { display: flex; gap: 1cqw; align-items: center; color: var(--energy); font-family: var(--display); font-weight: 700; font-size: clamp(12px, 1.6cqw, 22px); }
.quiz h2 { margin: 0; font-family: var(--display); font-size: clamp(15px, 2.6cqw, 36px); text-align: center; text-wrap: balance; line-height: 1.5; }
.quiz .opts { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2cqw; width: min(100%, 78cqw); }
.quiz .opts button {
  font: inherit; font-size: clamp(12px, 1.9cqw, 26px); color: var(--text); text-align: right; background: #15253f; border: 2px solid var(--line);
  border-radius: 1cqw; padding: .6em .9em; cursor: pointer; line-height: 1.45;
}
.quiz .opts button:hover:not(:disabled) { border-color: var(--sky); }
.quiz .opts button.right { border-color: var(--life); background: #12382c; }
.quiz .opts button.wrong { border-color: var(--alert); background: #3a1a22; }
.quiz .opts button:disabled { cursor: default; }
.quiz .why { font-size: clamp(12px, 1.75cqw, 24px); color: var(--text); background: rgba(94,224,160,.08); border: 1px solid rgba(94,224,160,.35); border-radius: 1cqw; padding: .6em 1em; width: min(100%, 78cqw); line-height: 1.6; }
.quiz .why b { color: var(--life); }
.quiz .row { display: flex; gap: 1.2cqw; align-items: center; }
.quiz .row button { font: inherit; font-size: clamp(12px, 1.7cqw, 22px); border-radius: 999px; padding: .45em 1.2em; cursor: pointer; border: 1px solid var(--line); background: #1a2a46; color: var(--text); }
.quiz .row button.primary { background: var(--life); color: #062014; border-color: transparent; font-weight: 700; }
.quiz .row a.btnlink { font-size: clamp(12px, 1.7cqw, 22px); border-radius: 999px; padding: .45em 1.2em; text-decoration: none; background: var(--life); color: #062014; font-weight: 700; }
.quiz .row a.btnlink:focus-visible { outline: 2px solid var(--sky); outline-offset: 2px; }
.quiz .row button:disabled { opacity: .45; cursor: default; }
.quiz .think { color: var(--muted); font-size: clamp(11px, 1.5cqw, 20px); font-variant-numeric: tabular-nums; }
.quiz .score { font-family: var(--display); font-size: clamp(28px, 7cqw, 96px); color: var(--life); font-weight: 800; }
.quiz p { margin: 0; text-align: center; color: var(--muted); font-size: clamp(12px, 1.8cqw, 24px); line-height: 1.6; }

.player > .caption { position: static; padding: 14px 12px 4px; min-height: calc(2 * 1.3 * 24px + 18px); align-items: center; background: #0d1a2e; }
.player > .caption .hs { font-size: 18px; max-width: 100%; }
.player > .caption .hs.hard { font-size: 22px; }

/* Fullscreen (real Fullscreen API, or the full-viewport takeover used on iPhone): picture fills the screen,
   controls float over the bottom and fade out while playing */
html.fs-lock, html.fs-lock body { overflow: hidden; overscroll-behavior: none; }
.player.fs {
  position: fixed; inset: 0; z-index: 1000; width: 100vw; height: 100vh; height: 100dvh; max-width: none;
  border: 0; border-radius: 0; background: #000; align-content: center; justify-items: center; overflow: hidden;
}
.player.fs .screen { width: min(100vw, calc(100vh * 16 / 9)); width: min(100vw, calc(100dvh * 16 / 9)); }
.player.fs .bar {
  position: absolute; inset-inline: 0; bottom: 0; z-index: 3; border-top: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, .88), rgba(0, 0, 0, .55) 65%, transparent);
  padding: 22px max(14px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  transition: opacity .35s, transform .35s;
}
.player.fs .bar button:not(.play) { background: rgba(26, 42, 70, .8); }
.player.fs .bar label.btn, .player.fs .note { display: none; }
.player.fs .screen .caption { bottom: calc(76px + env(safe-area-inset-bottom)); transition: bottom .35s; }
.player.fs .screen .caption .hs.soft { font-size: clamp(16px, 2.2cqw, 36px); }
.player.fs.idle .screen .caption { bottom: max(3.6cqw, env(safe-area-inset-bottom)); }
.player.fs.idle .bar { opacity: 0; transform: translateY(40%); pointer-events: none; }
.player.fs.idle, .player.fs.idle * { cursor: none; }
.player.fs .chapter-chip { top: max(2.2cqw, env(safe-area-inset-top)); }
.player.fs > .caption { width: 100%; background: transparent; }
.rot {
  position: absolute; inset: 0; margin: auto; width: fit-content; height: fit-content; z-index: 4; pointer-events: none;
  font-family: var(--display); font-weight: 700; font-size: 15px; color: var(--text);
  background: rgba(6, 12, 24, .85); border: 1px solid rgba(255, 255, 255, .15); border-radius: 999px; padding: .6em 1.2em;
}
.rot span { display: inline-block; color: var(--life); animation: spin 1.6s ease-in-out infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 560px) {
  .quiz .opts { grid-template-columns: 1fr; }
  .time { display: none; }
}
@media (prefers-reduced-motion: reduce) { .player.fs .caption, .player.fs .bar { transition: none; } .rot span { animation: none; } }

/* embedded in the course page: just the player */
html.embed, html.embed body { height: auto; }
html.embed body { padding: 0; background: transparent; overflow: hidden; }
html.embed .head, html.embed .chips, html.embed .note { display: none; }
html.embed .app { gap: 0; }
html.embed .player { border-radius: 0; border: 0; }

/* small screens: the quiz needs more room than the 16:9 picture, so the screen grows to fit it */
@media (max-width: 700px) {
  .player.quizmode:not(.fs) .screen { aspect-ratio: auto; }
  .player.quizmode:not(.fs) .quiz { position: relative; inset: auto; min-height: 56vw; padding: 18px 14px; gap: 12px; }
  .player.quizmode:not(.fs) .quiz h2 { font-size: 18px; }
  .player.quizmode:not(.fs) .quiz .opts button, .player.quizmode:not(.fs) .quiz .why { font-size: 15px; }
  .player.quizmode:not(.fs) .quiz .qhead, .player.quizmode:not(.fs) .quiz .think, .player.quizmode:not(.fs) .quiz .row button,
  .player.quizmode:not(.fs) .quiz .row a.btnlink { font-size: 14px; }
  .player.quizmode:not(.fs) .quiz .opts { width: 100%; }
}
