/* London scene stage — image + YouTube-style subtitle bars. london-only, no inline styles.
   Subtitle layer is confined to the bottom 22% of the image (image height 78% -> 100%),
   so it never covers faces or the key props. Text is real DOM text, ordered, screen-reader readable. */

.scene-hero {
  display: none;
  margin: 0 0 14px;
  padding: 0;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card-bg-solid);
}
.scene-hero-on .scene-hero { display: block; }
.scene-hero[hidden] { display: none; }
.scene-hero picture { display: block; width: 100%; height: 100%; }
.scene-hero img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: var(--card-bg-solid);
}

/* --- stage wrapper --- */
.scene-stage {
  position: relative;
  aspect-ratio: 16 / 9;
}
.scene-stage > picture {
  position: absolute;
  inset: 0;
}
.scene-stage > picture img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: auto;
  min-height: 100%;
  object-fit: cover;
}

/* --- subtitle layer: bottom safe zone only, dialogue is never clipped --- */
.scene-subs {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  box-sizing: border-box;
  max-height: none;
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  overflow: visible;          /* never cut dialogue: height follows the text */
  pointer-events: none;
}
.sub-lines {
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.sub-line {
  width: 100%;
  display: flex;
  justify-content: center;
}
/* lines that are not currently displayed stay in the DOM (accessible) but take no space */
.sub-line:not(.is-visible) {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.sub-bar {
  display: block;
  max-width: 88%;
  box-sizing: border-box;
  padding: 10px 18px;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.72);
  border-left: 3px solid #f59e0b;
  color: #ffffff;
  font-size: 34px;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.35;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.85), 0 1px 2px rgba(0, 0, 0, 0.9);
  opacity: 1;
  /* dialogue is never truncated: wrap naturally and let the bar grow */
  white-space: normal;
  overflow-wrap: anywhere;
  overflow: visible;
  text-overflow: clip;
  text-align: center;
}
.sub-bar.who-you { border-left-color: #60a5fa; }
.sub-line.is-near .sub-bar { opacity: 0.65; }
.sub-who {
  display: inline;
  margin-right: 10px;
  font-size: 0.5em;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #fbbf24;
  vertical-align: 0.18em;
}
.sub-bar.who-you .sub-who { color: #93c5fd; }
.sub-en {
  display: inline;
  font-size: 1em;
  font-weight: 700;
  color: #ffffff;
}
.sub-zh {
  display: block;
  font-size: 0.78em;
  font-weight: 600;
  line-height: 1.25;
  opacity: 0.88;
  color: #ffffff;
  white-space: normal;
  overflow-wrap: anywhere;
  overflow: visible;
  text-overflow: clip;
}

/* --- viewport-scaled subtitle type --- */
@media (max-width: 1100px) {
  .sub-bar { font-size: 28px; }
}
@media (max-width: 850px) {
  .sub-bar { font-size: 18px; padding: 8px 16px; }
}
@media (max-width: 480px) {
  .scene-subs { padding: 0 8px; }
  .sub-bar { font-size: 20px; padding: 6px 12px; }
  .sub-zh { line-height: 1.2; }
}

/* --- step-down ladder: only the font shrinks, never the text (fs-1 = -4px, fs-2 = -8px) --- */
.scene-stage.fs-1 .sub-bar { font-size: 30px; }
.scene-stage.fs-2 .sub-bar { font-size: 26px; }
@media (max-width: 1100px) {
  .scene-stage.fs-1 .sub-bar { font-size: 24px; }
  .scene-stage.fs-2 .sub-bar { font-size: 20px; }
}
@media (max-width: 850px) {
  .scene-stage.fs-1 .sub-bar { font-size: 16px; }
  .scene-stage.fs-2 .sub-bar { font-size: 14px; }
}
@media (max-width: 480px) {
  .scene-stage.fs-1 .sub-bar { font-size: 16px; }
  .scene-stage.fs-2 .sub-bar { font-size: 12px; }
}

/* --- mobile (<=767.98px): 4:3 stage, 18px subtitles, up to 3 wrapped lines.
   Same 1200x675 master image is centre-cropped by object-fit: cover
   (about 11% off each side), never stretched. Desktop keeps 16:9. --- */
@media (max-width: 767.98px) {
  .scene-hero,
  .scene-stage { aspect-ratio: 4 / 3; }
  .scene-subs { padding: 0 8px; }
  .sub-bar { font-size: 18px; padding: 6px 12px; }
  .scene-stage.fs-1 .sub-bar { font-size: 16px; }
  .scene-stage.fs-2 .sub-bar { font-size: 14px; }
}

/* --- speaking highlight (3px left bar turns to the accent colour) --- */
.sub-line.is-visible.is-speaking .sub-bar {
  border-left-color: #fbbf24;
  box-shadow: 0 0 0 2px rgba(251, 191, 36, 0.9);
}

/* --- view toggle bar --- */
.scene-bar {
  display: none;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 8px 0 0;
}
.scene-bubbles-on .scene-bar { display: flex; }
.scene-toggle,
.scene-bubbles-btn {
  font: 600 12px/1 system-ui, -apple-system, "Segoe UI", sans-serif;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card-bg-solid);
  color: var(--text-secondary);
  cursor: pointer;
}
.scene-toggle[aria-pressed="true"] {
  background: #0f172a;
  border-color: #0f172a;
  color: #f8fafc;
}
.scene-toggle:focus-visible,
.scene-bubbles-btn:focus-visible {
  outline: 2px solid #f59e0b;
  outline-offset: 2px;
}
.scene-bubbles-btn { display: inline-block; }

/* --- image-only / dialog-only --- */
.scene-stage.image-only .scene-subs { display: none; }
.scene-stage.dialog-only {
  aspect-ratio: auto;
  background: #0f172a;
  border-color: #0f172a;
}
.scene-stage.dialog-only > picture { display: none; }
.scene-stage.dialog-only .scene-subs {
  position: static;
  max-height: none;
  overflow: visible;
  padding: 10px 0;
  background: transparent;
}
.scene-stage.dialog-only .sub-line:not(.is-visible),
.scene-stage.all-open .sub-line:not(.is-visible) {
  position: static;
  width: auto;
  height: auto;
  margin: 0;
  overflow: visible;
  clip-path: none;
  white-space: normal;
}
.scene-stage.dialog-only .sub-bar {
  background: transparent;
  text-shadow: none;
}

/* --- "展开对话": user-initiated full list over the image --- */
.scene-stage.all-open .scene-subs {
  max-height: 46%;
  overflow-y: auto;
  background: linear-gradient(to top, rgba(2, 6, 23, 0.92), rgba(2, 6, 23, 0.55));
  pointer-events: auto;
  scrollbar-width: thin;
}

/* --- left rail thumbnails --- */
#lessons button.has-thumb {
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
}
.scene-thumb {
  display: block;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  object-fit: cover;
  background: var(--card-bg-solid);
}
