/*
 * FFB video player: pairs with videoplayer.js.
 *
 * Theme it by setting any --fvp-* property on the player or on an ancestor;
 * the fallbacks below are FFB's colours. The player is a size container
 * (inline axis), so give it a width from its parent, as any block or grid
 * item gets: an auto-width inline-block or flex item would collapse.
 *
 *   --fvp-accent, --fvp-accent-hover, --fvp-accent-ink   green, its hover, text on it
 *   --fvp-bg                                             behind the picture
 *   --fvp-menu-bg, --fvp-menu-text, --fvp-menu-muted     settings menu
 *   --fvp-hover, --fvp-track, --fvp-buffer, --fvp-focus  controls
 *   --fvp-caption-bg, --fvp-shade                        caption box, bar gradient
 *   --fvp-font, --fvp-ui-font, --fvp-radius
 */

.fvp {
  --_accent: var(--fvp-accent, #19ca8f);
  --_accent-hover: var(--fvp-accent-hover, #9fe9cc);
  --_accent-ink: var(--fvp-accent-ink, #04261b);
  --_bg: var(--fvp-bg, #0f2a3f);
  --_menu-bg: var(--fvp-menu-bg, rgba(15, 42, 63, 0.96));
  --_menu-text: var(--fvp-menu-text, #fff);
  --_menu-muted: var(--fvp-menu-muted, #93a8b9);
  --_hover: var(--fvp-hover, rgba(255, 255, 255, 0.14));
  --_track: var(--fvp-track, rgba(255, 255, 255, 0.35));
  --_buffer: var(--fvp-buffer, rgba(255, 255, 255, 0.55));
  --_focus: var(--fvp-focus, #19ca8f);
  --_font: var(--fvp-font, system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif);
  --_ui-font: var(--fvp-ui-font, var(--_font));

  position: relative;
  overflow: hidden;
  isolation: isolate;
  container: fvp / inline-size;
  border-radius: var(--fvp-radius, 0);
  background: var(--_bg);
  color: #fff;
  font-family: var(--_font);
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
}

.fvp [hidden] {
  display: none !important;
}

.fvp:focus {
  outline: none;
}

.fvp :focus-visible {
  outline: 2px solid var(--_focus);
  outline-offset: 2px;
}

.fvp > video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.fvp--hide {
  cursor: none;
}

.fvp-icon {
  display: block;
  width: 22px;
  height: 22px;
}

/* ---- Buttons ----------------------------------------------------------- */

.fvp-btn {
  display: grid;
  flex: none;
  place-items: center;
  width: 36px;
  height: 36px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.fvp-btn:hover {
  background: var(--_hover);
}

.fvp-cc[aria-pressed='true'] {
  background: #fff;
  color: var(--_bg);
}

.fvp-pip:hover,
.fvp-gear[aria-expanded='true'] {
  background: var(--_accent);
  color: var(--_accent-ink);
}

.fvp-big {
  position: absolute;
  inset: 0;
  z-index: 3;
  width: 72px;
  height: 72px;
  margin: auto;
  border-radius: 50%;
  background: var(--_accent);
  color: var(--_accent-ink);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.fvp-big:hover {
  background: var(--_accent-hover);
  box-shadow: 0 0 18px rgba(25, 202, 143, 0.45), 0 0 40px rgba(25, 202, 143, 0.25);
}

.fvp-big .fvp-icon {
  width: 30px;
  height: 30px;
  margin-left: 4px;
}

/* ---- Control bar ------------------------------------------------------- */

.fvp-bar {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: clamp(4px, 1.6cqi, 18px);
  padding: 28px clamp(10px, 2cqi, 20px) 14px;
  background: linear-gradient(180deg, rgba(6, 20, 32, 0), var(--fvp-shade, rgba(6, 20, 32, 0.78)) 70%);
  transition: opacity 0.25s ease;
}

.fvp:not(.fvp--started) .fvp-bar {
  visibility: hidden;
  opacity: 0;
}

.fvp--hide .fvp-bar {
  opacity: 0;
  pointer-events: none;
}

.fvp-seek {
  position: relative;
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  min-width: 48px;
}

.fvp-seek__tip {
  position: absolute;
  bottom: calc(100% + 4px);
  left: calc(var(--fvp-x, 0) * 100%);
  padding: 3px 7px;
  border-radius: 4px;
  background: var(--_menu-bg);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  transform: translateX(-50%);
  pointer-events: none;
}

.fvp-time {
  flex: none;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.fvp-vol {
  display: flex;
  flex: none;
  align-items: center;
  gap: 6px;
}

.fvp-vol .fvp-range {
  width: 90px;
}

/* ---- Sliders (seek and volume) ----------------------------------------- */

/* The fill is a gradient on the track: played (--fvp-pct), then buffered
   (--fvp-buf, seek only), then the bare track. Both set by the script. */
.fvp-range {
  display: block;
  width: 100%;
  height: 24px;
  margin: 0;
  padding: 0;
  border-radius: 4px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.fvp-range::-webkit-slider-runnable-track {
  height: 5px;
  border-radius: 999px;
  background: linear-gradient(to right,
    var(--_accent) var(--fvp-pct, 0%),
    var(--_buffer) var(--fvp-pct, 0%) var(--fvp-buf, 0%),
    var(--_track) 0);
}

.fvp-range::-moz-range-track {
  height: 5px;
  border-radius: 999px;
  background: linear-gradient(to right,
    var(--_accent) var(--fvp-pct, 0%),
    var(--_buffer) var(--fvp-pct, 0%) var(--fvp-buf, 0%),
    var(--_track) 0);
}

.fvp-range::-webkit-slider-thumb {
  width: 16px;
  height: 16px;
  margin-top: -5.5px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  -webkit-appearance: none;
  appearance: none;
}

.fvp-range::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

/* ---- Settings menu ----------------------------------------------------- */

.fvp-settings {
  position: relative;
  flex: none;
}

.fvp-menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 10px);
  min-width: 180px;
  padding: 6px;
  overflow-y: auto;
  border-radius: 10px;
  background: var(--_menu-bg);
  box-shadow: 0 12px 32px -12px rgba(0, 0, 0, 0.5);
  color: var(--_menu-text);
}

.fvp-menu__item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin: 0;
  padding: 8px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  font-family: var(--_ui-font);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}

.fvp-menu__item:hover,
.fvp-menu__item:focus-visible {
  background: rgba(255, 255, 255, 0.08);
}

.fvp-menu__item .fvp-icon {
  flex: none;
  width: 16px;
  height: 16px;
}

.fvp-menu__name {
  flex: 1 1 auto;
}

.fvp-menu__value {
  padding-left: 16px;
  color: var(--_menu-muted);
  font-weight: 500;
}

.fvp-menu__row .fvp-icon {
  color: var(--_menu-muted);
}

.fvp-menu__back {
  margin-bottom: 4px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px 6px 0 0;
  color: var(--_menu-muted);
  font-family: var(--_font);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.fvp-menu__option {
  padding-left: 32px;
}

.fvp-menu__option[aria-checked='true'] {
  color: var(--_accent);
}

/* ---- Captions, spinner, error ------------------------------------------ */

/* Drawn by the script from the active cue, above the bar while it shows. */
.fvp-captions {
  position: absolute;
  right: 0;
  bottom: clamp(70px, 9%, 96px);
  left: 0;
  z-index: 2;
  width: fit-content;
  max-width: min(80%, 760px);
  margin-inline: auto;
  padding: 6px 14px 8px;
  border-radius: 6px;
  background: var(--fvp-caption-bg, rgba(6, 20, 32, 0.82));
  font-size: clamp(15px, 1.6cqi, 22px);
  font-weight: 500;
  line-height: 1.4;
  text-align: center;
  white-space: pre-line;
  pointer-events: none;
  transition: bottom 0.25s ease;
}

.fvp--hide .fvp-captions,
.fvp:not(.fvp--started) .fvp-captions {
  bottom: 5%;
}

.fvp--fs .fvp-captions {
  font-size: clamp(18px, 2cqi, 36px);
}

.fvp-spinner {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 44px;
  height: 44px;
  margin: auto;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: fvp-spin 0.9s linear infinite;
  pointer-events: none;
}

@keyframes fvp-spin {
  to {
    transform: rotate(360deg);
  }
}

.fvp-error {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(6, 20, 32, 0.85);
  font-size: 15px;
  text-align: center;
}

/* ---- Full screen ------------------------------------------------------- */

.fvp--fs {
  border-radius: 0;
}

/* ---- Narrow players ---------------------------------------------------- */

@container fvp (max-width: 640px) {
  .fvp-time,
  .fvp-vol .fvp-range {
    display: none;
  }
}

@container fvp (max-width: 400px) {
  .fvp-pip {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .fvp,
  .fvp * {
    transition: none !important;
  }

  .fvp-spinner {
    animation-duration: 2s;
  }
}
