/* ============================================================
   voice-lesson.css — Voice lessons (shared by every simulator)
   ─────────────────────────────────────────
   PURPOSE : Toolbar launcher, spotlight, instructor pointer, on-eye
             teaching marks, the docked player panel and the start
             sheet drawn by js/shared/voice-lesson/ (strabismus marks:
             js/voice-lesson/; retinoscopy page layer:
             css/voice-lesson/retinoscopy-lesson.css).
   NOTES   : · the overlay root is pointer-events: none; only the panel
               and the sheet take clicks, so every simulator tool stays
               usable under the dimming (practice mode needs that)
             · the panel's height is published as --vl-panel-h; the page
               gets matching bottom padding so nothing is trapped under it
   ============================================================ */

:root {
  --vl-ok: #1d7a62;
  --vl-ok-tint: #e1f2ec;
  --vl-ink: #10302d;
  --vl-dim: rgba(9, 22, 21, 0.44);
  --vl-ease: cubic-bezier(0.22, 0.8, 0.2, 1);
  --vl-glide: cubic-bezier(0.45, 0.05, 0.2, 1);
  --vl-font: 'IBM Plex Sans Arabic', 'Tajawal', 'Segoe UI', system-ui, sans-serif;
}

html.vl-active body { padding-bottom: calc(var(--vl-panel-h, 0px) + 24px); }

/* ── Toolbar launcher ─────────────────────────────────────────── */

.vl-launch {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px 0 12px;
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
  border-radius: 999px;
  background: linear-gradient(180deg, #fff, var(--accent-tint));
  color: var(--accent);
  font: 600 13px/1 var(--vl-font);
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 1px 2px hsl(var(--shadow-color) / 0.08);
  transition: transform 0.15s var(--vl-ease), box-shadow 0.2s, background 0.2s;
}
.vl-launch svg { width: 18px; height: 18px; flex: none; }
.vl-launch:hover { box-shadow: 0 4px 14px -4px color-mix(in srgb, var(--accent) 45%, transparent); }
.vl-launch:active { transform: scale(0.97); }
.vl-launch:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.vl-launch[aria-busy="true"] { opacity: 0.7; cursor: progress; }
.vl-launch__wave { display: inline-flex; gap: 2px; align-items: center; height: 12px; }
.vl-launch__wave i {
  width: 2.5px; height: 100%; border-radius: 2px; background: currentColor; opacity: 0.75;
  animation: vl-wave 1.2s ease-in-out infinite;
}
.vl-launch__wave i:nth-child(2) { animation-delay: 0.15s; }
.vl-launch__wave i:nth-child(3) { animation-delay: 0.3s; }
@keyframes vl-wave { 0%, 100% { transform: scaleY(0.35); } 50% { transform: scaleY(1); } }

@media (max-width: 640px) {
  .vl-launch { height: 34px; padding: 0 10px; }
  .vl-launch__wave { display: none; }
}

/* Cover-test console: the lesson's own launcher leads the step bar, with its
   label — the workspace shrinks every other .vl-launch to an icon
   (lab-workspace.css), which a beginner would not recognise. */
#ct-console .ctc-steps:has(> .ct-vl-launch) { display: flex; flex-direction: row; align-items: stretch; gap: 8px; }
#ct-console .ctc-steps > .ctc-step-list { flex: 1 1 auto; min-width: 0; }
#ct-console .ctc-steps > .ct-vl-launch.vl-launch { flex: none; width: auto; height: auto; min-height: 40px; padding: 0 14px 0 12px; }
#ct-console .ctc-steps > .ct-vl-launch.vl-launch .vl-launch__label { display: inline; }
#ct-console .ctc-steps > .ct-vl-launch.vl-launch .vl-launch__wave { display: inline-flex; }
@media (max-width: 760px) {
  #ct-console .ctc-steps:has(> .ct-vl-launch) { flex-wrap: wrap; }
  #ct-console .ctc-steps > .ct-vl-launch.vl-launch { flex: 1 1 100%; justify-content: center; min-height: 44px; }
  #ct-console .ctc-steps > .ctc-step-list { flex-basis: 100%; }
}

/* Krimsky console: same launcher, same reason — kr-workspace.css shrinks
   every .vl-launch in #kr-console.kr-workspace to an icon (1,2,0); this
   selector (1,3,0) keeps the label on the lesson's own button. */
#kr-console .ctc-steps:has(> .kr-vl-launch) { display: flex; flex-direction: row; align-items: stretch; gap: 8px; }
#kr-console .ctc-steps > .ctc-step-list { flex: 1 1 auto; min-width: 0; }
#kr-console .ctc-steps > .kr-vl-launch.vl-launch { flex: none; width: auto; height: auto; min-height: 36px; padding: 0 14px 0 12px; }
#kr-console .ctc-steps > .kr-vl-launch.vl-launch .vl-launch__label { display: inline; }
#kr-console .ctc-steps > .kr-vl-launch.vl-launch .vl-launch__wave { display: inline-flex; }
@media (max-width: 760px) {
  #kr-console .ctc-steps:has(> .kr-vl-launch) { flex-wrap: wrap; }
  #kr-console .ctc-steps > .kr-vl-launch.vl-launch { flex: 1 1 100%; justify-content: center; min-height: 44px; }
  #kr-console .ctc-steps > .ctc-step-list { flex-basis: 100%; }
}

/* ── Overlay root ─────────────────────────────────────────────── */

.vl-root {
  position: fixed;
  inset: 0;
  z-index: 1150;
  pointer-events: none;
  font-family: var(--vl-font);
  color: var(--text);
}
.vl-root [hidden] { display: none !important; }

/* Lesson language is independent of the host page's language. */
.vl-root[dir="ltr"], .vl-marks[dir="ltr"] { --vl-font: 'Segoe UI', system-ui, sans-serif; }
.vl-root[dir="ltr"] [data-vl-action="prev"] > svg,
.vl-root[dir="ltr"] [data-vl-action="next"] > svg,
.vl-root[dir="ltr"] [data-vl-action="nextCase"] > svg { transform: scaleX(-1); }
.vl-preferences { display: flex; flex-wrap: wrap; gap: 12px 24px; padding: 14px 24px; border-bottom: 1px solid var(--border-soft); }
.vl-preference { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 12px; color: var(--text-soft); }
.vl-language, .vl-voices { display: inline-flex; gap: 3px; padding: 3px; border: 1px solid var(--border-soft); border-radius: 10px; background: var(--surface); }
.vl-language button, .vl-voices button { min-height: 34px; padding: 5px 11px; border: 0; border-radius: 7px; font: 600 12px/1.3 var(--vl-font); color: var(--text-soft); background: transparent; cursor: pointer; }
.vl-language button[aria-pressed="true"], .vl-voices button[aria-pressed="true"] { background: var(--accent-tint); color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.vl-language button:focus-visible, .vl-voices button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.vl-preview { margin: 0; padding: 7px 24px; background: var(--accent-tint); color: var(--accent); font-size: 12px; }
.vl-controls .vl-language { flex: none; }
@media (max-width: 640px) {
  .vl-preferences { padding: 10px 14px; gap: 8px 16px; }
  .vl-preview { padding-inline: 14px; font-size: 11px; }
}

/* ── Spotlight ────────────────────────────────────────────────── */

.vl-spot {
  position: absolute;
  top: 0;
  left: 0;
  border-radius: 18px;
  box-shadow:
    0 0 0 2px rgba(255, 255, 255, 0.95),
    0 0 0 7px color-mix(in srgb, var(--accent) 28%, transparent),
    0 0 0 200vmax var(--vl-dim);
  transition:
    transform 0.55s var(--vl-ease),
    width 0.55s var(--vl-ease),
    height 0.55s var(--vl-ease),
    border-radius 0.55s var(--vl-ease);
}
/* Round targets (data-vl-spot="round", e.g. the retinoscopy eye) get a round spotlight. */
.vl-spot.is-round { border-radius: 50%; }
.vl-spot::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  border: 2px solid rgba(255, 255, 255, 0.9);
  animation: vl-spot-breathe 2.4s ease-in-out infinite;
}
@keyframes vl-spot-breathe {
  0%, 100% { opacity: 0.25; transform: scale(1); }
  50% { opacity: 0.9; transform: scale(1.012); }
}

/* ── Instructor pointer ───────────────────────────────────────── */

.vl-pointer {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  opacity: 0;
  transition-property: transform, opacity;
  transition-timing-function: var(--vl-glide), ease;
  z-index: 2;
}
.vl-pointer.is-in { opacity: 1; }
.vl-pointer__hand {
  position: absolute;
  /* fingertip of the drawing sits at (18.4, 4) of the 40×46 box */
  left: -18px;
  top: -4px;
  width: 40px;
  height: 46px;
  filter: drop-shadow(0 6px 10px rgba(6, 20, 19, 0.35)) drop-shadow(0 1px 1px rgba(6, 20, 19, 0.3));
  transform-origin: 18px 4px;
  transition: transform 0.18s var(--vl-ease);
}
.vl-pointer__ripple {
  position: absolute;
  left: -22px;
  top: -22px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 60%, transparent);
  opacity: 0;
  transform: scale(0.3);
}
.vl-pointer.is-tap .vl-pointer__hand { animation: vl-press 0.36s var(--vl-ease); }
.vl-pointer.is-tap .vl-pointer__ripple { animation: vl-ripple 0.6s ease-out; }
@keyframes vl-press { 0%, 100% { transform: scale(1); } 45% { transform: scale(0.86) translateY(2px); } }
@keyframes vl-ripple { 0% { opacity: 0.95; transform: scale(0.3); } 100% { opacity: 0; transform: scale(1.5); } }

/* ── On-eye teaching marks ────────────────────────────────────── */

.vl-marks {
  position: absolute;
  inset: 0;
  z-index: 40;
  pointer-events: none;
  font-family: var(--vl-font);
}
.vl-mark {
  --tone: var(--accent);
  --tone-ink: #fff;
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  transform: translate(var(--x, 0), var(--y, 0));
  transition: transform 0.12s linear;
  opacity: 0;
}
.vl-mark.is-in { opacity: 1; transition: transform 0.12s linear, opacity 0.35s ease; }
.vl-mark[data-tone="ok"] { --tone: var(--vl-ok); }
.vl-mark[data-tone="warn"] { --tone: var(--warn); }
.vl-mark[data-tone="note"] { --tone: var(--note); }

.vl-mark__ring {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--ring, 26px);
  height: var(--ring, 26px);
  border-radius: 50%;
  border: 2.5px solid var(--tone);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.85), 0 0 14px 2px color-mix(in srgb, var(--tone) 55%, transparent);
  transform: translate(-50%, -50%) scale(0.4);
  transition: transform 0.45s var(--vl-ease);
}
.vl-mark.is-in .vl-mark__ring { transform: translate(-50%, -50%) scale(1); animation: vl-ring 1.8s ease-in-out 0.45s infinite; }
@keyframes vl-ring {
  0%, 100% { box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.85), 0 0 10px 1px color-mix(in srgb, var(--tone) 45%, transparent); }
  50% { box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.85), 0 0 22px 6px color-mix(in srgb, var(--tone) 60%, transparent); }
}
.vl-mark--watch .vl-mark__ring {
  width: calc(var(--ring, 26px) * 2.7);
  height: calc(var(--ring, 26px) * 2.7);
  border-style: dashed;
  border-width: 2.5px;
}
.vl-mark--watch.is-in .vl-mark__ring { animation: vl-spin 9s linear infinite; }
@keyframes vl-spin { to { transform: translate(-50%, -50%) rotate(360deg); } }

.vl-mark__label {
  position: absolute;
  left: 0;
  top: 0;
  transform: translate(-50%, calc(-1 * var(--lift, 56px) - 100%)) translateY(6px);
  padding: 5px 11px 6px;
  border-radius: 999px;
  background: var(--tone);
  color: var(--tone-ink);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  box-shadow: 0 6px 16px -6px rgba(6, 20, 19, 0.55);
  transition: transform 0.45s var(--vl-ease);
}
.vl-mark.is-in .vl-mark__label { transform: translate(-50%, calc(-1 * var(--lift, 56px) - 100%)); }
.vl-mark__label::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -5px;
  width: 10px;
  height: 10px;
  background: inherit;
  border-radius: 2px;
  transform: translateX(-50%) rotate(45deg);
}
.vl-mark--side .vl-mark__label { background: rgba(255, 255, 255, 0.95); color: var(--vl-ink); border: 1px solid var(--border); }

.vl-mark__arrow {
  position: absolute;
  left: 0;
  top: 0;
  width: 104px;
  height: 28px;
  color: var(--tone);
  filter: drop-shadow(0 0 1.5px #fff) drop-shadow(0 0 1.5px #fff) drop-shadow(0 2px 4px rgba(6, 20, 19, 0.35));
  /* Below the eye, clear of the label above it and the lids. */
  transform: translate(-50%, -50%) translateY(calc(var(--lift, 56px) * 0.66)) scaleX(var(--dir, 1));
}
.vl-mark__arrow svg { width: 100%; height: 100%; overflow: visible; }
.vl-mark__shaft, .vl-mark__head {
  fill: none;
  stroke: currentColor;
  stroke-width: 5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.vl-mark__shaft { stroke-dasharray: 70; stroke-dashoffset: 70; }
.vl-mark__head { opacity: 0; }
.vl-mark.is-in .vl-mark__shaft { animation: vl-draw 0.6s var(--vl-ease) 0.15s forwards; }
.vl-mark.is-in .vl-mark__head { animation: vl-fade 0.25s ease 0.6s forwards; }
.vl-mark--move.is-in .vl-mark__arrow svg { animation: vl-nudge 1.6s ease-in-out 1s infinite; }
@keyframes vl-draw { to { stroke-dashoffset: 0; } }
@keyframes vl-fade { to { opacity: 1; } }
@keyframes vl-nudge { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(6px); } }

/* The reflex arrow is short and sits beside the ring, on its temporal side. */
.vl-mark--reflex .vl-mark__arrow {
  width: 46px;
  height: 18px;
  transform: translate(-50%, -50%) translateX(calc(var(--dir, 1) * (var(--ring, 26px) * 0.5 + 30px))) scaleX(var(--dir, 1));
}

/* ── Panel ────────────────────────────────────────────────────── */

.vl-panel {
  container: voice-panel / inline-size;
  position: absolute;
  left: 50%;
  bottom: max(14px, env(safe-area-inset-bottom));
  width: min(720px, calc(100vw - 24px));
  padding: 12px 16px 12px;
  border-radius: 22px;
  border: 1px solid color-mix(in srgb, var(--accent) 14%, transparent);
  background: rgba(255, 255, 255, 0.9);
  -webkit-backdrop-filter: blur(20px) saturate(1.5);
  backdrop-filter: blur(20px) saturate(1.5);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.8) inset,
    0 26px 60px -20px rgba(6, 26, 24, 0.5),
    0 4px 14px -6px rgba(6, 26, 24, 0.2);
  pointer-events: auto;
  transform: translate(-50%, 28px);
  opacity: 0;
  transition: transform 0.5s var(--vl-ease), opacity 0.35s ease;
}
.vl-panel.is-in { transform: translate(-50%, 0); opacity: 1; }
/* Placement (lesson-overlay.js placePanel): out of the way of the target.
   Corner places are narrower (inline width) and slide in without centring. */
.vl-panel[data-place="bl"], .vl-panel[data-place="tl"] { left: max(12px, env(safe-area-inset-left)); right: auto; }
.vl-panel[data-place="br"], .vl-panel[data-place="tr"] { left: auto; right: max(12px, env(safe-area-inset-right)); }
.vl-panel[data-place]:not([data-place="c"]) { transform: translateY(16px); }
.vl-panel[data-place]:not([data-place="c"]).is-in { transform: none; }
.vl-panel[data-place="tl"], .vl-panel[data-place="tr"] { max-height: calc(100dvh - 24px); overflow-y: auto; }

.vl-panel__head { display: flex; align-items: center; gap: 8px; min-height: 34px; }
.vl-panel__chapter {
  padding: 4px 10px 5px;
  border-radius: 999px;
  background: var(--accent-tint);
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 52%;
}
.vl-panel__chapter b, .vl-index__chapter b {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  margin-inline-end: 6px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  vertical-align: 1px;
}
.vl-panel__count { color: var(--text-soft); font-size: 12.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.vl-panel__mode {
  padding: 3px 8px 4px;
  border-radius: 6px;
  border: 1px solid var(--border);
  color: var(--text-soft);
  font-size: 11.5px;
  font-weight: 600;
}
.vl-panel__mode[data-mode="practice"] { border-color: color-mix(in srgb, var(--warn) 35%, transparent); color: var(--warn); background: var(--warn-tint); }
.vl-spacer { flex: 1; }

.vl-steps { display: flex; gap: 4px; margin: 8px 0 8px; padding: 0; list-style: none; }
.vl-step { flex: 1; height: 4px; border-radius: 4px; background: var(--border-soft); transition: background 0.4s; }
.vl-step.is-done { background: color-mix(in srgb, var(--accent) 45%, var(--border-soft)); }
.vl-step.is-current { background: var(--accent); }

.vl-panel__title {
  margin: 0 0 4px;
  font-size: 17px;
  font-weight: 700;
  color: var(--vl-ink);
  letter-spacing: 0;
}
.vl-caption {
  margin: 0;
  min-height: 3.4em;
  max-height: 5.6em;
  overflow-y: auto;
  font-size: 16.5px;
  line-height: 1.9;
  color: var(--text);
  text-wrap: pretty;
  scrollbar-width: thin;
}
@media (min-height: 760px) { .vl-caption { max-height: 7.6em; } }

/* Follow-along: the sentence being read is in full ink with a soft marker
   underneath; the others step back. Finished lines read normally again. */
.vl-cap__s { transition: color 0.35s ease, opacity 0.35s ease, background-size 0.5s var(--vl-ease); }
.vl-caption.is-following .vl-cap__s[data-state="past"],
.vl-caption.is-following .vl-cap__s[data-state="next"] { opacity: 0.5; }
.vl-caption.is-following .vl-cap__s[data-state="now"] {
  color: var(--vl-ink);
  background-image: linear-gradient(transparent 64%, color-mix(in srgb, var(--accent) 16%, transparent) 64%);
  background-repeat: no-repeat;
  background-size: 100% 100%;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
/* English terms: quieter, in the Latin face — the Arabic stays the reading line. */
.vl-cap__en {
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  font-size: 0.86em;
  color: var(--text-soft);
  letter-spacing: 0.01em;
}
/* Numbers and prescriptions: a chip, tabular, never wrapped. */
.vl-cap__num {
  display: inline-block;
  padding: 0 0.32em;
  margin: 0 0.08em;
  border-radius: 6px;
  background: var(--surface-sunken);
  color: var(--accent-strong);
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  font-size: 0.9em;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
@media (prefers-reduced-motion: reduce) { .vl-cap__s { transition: none; } }
.is-fresh { animation: vl-in 0.45s var(--vl-ease); }
@keyframes vl-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

.vl-summary {
  margin: 10px 0 2px;
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--surface-sunken);
  border: 1px solid var(--border-soft);
  animation: vl-in 0.5s var(--vl-ease);
}
.vl-summary__title { margin: 0 0 6px; font-weight: 700; font-size: 13px; color: var(--accent); }
.vl-summary dl { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; margin: 0; }
.vl-summary dl div { display: flex; flex-direction: column; gap: 1px; }
.vl-summary dt { font-size: 11.5px; color: var(--text-soft); }
.vl-summary dd { margin: 0; font-size: 13.5px; font-weight: 600; color: var(--vl-ink); }

.vl-await {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 10px;
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 14px;
  background: var(--warn-tint);
  border: 1px solid color-mix(in srgb, var(--warn) 22%, transparent);
  animation: vl-in 0.4s var(--vl-ease);
}
.vl-await__badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--warn);
  font-weight: 700;
  font-size: 13px;
}
.vl-await__badge svg { width: 18px; height: 18px; animation: vl-bob 1.4s ease-in-out infinite; }
@keyframes vl-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
.vl-await__text { flex: 1; min-width: 160px; font-size: 13px; color: var(--text-soft); }
/* A gentle correction ("you added minus, the motion is with — try plus"). */
.vl-hint,
.vl-audio-notice {
  flex-basis: 100%;
  margin: 0;
  padding: 6px 10px;
  border-radius: 10px;
  background: var(--surface, #fff);
  border-inline-start: 3px solid var(--note);
  color: var(--text);
  font-size: 14px;
  line-height: 1.7;
}

.vl-done {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--vl-ok-tint);
  animation: vl-in 0.45s var(--vl-ease);
}
.vl-done__badge {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--vl-ok);
  color: #fff;
}
.vl-done__badge svg { width: 20px; height: 20px; }
.vl-done__text { flex: 1; min-width: 150px; display: flex; flex-direction: column; font-size: 13px; color: var(--text-soft); }
.vl-done__text strong { color: var(--vl-ink); font-size: 14.5px; }

.vl-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; }
.vl-controls > button, .vl-panel__head > button { flex-shrink: 0; }
.vl-controls.is-done .vl-play { opacity: 0.5; }

.vl-icon {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.15s var(--vl-ease);
}
.vl-icon svg { width: 19px; height: 19px; }
.vl-icon:hover { background: var(--surface-sunken); color: var(--vl-ink); }
.vl-icon:active { transform: scale(0.92); }
.vl-icon--nav { width: 40px; height: 40px; background: var(--surface-sunken); color: var(--vl-ink); }
.vl-icon--nav:hover { background: var(--border-soft); }
.vl-icon[aria-expanded="true"] { background: var(--accent-tint); color: var(--accent); }

.vl-play {
  position: relative;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin: 0 4px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  cursor: pointer;
  box-shadow: 0 8px 18px -8px color-mix(in srgb, var(--accent) 80%, transparent);
  transition: transform 0.18s var(--vl-ease), background 0.2s;
}
.vl-play:hover { background: var(--accent-strong); }
.vl-play:active { transform: scale(0.94); }
.vl-play__icon { display: grid; place-items: center; }
.vl-play__icon svg { width: 22px; height: 22px; }
.vl-play__ring { position: absolute; inset: -4px; width: calc(100% + 8px); height: calc(100% + 8px); transform: rotate(-90deg) scaleY(-1); }
.vl-play__track, .vl-play__fill { fill: none; stroke-width: 2.6; }
.vl-play__track { stroke: color-mix(in srgb, var(--accent) 14%, transparent); }
.vl-play__fill {
  stroke: color-mix(in srgb, var(--accent) 70%, #fff);
  stroke-linecap: round;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  transition: stroke-dashoffset 0.25s linear;
}
.vl-play.is-paused { animation: vl-call 1.6s ease-in-out infinite; }
@keyframes vl-call {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 40%, transparent); }
  50% { box-shadow: 0 0 0 9px color-mix(in srgb, var(--accent) 0%, transparent); }
}

.vl-pill {
  min-width: 44px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--vl-ink);
  font: 600 13px/1 var(--vl-font);
  cursor: pointer;
}
.vl-pill:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
/* Narrator persona (Hassan / Rawan): tinted monogram + name + role. */
.vl-pill--voice {
  --vl-persona: #2f6f6a;
  --vl-persona-2: #1f4f4b;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 12px 0 4px;
  padding-inline: 4px 12px;
  margin-inline-end: 6px;
  background: linear-gradient(180deg, var(--surface), color-mix(in srgb, var(--vl-persona) 6%, var(--surface)));
  border-color: color-mix(in srgb, var(--vl-persona) 22%, var(--border));
  transition: border-color .2s ease, box-shadow .2s ease, background-color .2s ease;
}
.vl-pill--voice[data-gender="female"] { --vl-persona: #a0526b; --vl-persona-2: #7a3a50; }
.vl-pill--voice[hidden] { display: none; }
.vl-pill--voice:hover {
  border-color: color-mix(in srgb, var(--vl-persona) 45%, var(--border));
  box-shadow: 0 2px 10px color-mix(in srgb, var(--vl-persona) 14%, transparent);
}
.vl-pill--voice:focus-visible { outline: 2px solid var(--vl-persona); outline-offset: 2px; }

.vl-persona { position: relative; display: inline-grid; place-items: center; width: 32px; height: 32px; flex: none; }
.vl-persona__disc {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, color-mix(in srgb, #fff 18%, var(--vl-persona)), var(--vl-persona) 55%, var(--vl-persona-2));
  color: #fff;
  font: 700 15px/1 var(--vl-font);
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px color-mix(in srgb, var(--vl-persona) 35%, transparent),
              0 2px 6px color-mix(in srgb, var(--vl-persona-2) 35%, transparent);
  transition: transform .3s cubic-bezier(.2, .9, .3, 1.3), background .3s ease;
}
/* Soft halo that breathes while this narrator is speaking. */
.vl-persona::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 2px solid var(--vl-persona);
  opacity: 0;
  pointer-events: none;
}
.vl-pill--voice.is-speaking .vl-persona::after { animation: vl-persona-speak 1.8s ease-out infinite; }
@keyframes vl-persona-speak {
  0%   { opacity: .55; transform: scale(1); }
  100% { opacity: 0;   transform: scale(1.35); }
}
.vl-pill--voice:active .vl-persona__disc { transform: scale(.92); }

.vl-persona__text { display: grid; gap: 2px; text-align: start; line-height: 1; white-space: nowrap; }
.vl-persona__name { font: 700 13px/1.1 var(--vl-font); color: var(--vl-ink); }
.vl-persona__role { font: 500 10.5px/1.1 var(--vl-font); color: var(--vl-persona); opacity: .9; }

/* A corner player is narrow even on a large monitor. Adapt to its own width,
   keeping transport controls and narration preferences on separate rows. */
@container voice-panel (max-width: 520px) {
  .vl-controls { justify-content: center; row-gap: 6px; }
  .vl-controls > .vl-spacer { display: block; flex: 0 0 100%; height: 0; }
  .vl-controls .vl-language button { padding-inline: 8px; min-height: 36px; }
  .vl-controls .vl-pill--voice { margin-inline-end: 0; padding-inline-end: 8px; }
  .vl-panel__mode { display: none; }
  .vl-panel__chapter { min-width: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .vl-persona__disc { transition: none; }
  .vl-pill--voice.is-speaking .vl-persona::after { animation: none; opacity: .5; }
}

.vl-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid transparent;
  font: 600 13.5px/1 var(--vl-font);
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.15s var(--vl-ease), background 0.2s, border-color 0.2s;
}
.vl-btn svg { width: 17px; height: 17px; }
.vl-btn:active { transform: scale(0.97); }
.vl-btn--primary { background: var(--accent); color: var(--on-accent); box-shadow: 0 8px 18px -10px color-mix(in srgb, var(--accent) 90%, transparent); }
.vl-btn--primary:hover { background: var(--accent-strong); }
.vl-btn--ghost { background: var(--surface); color: var(--vl-ink); border-color: var(--border); }
.vl-btn--ghost:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); color: var(--accent); }
.vl-btn--quiet { background: transparent; color: var(--text-soft); }
.vl-btn--quiet:hover { color: var(--vl-ink); }
.vl-btn--lg { height: 48px; font-size: 15.5px; padding: 0 22px; }

.vl-root button:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

/* The lesson index opens INSIDE the panel, under the controls. It used to
   float above the panel, but the panel scrolls (overflow-y: auto on short
   screens and on retinoscopy), which clipped it: the button did nothing. */
.vl-index {
  margin-top: 10px;
  max-height: min(42vh, 340px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 6px 8px 8px;
  border-radius: 14px;
  border: 1px solid var(--border-soft);
  background: var(--surface);
  animation: vl-in 0.3s var(--vl-ease);
}
.vl-index[hidden] { display: none; }
.vl-index__chapter { margin: 8px 4px 4px; font-size: 12px; font-weight: 700; color: var(--accent); }
.vl-index ol { margin: 0; padding: 0; list-style: none; display: grid; gap: 2px; }
.vl-index button {
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font: 500 14px/1.3 var(--vl-font);
  text-align: start;
  cursor: pointer;
}
.vl-index button:hover { background: var(--surface-sunken); }
.vl-index button[aria-current] { background: var(--accent-tint); color: var(--accent); font-weight: 700; }

/* ── Start sheet ──────────────────────────────────────────────── */

.vl-sheet {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(9, 22, 21, 0.42);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
  pointer-events: auto;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.vl-sheet.is-in { opacity: 1; }
/* Desktop: one screen, no scrolling — intro on top, the two choices side by
   side (chapters | mode), the start button pinned at the bottom. */
.vl-sheet__card {
  display: flex;
  flex-direction: column;
  width: min(820px, 100%);
  max-height: calc(100dvh - 32px);
  overflow: hidden;
  border-radius: 26px;
  background: var(--surface);
  box-shadow: 0 40px 90px -30px rgba(6, 26, 24, 0.65);
  transform: translateY(18px) scale(0.98);
  transition: transform 0.5s var(--vl-ease);
}
.vl-sheet.is-in .vl-sheet__card { transform: none; }
.vl-sheet__hero, .vl-preferences, .vl-preview, .vl-sheet__foot { flex-shrink: 0; }

.vl-sheet__hero {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 22px 24px 18px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent-tint) 75%, var(--surface)), var(--surface));
  border-bottom: 1px solid var(--border-soft);
}
.vl-sheet__icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: linear-gradient(145deg, color-mix(in srgb, var(--accent) 78%, #3fa58b), var(--accent-strong));
  color: #fff;
  box-shadow: 0 14px 28px -12px color-mix(in srgb, var(--accent) 90%, transparent);
}
.vl-sheet__icon svg { width: 27px; height: 27px; }
.vl-sheet__intro { flex: 1; min-width: 0; padding-inline-end: 34px; }
.vl-sheet__title { margin: 2px 0 4px; font-size: 22px; font-weight: 700; line-height: 1.35; color: var(--vl-ink); }
.vl-sheet__lead { margin: 0; font-size: 14px; line-height: 1.7; color: var(--text-soft); }
.vl-sheet__meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; }
.vl-sheet__meta span {
  padding: 3px 10px 4px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
}
.vl-sheet__close { position: absolute; top: 14px; inset-inline-end: 14px; }

.vl-sheet__body {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 22px;
  min-height: 0;
  padding: 16px 24px 4px;
  overflow-y: auto;
}
.vl-sheet__group { display: flex; flex-direction: column; min-width: 0; }
.vl-sheet__label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 2px 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--vl-ink);
}
.vl-sheet__label b {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent-tint);
  color: var(--accent);
  font-size: 11.5px;
}

.vl-chapters, .vl-modes { display: grid; gap: 8px; }

.vl-chapter, .vl-choice {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 9px 14px;
  border: 1.5px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  font-family: var(--vl-font);
  text-align: start;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.15s var(--vl-ease), box-shadow 0.2s;
}
.vl-chapter:hover, .vl-choice:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.vl-chapter:active, .vl-choice:active { transform: scale(0.985); }
.vl-chapter[aria-checked="true"], .vl-choice[aria-checked="true"] {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent-tint) 70%, #fff);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent);
}
.vl-chapter__num {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--surface-sunken);
  color: var(--vl-ink);
  font-weight: 700;
}
.vl-chapter[aria-checked="true"] .vl-chapter__num { background: var(--accent); color: #fff; }
.vl-chapter__text, .vl-choice__text { display: flex; flex: 1; flex-direction: column; gap: 2px; min-width: 0; }
.vl-chapter__tick {
  display: grid;
  place-items: center;
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  color: transparent;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.vl-chapter__tick svg { width: 13px; height: 13px; }
.vl-chapter[aria-checked="true"] .vl-chapter__tick { background: var(--accent); border-color: var(--accent); color: #fff; }
.vl-chapter__text strong, .vl-choice__text strong { font-size: 14.5px; color: var(--vl-ink); }
.vl-chapter__text span, .vl-choice__text span { font-size: 12.5px; color: var(--text-soft); line-height: 1.45; }
.vl-choice { align-items: flex-start; }
.vl-choice__icon { flex: none; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--surface-sunken); color: var(--accent); }
.vl-choice__icon svg { width: 18px; height: 18px; }
.vl-choice[aria-checked="true"] .vl-choice__icon { background: var(--accent); color: #fff; }

.vl-sheet__hint {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 10px 2px 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-soft);
}
.vl-sheet__hint svg { flex: none; width: 15px; height: 15px; color: var(--accent); }

.vl-sheet__foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px 16px;
}
.vl-sheet__foot .vl-btn--primary { flex: 1; }

/* Short desktop windows (laptops, long lessons like retinoscopy's five
   parts): drop the lead line and tighten rows before anything scrolls. */
@media (min-width: 641px) and (max-height: 760px) {
  .vl-sheet__lead { display: none; }
  .vl-sheet__hero { padding-block: 16px 12px; }
  .vl-sheet__body { padding-top: 12px; }
  .vl-chapter { padding-block: 7px; }
}

/* ── Phones ───────────────────────────────────────────────────── */

@media (max-height: 480px) {
  .vl-panel .vl-caption { min-height: 0; max-height: 3.4em; }
  .vl-sheet { padding: 8px; }
  .vl-sheet__card { max-height: calc(100dvh - 16px); }
  .vl-sheet__hero { padding: 8px 14px; }
  .vl-sheet__title { font-size: 17px; }
  .vl-sheet__icon { display: none; }
  .vl-sheet__lead, .vl-sheet__meta { display: none; }
  .vl-preferences { padding: 6px 14px; gap: 4px 16px; }
  .vl-preview { padding: 4px 14px; font-size: 11px; }
  .vl-sheet__body { padding-block: 8px 2px; }
  .vl-sheet__foot { padding: 8px 14px; }
}

@media (max-width: 640px) {
  .vl-panel { width: calc(100vw - 16px); bottom: max(8px, var(--app-bottom-inset, env(safe-area-inset-bottom))); padding: 10px 12px; border-radius: 20px; }
  .vl-panel__mode { display: none; }
  .vl-panel__title { font-size: 15.5px; }
  .vl-caption { font-size: 15px; line-height: 1.7; min-height: 3.2em; max-height: 4.9em; }
  .vl-summary dl { grid-template-columns: 1fr; }
  .vl-play { width: 48px; height: 48px; }
  .vl-sheet { place-items: end center; padding: 8px; }
  .vl-sheet__card { border-radius: 24px; }
  .vl-sheet__hero { gap: 12px; padding: 16px 16px 12px; }
  .vl-sheet__icon { width: 42px; height: 42px; border-radius: 13px; }
  .vl-sheet__icon svg { width: 22px; height: 22px; }
  .vl-sheet__title { font-size: 18.5px; }
  .vl-sheet__lead { display: none; }
  .vl-sheet__meta { margin-top: 6px; gap: 4px; }
  .vl-sheet__meta span { padding: 2px 8px 3px; font-size: 11px; }
  .vl-sheet__hint { display: none; }
  .vl-sheet__body { grid-template-columns: 1fr; gap: 14px; padding: 12px 14px 2px; }
  .vl-sheet__label { margin-bottom: 7px; }
  .vl-chapter { padding: 9px 12px; }
  .vl-chapter__num { width: 28px; height: 28px; }
  /* Mode: two compact tiles side by side. */
  .vl-modes { grid-template-columns: 1fr 1fr; }
  .vl-choice { flex-direction: column; gap: 6px; padding: 10px 12px; }
  .vl-choice__text span { font-size: 11.5px; }
  .vl-sheet__foot { padding: 12px 14px max(14px, var(--app-bottom-inset, env(safe-area-inset-bottom))); }
  .vl-mark__label { font-size: 12px; padding: 4px 9px 5px; }
}

@media (prefers-reduced-motion: reduce) {
  .vl-root *, .vl-marks *, .vl-launch * { animation: none !important; transition-duration: 0.01ms !important; }
  .vl-mark__shaft { stroke-dashoffset: 0; }
  .vl-mark__head { opacity: 1; }
}

/* ── Stage notice: a lesson closed because the learner opened another lab
   (js/shared/voice-lesson/lesson-stage.js) ─────────────────────────── */
.vl-notice {
  position: fixed;
  inset-inline: 16px;
  bottom: max(20px, var(--app-bottom-inset, env(safe-area-inset-bottom)));
  z-index: 2147483000;
  margin-inline: auto;
  max-width: 520px;
  padding: 12px 18px;
  border-radius: 14px;
  background: var(--vl-ink);
  color: #fff;
  font: 500 14px/1.6 var(--vl-font);
  text-align: center;
  box-shadow: 0 10px 30px rgba(9, 22, 21, 0.28);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.3s var(--vl-ease), transform 0.3s var(--vl-ease);
  pointer-events: none;
}
.vl-notice.is-in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .vl-notice { transition-duration: 0.01ms; }
}
