/* ==========================================================================
   Video module — cinematic facade player + teaser loops
   Depends on tokens from main.css (--accent, --bg-elev, --ease, --mono …)
   ========================================================================== */

/* ---------- Facade / hero player ---------- */

.ep-video {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-md, 12px);
  background: var(--bg-elev);
  cursor: pointer;
}

/* Aspect ratio is carried by the wrapper so poster, video and iframe
   all share the same box. Existing .video-frame-- classes keep working. */
.ep-video                    { aspect-ratio: 16 / 9; }
.ep-video.video-frame--21-9  { aspect-ratio: 21 / 9; }
.ep-video.video-frame--4-3   { aspect-ratio: 4 / 3; }
.ep-video.video-frame--1-1   { aspect-ratio: 1 / 1; max-width: 800px; margin-left: auto; margin-right: auto; }
.ep-video.video-frame--9-16  { aspect-ratio: 9 / 16; max-width: 500px; margin-left: auto; margin-right: auto; }

.ep-video iframe,
.ep-video video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.ep-video__poster,
.ep-video__poster img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.ep-video__poster img {
  object-fit: cover;
  transition: transform 1.2s var(--ease), filter .6s var(--ease);
}
.ep-video:hover .ep-video__poster img {
  transform: scale(1.03);
}
.ep-video__poster::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,.45), transparent 40%);
}
.ep-video__poster--empty {
  background:
    radial-gradient(ellipse at 70% 30%, rgba(255,117,68,.18), transparent 60%),
    var(--bg-elev);
}

/* Play button — glass pill, morphs to accent on hover (matches carousel arrow) */
.ep-video__play {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 100%;
}
.ep-video__play-btn {
  width: clamp(64px, 8vw, 92px);
  height: clamp(64px, 8vw, 92px);
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.28);
  backdrop-filter: blur(16px) saturate(150%);
  -webkit-backdrop-filter: blur(16px) saturate(150%);
  transition: transform .4s var(--ease), background .3s var(--ease), border-color .3s var(--ease);
}
.ep-video__play-btn svg { margin-left: 4px; }
.ep-video:hover .ep-video__play-btn,
.ep-video__play:focus-visible .ep-video__play-btn {
  transform: scale(1.1);
  background: var(--accent);
  border-color: var(--accent);
}
.ep-video__play:focus-visible { outline: none; }

/* Meta chip bottom-left */
.ep-video__meta {
  position: absolute;
  left: 20px;
  bottom: 16px;
  z-index: 3;
  display: flex;
  gap: 12px;
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 11px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: rgba(255,255,255,.85);
}
.ep-video__duration { color: rgba(255,255,255,.55); }

/* GDPR consent note — quiet, bottom-right */
.ep-video__consent {
  position: absolute;
  right: 20px;
  bottom: 16px;
  z-index: 3;
  max-width: 260px;
  text-align: right;
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 10px;
  line-height: 1.5;
  color: rgba(255,255,255,.5);
}
@media (max-width: 700px) {
  .ep-video__consent { display: none; }
}

/* Playing state — facade elements out, player in */
.ep-video.is-playing { cursor: default; }
.ep-video.is-playing .ep-video__poster,
.ep-video.is-playing .ep-video__play,
.ep-video.is-playing .ep-video__meta,
.ep-video.is-playing .ep-video__consent {
  opacity: 0;
  pointer-events: none;
  transition: opacity .5s var(--ease);
}

/* ---------- Theater mode (single project page) ---------- */
/* While a film plays, everything around the player recedes. */
body.ep-theater .case-head,
body.ep-theater .case-brief,
body.ep-theater .case-credits,
body.ep-theater .case-foot,
body.ep-theater .site-header,
body.ep-theater .filmstrip {
  opacity: .18;
  transition: opacity .7s var(--ease);
}
body.ep-theater .case-head:hover,
body.ep-theater .case-brief:hover,
body.ep-theater .case-credits:hover { opacity: 1; }

/* ---------- Teaser loops on cards / tiles ---------- */

.ep-teaser {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;               /* above the still; gradient/meta come later in DOM and stay on top */
  opacity: 0;
  transition: opacity .55s var(--ease);
  pointer-events: none;
}
.ep-teaser.is-on { opacity: 1; }

/* Live indicator while a loop plays */
.ep-teaser-dot {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 6;
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 9.5px;
  letter-spacing: .14em;
  padding: 4px 9px;
  border-radius: 999px;
  color: #fff;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity .3s var(--ease);
  pointer-events: none;
}
.ep-teaser-dot::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  margin-right: 6px;
  animation: ep-pulse 1.2s infinite;
}
.ep-teaser-dot.is-on { opacity: 1; }
@keyframes ep-pulse { 50% { opacity: .3; } }

/* Carousel cards: video badge yields to the live loop */
.carousel-card .ep-teaser { border-radius: inherit; }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .ep-video__poster img,
  .ep-video__play-btn { transition: none !important; }
  .ep-video:hover .ep-video__poster img { transform: none; }
  .ep-teaser, .ep-teaser-dot { display: none !important; }
}
