/*
 * Video grid + morph player — /media/video. "Mystery card" expand effect
 * adapted from media/audio/dist and generalized to any count: cards stack at
 * the stage center with only the featured card visible; hovering the stage
 * expands the rest into a computed grid, collapsing on mouse-leave. Positions
 * (--cx/--cy), the card size, and stagger delays are set by assets/js/video.js.
 * The player hosts a YouTube embed. Mirrors assets/css/audio.css (no equalizer,
 * 16:9 player frame). Titles stay horizontally centered.
 */

:root {
  /* The reference's CustomEase "0.86,0,0.07,1" as a cubic-bezier. */
  --video-ease: cubic-bezier(0.86, 0, 0.07, 1);
  --video-dur: 0.64s;
}

.videos {
  --nav-h: 100px;
  position: relative;
  z-index: 10;
  min-height: calc(100vh - var(--nav-h));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 40px 20px var(--nav-h);
}
.videos-empty {
  text-align: center;
  font-family: var(--font-brand);
  color: var(--color-text-muted);
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* ---- Stage: a relatively-positioned box sized to the full grid ---- */
.videos-stage {
  position: relative;
  margin: 0 auto;
}

/* ---- Card ---- */
.vcard {
  position: absolute;
  width: var(--card-size, 220px);
  height: var(--card-size, 220px);
  /* Collapsed: stacked at the stage center, hidden. */
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0.6);
  opacity: 0;
  visibility: hidden;
  padding: 0;
  border: 1px solid var(--color-border-default);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  background: linear-gradient(160deg, rgba(20, 28, 48, 0.72), rgba(8, 12, 24, 0.82));
  box-shadow:
    0 18px 44px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(255, 255, 255, 0.02);
  transition:
    left var(--video-dur) var(--video-ease),
    top var(--video-dur) var(--video-ease),
    transform var(--video-dur) var(--video-ease),
    opacity var(--video-dur) var(--video-ease),
    border-color 160ms ease,
    box-shadow 160ms ease;
  transition-delay: var(--delay, 0s);
}

/* Featured card: visible at rest, centered in the stage (viewport center).
   When the grid expands it moves to its own cell — the higher-specificity
   .is-expanded / .is-static rule below overrides these left/top. */
.vcard.is-featured {
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
  visibility: visible;
  z-index: 10;
  transition-delay: 0s;
}

/* Expanded (or static): every card flies to its cell and shows. */
.videos-stage.is-expanded .vcard,
.videos-stage.is-static .vcard {
  left: var(--cx, 50%);
  top: var(--cy, 50%);
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
  visibility: visible;
}

.vcard:hover,
.vcard:focus-visible {
  outline: none;
  border-color: rgba(var(--color-accent-rgb), 0.55);
  box-shadow: 0 22px 54px rgba(0, 0, 0, 0.55), 0 0 22px rgba(203, 62, 212, 0.22);
}

/* A card whose video has no YouTube link yet: dimmed, not clickable. */
.vcard--nolink { cursor: default; opacity: 0.55; }
.vcard__nolink {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 12px;
  z-index: 3;
  font-family: var(--font-brand);
  font-size: 11px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--color-text-muted);
  text-align: center;
  opacity: 0;
  transition: opacity 220ms ease;
}
.vcard--nolink:hover .vcard__nolink,
.vcard--nolink:focus-visible .vcard__nolink { opacity: 1; }

.vcard__scrim {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(to top, rgba(4, 8, 16, 0.85) 0%, rgba(4, 8, 16, 0.15) 55%, rgba(4, 8, 16, 0) 100%);
}

/* Title: always horizontally centered. Centered at rest; drops to the
   bottom-center on hover so the play button clears it (never to a corner). */
.vcard__name {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  z-index: 3;
  transform: translateY(-50%);
  padding: 0 14px;
  font-family: var(--font-brand);
  font-size: clamp(12px, 1.4vw, 16px);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--color-text-primary);
  text-align: center;
  transition: top 260ms ease, transform 260ms ease;
}
.vcard:hover .vcard__name,
.vcard:focus-visible .vcard__name {
  top: auto;
  bottom: 14px;
  transform: none;
}
/* No-link cards keep the title centered (the hint uses the bottom slot). */
.vcard--nolink:hover .vcard__name,
.vcard--nolink:focus-visible .vcard__name {
  top: 50%;
  bottom: auto;
  transform: translateY(-50%);
}

/* Align the injected nav-fx drawn border to the card edge. */
.vcard .nav-fx { top: 0; left: 0; width: 100%; height: 100%; z-index: 2; }
.vcard .nav-fx-rect { rx: 12px; ry: 12px; }

/* Morph play button, centered, appears on hover. */
.vcard__play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  z-index: 4;
  width: clamp(52px, 34%, 84px);
  aspect-ratio: 1;
  opacity: 0;
  transition: opacity 220ms ease, transform 220ms ease;
}
.vcard:hover .vcard__play,
.vcard:focus-visible .vcard__play {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* ---- The rings + triangle play button ---- */
.vplay {
  width: 100%;
  height: 100%;
  overflow: visible;
  display: block;
  filter: drop-shadow(0 0 10px rgba(203, 62, 212, 0.35));
}
.vplay__ring {
  fill: none;
  stroke: rgba(203, 62, 212, 0.7);
  stroke-width: 3;
  transform-origin: center;
}
.vplay__ring--2 { stroke: rgba(70, 156, 243, 0.6); }
.vplay__tri {
  fill: none;
  stroke: url(#vplayStroke);
  stroke-width: 6;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.vcard:hover .vplay__ring--1 { animation: vplaySpin 6s linear infinite; }
.vcard:hover .vplay__ring--2 { animation: vplaySpin 8s linear infinite reverse; }
@keyframes vplaySpin { to { transform: rotate(360deg); } }

/* ---- Player (morph open, hosts the YouTube embed) ---- */
.vplayer {
  position: fixed;
  inset: 0;
  z-index: 60; /* above the fixed nav (10) */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}
.vplayer[hidden] { display: none !important; }
body.vplayer-open { overflow: hidden; }
.vplayer__backdrop {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(4, 8, 16, 0.85) 0%, rgba(4, 8, 16, 0.96) 100%);
  opacity: 0;
  transition: opacity 380ms ease;
}
.vplayer.is-open .vplayer__backdrop { opacity: 1; }

.vplayer__stage {
  position: relative;
  transform: scale(0.55);
  opacity: 0;
  transition: transform 440ms cubic-bezier(0.2, 0.8, 0.2, 1), opacity 320ms ease;
}
.vplayer.is-open .vplayer__stage { transform: scale(1); opacity: 1; }

/* 16:9 frame for the YouTube embed. */
.vplayer__frame {
  position: relative;
  width: min(92vw, 1120px);
  aspect-ratio: 16 / 9;
  max-height: 78vh;
  border: 1px solid var(--color-border-strong);
  border-radius: 14px;
  overflow: hidden;
  background: #000;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.7);
}
.vplayer__embed {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

/* ---- Dual-mode toggling ---- */
.vplayer--youtube .vplayer__video,
.vplayer--youtube .vplayer__big,
.vplayer--youtube .vplayer__bar { display: none; }
.vplayer--local .vplayer__embed { display: none; }

/* ---- Local themed player ---- */
.vplayer__video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  display: block;
}

/* Big center play/pause overlay: shown while paused. */
.vplayer__big {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: clamp(64px, 12vh, 104px);
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  opacity: 1;
  transition: opacity 220ms ease;
}
.vplayer.is-playing .vplayer__big { opacity: 0; pointer-events: none; }

/* Control bar: visible while paused; auto-hides during play unless hovered. */
.vplayer__bar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: linear-gradient(to top, rgba(4, 8, 16, 0.88), rgba(4, 8, 16, 0));
  opacity: 1;
  transition: opacity 240ms ease;
}
.vplayer--local.is-playing .vplayer__bar { opacity: 0; }
.vplayer--local.is-playing .vplayer__frame:hover .vplayer__bar,
.vplayer--local.is-playing .vplayer__bar:focus-within { opacity: 1; }

.vplayer__bar button {
  flex: 0 0 auto;
  width: 34px; height: 34px;
  padding: 6px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--color-text-primary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 140ms ease;
}
.vplayer__bar button:hover,
.vplayer__bar button:focus-visible { outline: none; color: #cb3ed4; }
.vplayer__bar svg {
  width: 100%; height: 100%;
  fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
/* Play/pause + mute icon swaps. */
.vplayer__pp .ic-play, .vplayer__pp .ic-pause { fill: currentColor; stroke: none; }
.vplayer__pp .ic-pause { display: none; }
.vplayer.is-playing .vplayer__pp .ic-play { display: none; }
.vplayer.is-playing .vplayer__pp .ic-pause { display: inline; }
.vplayer__mute .ic-mute { display: none; }
.vplayer.is-muted .vplayer__mute .ic-vol { display: none; }
.vplayer.is-muted .vplayer__mute .ic-mute { display: inline; }

.vplayer__t {
  flex: 0 0 auto;
  min-width: 42px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--color-text-primary);
  text-align: center;
}

/* Scrub bar. */
.vplayer__scrub {
  position: relative;
  flex: 1 1 auto;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  cursor: pointer;
  touch-action: none;
}
.vplayer__buffered,
.vplayer__played {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 0;
  border-radius: 999px;
}
.vplayer__buffered { background: rgba(255, 255, 255, 0.28); }
.vplayer__played { background: linear-gradient(90deg, #469cf3, #cb3ed4); }
.vplayer__handle {
  position: absolute;
  right: -7px; top: 50%;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #fff;
  transform: translateY(-50%);
  box-shadow: 0 0 8px rgba(203, 62, 212, 0.6);
  opacity: 0;
  transition: opacity 160ms ease;
}
.vplayer__scrub:hover .vplayer__handle,
.vplayer__scrub:focus-visible .vplayer__handle { opacity: 1; }
.vplayer__scrub:focus-visible { outline: 2px solid rgba(203, 62, 212, 0.6); outline-offset: 4px; }

.vplayer__close {
  position: absolute;
  top: -14px;
  right: -14px;
  z-index: 4;
  width: 46px;
  height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--color-border-default);
  border-radius: 999px;
  background: rgba(12, 20, 36, 0.85);
  color: var(--color-text-primary);
  cursor: pointer;
  transition: border-color 140ms ease, box-shadow 140ms ease, color 140ms ease;
}
.vplayer__close svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
.vplayer__close:hover,
.vplayer__close:focus-visible {
  outline: none;
  color: #cb3ed4;
  border-color: rgba(var(--color-accent-rgb), 0.55);
  box-shadow: 0 0 0 2px rgba(var(--color-accent-rgb), 0.18), 0 0 18px rgba(203, 62, 212, 0.3);
}

/* Close (X) under the grid — returns to /media with the warp. */
.videos-actions { display: flex; justify-content: center; }
.videos-close {
  display: inline-flex; align-items: center; justify-content: center;
  width: 48px; height: 48px;
  border: 1px solid var(--color-border-default);
  border-radius: 999px;
  background: rgba(12, 20, 36, 0.6);
  color: var(--color-text-primary);
  text-decoration: none;
  transition: border-color 140ms ease, box-shadow 140ms ease, color 140ms ease;
}
.videos-close svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
.videos-close:hover,
.videos-close:focus-visible {
  outline: none; color: #cb3ed4;
  border-color: rgba(var(--color-accent-rgb), 0.55);
  box-shadow: 0 0 0 2px rgba(var(--color-accent-rgb), 0.18), 0 0 18px rgba(203, 62, 212, 0.3);
}

@media (prefers-reduced-motion: reduce) {
  .vcard { transition: opacity 200ms ease !important; transition-delay: 0s !important; }
  .vplay__ring--1, .vplay__ring--2 { animation: none !important; }
  .vplayer__stage { transition: opacity 200ms ease; transform: none; }
}

@media (max-width: 768px) {
  .videos { --nav-h: 76px; }
  .vplayer__close { top: 8px; right: 8px; }
}
