/* =============================================================================
   Hero video lightbox
   Native <dialog> element. The hero image morphs into the centered 16:9
   wrapper via the View Transitions API (see view-transition-name in
   landing/head.blade.php). When VT isn't available (Firefox today) the
   default fade defined here still produces a clean open/close.
   ============================================================================= */

.hero-lightbox {
  /* Reset all default dialog chrome — we own the styling. */
  padding: 0;
  border: 0;
  background: transparent;
  max-width: 100vw;
  max-height: 100vh;
  width: 100vw;
  height: 100vh;
  inset: 0;
  margin: 0;
  overflow: hidden;
  /* Hidden by default — <dialog> is display:none until showModal(). */
}

/* Backdrop — solid site-background color at 100%, no tint, no blur. The
   lightbox reads as a clean continuation of the page rather than a dim
   overlay on top of it. Matches body { background: #D9E7F6 } from base.css. */
.hero-lightbox::backdrop {
  background: #D9E7F6;
}

/* Open-state container — fills the viewport, centers the wrapper. */
.hero-lightbox[open] {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* The 16:9 player container — what the hero image morphs INTO. */
.hero-lightbox__wrap {
  position: relative;
  width: min(1280px, 92vw);
  aspect-ratio: 16 / 9;
  border-radius: 14px;
  overflow: hidden;
  background: #000;
  box-shadow: 0 32px 96px rgba(0, 0, 0, 0.5);
}

.hero-lightbox__wrap iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

/* Close button — top-right corner of the wrapper, sits over the video.
   White on a translucent dark circle so it reads against any frame of
   video content. */
.hero-lightbox__close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  transition: background .15s ease, transform .15s ease;
  z-index: 2;
}
.hero-lightbox__close:hover  { background: rgba(0, 0, 0, 0.75); transform: scale(1.05); }
.hero-lightbox__close:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
  background: rgba(0, 0, 0, 0.85);
}

/* Lock body scroll while the lightbox is open (the <dialog> already makes
   the rest inert, but locking scroll prevents the scrollbar from
   reflowing). */
body.hero-lightbox--open { overflow: hidden; }

/* Fallback fade for browsers without View Transitions (Firefox today).
   When VT runs, the browser's snapshot system supplants this entirely. */
@keyframes hero-lightbox-fade-in {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1); }
}
.hero-lightbox[open] .hero-lightbox__wrap {
  animation: hero-lightbox-fade-in 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

@media (prefers-reduced-motion: reduce) {
  .hero-lightbox[open] .hero-lightbox__wrap { animation: none; }
  .hero-lightbox__close { transition: none; }
}

/* Mobile — close button is a little smaller so it doesn't crowd the video,
   wrapper grows toward the screen edges. */
@media (max-width: 640px) {
  .hero-lightbox__wrap { width: 96vw; }
  .hero-lightbox__close { width: 36px; height: 36px; font-size: 22px; }
}

/* Portrait variant — kicks in when the JS picks the mobile (9:16) video.
   Wrapper flips aspect ratio and is sized to viewport HEIGHT so the
   portrait video fills the screen nicely without overflowing. The width
   then derives from the aspect ratio. */
.hero-lightbox.is-portrait .hero-lightbox__wrap {
  aspect-ratio: 9 / 16;
  width: auto;
  height: min(85vh, 760px);
  max-width: 96vw;
}

/* Phone: drop the 760px desktop cap so the portrait video grows to fill
   the tall viewport — without this the wrap floats at 760px tall with
   ~600px of empty viewport above and below it. Use `svh` (small viewport
   height) on the dialog AND the wrap so dimensions track the visible
   viewport (browser chrome shown) instead of the larger chrome-collapsed
   `vh` — otherwise flex centering puts the wrap behind the chrome and
   visually off-center. */
@media (max-width: 720px) {
  .hero-lightbox {
    height: 100svh;
    max-height: 100svh;
  }
  .hero-lightbox.is-portrait .hero-lightbox__wrap {
    height: 88svh;
  }
}
