/* lb-video player styling (TK-103, FR-20).
   Every colour is an existing token, so the player repaints with the theme for
   free. Prose follows the page direction; the TRANSPORT DOES NOT — see the note
   above .lbv-bar. */

.lbv {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg2);
  overflow: hidden;
  min-inline-size: 0;
  box-shadow: var(--shadow);
}

.lbv-stage {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lbv-video { inline-size: 100%; block-size: 100%; display: block; object-fit: contain; }

/* ── big play ───────────────────────────────────────────────────────────── */
.lbv-bigplay {
  position: absolute;
  inline-size: 72px; block-size: 72px;
  border-radius: 50%;
  border: 1px solid var(--border2);
  background: color-mix(in srgb, var(--bg2) 82%, transparent);
  color: var(--text);
  font-size: 1.6rem;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: transform var(--transition), border-color var(--transition);
}
.lbv-bigplay::before { content: '▶'; }
.lbv-bigplay:hover { border-color: var(--accent); color: var(--accent); }
.lbv-bigplay:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.lbv[data-state="playing"] .lbv-bigplay { display: none; }

/* ── coming soon ────────────────────────────────────────────────────────── */
.lbv-missing {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 10px; padding: 24px;
  text-align: center;
  background: var(--bg3);
  color: var(--text2);
}
.lbv-missing[hidden] { display: none; }
.lbv-missing-body { margin: 0; max-inline-size: 46ch; font-size: .86rem; line-height: 1.6; }
.lbv[data-state="missing"] .lbv-stage { aspect-ratio: 16 / 6; }

/* ── spinner + on-screen display ────────────────────────────────────────── */
.lbv-spinner {
  position: absolute;
  inline-size: 34px; block-size: 34px;
  border: 3px solid var(--border2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: lbv-spin .7s linear infinite;
}
.lbv-spinner[hidden] { display: none; }
@keyframes lbv-spin { to { transform: rotate(360deg); } }

.lbv-osd {
  position: absolute; inset-block-start: 12px; inset-inline-start: 12px;
  padding: 6px 12px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  color: var(--text);
  font-family: var(--mono);
  font-size: .8rem;
  opacity: 0;
  transition: opacity var(--transition);
  pointer-events: none;
}
.lbv-osd.is-on { opacity: 1; }

/* ── transport ──────────────────────────────────────────────────────────────
   dir="ltr" is set on the element in JS. Inside this block PHYSICAL properties
   (left, width) are used DELIBERATELY, unlike everywhere else in this codebase:
   a media timeline runs left-to-right for every reader, and mirroring it makes
   the buffered range ambiguous and inverts arrow-key semantics for some
   assistive technology. Do not "fix" these into logical properties. */
.lbv-bar {
  padding: 10px 12px 12px;
  background: var(--bg2);
  border-block-start: 1px solid var(--border);
  transition: opacity var(--transition);
}
.lbv-bar[hidden] { display: none; }
.lbv.is-idle .lbv-bar { opacity: .35; }

.lbv-scrub {
  position: relative;
  padding: 10px 0;
  cursor: pointer;
  touch-action: none;
}
.lbv-scrub:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.lbv-track {
  position: relative;
  height: 6px;
  border-radius: 999px;
  background: var(--bg3);
  overflow: visible;
}
.lbv-buffered, .lbv-played {
  position: absolute; top: 0; bottom: 0; left: 0;
  border-radius: 999px;
  pointer-events: none;
}
.lbv-buffered {
  width: var(--to, 0%);
  background: color-mix(in srgb, var(--text2) 30%, transparent);
}
.lbv-played { width: var(--played, 0%); background: var(--accent); }

.lbv-thumb {
  position: absolute; top: 50%;
  left: var(--played, 0%);
  width: 13px; height: 13px;
  margin-left: -6.5px;
  transform: translateY(-50%);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
  pointer-events: none;
}

.lbv-markers { position: absolute; inset: 0; pointer-events: none; }
.lbv-marker {
  position: absolute; top: 50%;
  left: var(--at, 0%);
  width: 4px; height: 14px;
  margin-left: -2px;
  transform: translateY(-50%);
  padding: 0;
  border: 0;
  border-radius: 2px;
  background: var(--text);
  opacity: .55;
  cursor: pointer;
  pointer-events: auto;
}
.lbv-marker:hover, .lbv-marker:focus-visible { opacity: 1; background: var(--warning); }
.lbv-marker:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.lbv-hover {
  position: absolute; bottom: 28px;
  left: var(--at, 0%);
  transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 6px;
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  background: var(--bg2);
  box-shadow: var(--shadow);
  pointer-events: none;
  z-index: 2;
}
.lbv-hover[hidden] { display: none; }
.lbv-hover-video { width: 168px; height: 94px; object-fit: cover; border-radius: 6px; background: #000; }
.lbv-hover-time { font-family: var(--mono); font-size: .74rem; color: var(--text2); }

/* ── control row ────────────────────────────────────────────────────────── */
.lbv-controls { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.lbv-spacer { flex: 1 1 auto; min-width: 0; }

.lbv-btn {
  min-width: 44px; min-height: 44px;
  padding: 0 10px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text2);
  font-size: .95rem;
  font-family: var(--font);
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
}
.lbv-btn:hover { color: var(--text); background: var(--bg3); }
.lbv-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.lbv-btn[hidden] { display: none; }
.lbv-cc.is-on, .lbv-rate { color: var(--accent); }

.lbv-vol { display: flex; align-items: center; gap: 4px; }
.lbv-vol-range { inline-size: 84px; accent-color: var(--accent); }

.lbv-time {
  display: inline-flex; align-items: center; gap: 5px;
  padding-inline: 6px;
  font-family: var(--mono);
  font-size: .8rem;
  color: var(--text2);
  unicode-bidi: isolate;
}

.lbv-menu-wrap { position: relative; }
.lbv-menu {
  position: absolute; bottom: calc(100% + 6px); right: 0;
  min-inline-size: 110px;
  padding: 6px;
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  background: var(--bg2);
  box-shadow: var(--shadow);
  z-index: 3;
}
.lbv-menu[hidden] { display: none; }
.lbv-menu-item {
  display: block; inline-size: 100%;
  min-block-size: 40px;
  padding-inline: 12px;
  border: 0; border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-family: var(--mono); font-size: .82rem;
  text-align: start;
  cursor: pointer;
}
.lbv-menu-item:hover { background: var(--bg3); }
.lbv-menu-item[aria-checked="true"] { color: var(--accent); font-weight: 600; }
.lbv-menu-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* ── small screens ──────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .lbv { border-radius: var(--radius); }
  .lbv-bar { padding: 8px 8px 10px; }
  .lbv-vol-range { display: none; }        /* the mute button remains */
  .lbv-hover { display: none !important; } /* scrub preview is desktop-only */
  .lbv-btn { min-width: 40px; padding: 0 6px; }
  .lbv-bigplay { inline-size: 56px; block-size: 56px; font-size: 1.2rem; }
}

/* ── reduced motion ─────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .lbv-bigplay, .lbv-osd, .lbv-bar, .lbv-btn { transition: none; }
  .lbv.is-idle .lbv-bar { opacity: 1; }    /* controls never fade away */
  .lbv-spinner { animation: none; border-top-color: var(--border2); }
}

/* ── fullscreen ─────────────────────────────────────────────────────────── */
.lbv:fullscreen { border: 0; border-radius: 0; display: flex; flex-direction: column; }
.lbv:fullscreen .lbv-stage { flex: 1 1 auto; aspect-ratio: auto; }
