/* ==========================================================================
   video-page.css — video detail page, laid out like the book and audio pages:
   the details card (material-page.css) holds the player under the languages
   (.mp-media), then the related videos. Shared player pieces:
   media-player.css.
   ========================================================================== */

/* The player controls run left-to-right in both page directions, so the LTR
   build (src/build.js → rtlcss) leaves this whole file as it is. */
/*rtl:begin:ignore*/

/* --------------------------------------------------------------------------
   Blue panel around the picture (same blue as the audio player panel), so the
   video stands apart from the white card. On wide but short screens it
   narrows (centred) so the whole 16:9 picture fits the window height.
   -------------------------------------------------------------------------- */
.vp-panel {
  width: 100%;
  max-width: max(592px, calc((100vh - 172px) * 16 / 9 + 32px));
  margin: 0 auto;
  box-sizing: border-box;
  padding: 16px;
  border-radius: 24px;
  background:
    radial-gradient(60% 90% at 50% 0%, rgba(255, 255, 255, .12) 0%, rgba(255, 255, 255, 0) 70%),
    var(--color-blue-500);
  box-shadow: 0 30px 60px -40px rgba(26, 43, 69, .8);
}

/* Stage: the 16:9 picture */
.vp-stage {
  border-radius: 14px;
  overflow: hidden;
  background: var(--color-navy-950);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .14);
}

.mpl--video {
  --bar-h: 62px;               /* height of the control bar (timeline + buttons) */
  container-type: inline-size; /* the control bar adapts to the player's own width */
  aspect-ratio: 16 / 9;
  background: var(--color-navy-950);
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
}

.mpl--video .mpl__media {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: var(--color-navy-950);
}

/* clickable picture (play / pause, double-click = full screen) */
.mpl--video .mpl__surface {
  position: absolute;
  inset: 0;
  cursor: pointer;
}

/* Dark layer: whenever the video isn't playing (before the first play, paused,
   ended) the picture is tinted and the play button shows in the middle;
   it fades in / out with play and pause */
.mpl--video::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 50% 50%, rgba(10, 18, 32, .6) 0%, rgba(10, 18, 32, .42) 40%, rgba(10, 18, 32, .32) 100%);
  opacity: 0;
  transition: opacity .3s ease;
}

.mpl--video:not(.is-playing)::before {
  opacity: 1;
}

/* Short, eased shade along the bottom edge, behind the control bar only
   (none before the first play; fades out with the bar while idle) */
.mpl--video::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(0deg,
    rgba(10, 18, 32, .7) 0,
    rgba(10, 18, 32, .42) min(44px, 16%),
    rgba(10, 18, 32, .14) min(92px, 30%),
    rgba(10, 18, 32, 0) min(136px, 44%));
  transition: opacity .35s ease;
}

.mpl--video:not(.is-started)::after {
  opacity: 0;
}

/* Big play button: whenever the video isn't playing (on the dark layer) */
.mpl__big {
  position: absolute;
  z-index: 2;
  top: 50%;
  left: 50%;
  width: 96px;
  height: 96px;
  margin: -48px 0 0 -48px;
  padding: 0 0 0 6px; /* optical centre of the triangle */
  box-sizing: border-box;
  border: 0;
  border-radius: 50%;
  background: var(--mpl-gold);
  color: var(--mpl-navy);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 0 0 8px rgba(255, 255, 255, .28), 0 20px 44px -10px rgba(0, 0, 0, .7);
  transition: background .2s ease, box-shadow .2s ease, opacity .3s ease, visibility .3s;
}

.mpl__big svg {
  width: 40px;
  height: 40px;
}

.mpl__big:hover {
  background: var(--mpl-gold-hover);
  box-shadow: 0 0 0 8px rgba(255, 255, 255, .4), 0 20px 44px -10px rgba(0, 0, 0, .7);
}

.mpl--video.is-playing .mpl__big {
  opacity: 0;
  visibility: hidden;
}

.mpl--video .mpl__spin {
  position: absolute;
  z-index: 2;
  top: 50%;
  left: 50%;
  width: 52px;
  height: 52px;
  margin: -26px 0 0 -26px;
  box-sizing: border-box;
}

.mpl--video .mpl__err {
  position: absolute;
  z-index: 3;
  top: 50%;
  left: 50%;
  width: min(420px, calc(100% - 32px));
  box-sizing: border-box;
  transform: translate(-50%, -50%);
}

.mpl--video.is-error .mpl__big {
  display: none;
}

/* --------------------------------------------------------------------------
   Control bar over the bottom of the picture
   -------------------------------------------------------------------------- */
.mpl--video .mpl__ctrl {
  position: absolute;
  z-index: 2;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: opacity .3s ease, transform .3s ease;
}

/* hidden before the first play (the big button invites it) and while idle */
.mpl--video:not(.is-started) .mpl__ctrl,
.mpl--video.is-idle .mpl__ctrl {
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
}

.mpl--video.is-idle {
  cursor: none;
}

.mpl--video.is-idle .mpl__surface {
  cursor: none;
}

.mpl--video.is-idle::after {
  opacity: 0;
}

.mpl--video .mpl__row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.mpl--video .mpl__time {
  margin-left: 8px;
  color: rgba(255, 255, 255, .92);
}

.mpl__time-sep {
  margin: 0 6px;
  opacity: .6;
}

.mpl__gap {
  flex: 1;
}

.mpl--video .mpl__speed {
  margin-right: 4px;
}

/* touch screens: the timeline is taller (media-player.css) */
@media (pointer: coarse) {
  .mpl--video {
    --bar-h: 72px;
  }
}

/* full screen on the whole player: the picture fills the screen */
.mpl--video.is-fs,
.mpl--video:fullscreen {
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 640px) {
  .vp-panel {
    padding: 10px;
    border-radius: 20px;
  }

  .vp-stage {
    border-radius: 12px;
  }

  .mpl__big {
    width: 72px;
    height: 72px;
    margin: -36px 0 0 -36px;
    box-shadow: 0 0 0 6px rgba(255, 255, 255, .28), 0 14px 30px -10px rgba(0, 0, 0, .7);
  }

  .mpl__big svg {
    width: 30px;
    height: 30px;
  }

  .mpl--video .mpl__ctrl {
    padding: 0 10px 6px;
  }

  .mpl--video .mpl__btn {
    width: 38px;
    height: 38px;
  }

  .mpl--video .mpl__time {
    margin-left: 4px;
    font-size: 12.5px;
  }

  .mpl--video .mpl__speed {
    min-width: 44px;
    padding: 0 8px;
    font-size: 12.5px;
  }
}

/* a narrow player (phones; not in full screen) drops ±10 s so the control bar
   always fits inside the picture (the timeline still seeks) */
@container (max-width: 400px) {
  .mpl--video .mpl__skip {
    display: none;
  }

  .mpl--video .mpl__big {
    width: 60px;
    height: 60px;
    margin: -30px 0 0 -30px;
  }

  .mpl--video .mpl__big svg {
    width: 26px;
    height: 26px;
  }

  /* paused with the control bar showing: the button centres in the picture
     above the bar instead of touching the timeline */
  .mpl--video.is-started .mpl__big {
    top: calc((100% - var(--bar-h)) / 2);
  }
}

/* very narrow player (small phones): no mute button — the phone's own
   buttons set the volume — and slightly smaller controls */
@container (max-width: 300px) {
  .mpl--video .mpl__vol {
    display: none;
  }

  .mpl--video .mpl__ctrl {
    padding: 0 8px 4px;
  }

  .mpl--video .mpl__btn {
    width: 34px;
    height: 34px;
  }

  .mpl--video .mpl__speed {
    min-width: 40px;
    padding: 0 6px;
  }

  .mpl--video .mpl__time {
    font-size: 12px;
  }

  .mpl--video .mpl__big {
    width: 52px;
    height: 52px;
    margin: -26px 0 0 -26px;
  }

  .mpl--video .mpl__big svg {
    width: 22px;
    height: 22px;
  }
}

/* smallest phones (320px screens) */
@container (max-width: 240px) {
  .mpl--video .mpl__big {
    width: 44px;
    height: 44px;
    margin: -22px 0 0 -22px;
  }

  .mpl--video .mpl__big svg {
    width: 20px;
    height: 20px;
  }

  .mpl--video.is-started .mpl__big {
    top: calc((100% - var(--bar-h) - 8px) / 2);
  }
}

@media (prefers-reduced-motion: reduce) {
  .mpl--video .mpl__ctrl,
  .mpl--video::before,
  .mpl--video::after,
  .mpl__big {
    transition: none;
  }
}
/*rtl:end:ignore*/
