/* ==========================================================================
   Flexopack — Hero Video
   --------------------------------------------------------------------------
   Full-bleed video background, dark overlay, centered content. Content
   starts hidden (opacity 0); JS adds `.is-ready` after the video has played
   through (or immediately for return visitors / reduced-motion users).
   ========================================================================== */

@layer components {

  .hero-vid {
    container-type: inline-size;
    container-name: hero-vid;
    position: relative;
    display: flex;
    align-items: center;
    overflow: hidden;
    padding: 0;
    height: 78vh;
    min-height: 64rem;
    max-height: 88rem;
    background: var(--secondary);
  }

  .hero-vid__media {
    position: absolute;
    inset: 0;
    z-index: 0;
  }

  .hero-vid__poster,
  .hero-vid__video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
  }

  /* Poster sits under the video; video fades in once it can play. */
  .hero-vid__poster {
    z-index: 0;
    opacity: 1;
    transition: opacity var(--duration-slow) var(--ease-standard);
  }

  .hero-vid__video {
    z-index: 1;
    opacity: 0;
    transition: opacity var(--duration-slow) var(--ease-standard);
  }

  .hero-vid.is-playing .hero-vid__video {
    opacity: 1;
  }

  /* End of clip: crossfade the held last frame back down to the start-frame
     poster over a longer, eased dissolve, so the hero reads as a loop returning
     to where it began (client request 2026-06-21). The poster is now the
     opening establishing frame, not the last frame. */
  .hero-vid.is-freezing .hero-vid__video {
    opacity: 0;
    transition: opacity 800ms var(--ease-emphasized);
  }

  /* On return visits, the video element is hidden entirely and the poster
     stays as a static freeze-frame backdrop. */
  .hero-vid.is-replay .hero-vid__video {
    display: none;
  }

  .hero-vid__overlay {
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    background: linear-gradient(
      to top,
      oklch(0.08 0 0 / 0.75) 0%,
      oklch(0.08 0 0 / 0.45) 40%,
      oklch(0.08 0 0 / 0.2)  65%,
      transparent 100%
    );
  }

  .hero-vid > .container {
    position: relative;
    z-index: 3;
    width: 100%;
  }

  /* ---------- Skip control ----------
     Only shown during the first-visit playback (before the content reveal).
     Clicking it jumps to the frozen end-frame + content immediately. */
  .hero-vid__skip {
    position: absolute;
    z-index: 4;
    right: var(--space-l);
    bottom: var(--space-l);
    display: inline-flex;
    align-items: center;
    gap: var(--space-2xs);
    padding: 0.7rem 1.2rem;
    font-family: inherit;
    font-size: var(--text-s);
    font-weight: var(--weight-medium);
    color: oklch(1 0 0 / 0.9);
    background: oklch(1 0 0 / 0.1);
    border: 1px solid oklch(1 0 0 / 0.25);
    border-radius: 999px;
    backdrop-filter: blur(8px);
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--duration-normal) var(--ease-standard),
                background var(--duration-fast) var(--ease-standard),
                border-color var(--duration-fast) var(--ease-standard);
  }

  .hero-vid.is-playing:not(.is-ready) .hero-vid__skip {
    opacity: 1;
    pointer-events: auto;
  }

  .hero-vid__skip:hover {
    background: oklch(1 0 0 / 0.18);
    border-color: oklch(1 0 0 / 0.4);
  }

  .hero-vid__skip .icon {
    width: 1.4rem;
    height: 1.4rem;
    transition: transform var(--duration-fast) var(--ease-standard);
  }

  .hero-vid__skip:hover .icon {
    transform: translateX(2px);
  }

  @media (prefers-reduced-motion: reduce) {
    .hero-vid__skip {
      transition: opacity var(--duration-fast) linear;
    }
  }

  /* ---------- Replay / play control ----------
     Always-reachable "watch the intro" button. Appears once content is
     revealed (.can-replay) and the clip isn't currently playing. Doubles as
     the manual entry point when autoplay is blocked (Edge, iOS Safari
     Low-Power Mode) — so the video is never stranded behind a failed
     autoplay. */
  .hero-vid__replay {
    position: absolute;
    z-index: 4;
    right: var(--space-l);
    bottom: var(--space-l);
    display: inline-flex;
    align-items: center;
    gap: var(--space-2xs);
    padding: 0.7rem 1.2rem;
    font-family: inherit;
    font-size: var(--text-s);
    font-weight: var(--weight-medium);
    color: oklch(1 0 0 / 0.9);
    background: oklch(1 0 0 / 0.1);
    border: 1px solid oklch(1 0 0 / 0.25);
    border-radius: 999px;
    backdrop-filter: blur(8px);
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity var(--duration-normal) var(--ease-standard),
                background var(--duration-fast) var(--ease-standard),
                border-color var(--duration-fast) var(--ease-standard);
  }

  .hero-vid.can-replay:not(.is-playing) .hero-vid__replay {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  .hero-vid__replay:hover {
    background: oklch(1 0 0 / 0.18);
    border-color: oklch(1 0 0 / 0.4);
  }

  .hero-vid__replay .icon {
    width: 1.4rem;
    height: 1.4rem;
  }

  @media (prefers-reduced-motion: reduce) {
    .hero-vid__replay {
      transition: opacity var(--duration-fast) linear;
    }
  }

  /* ---------- Content (fades in on reveal) ---------- */
  .hero-vid__content {
    max-width: 76rem;
    margin-inline: auto;
    margin-top: var(--space-5xl);
    text-align: center;
    opacity: 0;
    transform: translateY(2.4rem);
    transition: opacity var(--duration-slow) var(--ease-emphasized),
                transform var(--duration-slow) var(--ease-emphasized);
  }

  .hero-vid.is-ready .hero-vid__content {
    opacity: 1;
    transform: translateY(0);
  }

  /* Reduced-motion: skip the transform, just snap in. */
  @media (prefers-reduced-motion: reduce) {
    .hero-vid__content {
      transform: none;
      transition: opacity var(--duration-fast) linear;
    }
  }

  /* ---------- Badge ----------
     Visual style comes from the shared .hero-badge component; this is
     just the section-specific spacing (parent is text-align centered
     with no gap, so children space themselves via margin-bottom). */
  .hero-vid__badge {
    margin-bottom: var(--space-l);
  }

  /* ---------- Title ---------- */
  .hero-vid__title {
    margin-bottom: var(--space-l);
    font-size: var(--hero-title-size);
    font-weight: var(--weight-semibold);
    line-height: 1.05;
    letter-spacing: -0.025em;
    color: var(--always-light);
    text-wrap: balance;
  }

  /* ---------- Subtitle ---------- */
  .hero-vid__subtitle {
    margin-inline: auto;
    margin-bottom: var(--space-2xl);
    max-width: 56rem;
    font-size: var(--text-l);
    line-height: var(--leading-relaxed);
    color: oklch(1 0 0 / 0.78);
  }

  /* ---------- Actions ---------- */
  .hero-vid__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: var(--space-m);
    margin-bottom: var(--space-3xl);
  }

  .hero-vid__cta-primary .icon,
  .hero-vid__cta-outline .icon {
    transition: transform var(--duration-fast) var(--ease-standard);
  }

  .hero-vid__cta-primary:hover .icon { transform: translateX(3px); }
  .hero-vid__cta-outline:hover .icon { transform: translateY(2px); }

  /* ---------- Stats strip ---------- */
  .hero-vid__stats {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xl);
  }

  .hero-vid__stat {
    display: flex;
    flex-direction: column;
    gap: var(--space-3xs);
    align-items: center;
  }

  .hero-vid__stat-value {
    font-size: var(--text-2xl);
    font-weight: var(--weight-bold);
    line-height: 1;
    letter-spacing: -0.02em;
    color: var(--primary);
  }

  .hero-vid__stat-label {
    font-size: var(--text-xs);
    font-weight: var(--weight-medium);
    letter-spacing: 0.02em;
    color: oklch(1 0 0 / 0.65);
  }

  .hero-vid__stat-divider {
    width: 1px;
    height: 3.6rem;
    background: oklch(1 0 0 / 0.22);
  }

  /* ---------- Responsive ---------- */
  @container hero-vid (max-width: 768px) {
    .hero-vid {
      min-height: 56rem;
    }

    .hero-vid__content {
      padding-bottom: var(--space-3xl);
    }

    .hero-vid__title {
      font-size: var(--text-3xl);
    }

    .hero-vid__subtitle {
      font-size: var(--text-m);
    }

    .hero-vid__stats {
      gap: var(--space-l);
    }

    .hero-vid__stat-value {
      font-size: var(--text-xl);
    }
  }

  @container hero-vid (max-width: 480px) {
    .hero-vid {
      min-height: 48rem;
    }

    .hero-vid__title {
      font-size: var(--text-2xl);
    }

    .hero-vid__subtitle {
      font-size: var(--text-s);
      margin-bottom: var(--space-xl);
    }

    .hero-vid__actions {
      flex-direction: column;
      align-items: stretch;
      gap: var(--space-s);
      margin-bottom: var(--space-2xl);
    }

    .hero-vid__stats {
      gap: var(--space-m);
    }

    .hero-vid__stat-divider {
      height: 2.8rem;
    }
  }
}
