/* ============================================================================
   Hero Curtain Scroll — front-end styles.

   Structure mirrors the JS module layout:
     1. Container + immersive lock
     2. Stages (preload splash, reveal surface, image layers)
     3. Media (video/iframe intro layer, per-mode, fallback image)
     4. Curtain reveal (mask gradient while the curtain parts)
     5. Loader + interaction capture
     6. Hints
     7. Debug label
     8. Dismissed state
   ============================================================================ */


/* ============================================================================
   1. Container

   The immersive `<html>`/`<body>` scroll-lock that used to live here is now
   `.be-platform-scroll-lock-doc` from the wp-be-platform UI primitives
   stylesheet (be-platform-ui). The JS toggles that class on document and
   body during the intro overlay.
   ============================================================================ */
.hcs-hero-curtain {
  position: relative;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  background: #fff;
  background-color: #fff;
  --hcs-curtain-progress: 0;
  --hcs-curtain-gap: 0%;
}


/* ============================================================================
   2. Stages (preload splash + reveal surface + image layers)
   ============================================================================ */
.hcs-preload-splash {
  position: fixed;
  inset: 0;
  z-index: 999993;
  background: var(--hcs-intro-bg, #fff);
  opacity: 1;
  transition: opacity 250ms linear;
}

.hcs-reveal-surface {
  position: relative;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  background: #fff;
  background-color: #fff;
}

.hcs-hero-curtain.hcs-intro-overlay-active .hcs-reveal-surface {
  position: fixed;
  inset: 0;
  z-index: 999992;
}

.hcs-hero-curtain.hcs-intro-overlay-active .hcs-stage-image-1,
.hcs-hero-curtain.hcs-intro-overlay-active .hcs-stage-image-2 {
  position: absolute;
}

.hcs-stage {
  position: absolute;
  inset: 0;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  will-change: opacity, transform;
}

.hcs-stage-image-1 {
  position: fixed;
  left: 0;
  right: 0;
  top: auto;
  bottom: 5vh;
  height: 45vh;
  background-size: auto 45vh;
  background-position: center bottom;
  background-repeat: no-repeat;
  will-change: transform, opacity;
  z-index: 2;
  opacity: 1;
}

.hcs-stage-image-2 {
  position: fixed;
  left: 0;
  right: 0;
  top: 50%;
  margin-top: -35vh;
  height: 70vh;
  background-size: auto 70vh;
  background-position: center center;
  background-repeat: no-repeat;
  will-change: transform, opacity;
  z-index: 1;
  opacity: 0;
  transition: opacity 1000ms linear;
}

.hcs-hero-curtain.hcs-mobile-portrait-mode .hcs-stage-image-1 {
  left: var(--hcs-image1-pad-x, 0px);
  right: var(--hcs-image1-pad-x, 0px);
  background-size: 100% auto;
  background-position: center bottom;
}

.hcs-hero-curtain.hcs-mobile-portrait-mode .hcs-stage-image-2 {
  left: var(--hcs-image2-pad-x, 0px);
  right: var(--hcs-image2-pad-x, 0px);
  background-size: 100% auto;
}

.hcs-hero-curtain.hcs-mobile-portrait-mode.hcs-image2-mobile-center .hcs-stage-image-2 {
  top: 50%;
  bottom: auto;
  margin-top: -35vh;
  background-position: center center;
}

.hcs-hero-curtain.hcs-mobile-portrait-mode.hcs-image2-mobile-bottom .hcs-stage-image-2 {
  top: auto;
  bottom: var(--hcs-image2-mobile-bottom, 0px);
  margin-top: 0;
  background-position: center bottom;
}

.hcs-hero-curtain.hcs-curtain-complete .hcs-stage-image-2,
.hcs-hero-curtain.hcs-intro-dismissed .hcs-stage-image-2 {
  opacity: 1;
}


/* ============================================================================
   3. Media (intro video + fallback image)
   ============================================================================ */
.hcs-stage-video {
  z-index: 3;
  overflow: hidden;
  opacity: 1;
}

.hcs-hero-curtain.hcs-intro-overlay-active .hcs-stage-video {
  position: fixed;
  inset: 0;
  z-index: 999994;
  opacity: 1;
  background: var(--hcs-intro-bg, #fff);
  transition: background-color 250ms linear;
}

.hcs-intro-media {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  opacity: 0;
  transition: opacity 250ms linear;
}

/*
 * Safari-specific pre-JS guard.
 *
 * Without this, Safari paints a <video> element's poster + the native
 * autoplay-blocked circular play button in the brief window between HTML parse
 * and our JS hiding the element. Marking the media `visibility: hidden` until
 * `hcs-video-visible` is added prevents that render path entirely; JS later
 * clears the inline style and the class appears together, so there's no race.
 */
.hcs-hero-curtain:not(.hcs-video-visible) .hcs-intro-media {
  visibility: hidden;
}

.hcs-hero-curtain.hcs-intro-overlay-active.hcs-video-visible .hcs-intro-media {
  opacity: 1;
  visibility: visible;
}

.hcs-hero-curtain.hcs-fallback-image-active .hcs-intro-media {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
  display: none !important;
}

.hcs-hero-curtain.hcs-fallback-image-active .hcs-stage-video {
  background-color: var(--hcs-intro-bg, #ffffff) !important;
  background-position: center center;
  background-repeat: no-repeat;
  background-size: var(--hcs-fallback-size-active-vw, var(--hcs-fallback-size-landscape-vw, 40vw)) auto !important;
}

.hcs-hero-curtain.hcs-intro-overlay-active.hcs-video-visible .hcs-stage-video {
  background: var(--hcs-intro-bg, #fff);
}

video.hcs-intro-media {
  object-fit: cover;
}

.hcs-intro-media-vimeo {
  top: 50%;
  left: 50%;
  width: 100vw;
  height: 56.25vw;
  min-width: 177.78vh;
  min-height: 100dvh;
  transform: translate(-50%, -50%);
}


/* ============================================================================
   4. Curtain reveal mask
   ============================================================================ */
.hcs-hero-curtain.hcs-curtain-active .hcs-stage-video {
  opacity: 1;
  -webkit-mask-image: linear-gradient(
    to right,
    #000 0%,
    #000 calc(50% - (var(--hcs-curtain-gap) / 2)),
    transparent calc(50% - (var(--hcs-curtain-gap) / 2)),
    transparent calc(50% + (var(--hcs-curtain-gap) / 2)),
    #000 calc(50% + (var(--hcs-curtain-gap) / 2)),
    #000 100%
  );
  mask-image: linear-gradient(
    to right,
    #000 0%,
    #000 calc(50% - (var(--hcs-curtain-gap) / 2)),
    transparent calc(50% - (var(--hcs-curtain-gap) / 2)),
    transparent calc(50% + (var(--hcs-curtain-gap) / 2)),
    #000 calc(50% + (var(--hcs-curtain-gap) / 2)),
    #000 100%
  );
}


/* ============================================================================
   5. Loader + interaction capture

   The loader overlay, its spinner, and its text label come from the platform
   primitives (be-platform-ui): `.be-platform-loader`, `.be-platform-spinner`,
   `.be-platform-loader__text`. Only consumer-specific overrides live here:
   - Promote to fixed full-viewport positioning during the intro overlay.
   - Match the curtain's existing 250ms fade (platform default is 180ms).
   - Use the curtain's z-index stack (loader sits above the interaction
     capture and below the continue hint and debug label).
   ============================================================================ */
.hcs-hero-curtain .be-platform-loader {
  --be-platform-loader-fade: 250ms;
}

.hcs-hero-curtain.hcs-intro-overlay-active .be-platform-loader {
  position: fixed;
  inset: 0;
  z-index: 999996;
}

.hcs-interaction-capture {
  position: absolute;
  inset: 0;
  z-index: 4;
  background: transparent;
}

.hcs-hero-curtain.hcs-intro-overlay-active .hcs-interaction-capture {
  position: fixed;
  inset: 0;
  z-index: 999995;
}

.hcs-hero-curtain.hcs-video-visible .be-platform-loader {
  opacity: 0;
  pointer-events: none;
}

.hcs-hero-curtain.hcs-video-visible .hcs-preload-splash {
  opacity: 0;
  pointer-events: none;
}


/* ============================================================================
   6. Hints
   ============================================================================ */
.hcs-continue-hint {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 999997;
  color: rgba(0, 0, 0, 0.9);
  background: rgba(255, 255, 255, 0.2);
  padding: 5px;
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0;
  transition: opacity 220ms ease;
}

.hcs-hero-curtain.hcs-hint-visible .hcs-continue-hint {
  opacity: 1;
}


/* ============================================================================
   7. Debug label
   ============================================================================ */
.hcs-debug {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 999997;
  color: #fff;
  font-family: Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  line-height: 1.4;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 4px;
  padding: 6px 10px;
  display: none;
}

.hcs-hero-curtain.hcs-debug-enabled[data-stage] .hcs-debug {
  display: block;
}

.hcs-hero-curtain.hcs-media-error .be-platform-loader__text::after {
  content: " (check video URL)";
}


/* ============================================================================
   8. Dismissed state
   ============================================================================ */
.hcs-hero-curtain.hcs-intro-dismissed .hcs-interaction-capture {
  display: none;
}

.hcs-hero-curtain.hcs-intro-dismissed .hcs-continue-hint {
  opacity: 0;
  pointer-events: none;
}

.hcs-hero-curtain.hcs-intro-dismissed .hcs-stage-video {
  opacity: 0;
  pointer-events: none;
}

.hcs-hero-curtain.hcs-intro-dismissed .hcs-preload-splash {
  display: none;
}


/* ============================================================================
   9. Static preview state

   The static post-curtain view: both stage background graphics visible inside
   the section box (not `position: fixed` to the iframe viewport, which would
   float them across the canvas as the user scrolls). The intro overlay,
   video, loader, hint, and the transparent click-trap are all suppressed.

   Two callers, both in hero-curtain.js → activateStaticPreviewReadyState():

   1. Elementor editor (`elementorFrontend.isEditMode()` returns true). Without
      this state the section would render as an empty viewport-tall box and
      the admin would have no way to scroll past the hero to edit the rest of
      the page (and no visual context for what the widget actually contains).

   2. Front-end revisit within the same browser session. After the user
      completes the curtain + handoff once, a `sessionStorage` flag (keyed by
      the Elementor widget instance id) records that. On any later page load
      in the same tab — including bfcache restores that re-run the boot path
      — we skip the immersive intro and drop straight into this state.
   ============================================================================ */
.hcs-hero-curtain.hcs-static-preview .hcs-preload-splash,
.hcs-hero-curtain.hcs-static-preview .hcs-stage-video,
.hcs-hero-curtain.hcs-static-preview .be-platform-loader,
.hcs-hero-curtain.hcs-static-preview .hcs-interaction-capture,
.hcs-hero-curtain.hcs-static-preview .hcs-continue-hint {
  display: none;
}

.hcs-hero-curtain.hcs-static-preview .hcs-stage-image-1,
.hcs-hero-curtain.hcs-static-preview .hcs-stage-image-2 {
  position: absolute;
  opacity: 1;
}
