/* ==========================================================================
   OrtoToolkit — Video Popup Widget + Lightbox
   Tokens match base.css variables (--color-*, --radius-*, --font-body).
   ========================================================================== */

/* ── Widget (bottom-right card) ──────────────────────────────────────────── */

.ovp-widget {
  position: fixed;
  bottom: 28px;
  left: 24px;
  z-index: 9990;

  /* Side-by-side: [portrait video card] [white info pill] */
  display: flex;
  align-items: flex-end;
  gap: 10px;

  /* Slide-up entrance – delayed so it doesn’t fight page load */
  animation: ovp-rise 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  animation-delay: 1.8s;
}

@keyframes ovp-rise {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.94);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Dismissed state */
.ovp-widget.is-hidden {
  display: none !important;
}

/* Close button sits over top-LEFT of video card (leftmost item now) */
.ovp-close {
  position: absolute;
  top: 8px;
  left: 8px;
  right: auto;
  z-index: 10; /* above play button (z-index: 1) */
  width: 24px;
  height: 24px;

  display: flex;
  align-items: center;
  justify-content: center;

  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  color: #ffffff;
  cursor: pointer;
  padding: 0;

  transition:
    background 0.15s ease,
    transform 0.15s ease;
}

.ovp-close:hover,
.ovp-close:focus-visible {
  background: rgba(0, 0, 0, 0.72);
  transform: scale(1.1);
  outline: none;
}

/* ── Play button / thumbnail ─────────────────────────────────────────────── */

.ovp-play-btn {
  /* Portrait video card — self-contained, not stretched into widget */
  position: relative;
  flex-shrink: 0;
  width: 160px;
  aspect-ratio: 9 / 16;

  border: none;
  border-radius: 18px;
  padding: 0;
  overflow: hidden;
  cursor: pointer;
  background: #0b1220; /* fallback while video loads */
  display: flex;
  align-items: center;
  justify-content: center;

  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.45),
    0 2px 6px rgba(0, 0, 0, 0.2);

  transition:
    transform 0.22s ease,
    box-shadow 0.22s ease;
}

.ovp-play-btn:hover,
.ovp-play-btn:focus-visible {
  transform: scale(1.03);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
  outline: none;
}

/* Muted looping preview — fills the card with no black bars */
.ovp-preview-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
}

/* Bottom gradient scrim — kept for backwards compat but no longer rendered */
.ovp-card-footer {
  display: none;
}

/* Centered play icon — always visible; brighter on hover */
.ovp-play-overlay {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.88;
  transition:
    opacity 0.18s ease,
    transform 0.18s ease;
}

.ovp-play-btn:hover .ovp-play-overlay,
.ovp-play-btn:focus-visible .ovp-play-overlay {
  opacity: 1;
  transform: scale(1.08);
}

.ovp-play-icon {
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.6));
}

/* ── Lightbox — corner player anchored to bottom-right ───────────────────── */
/*
 * Videos are vertical (portrait). We anchor the player to the same corner
 * as the widget so there are no horizontal black bars. JS sets the real
 * aspect-ratio on .ovp-lightbox__inner once video metadata loads.
 */

.ovp-lightbox {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: none;
  /* push inner card to the same corner as the widget (bottom-left) */
  align-items: flex-end;
  justify-content: flex-start;
}

.ovp-lightbox.ovp-is-open {
  display: flex;
}

/* Backdrop — light scrim only; no blur so the page stays readable */
.ovp-lightbox__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(11, 18, 32, 0.38);
}

/* Inner wrapper — portrait card that grows from the widget corner */
.ovp-lightbox__inner {
  position: relative;
  z-index: 1;
  /* margin mirrors widget offsets so the card sits in the same spot */
  margin: 0 0 28px 24px;
  /* height drives the size; aspect-ratio (default 9/16) drives the width */
  height: min(82vh, 620px);
  width: auto;
  aspect-ratio: 9 / 16; /* JS overrides with real ratio after loadedmetadata */
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6);
  /* expand from the bottom-left origin (where the widget lives) */
  transform-origin: bottom left;
  animation: ovp-expand 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes ovp-expand {
  from {
    opacity: 0;
    transform: scale(0.72);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Close button — overlaid inside the card (top-right corner) */
.ovp-lightbox__close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 40px;
  height: 40px;
  z-index: 3; /* must be above pause overlay (z-index: 2) */

  display: flex;
  align-items: center;
  justify-content: center;

  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(4px);
  color: #ffffff;
  cursor: pointer;

  transition:
    background 0.2s ease,
    transform 0.2s ease;
}

.ovp-lightbox__close:hover,
.ovp-lightbox__close:focus-visible {
  background: rgba(255, 255, 255, 0.26);
  transform: scale(1.1);
  outline: none;
}

/* Video fills the card exactly — no black bars because card IS the video size */
.ovp-lightbox__video {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 0; /* card's overflow:hidden + border-radius handles rounding */
  background: #000;
  object-fit: cover;
}

/* ── Custom pause / resume overlay button ────────────────────────────────── */

.ovp-lightbox__pause {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  cursor: pointer;
  /* icon circle */
  z-index: 2;
  /* hidden by default — appears only when paused or hovered */
  opacity: 0;
  transition: opacity 0.2s ease;
}

/* Show the overlay on hover (pointer devices) */
.ovp-lightbox__inner:hover .ovp-lightbox__pause {
  opacity: 1;
}

/* Always show when paused */
.ovp-lightbox__inner.is-paused .ovp-lightbox__pause {
  opacity: 1;
}

/* Icon background pill */
.ovp-lightbox__pause::before {
  content: "";
  position: absolute;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  transition:
    background 0.15s ease,
    transform 0.15s ease;
}

.ovp-lightbox__pause:hover::before,
.ovp-lightbox__pause:focus-visible::before {
  background: rgba(0, 0, 0, 0.65);
  transform: scale(1.1);
}

.ovp-lightbox__pause:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.6);
  outline-offset: -4px;
  border-radius: 50%;
}

.ovp-pause-icon,
.ovp-resume-icon {
  position: relative;
  z-index: 1;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
}

/* While playing: show pause icon, hide play icon */
.ovp-resume-icon {
  display: none;
}

/* While paused: hide pause icon, show play icon */
.ovp-lightbox__inner.is-paused .ovp-pause-icon {
  display: none;
}
.ovp-lightbox__inner.is-paused .ovp-resume-icon {
  display: block;
}

/* ── Mobile adjustments ──────────────────────────────────────────────────── */

@media (max-width: 480px) {
  .ovp-widget {
    left: 12px;
    bottom: 16px;
    gap: 8px;
  }

  /* Slightly smaller preview card on mobile */
  .ovp-play-btn {
    width: 110px;
  }

  .ovp-lightbox__inner {
    /* on narrow screens use a smaller card height so it doesn’t swamp the UI */
    height: min(72vh, 480px);
    margin: 0 16px 16px;
  }

  .ovp-lightbox__close {
    top: 10px;
    right: 10px;
    width: 36px;
    height: 36px;
  }
}

/* Respect reduced-motion preference */
@media (prefers-reduced-motion: reduce) {
  .ovp-widget {
    animation: none;
  }
  .ovp-lightbox__inner {
    animation: none;
  }
  .ovp-play-btn,
  .ovp-play-icon {
    transition: none;
  }
}
