/* ==========================================================================
   /cool/ — cinematic box film. LOADED ONLY ON /cool/.
   Moved out of assets/theme-scroll.css so the homepage never ships the rules
   that hide navigation or stretch the document to 340vh.

   Layer contract (do not reorder):
     1  .cool-page-media     canvas + poster
     2  .cool-page-overlay   vignette / glow, pointer-events:none
     3  .cool-page-content   headline + CTA
    10  .cool-page-controls  back / skip / beta — always reachable
   ========================================================================== */

.cool-page {
  background: #000;
}

/* Tall track drives the scrub. Sticky panel is one viewport of pure black. */
.cool-hero {
  position: relative;
  height: 340vh;
  margin: 0;
  padding: 0;
  background: #000;
}
/* Once the film is done (or skipped) the track collapses so the page scrolls
   normally into the product copy below. */
.cool-hero.is-released {
  height: 100vh;
  height: 100dvh;
}

.cool-hero-sticky {
  position: sticky;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #000;
  isolation: isolate;
}

/* ---- Layer 1: media ---- */
.cool-page-media {
  position: absolute;
  inset: 0;
  z-index: 1;
}
.cool-hero-poster,
.cool-hero-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  background: #000;
  transform: translateZ(0) scale(1.01);
  backface-visibility: hidden;
  will-change: transform;
}
/* The canvas must never eat a click, a wheel event or a tap. */
.cool-hero-canvas,
.cool-page canvas {
  pointer-events: none;
}
.cool-hero-canvas {
  opacity: 0;
  transition: opacity 0.2s linear;
}
.cool-hero.is-ready .cool-hero-canvas { opacity: 1; }
.cool-hero.is-ready .cool-hero-poster { opacity: 0; }

/* Idle breathing while the visitor is not scrubbing. */
.cool-hero.is-idle .cool-hero-canvas,
.cool-hero.is-idle .cool-hero-poster {
  animation: cool-breathe 5.5s ease-in-out infinite;
}
@keyframes cool-breathe {
  0%, 100% { transform: translateZ(0) scale(1.01); }
  50%      { transform: translateZ(0) scale(1.045); }
}

/* ---- Layer 2: overlay ---- */
.cool-page-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}
.cool-hero-glow {
  position: absolute;
  inset: -10%;
  opacity: 0;
  transition: opacity 0.8s var(--ease);
  mix-blend-mode: screen;
  background:
    radial-gradient(ellipse 50% 40% at 50% 55%, rgba(167, 139, 250, 0.22), transparent 60%),
    radial-gradient(ellipse 40% 35% at 40% 40%, rgba(34, 211, 238, 0.12), transparent 55%),
    radial-gradient(ellipse 35% 30% at 60% 45%, rgba(232, 121, 249, 0.10), transparent 50%);
}
.cool-hero.is-idle .cool-hero-glow {
  opacity: 1;
  animation: cool-glow-drift 7s ease-in-out infinite alternate;
}
@keyframes cool-glow-drift {
  from { transform: translate3d(-2%, -1%, 0) scale(1); }
  to   { transform: translate3d(2%, 2%, 0) scale(1.08); }
}
.cool-hero-vignette {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 55% 50% at 50% 48%, transparent 0%, transparent 42%, rgba(0,0,0,0.55) 100%),
    linear-gradient(180deg, rgba(0,0,0,0.55) 0%, transparent 22%, transparent 58%, rgba(0,0,0,0.75) 100%);
}

/* ---- Layer 3: content ---- */
.cool-page-content {
  position: relative;
  z-index: 3;
  width: min(100% - 2rem, 40rem);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.85rem;
  padding: 1.75rem 1.5rem 2rem;
  border-radius: 28px;
  background: rgba(4, 2, 12, 0.55);
  border: 1px solid rgba(167, 139, 250, 0.22);
  box-shadow:
    0 0 0 1px rgba(0,0,0,0.4) inset,
    0 24px 80px rgba(0,0,0,0.55),
    0 0 60px rgba(124, 58, 237, 0.15);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  /* DEFAULT IS VISIBLE. The copy and CTA must be readable with JavaScript
     disabled, with the frame sequence unavailable, or before the animation
     initialises. Concealment below is opt-in and applied only by JS during
     active scrubbing, so a failure can never leave the hero blank. */
  opacity: 1;
  transform: none;
  transition: opacity 0.55s var(--ease), transform 0.55s var(--ease);
}
/* Mid-film only: JS adds .is-mid while the box is actually opening, so the
   frame gets the viewport to itself. Removed on end, skip, failure or release. */
.cool-hero.is-mid .cool-page-content {
  opacity: 0;
  transform: translate3d(0, 20px, 0);
  pointer-events: none;
}
/* Released/finished states are explicit so nothing can strand the copy. */
.cool-hero.is-end .cool-page-content,
.cool-hero.is-released .cool-page-content {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}
/* On release, snap rather than transition — if the film failed, the visitor
   should not wait out a fade to read the page. */
.cool-hero.is-released .cool-page-content {
  transition: none;
}
.cool-page-content .cta-row {
  justify-content: center;
  margin-top: 0.35rem;
  margin-bottom: 0;
}
.cool-page-content h1 {
  font-size: clamp(2.15rem, 5.5vw, 3.6rem);
  max-width: 14ch;
  margin: 0;
  color: #fff;
  text-shadow: 0 2px 4px rgba(0,0,0,0.9), 0 8px 32px rgba(0,0,0,0.75);
  line-height: 1.08;
}
.cool-page-content h1 .accent-text {
  background: linear-gradient(135deg, #F0E7FF 0%, #C4B5FD 35%, #5EEAD4 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.6));
}
.cool-page-content .lead {
  color: rgba(255,255,255,0.88);
  max-width: 32rem;
  margin: 0;
  font-size: clamp(0.95rem, 1.5vw, 1.08rem);
  text-shadow: 0 2px 12px rgba(0,0,0,0.85);
}
.cool-page-content .btn-ghost {
  border-color: rgba(255,255,255,0.28);
  color: #fff;
  background: rgba(255,255,255,0.06);
}
.cool-page-content .btn-ghost:hover {
  border-color: rgba(167,139,250,0.55);
  background: rgba(167,139,250,0.12);
}

.cool-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  border: 1px solid rgba(167, 139, 250, 0.4);
  background: rgba(10, 8, 24, 0.75);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #E9E0FF;
}
.cool-badge .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22D3EE;
  box-shadow: 0 0 12px #22D3EE;
  animation: cool-pulse-dot 1.6s ease-in-out infinite;
}
@keyframes cool-pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.55; transform: scale(0.85); }
}

/* ---- Layer 10: escape hatches. Always visible, always above the canvas. ---- */
.cool-page-controls {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem clamp(0.85rem, 3vw, 1.5rem);
  padding-top: max(0.85rem, env(safe-area-inset-top, 0px));
  background: linear-gradient(180deg, rgba(0,0,0,0.75), transparent);
  pointer-events: none;
}
.cool-page-controls > * { pointer-events: auto; }
.cool-controls-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.cool-control {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  /* 44px minimum touch target */
  min-height: 44px;
  padding: 0.6rem 1rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(8, 6, 18, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #fff;
  font-size: 0.84rem;
  font-weight: 600;
  transition: border-color 0.2s, background 0.2s, transform 0.2s var(--ease);
}
.cool-control:hover {
  border-color: rgba(167, 139, 250, 0.6);
  background: rgba(30, 20, 60, 0.9);
}
.cool-control:active { transform: scale(0.98); }
.cool-control-primary {
  background: linear-gradient(135deg, #C4B5FD, #A78BFA 50%, #7C3AED);
  border-color: transparent;
  color: #0a0614;
}
.cool-control-primary:hover {
  background: linear-gradient(135deg, #D6CBFF, #B49BFF 50%, #8B4DF0);
  border-color: transparent;
}
/* Focus must be obvious against a black film. */
.cool-page-controls a:focus-visible,
.cool-page-controls button:focus-visible {
  outline: 3px solid #22D3EE;
  outline-offset: 3px;
}

/* ---- Scrub affordances ---- */
.cool-hero-progress {
  position: absolute;
  left: 50%;
  bottom: max(1.25rem, env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 4;
  width: min(180px, 36vw);
  height: 2px;
  border-radius: 99px;
  background: rgba(255,255,255,0.1);
  overflow: hidden;
}
.cool-hero-progress > i {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #22D3EE, #A78BFA, #E879F9);
  will-change: width;
}
.cool-scroll-hint {
  position: absolute;
  bottom: max(2.4rem, calc(env(safe-area-inset-bottom, 0px) + 1.75rem));
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  font-size: 0.68rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.5);
  text-shadow: 0 2px 12px rgba(0,0,0,0.8);
  transition: opacity 0.4s;
  animation: cool-hint-bob 2.4s ease-in-out infinite;
}
@keyframes cool-hint-bob {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50%      { transform: translateX(-50%) translateY(5px); }
}
.cool-hero.is-autoplaying .cool-scroll-hint,
.cool-hero.is-mid .cool-scroll-hint,
.cool-hero.is-end .cool-scroll-hint,
.cool-hero.is-released .cool-scroll-hint {
  opacity: 0;
  pointer-events: none;
  animation: none;
}

/* Product copy that follows the film. */
.cool-outro {
  position: relative;
  z-index: 5;
  background: var(--bg);
}

/* ==========================================================================
   Reduced motion: no frame scrub, no parallax, no "scroll to open" prompt.
   Strongest static frame + full copy + CTA, immediately.
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  .cool-hero,
  .cool-hero.is-released {
    height: auto;
  }
  .cool-hero-sticky {
    position: relative;
    height: auto;
    min-height: 100vh;
  }
  .cool-page-content {
    opacity: 1 !important;
    transform: none !important;
  }
  .cool-hero-canvas { display: none; }
  .cool-hero-poster { opacity: 1 !important; animation: none !important; }
  .cool-hero.is-idle .cool-hero-poster,
  .cool-hero.is-idle .cool-hero-glow { animation: none !important; }
  /* No scroll prompt when scrolling no longer drives anything. */
  .cool-scroll-hint,
  .cool-hero-progress { display: none !important; }
}

@media (max-width: 640px) {
  .cool-page-controls {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .cool-control {
    padding: 0.55rem 0.85rem;
    font-size: 0.78rem;
  }
  .cool-page-content { padding: 1.35rem 1.15rem 1.6rem; }
}
