/* AIDC docs video player — companion sheet for assets/js/docs-video.js.
   Page palette comes from site.css tokens. The --dv-* values below are
   overlay colours that sit on top of video frames, not palette entries: a
   control bar over moving pixels has to read the same in either theme. */

.dv {
  --dv-scrim: rgba(0, 0, 0, 0.55);
  --dv-scrim-hi: rgba(0, 0, 0, 0.72);
  --dv-on: #ffffff;
  --dv-track: rgba(255, 255, 255, 0.3);
  --dv-hover: rgba(255, 255, 255, 0.16);
  margin: 1.6rem 0 1.9rem;
}
/* the player toggles [hidden] on grid/flex boxes, which would otherwise win */
.dv [hidden] { display: none; }

.dv-stage {
  position: relative;
  aspect-ratio: var(--dv-ratio, 16 / 9);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.dv-stage.is-idle { cursor: none; }

.dv-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: var(--bg-3);
  display: block;
  -webkit-user-select: none;
  user-select: none;
}

/* ---------- centre play affordance ---------- */
.dv-big {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 60px;
  height: 60px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: var(--radius-full);
  background: var(--dv-scrim);
  color: var(--dv-on);
  cursor: pointer;
  transition: background 0.15s var(--ease);
}
.dv-big:hover { background: var(--dv-scrim-hi); }
.dv-big svg { width: 26px; height: 26px; margin-left: 3px; }
.dv-stage.is-dead .dv-big { display: none; }

/* ---------- buffering ----------
   Driven by the media's own waiting/playing/canplay, so it appears on either
   lane and only while playback is actually starved. */
.dv-load {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 60px;
  height: 60px;
  display: grid;
  place-items: center;
  /* a frame can be any colour, white whiteboards included, so the ring gets the
     same scrim disc .dv-big sits on rather than trusting the video behind it */
  border-radius: var(--radius-full);
  background: var(--dv-scrim);
  pointer-events: none;
}
.dv-ring {
  width: 26px;
  height: 26px;
  border: 2px solid var(--dv-track);
  border-top-color: var(--dv-on);
  border-radius: var(--radius-full);
  animation: dv-spin 0.8s linear infinite;
}
@keyframes dv-spin { to { transform: rotate(360deg); } }
/* spoken by role="status"; the ring carries it visually */
.dv-load-t {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------- control bar ---------- */
.dv-ctl {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 1.6rem 0.6rem 0.5rem;
  background: linear-gradient(to top, var(--dv-scrim), transparent);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s var(--ease);
}
.dv-stage:hover .dv-ctl,
.dv-stage:focus-within .dv-ctl,
.dv-stage.is-paused .dv-ctl {
  opacity: 1;
  pointer-events: auto;
}
.dv-stage.is-idle .dv-ctl { opacity: 0; pointer-events: none; }
.dv-stage.is-idle:focus-within .dv-ctl { opacity: 1; pointer-events: auto; }

.dv-btn {
  flex: none;
  width: 32px;
  height: 32px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--dv-on);
  cursor: pointer;
  transition: background 0.15s var(--ease);
}
.dv-btn:hover { background: var(--dv-hover); }
.dv-btn svg { width: 18px; height: 18px; }

.dv-time {
  flex: none;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-variant-numeric: tabular-nums;
  color: var(--dv-on);
  padding: 0 0.15rem;
  white-space: nowrap;
}

/* ---------- seek bar (native range: keyboard + drag for free) ---------- */
.dv-seek {
  flex: 1 1 auto;
  min-width: 0;
  height: 18px;
  margin: 0;
  background: transparent;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
.dv-seek::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: var(--radius-full);
  background: linear-gradient(
    to right,
    var(--signal) 0 calc(var(--dv-p, 0) * 1%),
    var(--dv-track) calc(var(--dv-p, 0) * 1%) 100%
  );
}
.dv-seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  margin-top: -4px;
  border: 0;
  border-radius: var(--radius-full);
  background: var(--dv-on);
}
.dv-seek::-moz-range-track {
  height: 4px;
  border-radius: var(--radius-full);
  background: var(--dv-track);
}
.dv-seek::-moz-range-progress {
  height: 4px;
  border-radius: var(--radius-full);
  background: var(--signal);
}
/* ---------- hover time ---------- */
.dv-tip {
  position: absolute;
  bottom: 2.2rem;
  transform: translateX(-50%);
  padding: 0.1rem 0.35rem;
  border-radius: var(--radius);
  background: var(--dv-scrim-hi);
  color: var(--dv-on);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  pointer-events: none;
}

.dv-seek::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: 0;
  border-radius: var(--radius-full);
  background: var(--dv-on);
}

/* ---------- degraded state ---------- */
.dv-msg {
  position: absolute;
  inset: 0;
  margin: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 0.7rem;
  padding: 1.2rem;
  text-align: center;
  background: var(--bg-2);
  color: var(--mut);
  font-size: 0.88rem;
}
/* Transient failures keep a way back. The button sits on the page background,
   not on video frames, so it takes site.css tokens rather than the --dv-*
   overlay colours the control bar uses. */
.dv-retry {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 0.82rem;
  padding: 0.35rem 0.85rem;
  cursor: pointer;
  transition: background 0.15s var(--ease);
}
.dv-retry:hover { background: var(--bg-3); color: var(--ink-strong); }

.dv figcaption {
  margin-top: 0.6rem;
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--mut);
}

/* ---------- narrow ---------- */
@media (max-width: 560px) {
  .dv-ctl { gap: 0.25rem; padding: 1.2rem 0.35rem 0.35rem; }
  .dv-btn { width: 28px; height: 28px; }
  .dv-btn svg { width: 16px; height: 16px; }
  .dv-time { font-size: 0.68rem; }
  .dv-big { width: 48px; height: 48px; }
  .dv-big svg { width: 20px; height: 20px; }
  .dv-load { width: 48px; height: 48px; }
  .dv-ring { width: 22px; height: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  .dv-ctl, .dv-btn, .dv-big { transition: none; }
  /* no spinner to watch, so the label carries the state instead */
  .dv-ring { display: none; }
  .dv-load { width: auto; height: auto; background: transparent; }
  .dv-load-t {
    position: static;
    width: auto;
    height: auto;
    clip-path: none;
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius);
    background: var(--dv-scrim);
    color: var(--dv-on);
    font-size: 0.78rem;
  }
  .dv-stage.is-idle .dv-ctl { opacity: 1; pointer-events: auto; }
  .dv-stage.is-idle { cursor: auto; }
}
