/* Explainer player: dual-strip chapter selector (Prior methods -> LCP ours), canvas stage, play bar. */

.player {
  --w: min(1360px, calc(100vw - 2 * var(--gutter)), calc(100vw - 2 * var(--side-nav-room, 0px)));
  display: grid; grid-template-columns: 1fr; gap: 14px;
  width: var(--w); margin: var(--sp-3) 0 0 calc(50% - var(--w) / 2);
}

/* ---------- Dual chapter strips ---------- */
.rail {
  display: flex; flex-direction: column; gap: 8px;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--surface);
}
.rail-row { display: grid; grid-template-columns: 112px minmax(0, 1fr); align-items: center; gap: 10px; }
.rail-row + .rail-row { padding-top: 8px; border-top: 1px solid var(--line); }
.rail-tag {
  font: 500 10px/1.2 var(--mono); letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--faint); white-space: nowrap;
}
.rail-row.is-ours .rail-tag { color: var(--accent); }
.rail-track {
  display: flex; align-items: center; gap: 6px; overflow-x: auto;
  scrollbar-width: none; -webkit-overflow-scrolling: touch; padding: 2px 1px;
}
.rail-track::-webkit-scrollbar { display: none; }
.rail a {
  position: relative; display: inline-flex; align-items: baseline; gap: 6px;
  padding: 6px 11px; white-space: nowrap; border-radius: 5px;
  border: 1px solid var(--line); background: var(--card-bg); cursor: pointer;
  font: 400 13.5px/1.25 var(--sans); color: var(--muted); text-decoration: none;
  box-shadow: 0 1px 1px color-mix(in srgb, var(--ink) 4%, transparent);
  transition: color 0.14s, background-color 0.14s, border-color 0.14s, box-shadow 0.14s;
}
.rail a:not([aria-current]):hover {
  color: var(--ink); border-color: color-mix(in srgb, var(--ink) 38%, var(--line));
  background: color-mix(in srgb, var(--ink) 4%, var(--card-bg));
  box-shadow: 0 1px 3px color-mix(in srgb, var(--ink) 8%, transparent);
}
.rail-row.is-ours a:not([aria-current]):hover {
  color: var(--ink); border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  background: color-mix(in srgb, var(--accent) 7%, var(--card-bg));
}
.rail a[aria-current] {
  color: var(--ground); font-weight: 500;
  background: var(--ink); border-color: var(--ink);
  box-shadow: 0 1px 3px color-mix(in srgb, var(--ink) 16%, transparent);
}
.rail a[aria-current] .dur { color: color-mix(in srgb, var(--ground) 72%, transparent); }
.rail-row.is-ours a[aria-current] {
  color: #fff;
  border-color: var(--accent);
  background: var(--accent);
}
.rail a:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.rail a .dur { font: 400 11px/1 var(--mono); color: var(--faint); }
.rail-row.is-ours a[aria-current] .dur { color: rgba(255, 255, 255, 0.8); }

/* ---------- Stage ---------- */
.screen { min-width: 0; }
.stage {
  position: relative; aspect-ratio: 16 / 9; border: 1px solid var(--line); border-radius: 6px;
  overflow: hidden; cursor: pointer; background: var(--ground);
}
.stage canvas, .stage video { display: block; width: 100%; height: 100%; }
.stage:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; }
.player.is-compact { --w: min(960px, calc(100vw - 2 * var(--gutter))); }

/* ---------- Play bar ---------- */
.controls { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.controls .pp {
  position: relative; flex: none; width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center;
  padding: 0; border: 1px solid var(--line); border-radius: 50%; background: var(--card-bg); color: var(--muted); cursor: pointer;
}
.controls .pp::after { content: ""; position: absolute; inset: -6px; }
.controls .pp svg { display: block; fill: currentColor; }
.controls .pp .i-pause, .controls .pp[aria-pressed="true"] .i-play { display: none; }
.controls .pp[aria-pressed="true"] .i-pause { display: inline; }
.controls .pp:hover { color: var(--ink); border-color: var(--muted); }
.controls .pp:focus-visible, .controls input[type=range]:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.scrub { position: relative; flex: 1; min-width: 0; }
.scrub input[type=range] {
  --p: 0%; display: block; width: 100%; height: 18px; margin: 0; padding: 0; cursor: pointer;
  -webkit-appearance: none; appearance: none; border: 0; background:
    linear-gradient(to right, var(--ink) var(--p), var(--line) var(--p)) center / 100% 2px no-repeat;
}
.scrub input[type=range]::-webkit-slider-runnable-track { height: 18px; background: transparent; }
.scrub input[type=range]::-moz-range-track { height: 18px; background: transparent; }
.scrub input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 11px; height: 11px; margin-top: 3.5px; border: 0; border-radius: 50%; background: var(--ink);
}
.scrub input[type=range]::-moz-range-thumb { width: 11px; height: 11px; border: 0; border-radius: 50%; background: var(--ink); }
.ticks { position: absolute; inset: 0; pointer-events: none; }
.ticks i { position: absolute; top: 4px; width: 2px; height: 10px; margin-left: -1px; background: var(--ground); }
.controls .time { font: 400 12px/1 var(--mono); color: var(--faint); min-width: 84px; text-align: right; font-variant-numeric: tabular-nums; }
.controls .pp.snd { width: auto; gap: 6px; padding: 0 11px 0 9px; border-radius: 16px; font: 400 12px/1 var(--mono); }
.controls .dl {
  flex: none; height: 32px; display: inline-flex; align-items: center; gap: 6px;
  padding: 0 11px 0 9px; border: 1px solid var(--line); border-radius: 16px;
  background: var(--card-bg); color: var(--muted); text-decoration: none;
  font: 400 12px/1 var(--mono); cursor: pointer;
}
.controls .dl svg { display: block; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.controls .dl:hover { color: var(--ink); border-color: var(--muted); }
.controls .dl:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.controls .fs {
  flex: none; height: 32px; display: inline-flex; align-items: center; gap: 6px;
  padding: 0 11px 0 9px; border: 1px solid var(--line); border-radius: 16px;
  background: var(--card-bg); color: var(--muted);
  font: 400 12px/1 var(--mono); cursor: pointer;
}
.controls .fs svg { display: block; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.controls .fs .i-exit, .controls .fs[aria-pressed="true"] .i-enter { display: none; }
.controls .fs[aria-pressed="true"] .i-exit { display: inline; }
.controls .fs:hover { color: var(--ink); border-color: var(--muted); }
.controls .fs:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- Fullscreen (left chapter sidebar on wide screens, top bar on narrow) ---------- */
.player:fullscreen, .player:-webkit-full-screen {
  width: 100vw; height: 100vh; max-width: none; margin: 0; padding: 14px 20px 16px;
  background: var(--ground); box-sizing: border-box;
  display: flex; flex-direction: column; gap: 10px; overflow: hidden;
}
#player:fullscreen, #player:-webkit-full-screen {
  display: grid; grid-template-columns: 236px minmax(0, 1fr); gap: 16px; align-items: stretch;
}
#player:fullscreen .rail, #player:-webkit-full-screen .rail {
  overflow-y: auto; padding: 14px 12px; gap: 14px;
}
#player:fullscreen .rail-row, #player:-webkit-full-screen .rail-row {
  display: flex; flex-direction: column; align-items: stretch; gap: 6px;
}
#player:fullscreen .rail-row + .rail-row, #player:-webkit-full-screen .rail-row + .rail-row {
  padding-top: 12px;
}
#player:fullscreen .rail-track, #player:-webkit-full-screen .rail-track {
  flex-direction: column; align-items: stretch; overflow-x: visible; gap: 5px;
}
#player:fullscreen .rail a, #player:-webkit-full-screen .rail a {
  justify-content: space-between; white-space: normal; padding: 8px 10px; font-size: 13px;
}
.player:fullscreen .screen, .player:-webkit-full-screen .screen {
  flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column;
}
.player:fullscreen .stage, .player:-webkit-full-screen .stage {
  flex: 1; min-height: 0; aspect-ratio: auto; width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
}
.player:fullscreen .stage canvas, .player:-webkit-full-screen .stage canvas,
.player:fullscreen .stage video, .player:-webkit-full-screen .stage video {
  width: auto; height: auto; max-width: 100%; max-height: 100%; object-fit: contain;
}
.player:fullscreen .cap, .player:-webkit-full-screen .cap {
  min-height: 2.2em; margin-top: 8px; font-size: 16px;
}
@media (max-width: 900px) {
  #player:fullscreen, #player:-webkit-full-screen {
    display: flex; flex-direction: column; gap: 10px;
  }
  #player:fullscreen .rail, #player:-webkit-full-screen .rail {
    flex: none; overflow-y: visible; padding: 10px 12px; gap: 8px;
  }
  #player:fullscreen .rail-track, #player:-webkit-full-screen .rail-track {
    flex-direction: row; overflow-x: auto;
  }
  #player:fullscreen .rail a, #player:-webkit-full-screen .rail a {
    white-space: nowrap; justify-content: flex-start;
  }
}

/* ---------- Caption ---------- */
.cap { min-height: 3.2em; margin: 12px auto 0; max-width: 60em; text-align: center; font: 400 17px/1.55 var(--serif); color: var(--ink); }

/* ---------- Mobile ---------- */
@media (max-width: 720px) {
  .rail { padding: 10px; gap: 8px; }
  .rail-row { grid-template-columns: 1fr; gap: 5px; }
  .rail a { padding: 7px 10px; font-size: 13px; }
  .controls { flex-wrap: wrap; gap: 8px 10px; }
  .controls .scrub { order: -1; flex-basis: 100%; }
  .controls .time { margin-left: auto; min-width: 72px; }
  .cap { font-size: 15px; line-height: 1.5; min-height: 3.6em; text-align: left; }
}
@media (max-width: 540px) {
  .controls .fs span, .controls .dl span { display: none; }
  .controls .fs, .controls .dl { padding: 0 9px; }
}
