/* ============================================================
   DONARD DIGITAL — SCROLL INTRO (concept)
   Sequence: mist over the Mournes → scroll cue → tagline types in → filler
   words fall away → "Perform. Stand Out." lands and grows → logo → hero
   Progress values (--cue, --type, --tag-out, --logo, --exit,
   --zoom) are 0–1 and set by js/intro.js as the user scrolls.
   ============================================================ */

.intro {
  --cue: 1; --type: 0; --rm: 0; --collapse: 0; --punch: 0; --grow: 0; --growth: 0; --tag-out: 0; --logo: 0; --exit: 0; --zoom: 0;
  position: relative;
  height: 480vh;              /* 1 screen pinned + ~3.8 screens of scroll */
  background: var(--dark);
}

.intro-stage {
  position: sticky;
  top: 0;
  height: calc(100vh - 8px);
  height: calc(100svh - 8px);   /* stops short of the bottom edge so Safari's toolbar stays glass (see style.css RULE); the dark .intro behind fills the rest */
  overflow: hidden;
  display: grid;
  place-items: center;
  contain: layout paint;   /* keeps per-frame work inside the intro (also makes it the stacking context for ::before) */
}
/* The glow sits on a layer, not on the pinned stage itself. Safari 26 fills its
   bottom toolbar with the background colour of any pinned element touching the
   bottom edge, so a coloured stage gave a solid navy bar instead of clear glass. */
.intro-stage::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: radial-gradient(ellipse at 50% 60%, var(--navy) 0%, var(--dark) 70%);
  pointer-events: none;
}

/* --- Mournes: four layers by distance, rising on scroll at different speeds --- */
.intro-ridges {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: clamp(160px, 34vh, 400px);
  pointer-events: none;
}
/* Far = lightest (hazy with distance), near = darkest */
.intro-ridge-far    { fill: color-mix(in srgb, var(--light-blue) 30%, var(--navy)); transform: translateY(calc((1 - var(--zoom)) * 20px)); }
.intro-ridge-donard { fill: color-mix(in srgb, var(--blue) 45%, var(--navy)); transform: translateY(calc((1 - var(--zoom)) * 40px)); }
.intro-ridge-slopes { fill: var(--navy); transform: translateY(calc((1 - var(--zoom)) * 70px)); }
.intro-ridge-dunes  { fill: var(--dark); transform: translateY(calc((1 - var(--zoom)) * 100px)); }

/* --- Mist: soft bands over the peaks that drift, then part to the sides */
.intro-mist {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.intro-mist-band {
  --side: -1;
  position: absolute;
  width: 70vw;
  height: 14vh;
  transform: translateX(calc(var(--side) * var(--zoom) * 45vw));
  opacity: calc(1 - var(--exit) * 0.6);
}
.intro-mist-band:nth-child(1) { left: -10vw; bottom: 22vh; }
.intro-mist-band:nth-child(2) { --side: 1; left: 35vw; bottom: 26vh; height: 11vh; }
.intro-mist-band:nth-child(3) { left: 5vw;  bottom: 14vh; height: 10vh; }
.intro-mist-band:nth-child(4) { --side: 1; left: 45vw; bottom: 17vh; }
.intro-mist-band span {
  display: block;
  width: 100%;
  height: 100%;
  background: radial-gradient(ellipse at center, rgba(123, 159, 212, 0.4) 0%, rgba(123, 159, 212, 0.12) 45%, rgba(123, 159, 212, 0) 72%);   /* soft enough without a blur filter */
  will-change: transform;
  animation: intro-mist-drift 18s ease-in-out infinite alternate;
}
.intro-mist-band:nth-child(2) span { animation-duration: 24s; animation-delay: -6s; }
.intro-mist-band:nth-child(3) span { animation-duration: 21s; animation-delay: -12s; }
.intro-mist-band:nth-child(4) span { animation-duration: 27s; animation-delay: -3s; }
@keyframes intro-mist-drift {
  from { transform: translateX(-6vw); }
  to   { transform: translateX(6vw); }
}

/* Growth line: draws along Slieve Donard's edge as you scroll. A bright
   core line sits on a wide, soft, gently pulsing glow. */
.intro-growth { transform: translateY(calc((1 - var(--zoom)) * 40px)); }
.intro-growth path {
  fill: none;
  stroke-linecap: round;
  stroke-dasharray: 1;
  stroke-dashoffset: calc(1 - var(--growth));
}
/* Glow without filters (blur and drop-shadow were redrawn every frame and
   made the intro judder): the glow copy is now a wide faint stroke under
   the bright line. */
.intro-growth path:not(.intro-growth-glow) {
  stroke: color-mix(in srgb, var(--light-blue) 55%, var(--white));
  stroke-width: 2.5;
}
.intro-growth-glow {
  stroke: var(--light-blue);
  stroke-width: 9;
  opacity: 0.22;
}

/* --- Shared text layer --- */
.intro-layer {
  position: relative;
  z-index: 1;
  grid-area: 1 / 1;
  text-align: center;
  padding: 0 16px;
}

/* --- Tagline (always shown whole, both lines together) --- */
.intro-tagline {
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.01em;
  font-size: clamp(1.35rem, 5.6vw, 5rem);
  color: var(--white);
  opacity: calc(1 - var(--tag-out));
  transform: scale(calc(1 + var(--punch) * 0.35 + var(--grow) * 0.9));
}
.intro-tagline-line { display: block; white-space: nowrap; }
.intro-tagline-line + .intro-tagline-line { color: var(--light-blue); }
.intro-word { display: inline-block; }

/* Letter by letter: --type (0–1) sweeps across all --n letters; each letter
   fades and rises in as the sweep passes its index --i.
   --f (0–1) is the "fall away" amount, only used on filler letters. */
.intro-char {
  --o: clamp(0, calc(var(--type) * var(--n) - var(--i)), 1);
  --f: 0;
  --r: 0deg;
  display: inline-block;
  opacity: calc(var(--o) * (1 - var(--f)));
  transform:
    translateY(calc((1 - var(--o)) * 0.35em + var(--f) * 1.4em))
    rotate(calc(var(--f) * var(--r)));
}

/* --- Filler words ("Ads That", "Brands That") --- */
.intro-filler {
  display: inline-block;
  white-space: pre;
  vertical-align: top;
  width: calc(var(--w) * 1px * (1 - var(--collapse)));
}

/* Fall: filler letters drop one by one, each with a slight spin */
.intro-filler .intro-char {
  --f: clamp(0, calc((var(--rm) * (var(--nf) + 4) - var(--j)) / 4), 1);
}

/* --- Logo --- */
/* The logo is laid out at its LARGEST size (x1.1) and the animation only
   ever scales it down (0.77 to 1), so it is never stretched past its real
   pixels; the on-screen sizes are the same as before, just sharper. */
.intro-logo {
  opacity: var(--logo);
  transform: scale(calc((0.85 + var(--logo) * 0.15 + var(--exit) * 0.1) / 1.1));
}
.intro-logo img {
  width: clamp(176px, 24.2vw, 308px);
  margin: 0 auto;
}

/* --- Scroll cue --- */
.intro-cue {
  position: absolute;
  bottom: 40px;
  left: 50%;
  z-index: 2;
  transform: translateX(-50%);
  opacity: 0;
  animation: intro-fade-in 0.8s ease 1.6s forwards;
}
.intro-cue-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--light-blue);
  opacity: var(--cue);
}
.intro-cue-line {
  width: 1px;
  height: 48px;
  background: linear-gradient(to bottom, var(--light-blue), transparent);
  transform-origin: top;
  animation: intro-cue-pulse 1.8s ease-in-out infinite;
}
@keyframes intro-cue-pulse {
  0%   { transform: scaleY(0); opacity: 1; }
  60%  { transform: scaleY(1); opacity: 1; }
  100% { transform: scaleY(1); opacity: 0; }
}
@keyframes intro-fade-in { to { opacity: 1; } }

/* --- Skip button --- */
.intro-skip {
  position: absolute;
  top: 24px;
  right: 24px;
  z-index: 2;
  font-family: var(--font);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--light-blue);
  background: none;
  border: 1px solid rgba(123, 159, 212, 0.4);
  border-radius: 999px;
  padding: 0.6rem 1.1rem;
  cursor: pointer;
  opacity: calc(1 - var(--exit));
  transition: color var(--transition), border-color var(--transition);
}
.intro-skip:hover,
.intro-skip:focus-visible { color: var(--white); border-color: var(--white); }

/* --- Mountains fade into the hero ---
   As the logo exits, the lower mountains sink into the same dark navy the
   hero starts with, so the two sections meet with no visible edge. */
.intro-stage::after {
  content: '';
  position: absolute;
  inset: auto 0 0;
  height: 45%;
  background: linear-gradient(180deg, rgba(13, 31, 66, 0) 0%, var(--dark) 85%);
  opacity: var(--exit);
  pointer-events: none;
}

/* Hero slides up over the dark foot of the intro. Its background sits on a
   layer whose top fades out, so the mountains show through the overlap and
   there is no edge; the blue glow eases in below that. */
.intro ~ .hero-concept {
  --hero-overlap: 160px;
  z-index: 1;
  isolation: isolate;
  margin-top: calc(var(--hero-overlap) * -1);
  background: none;
}
.intro ~ .hero-concept::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(180deg, var(--dark) var(--hero-overlap), rgba(13, 31, 66, 0) calc(var(--hero-overlap) + 220px)),
    radial-gradient(ellipse 70% 60% at 75% 35%, rgba(46, 101, 184, 0.35) 0%, rgba(46, 101, 184, 0) 70%),
    linear-gradient(180deg, var(--dark) 0%, var(--navy) 100%);
  -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 var(--hero-overlap));
          mask-image: linear-gradient(180deg, transparent 0, #000 var(--hero-overlap));
  pointer-events: none;
}

/* --- Nav stays hidden until the intro is done --- */
.nav { transition: box-shadow var(--transition), transform 0.4s ease; }
body.intro-active .nav { transform: translateY(-100%); }

/* --- Reduced motion: no intro at all --- */
@media (prefers-reduced-motion: reduce) {
  .intro { display: none; }
}
