/* =============================================================
   Product Story — scroll-driven HVAC engineering walkthrough
   Additive module only: reuses tokens from css/styles.css
   (colors, fonts, radius, shadow, spacing). Does not override
   any existing site rule.
   ============================================================= */

/* ---------- Scroll stage: 500vh track, 100vh sticky viewport ---------- */
.product-story{
  position: relative;
  height: 500vh;
  background: var(--paper);
}

.product-story-sticky{
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  display: flex;
  align-items: center;
  background: var(--paper);
  isolation: isolate;
  contain: layout style;
  transform: translateZ(0);
  backface-visibility: hidden;
  will-change: transform;
}

/* ---------- Ambient background: white -> light blue -> white ---------- */
/* Opacity is driven by scroll progress in js/scroll-video.js */
.product-story-bg{
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(circle at 18% 28%, rgba(127,182,217,.38), transparent 55%),
    radial-gradient(circle at 84% 74%, rgba(244,123,32,.10), transparent 50%),
    linear-gradient(180deg, var(--paper) 0%, var(--frost) 50%, var(--paper) 100%);
  opacity: 0;
  transition: opacity .6s ease;
  will-change: opacity;
  transform: translateZ(0);
  backface-visibility: hidden;
}

.product-story-particles{
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
}
.product-story-particles span{
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--sky);
  opacity: .3;
  filter: blur(.5px);
  animation: story-float 9s ease-in-out infinite;
  will-change: transform, opacity;
}
.product-story-particles span:nth-child(1){ left: 8%;  top: 22%; animation-delay: 0s; }
.product-story-particles span:nth-child(2){ left: 22%; top: 68%; animation-delay: 1.4s; animation-duration: 11s; }
.product-story-particles span:nth-child(3){ left: 46%; top: 14%; animation-delay: 2.8s; animation-duration: 8s; }
.product-story-particles span:nth-child(4){ left: 62%; top: 78%; animation-delay: .7s; animation-duration: 10s; }
.product-story-particles span:nth-child(5){ left: 78%; top: 34%; animation-delay: 3.6s; animation-duration: 12s; }
.product-story-particles span:nth-child(6){ left: 92%; top: 58%; animation-delay: 2s; animation-duration: 9.5s; }

@keyframes story-float{
  0%, 100%{ transform: translateY(0) translateZ(0); opacity: .15; }
  50%{ transform: translateY(-28px) translateZ(0); opacity: .5; }
}

/* ---------- Grid: 40% copy / 60% media ---------- */
.product-story-grid{
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 2fr 3fr;
  gap: 3rem;
  align-items: center;
  width: 100%;
}

/* ---------- Copy column ---------- */
.product-story-copy{ max-width: 480px; }
.product-story-copy .eyebrow{ margin-bottom: 1rem; }

.product-story-heading{
  font-family: var(--font-display);
  font-weight: 800;
  font-stretch: expanded;
  font-size: clamp(1.9rem, 3vw, 2.6rem);
  line-height: 1.1;
  color: var(--ink-900);
  margin-bottom: .9rem;
}

.product-story-sub{
  font-size: clamp(1rem, 1.3vw, 1.15rem);
  color: var(--ink-700);
  font-weight: 600;
  margin-bottom: .6rem;
}

.product-story-desc{
  color: var(--steel);
  font-size: .98rem;
  max-width: 48ch;
  margin-bottom: 1.8rem;
}

/* ---------- Feature cards ---------- */
.product-story-features{
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: .7rem;
  margin-bottom: 2rem;
}

.story-feature{
  position: relative;
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .7rem .85rem;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--line-frost);
  background: rgba(255,255,255,.65);
  opacity: .4;
  transform: scale(.96) translateZ(0);
  backface-visibility: hidden;
  transition: opacity .35s ease, transform .35s ease, border-color .35s ease, background-color .35s ease;
  will-change: transform, opacity;
}
/* Glow ring is pre-rendered at opacity:0 and only ever fades — the
   box-shadow itself never animates, so no per-frame shadow repaint. */
.story-feature::after{
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  box-shadow: 0 0 0 1px var(--sky), 0 14px 30px -16px rgba(79,143,187,.6);
  opacity: 0;
  transition: opacity .35s ease;
  pointer-events: none;
  will-change: opacity;
}
.story-feature-icon{
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--frost);
  color: var(--sky-dark);
  transition: background-color .35s ease, color .35s ease;
}
.story-feature-icon svg{ width: 16px; height: 16px; }
.story-feature-label{ font-size: .8rem; font-weight: 700; color: var(--ink-700); line-height: 1.25; }

.story-feature.is-active{
  opacity: 1;
  transform: scale(1.05) translateZ(0);
  border-color: var(--sky);
  background: var(--paper);
}
.story-feature.is-active::after{ opacity: 1; }
.story-feature.is-active .story-feature-icon{
  background: var(--sky);
  color: var(--paper);
}
.story-feature.is-done{ opacity: .7; transform: scale(1) translateZ(0); }

/* ---------- CTA ---------- */
.product-story-cta{
  opacity: 0;
  transform: translateY(14px);
  pointer-events: none;
  transition: opacity .5s ease, transform .5s ease, box-shadow .25s ease;
}
.product-story-cta.is-visible{ opacity: 1; transform: none; pointer-events: auto; }
.product-story-cta:hover{ box-shadow: 0 0 0 1px var(--sky-dark), 0 18px 40px -18px rgba(79,143,187,.65); }

/* ---------- Media column ---------- */
.product-story-media{ position: relative; }

.product-story-video-card{
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--ink-900);
  box-shadow: var(--shadow-lg);
  aspect-ratio: 4 / 3.1;
  isolation: isolate;
  border: 1px solid rgba(255,255,255,.75);
  background-clip: padding-box;
  contain: paint;
  transform: translateZ(0);
  backface-visibility: hidden;
}
/* glassmorphism frame — a static gradient only. backdrop-filter was
   removed deliberately: it sat directly over the scrubbing <video> and
   forced a backdrop resample on every single decoded frame, which was
   one of the biggest hidden costs during fast scroll. */
.product-story-video-card::before{
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  border-radius: inherit;
  background: linear-gradient(155deg, rgba(255,255,255,.22), rgba(255,255,255,0) 30%);
}

.product-story-glow{
  position: absolute;
  inset: -20%;
  z-index: 0;
  background: radial-gradient(circle, rgba(127,182,217,.55), transparent 62%);
  filter: blur(34px);
  animation: pulse 6s ease-in-out infinite; /* keyframe defined in styles.css, opacity-only */
  will-change: opacity;
  transform: translateZ(0);
  backface-visibility: hidden;
}

.product-story-video{
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  will-change: transform;
  transform: translate3d(0, 0, 0);
  background: var(--ink-900);
}

/* ---------- Live scroll-progress percentage ---------- */
.product-story-percent{
  position: absolute;
  right: 2.2rem;
  top: 50%;
  transform: translateY(calc(-50% - 100px));
  z-index: 3;
  min-width: 2.6rem;
  text-align: center;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: .85rem;
  letter-spacing: .02em;
  color: var(--sky-dark);
  font-variant-numeric: tabular-nums;
}

/* ---------- Vertical progress indicator ---------- */
.product-story-progress{
  position: absolute;
  right: 2.2rem;
  top: 50%;
  transform: translateY(-50%);
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .55rem;
}
.product-story-progress li{
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--line);
  transition: background-color .3s ease, box-shadow .3s ease, transform .3s ease;
}
.product-story-progress li.is-active{
  background: var(--sky-dark);
  transform: scale(1.6);
  box-shadow: 0 0 0 4px rgba(79,143,187,.22);
}
.product-story-progress li.is-done{ background: var(--sky); }

/* ---------- Tablet + mobile (<=1024px): unpinned, stacked, natural
   flow. Scroll-scrub is desktop-only (>1024px) — see scroll-video.js;
   these widths get simple opacity/transform fades handled by the
   story-static state instead of a ScrollTrigger + video scrub. ---------- */
@media (max-width: 1024px){
  .product-story{ height: auto; }
  .product-story-sticky{
    position: static;
    height: auto;
    display: block;
    padding: var(--space-xl) 0;
  }
  .product-story-progress{ display: none; }
  .product-story-percent{ display: none; }
  .product-story-grid{ display: flex; flex-direction: column; gap: 2rem; }
  .product-story-media{ order: -1; }
  .product-story-video-card{ aspect-ratio: 4 / 3; max-height: none; }
  .product-story-copy{ max-width: none; }
  .product-story-desc{ display: block; }
  .product-story-features{ grid-template-columns: repeat(2, 1fr); gap: .5rem; margin-bottom: 1.2rem; }
  .story-feature{ padding: .55rem .7rem; opacity: 1; transform: none; }
  .product-story-heading{ font-size: clamp(1.5rem, 3.4vw, 2rem); margin-bottom: .5rem; }
  .product-story-sub{ margin-bottom: 0; font-size: .92rem; }
  .product-story-cta{ opacity: 1; transform: none; pointer-events: auto; }
  .product-story-bg{ opacity: 1; }
}

@media (prefers-reduced-motion: reduce){
  .product-story-bg,
  .story-feature,
  .story-feature::after,
  .product-story-cta,
  .product-story-progress li,
  .product-story-glow,
  .product-story-particles span{
    transition: none;
    animation: none;
  }
  .product-story-bg{ opacity: 1; }
}
