/* ════════════════════════════════════════════════════════════════
   POLYFLAKE — v2 "Protection Journey" homepage (dev preview)
   Scroll-driven phase narrative. Layers on top of site.css tokens.
   Brand tokens unchanged: navy / steel / gold / stone / D-DIN.

   Mechanism: each .phase is a tall scroll track (desktop) whose inner
   .phase__pin stays pinned (position: sticky). v2.js writes the track's
   normalized scroll progress into the CSS custom property --p (0..1);
   everything animated in a phase derives from --p, so scrolling back
   plays every animation in reverse for free.
═══════════════════════════════════════════════════════════════ */

/* ── Defaults are the STATIC layout (mobile / tablet / no-JS / reduced
      motion): phases are normal stacked full-height sections and --p
      defaults to 1 so all content is fully revealed. ── */
.phase { position: relative; --p: 1; }
.phase__pin {
  position: relative;
  min-height: 100svh; min-height: 100dvh;
  display: flex; align-items: flex-end;
  overflow: hidden;
}

/* ── Journey mode: tall tracks + sticky pins.
      v2.js adds body.v2-journey only on qualifying desktops (width,
      fine pointer, no reduced-motion). No JS → no class → static layout. ── */
body.v2-journey .phase { height: 200vh; }
body.v2-journey .phase--tall { height: 240vh; }
body.v2-journey .phase__pin {
  position: sticky; top: 0;
  height: 100svh; height: 100dvh; min-height: 0;
}

/* ── Phase media: full-bleed image, parallax + wipe reveal from --p ── */
.phase__media { position: absolute; inset: 0; z-index: 1; overflow: hidden; }
.phase__media img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  /* slow settle: starts slightly zoomed, eases out as the phase plays */
  transform: scale(calc(1.14 - var(--p) * 0.1)) translateY(calc(var(--p) * -2.5%));
  will-change: transform;
}
/* horizontal wipe: fully covered at p=0, fully revealed by p=0.18 */
.phase--wipe .phase__media {
  clip-path: inset(0 calc((1 - clamp(0, calc(var(--p) / 0.18), 1)) * 100%) 0 0);
}
/* vertical rise reveal variant */
.phase--rise .phase__media {
  clip-path: inset(calc((1 - clamp(0, calc(var(--p) / 0.18), 1)) * 100%) 0 0 0);
}

/* readability gradient, consistent with the site's hero language */
.phase__shade {
  position: absolute; inset: 0; z-index: 2; pointer-events: none;
  background:
    linear-gradient(110deg, rgba(7,23,44,0.78) 0%, rgba(7,23,44,0.48) 45%, rgba(7,23,44,0.15) 100%),
    linear-gradient(to top, rgba(7,23,44,0.80) 0%, transparent 55%);
}
.phase--copy-right .phase__shade {
  background:
    linear-gradient(250deg, rgba(7,23,44,0.78) 0%, rgba(7,23,44,0.48) 45%, rgba(7,23,44,0.15) 100%),
    linear-gradient(to top, rgba(7,23,44,0.80) 0%, transparent 55%);
}

/* exit dim: a gentle darkening in the final 8% so the next phase cuts in
   cleanly, without the earlier "tunnel" effect */
.phase__pin::after {
  content: ''; position: absolute; inset: 0; z-index: 4; pointer-events: none;
  background: #07172C;
  opacity: calc(clamp(0, calc((var(--p) - 0.92) / 0.08), 1) * 0.45);
}

/* ── Phase copy block ── */
.phase__inner {
  position: relative; z-index: 3; width: 100%;
  padding-bottom: clamp(3rem, 8vh, 6rem); padding-top: 7rem;
}
.phase__copy { max-width: 560px; }
.phase--copy-right .phase__copy { margin-left: auto; }
.phase__title { font-size: clamp(2rem, 4.6vw, 4rem); color: var(--stone-100); }
.phase__lead { color: var(--stone-300); font-size: clamp(0.95rem, 1.15vw, 1.1rem); line-height: 1.7; }

/* ghost numeral drifts slower than scroll (depth cue) */
.phase__num {
  position: absolute; z-index: 2; right: 2rem; top: 18vh;
  font-family: 'D-DIN Condensed', sans-serif; font-weight: 700; line-height: 1;
  font-size: clamp(8rem, 22vw, 20rem);
  color: transparent; -webkit-text-stroke: 1px rgba(245,185,30,0.16);
  user-select: none; pointer-events: none;
  transform: translateY(calc(var(--p) * -10vh));
}
.phase--copy-right .phase__num { right: auto; left: 2rem; }

/* per-phase progress hairline under the kicker */
.phase__meter {
  height: 2px; width: 100%; max-width: 220px; margin: 1.1rem 0 1.6rem;
  background: rgba(248,247,244,0.12); position: relative; overflow: hidden;
}
.phase__meter::before {
  content: ''; position: absolute; inset: 0; transform-origin: left;
  background: linear-gradient(90deg, var(--gold-500), var(--steel-400));
  transform: scaleX(var(--p));
}

/* stat row (Phase 4) */
.phase__stats { display: flex; flex-wrap: wrap; gap: 2.25rem; margin-top: 2rem; }
.phase__stat .num { font-size: clamp(2rem, 3vw, 2.9rem); color: var(--stone-100); }
.phase__stat .lbl { font-size: 0.72rem; color: var(--stone-400); letter-spacing: 0.08em; text-transform: uppercase; margin-top: 0.3rem; }

/* ── Phase rail (fixed left nav) — journey mode only ── */
#phase-rail { display: none; }
body.v2-journey #phase-rail {
  display: flex; flex-direction: column; gap: 1.4rem;
  position: fixed; left: 1.75rem; top: 50%; transform: translateY(-50%);
  z-index: 450;
}
.rail-item {
  --fill: 0;
  display: flex; align-items: center; gap: 0.7rem;
  text-decoration: none; opacity: 0.45;
  transition: opacity 0.3s var(--ease);
}
.rail-item:hover, .rail-item.is-current { opacity: 1; }
.rail-item__num {
  font-family: 'D-DIN Condensed', sans-serif; font-weight: 700;
  font-size: 0.8rem; color: var(--stone-100); letter-spacing: 0.08em; width: 1.4rem;
}
.rail-item__bar {
  width: 30px; height: 2px; background: rgba(248,247,244,0.18);
  position: relative; overflow: hidden;
}
.rail-item__bar::before {
  content: ''; position: absolute; inset: 0; transform-origin: left;
  background: var(--gold-500); transform: scaleX(var(--fill));
}
.rail-item__label {
  font-size: 0.62rem; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--stone-300); opacity: 0; transform: translateX(-6px);
  transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
  white-space: nowrap;
}
.rail-item:hover .rail-item__label, .rail-item.is-current .rail-item__label { opacity: 1; transform: none; }
.rail-item.is-current .rail-item__num { color: var(--gold-500); }

/* ── v2 hero (scrub-video, adapted from index) ── */
.hero-section { position: relative; }
.hero-sticky {
  position: sticky; top: 0; min-height: 100svh; min-height: 100dvh;
  display: flex; align-items: center; overflow: hidden;
}
#hero-video {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; object-position: center 45%; z-index: 1;
  opacity: 0; transition: opacity 0.8s ease;
}
#hero-video.is-ready { opacity: 1; }
body.v2-journey .hero-section { height: 230vh; }
.hero-img { position: absolute; inset: 0; background: url('images/hf-pails-tankfarm.webp') center 60%/cover no-repeat; }
.hero-overlay {
  position: absolute; inset: 0; z-index: 2; pointer-events: none;
  background:
    linear-gradient(110deg, rgba(7,23,44,0.92) 0%, rgba(7,23,44,0.68) 45%, rgba(7,23,44,0.30) 100%),
    linear-gradient(to top, rgba(7,23,44,0.9) 0%, transparent 55%);
}
.hero-inner { position: relative; z-index: 3; width: 100%; padding-top: 120px; padding-bottom: 96px; }
.hero-cue {
  position: absolute; bottom: 2.25rem; left: 50%; transform: translateX(-50%);
  z-index: 3; display: flex; flex-direction: column; align-items: center; gap: 0.6rem;
  opacity: calc(0.75 - var(--p, 0) * 6); /* gone almost immediately once scrolling starts */
  pointer-events: none;
}
.hero-cue__chev { animation: cue-bob 1.8s ease-in-out infinite; color: var(--gold-500); }
@keyframes cue-bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(7px); } }
.hero-section { --p: 0; }

/* gold pill (copied pattern from index page-level styles) */
.gold-pill {
  display: inline-flex; align-items: center; gap: 0.5rem;
  background: rgba(245,185,30,0.08); border: 1px solid rgba(245,185,30,0.25);
  color: #F5B91E; font-size: 0.7rem; font-weight: 600; letter-spacing: 0.12em;
  text-transform: uppercase; padding: 0.375rem 0.875rem; border-radius: 999px;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }

/* ── Final CTA ── */
#v2-cta { position: relative; overflow: hidden; }
#v2-cta .cta-shade { position: absolute; inset: 0; background: linear-gradient(135deg, rgba(7,23,44,0.95) 0%, rgba(18,96,168,0.72) 50%, rgba(7,23,44,0.88) 100%); }

/* ════════ THE ENEMY — corrosion villain + live cost ticker ════════ */
#enemy { position: relative; overflow: hidden; background: #060d1a; }
#enemy .enemy-bg { position: absolute; inset: 0; opacity: 0.5; }
#enemy .enemy-bg img { width: 100%; height: 100%; object-fit: cover; }
#enemy .enemy-shade { position: absolute; inset: 0; background: linear-gradient(to right, rgba(6,13,26,0.94) 0%, rgba(6,13,26,0.75) 55%, rgba(6,13,26,0.45) 100%); }
.ticker-num {
  font-family: 'D-DIN Condensed', sans-serif; font-weight: 700;
  font-size: clamp(2.6rem, 6.5vw, 5.5rem); line-height: 1; color: var(--gold-500);
  font-variant-numeric: tabular-nums; letter-spacing: 0.01em;
}
.ticker-cap { font-size: 0.72rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--stone-400); }

/* ════════ BEFORE / AFTER SLIDER ════════ */
.ba-wrap { position: relative; max-width: 1080px; margin: 0 auto; border: 1px solid rgba(255,255,255,0.1); border-radius: 4px; overflow: hidden; aspect-ratio: 16/9; }
.ba-wrap img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.ba-after { clip-path: inset(0 0 0 var(--ba, 50%)); }
.ba-divider {
  position: absolute; top: 0; bottom: 0; left: var(--ba, 50%); width: 2px;
  background: var(--gold-500); z-index: 3; pointer-events: none;
  box-shadow: 0 0 18px rgba(245,185,30,0.55);
}
.ba-handle {
  position: absolute; top: 50%; left: var(--ba, 50%); transform: translate(-50%, -50%);
  width: 46px; height: 46px; border-radius: 50%; z-index: 4; pointer-events: none;
  background: rgba(7,23,44,0.9); border: 1px solid var(--gold-500);
  display: flex; align-items: center; justify-content: center; gap: 2px;
  color: var(--gold-500); font-size: 0.8rem;
}
.ba-range {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; cursor: ew-resize; z-index: 5; margin: 0;
  -webkit-appearance: none; appearance: none;
}
.ba-tag {
  position: absolute; bottom: 1rem; z-index: 3; pointer-events: none;
  font-size: 0.66rem; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase;
  padding: 0.35rem 0.75rem; background: rgba(7,23,44,0.82); border-radius: 2px;
}
.ba-tag--before { left: 1rem; color: var(--stone-300); }
.ba-tag--after { right: 1rem; color: var(--gold-400); }

/* ════════ THE SYSTEMS — full-width product grid ════════
   Four cards that always fit the page width exactly: 4-up on desktop,
   2-up on tablet, stacked on phones. */
#systems { position: relative; background: #07172C; padding: clamp(3.5rem, 7vw, 6.5rem) 0; border-top: 1px solid rgba(255,255,255,0.05); }
.systems-row { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 640px)  { .systems-row { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .systems-row { grid-template-columns: repeat(4, 1fr); } }
.sys-card {
  position: relative; overflow: hidden; border-radius: 4px;
  aspect-ratio: 3/4; display: block;
  border: 1px solid rgba(255,255,255,0.08);
}
@media (max-width: 639px) { .sys-card { aspect-ratio: 16/10; } }
.sys-card img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: transform 0.7s var(--ease); }
.sys-card:hover img { transform: scale(1.05); }
.sys-card__shade { position: absolute; inset: 0; background: linear-gradient(to top, rgba(7,23,44,0.92) 0%, rgba(7,23,44,0.25) 55%, transparent 100%); }
.sys-card__body { position: absolute; left: 0; right: 0; bottom: 0; padding: 1.4rem; z-index: 2; }
.sys-card__idx { position: absolute; top: 1.1rem; right: 1.25rem; z-index: 2; font-family: 'D-DIN Condensed', sans-serif; font-weight: 700; font-size: 0.85rem; color: var(--gold-500); letter-spacing: 0.1em; }

/* ════════ PERSONA ROUTER ════════ */
.persona-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 900px) { .persona-grid { grid-template-columns: 1fr 1fr; } }
.persona {
  position: relative; overflow: hidden; border-radius: 4px; display: block;
  min-height: 460px; border: 1px solid rgba(255,255,255,0.08);
}
.persona img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: transform 0.8s var(--ease); }
.persona:hover img { transform: scale(1.06); }
.persona__shade { position: absolute; inset: 0; background: linear-gradient(to top, rgba(7,23,44,0.95) 0%, rgba(7,23,44,0.45) 55%, rgba(7,23,44,0.15) 100%); transition: background 0.4s var(--ease); }
.persona:hover .persona__shade { background: linear-gradient(to top, rgba(12,45,80,0.94) 0%, rgba(7,23,44,0.5) 60%, rgba(7,23,44,0.15) 100%); }
.persona__body { position: absolute; left: 0; right: 0; bottom: 0; padding: 2rem; z-index: 2; }
.persona__stats { display: flex; gap: 1.75rem; margin: 1.1rem 0 1.25rem; }
.persona__stat b { display: block; font-family: 'D-DIN Condensed', sans-serif; font-weight: 700; font-size: 1.6rem; color: var(--gold-500); }
.persona__stat span { font-size: 0.62rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--stone-400); }
.persona__go { display: inline-flex; align-items: center; gap: 0.5rem; color: var(--stone-100); font-weight: 600; font-size: 0.85rem; transition: gap 0.3s var(--ease); }
.persona:hover .persona__go { gap: 0.9rem; color: var(--gold-400); }

/* ════════ GLOBAL RESPONSE NETWORK ════════ */
#network { background: #060d1a; position: relative; overflow: hidden; }
.net-stage { position: relative; max-width: 1080px; margin: 0 auto; }
.net-stage svg { display: block; width: 100%; height: auto; }
.net-arc { fill: none; stroke: rgba(91,170,235,0.4); stroke-width: 1.2; stroke-dasharray: 6 7; animation: net-dash 2.6s linear infinite; }
@keyframes net-dash { to { stroke-dashoffset: -26; } }
.net-node { fill: var(--gold-500); }
.net-pulse { fill: none; stroke: var(--gold-500); stroke-width: 1; opacity: 0; transform-origin: center; animation: net-pulse 3s ease-out infinite; }
@keyframes net-pulse { 0% { opacity: 0.8; transform: scale(0.4); } 80% { opacity: 0; transform: scale(2.1); } 100% { opacity: 0; } }
.net-label { font-family: 'D-DIN', sans-serif; font-size: 10px; letter-spacing: 0.14em; fill: #B0A898; text-transform: uppercase; }
.net-label--hq { fill: #F5B91E; font-weight: 700; }
@media (prefers-reduced-motion: reduce) { .net-arc, .net-pulse { animation: none; } .net-pulse { opacity: 0; } }

/* ── Static-mode niceties ── */
@media (max-width: 1023px) {
  .phase__num { font-size: clamp(6rem, 26vw, 10rem); top: 10vh; }
  .phase__inner { padding-top: 5.5rem; }
  .persona { min-height: 400px; }
}
