/* ============================================================================
   Screen-type layout styles. One block per renderer.
   Currently: pptSlide (slideStage) — a PowerPoint-rendered image as the stage,
   with React-driven caption, character, hotspot, choice, and feedback overlays.
   Visual composition lives in PowerPoint; this file only positions the
   interactive/accessible overlays on top of it. Do not restyle the artwork.
   ============================================================================ */

/* --- stage: fills the CoursePlayer content zone --- */
.ppt-stage { position: absolute; inset: 0; overflow: hidden; background: var(--surface-stage, #1A2E60); }
.ppt-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center; display: block; background: #0A1023; }

/* Responsive mode (tablet/phone): a NARRATIVE slide keeps its fixed 1920x821 composition
   (CLAUDE.md — only template layouts reflow). The ResponsiveShell content area is portrait,
   so without this the absolutely-inset stage stretches to the viewport and the WHOLE scene —
   background, characters (which fill their wrapper 100%), and bubble positions — distorts
   vertically. Aspect-lock the stage to a proportional band instead: everything then scales
   together, and each pose canvas fills its wrapper at the correct aspect (no distortion). */
html.responsive .ppt-stage, body.responsive .ppt-stage {
  position: relative; inset: auto; width: 100%; height: auto; aspect-ratio: 1920 / 821;
}

/* ============================================================================
   Comic two-shot layout — responsive (tablet/phone) NARRATIVE scenes only. Comic panel with both
   characters' heads on top (speaker grows to ~2/3, their line types on in step with the clip),
   the live scene below, inside the ResponsiveShell chrome. Desktop renders the full stage instead.
   ============================================================================ */
.ppt-comic-layout {
  display: flex; flex-direction: column; min-height: 0;
  height: calc(100dvh - var(--rc-header-h, 56px) - 96px);   /* fill between the header and bottom bar */
}
/* top: signal-blue comic panel */
.ppt-comic {
  flex: 1 1 52%; min-height: 0; position: relative; overflow: hidden;
  display: flex; align-items: stretch; gap: 2vw; padding: 1.4vh 3vw 2.2vh;
  background:
    radial-gradient(rgba(255,255,255,0.16) 1.5px, transparent 1.7px) 0 0 / 13px 13px,
    radial-gradient(130% 95% at 50% 120%, #0089c4 0%, #00A3DD 55%, #23b6e8 100%);
  border-bottom: 4px solid #0E1C42;
}
/* Each side is a grid: the bubble occupies the flexible top row, head + name pin to the bottom.
   The top row is minmax(0, 1fr) — capped at its fair share, NOT allowed to grow with the bubble —
   so a long (multi-line) speaker line can never push that head lower than the silent listener's.
   Both heads stay bottom-aligned regardless of line length. */
.ppt-comic-side {
  flex: 1 1 0; min-width: 0;
  display: grid; grid-template-rows: minmax(0, 1fr) auto auto; justify-items: center; row-gap: 6px;
  transition: flex-grow .4s cubic-bezier(.3,.7,.3,1);
}
.ppt-comic-side.is-speaking { flex-grow: 2; }        /* speaker ~2/3, listener ~1/3 */
/* square comic panel: bold black outer line + crisp white inner keyline. Width-sized (capped) so
   the speaker's wider panel gives a bigger head; height follows via aspect-ratio. */
/* head + its floating bubble; pinned to the bottom of the side by the grid's 1fr top row */
.ppt-comic-headwrap {
  grid-row: 2; position: relative; width: 100%;
  display: flex; justify-content: center; align-items: flex-end;
}
.ppt-comic-head {
  width: min(90%, 190px); aspect-ratio: 1; border-radius: 8px; overflow: hidden; position: relative;
  background: radial-gradient(circle at 50% 40%, #163264 0%, #0a1633 100%);
  border: 5px solid #000; box-shadow: inset 0 0 0 3px #fff, 0 8px 18px rgba(8,12,26,.4);
  transition: filter .35s ease, opacity .35s ease;
}
.ppt-comic-head img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; object-position: center bottom; display: block; }
.ppt-comic-head.flip { transform: scaleX(-1); }
.ppt-comic-side:not(.is-speaking) .ppt-comic-head { filter: saturate(.7) brightness(.82); opacity: .9; }
.ppt-comic-name {
  grid-row: 3; margin-top: 6px; font-weight: 800; letter-spacing: .5px; color: #fff; text-transform: uppercase;
  font-size: clamp(10px, 2.4vw, 14px); text-shadow: 0 1px 0 #0E1C42, 0 2px 4px rgba(8,12,26,.4);
}
/* speaker's bubble: fills the flexible top row, pinned to its bottom so its tail sits just above the head */
.ppt-comic-bubble {
  /* floats above the head (out of flow) so it can't affect head alignment; centered over the head,
     ~2/3-panel wide via viewport units so a long line wraps to few lines instead of pushing down */
  position: absolute; bottom: calc(100% + 10px); left: 50%; transform: translateX(-50%);
  width: min(62vw, 440px);
  background: #fff; color: #16203A; border: 3px solid #0E1C42; border-radius: 15px; padding: 8px 12px;
  font-weight: 650; line-height: 1.2; font-size: clamp(12px, 2.9vw, 16px);
  box-shadow: 0 6px 16px rgba(8,12,26,.35); text-align: left;
}
.ppt-comic-bubble::after  { content: ""; position: absolute; top: 100%; left: 34px; width: 0; height: 0; border: 11px solid transparent; border-top-color: #0E1C42; }
.ppt-comic-bubble::before { content: ""; position: absolute; top: calc(100% - 4px); left: 37px; width: 0; height: 0; border: 8px solid transparent; border-top-color: #fff; z-index: 1; }
.ppt-comic-side:last-child .ppt-comic-bubble::after  { left: auto; right: 34px; }
.ppt-comic-side:last-child .ppt-comic-bubble::before { left: auto; right: 37px; }
.ppt-comic-caret { display: inline-block; width: 2px; height: 1.05em; margin-left: 1px; background: #00A3DD; vertical-align: text-bottom; animation: comicBlink 1s steps(1) infinite; }
@keyframes comicBlink { 50% { opacity: 0; } }
/* bottom: the scene, aspect-locked and cover-cropped to the character band; bubbles hidden here */
.ppt-comic-scene { flex: 1 1 48%; min-height: 0; position: relative; overflow: hidden; background: #101a34; }
body.responsive .ppt-comic-scene .ppt-stage, html.responsive .ppt-comic-scene .ppt-stage {
  position: absolute; inset: auto; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: auto; height: 108%; aspect-ratio: 1920 / 821;
}
.ppt-comic-scene .dlg-bubble { display: none; }      /* bubbles live in the panel; the hidden <audio> still plays */
@media (prefers-reduced-motion: reduce) { .ppt-comic-side { transition: none; } }

/* --- character layers: two wrappers so a pose swap can never move the character (§30.18) ---
   .ppt-char-motion  OUTER: canonical wrapper geometry (union of the deck's authored picture
                     boxes, from characterSlots) + the whole-character entrance transform.
   .ppt-char-slot    INNER: fixed at inset:0 — geometrically stable, never moves on a swap.
   .ppt-pose         every normalized pose canvas, filling the slot exactly. NO object-fit /
                     object-position: each PNG is already composited onto the wrapper, and the
                     canvas aspect equals the wrapper aspect, so 100%x100% is pixel-exact. */
.ppt-char-motion { position: absolute; z-index: 3; pointer-events: none; filter: drop-shadow(0 18px 16px rgba(0,0,0,0.35)); }
.ppt-char-slot { position: absolute; inset: 0; }
.ppt-pose { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* Character entrance is clock-driven (translateX set inline from currentTime in
   ppt-slide.js), so it replays on scrub/restart. Reduced motion snaps to rest. */
@media (prefers-reduced-motion: reduce) {
  .ppt-char-motion { transform: none !important; }
}

/* --- dialogue captions (accessibility). Always in the DOM for screen readers;
       visible bar toggled by the player's CC control. --- */
.ppt-sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.ppt-captions {
  position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%);
  width: min(78%, 1180px); z-index: 6; display: flex; flex-direction: column; gap: 8px;
  background: rgba(10,20,45,0.86); border: 1px solid var(--on-navy-border, rgba(255,255,255,0.5));
  border-radius: var(--radius-card, 16px); padding: 16px 22px; color: #fff;
  font-family: var(--font-sans, system-ui, sans-serif); box-shadow: var(--shadow-nav, 0 2px 20px rgba(19,37,84,0.25));
  animation: mvFadeInSlow 180ms ease;
}
.ppt-caption-line { font-size: 20px; line-height: 1.4; margin: 0; }

/* Comic mode (tablet/phone): the caption box is a SIBLING of the cropped stage (see
   ppt-slide.js → PptSlideView), so it positions against the visible scene area and its edges
   are never cropped. It shows ONE line, sized in real px — the stage here is fluid, not
   transform-scaled like desktop, so the desktop 20px would read oversized on a phone. Capped
   to ~40% of the scene so the scene it captions is never buried. */
.ppt-comic-scene > .ppt-captions {
  left: 8px; right: 8px; bottom: 8px; width: auto; transform: none;
  max-height: 40%; overflow-y: auto; padding: 8px 12px; gap: 4px;
  border-radius: var(--radius-card, 12px);
}
.ppt-comic-scene > .ppt-captions .ppt-caption-line { font-size: clamp(13px, 3.4vw, 17px); line-height: 1.35; }
.ppt-comic-scene > .ppt-captions .ppt-caption-speaker { margin-right: 6px; }
.ppt-caption-speaker { font-weight: 800; color: var(--signal, #00A3DD); margin-right: 8px; text-transform: uppercase; letter-spacing: 0.4px; }

/* --- hybrid speech bubbles: exact PowerPoint shell (PNG) + live animated text overlay --- */
.dlg-bubble {            /* positioned to the PowerPoint shape box; carries the pop-in */
  position: absolute; z-index: 6;
  animation: mvBubbleIn 300ms cubic-bezier(.2,.7,.3,1) both;
}
.dlg-shell {             /* the exact PPT bubble shell (shape + tail, no text) */
  position: absolute; inset: 0; width: 100%; height: 100%; display: block; pointer-events: none;
}
.dlg-text {              /* live text, clipped to the original PowerPoint text-box bounds */
  position: absolute; overflow: hidden; display: flex; align-items: center; justify-content: center;
  text-align: center; user-select: none;
  font-family: var(--font-sans, system-ui, sans-serif); font-weight: 600;
  line-height: 1.2; color: var(--ink, #16203A);
}
.dlg-fit { display: block; width: 100%; text-align: center; overflow-wrap: break-word; }
@media (prefers-reduced-motion: reduce) { .dlg-bubble { animation: none !important; } }

/* --- seekable narration timeline (footer) --- */
.media-scrubber { position: absolute; top: 0; left: 0; right: 0; height: 14px; cursor: pointer; z-index: 2; touch-action: none; }
.media-scrubber-track { position: absolute; left: 0; right: 0; top: 0; height: 5px; background: rgba(255,255,255,0.16); }
.media-scrubber-fill { position: absolute; left: 0; top: 0; height: 5px; background: var(--signal, #00A3DD); }
.media-scrubber-thumb { position: absolute; top: -4px; width: 14px; height: 14px; border-radius: 50%; background: var(--signal, #00A3DD); transform: translateX(-50%); box-shadow: 0 1px 4px rgba(0,0,0,0.45); }
.media-scrubber:hover .media-scrubber-thumb { transform: translateX(-50%) scale(1.18); }
.media-scrubber:focus-visible { outline: none; }
.media-scrubber:focus-visible .media-scrubber-thumb { box-shadow: 0 0 0 4px rgba(0,163,221,0.6); }

/* --- volume control: speaker button that expands to a vertical drag slider --- */
.vol { position: relative; display: inline-flex; align-items: center; justify-content: center; }
.vol-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 46px; height: 46px; border-radius: 10px; border: none; background: transparent;
  cursor: pointer; transition: background 120ms;
}
.vol-btn:hover { background: rgba(255,255,255,0.08); }
.vol-btn:focus-visible { outline: none; box-shadow: var(--focus-ring, 0 0 0 3px rgba(0,163,221,0.55)); }
.vol-pop {                     /* floats above the speaker button; no layout shift */
  position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); margin-bottom: 8px;
  background: rgba(14,28,66,0.98); border: 1px solid rgba(255,255,255,0.14);
  border-radius: 12px; padding: 14px 12px; box-shadow: 0 8px 22px rgba(0,0,0,0.45);
  opacity: 0; pointer-events: none; transition: opacity 130ms ease; z-index: 30;
}
.vol-pop.open { opacity: 1; pointer-events: auto; }
.vol-track { position: relative; width: 6px; height: 96px; margin: 0 auto; border-radius: 3px; background: rgba(255,255,255,0.20); cursor: pointer; touch-action: none; }
.vol-fill { position: absolute; left: 0; bottom: 0; width: 100%; border-radius: 3px; background: var(--signal, #00A3DD); }
.vol-thumb { position: absolute; left: 50%; width: 14px; height: 14px; border-radius: 50%; background: var(--signal, #00A3DD); transform: translate(-50%, 50%); box-shadow: 0 1px 4px rgba(0,0,0,0.5); }
.vol-track:hover .vol-thumb { transform: translate(-50%, 50%) scale(1.15); }
.vol-track:focus-visible { outline: none; }
.vol-track:focus-visible .vol-thumb { box-shadow: 0 0 0 4px rgba(0,163,221,0.6); }

/* --- interactive overlays: hotspots + choice buttons --- */
.ppt-overlay { position: absolute; inset: 0; z-index: 5; }
.ppt-hotspot {
  position: absolute; border: 2px dashed rgba(0,163,221,0.9); background: rgba(0,163,221,0.10);
  border-radius: var(--radius-sm, 8px); cursor: pointer; min-width: var(--hit-target, 44px); min-height: var(--hit-target, 44px);
}
.ppt-hotspot:focus-visible, .ppt-choice:focus-visible { outline: none; box-shadow: var(--focus-ring, 0 0 0 3px rgba(0,163,221,0.55)); }

/* choice panel: readable HTML buttons over the slide */
.ppt-choices {
  position: absolute; right: 40px; top: 50%; transform: translateY(-50%); z-index: 6;
  width: 40%; max-width: 640px; display: flex; flex-direction: column; gap: 13px;
  background: rgba(19,37,84,0.92); border: 1px solid var(--on-navy-border, rgba(255,255,255,0.5));
  border-radius: var(--radius-card, 16px); padding: 28px; animation: mvSlide 220ms cubic-bezier(.2,.7,.3,1);
}
.ppt-prompt { font-family: var(--font-sans); font-weight: 800; font-size: 26px; color: #fff; line-height: 1.2; margin: 0 0 6px; }
.ppt-choice {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; cursor: pointer;
  min-height: var(--hit-target, 44px); padding: 16px 18px; border-radius: var(--radius-option, 12px);
  border: var(--border-control, 1.5px) solid var(--border, #DCE2EC); background: #fff; color: var(--ink, #16203A);
  font-family: var(--font-sans); font-weight: 600; font-size: 18px; transition: background var(--dur-fast,120ms) ease, border-color var(--dur-fast,120ms) ease;
}
.ppt-choice:hover:not(:disabled) { background: var(--signal-wash, rgba(0,163,221,0.07)); }
.ppt-choice[aria-pressed="true"] { border-color: var(--signal, #00A3DD); border-width: var(--border-active, 2px); }
.ppt-choice[data-state="correct"] { border-color: var(--correct, #12A66A); background: var(--correct-wash, rgba(18,166,106,0.08)); }
.ppt-choice[data-state="incorrect"] { border-color: var(--incorrect, #E5463E); background: var(--incorrect-wash, rgba(229,70,62,0.07)); }
.ppt-choice .ppt-letter { flex: 0 0 auto; width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; background: var(--page, #EEF1F6); color: var(--navy, #132554); }
.ppt-choice:disabled { cursor: default; }

/* inline (non-modal) feedback — icon + label + text, never color alone */
.ppt-feedback {
  display: flex; gap: 12px; align-items: flex-start; margin-top: 6px; padding: 14px 16px;
  border-radius: var(--radius-option, 12px); border: 2px solid; animation: mvPop 320ms cubic-bezier(.34,1.56,.64,1);
}
.ppt-feedback[data-kind="correct"] { border-color: var(--correct, #12A66A); background: var(--correct-wash, rgba(18,166,106,0.08)); }
.ppt-feedback[data-kind="incorrect"] { border-color: var(--incorrect, #E5463E); background: var(--incorrect-wash, rgba(229,70,62,0.07)); }
.ppt-feedback .ppt-fb-badge { flex: 0 0 auto; width: 28px; height: 28px; border-radius: 50%; color: #fff; font-weight: 800; display: flex; align-items: center; justify-content: center; }
.ppt-feedback[data-kind="correct"] .ppt-fb-badge { background: var(--correct, #12A66A); }
.ppt-feedback[data-kind="incorrect"] .ppt-fb-badge { background: var(--incorrect, #E5463E); }
.ppt-fb-title { font-weight: 800; color: #fff; font-size: 17px; margin-bottom: 2px; }
.ppt-fb-body { color: rgba(255,255,255,0.85); font-size: 15px; line-height: 1.45; }
