/* ==========================================================================
   smudgechild — how it works
   Condensed scroll-scrubbed step sequence (desktop) / vertical timeline
   (mobile). Step count is data-driven via the --hiw-steps custom property
   and the #steps grid-template-columns, both set inline from PHP.
   Depends on :root variables in style.css.
   ========================================================================== */

.hiw-wrap {
  position: relative;
  /* ~70vh of scroll per step, so a normal scroll advances the sequence. */
  height: calc(var(--hiw-steps, 4) * 70vh);
  padding-top: 14vh;
  padding-bottom: 14vh;
}

.hiw-sticky {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.hiw {
  width: min(1180px, 92vw);
  padding: 48px 40px;
  position: relative;
}

.badge-row { display: flex; justify-content: center; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin: 0 auto 40px;
  padding: 8px 15px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--line);
  box-shadow: 0 1px 2px rgba(12, 12, 13, 0.04);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.18em;
  color: var(--ink);
  text-transform: uppercase;
}

.badge .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}

.hiw__title {
  text-align: center;
  max-width: 14ch;
}

/* timeline ---------------------------------------------------- */
.timeline {
  position: relative;
  height: 32px;
  margin: 0 auto 0;
  width: 100%;
}

.timeline__fill {
  position: absolute;
  top: 50%;
  height: 2px;
  transform: translateY(-50%);
  width: 0%;
  background: var(--accent);
  border-radius: 2px;
  -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 40px), rgba(0, 0, 0, 0) 100%);
  mask-image: linear-gradient(90deg, #000 calc(100% - 40px), rgba(0, 0, 0, 0) 100%);
  transition: width 0.12s linear;
}

.node {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--bg);
  border: 1.5px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.35s ease, box-shadow 0.35s ease;
}

.node::after {
  content: "";
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--ink-faint);
  transition: background 0.35s ease, transform 0.35s ease;
}

.node.is-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(239, 108, 35, 0.12);
}

.node.is-active::after {
  background: var(--accent);
  transform: scale(1.05);
}

/* steps ------------------------------------------------------- */
/* grid-template-columns is set inline per-instance to match the step count */
.steps {
  position: relative;
  display: grid;
  margin-top: 34px;
}

.glass {
  position: absolute;
  top: -10px;
  bottom: -10px;
  left: 0;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(12, 12, 13, 0.08);
  box-shadow: 0 18px 40px -20px rgba(12, 12, 13, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(14px) saturate(115%);
  -webkit-backdrop-filter: blur(14px) saturate(115%);
  transition: left 0.55s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.4s ease;
  z-index: 0;
}

.step {
  position: relative;
  z-index: 1;
  padding: 22px 24px 26px;
  text-align: center;
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.5s ease, transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.step__tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 13px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin-bottom: 18px;
}

.step__tag .pip {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.step__title {
  font-family: var(--sans);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 13px;
  color: var(--ink);
}

.step__body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink-soft);
  margin: 0;
  text-wrap: pretty;
}

/* cta --------------------------------------------------------- */
.cta {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-top: 56px;
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.btn {
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 500;
  padding: 14px 30px;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: transform 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.btn--primary {
  background: var(--accent);
  color: #fff;
}
.btn--primary:hover { transform: translateY(-1px); background: var(--accent-hover); }

.btn--ghost {
  background: rgba(255, 255, 255, 0.5);
  border-color: var(--line);
  color: var(--ink);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.btn--ghost:hover { transform: translateY(-1px); background: rgba(255, 255, 255, 0.85); }

/* enter state for title/badge */
.reveal { opacity: 0; transform: translateY(16px); transition: opacity 0.7s ease, transform 0.7s cubic-bezier(0.22,1,0.36,1); }
.reveal.in { opacity: 1; transform: none; }

/* vertical-timeline rail (mobile only, injected by hiw.js) */
.hiw__rail { display: none; }
.hiw__rail-fill { position: absolute; left: 0; top: 0; width: 100%; height: 0; background: var(--accent); border-radius: 2px; transition: height 0.12s linear; }

/* ── Phones (≤860px) ──────────────────────────────────────────────────
   Normal scroll (no pin). Only each step's STEP pill shows at first; a
   vertical line fills orange as you scroll, and each step's title +
   description open when the line reaches its node; the buttons appear
   once the last step opens.
   Look kept from desktop: black "STEP N" pill with the orange pip, the
   desktop title/body type, the timeline's ringed nodes turned vertical,
   and the same frosted .glass highlight — it slides down to the active
   step instead of across.
   The hide/reveal rules are scoped to .hiw-wrap.js-reveal (added by
   hiw.js), so without JS every description simply shows. */
@media (max-width: 860px) {
  .hiw-wrap { height: auto; margin: 0; padding: 0; }
  .hiw-sticky { position: static; top: auto; height: auto; padding: clamp(40px, 7vh, 76px) 0 clamp(36px, 6vh, 60px); overflow: visible; display: block; }
  .hiw { padding: 0; width: 100%; }
  .hiw__title { margin: 0 22px 32px; font-size: clamp(30px, 8.5vw, 42px); max-width: 18ch; }
  .timeline { display: none; }

  /* rail column on the left: node centres at 37px from .steps' left edge */
  .steps {
    display: block;
    grid-template-columns: none !important;
    margin: 0;
    position: relative;
    padding: 0 24px 0 54px;
    overflow: visible;
  }
  .hiw__rail {
    display: block; position: absolute; left: 36px; top: 0; width: 2px;
    background: rgba(12, 12, 13, 0.12); border-radius: 2px; z-index: 0;
  }

  /* desktop's glass highlight, sliding vertically (hiw.js sets --gt / --gh) */
  .glass {
    display: block;
    left: 50px !important; right: 18px; width: auto !important; /* 18px clear of the screen edge */
    top: var(--gt, 0px); bottom: auto; height: var(--gh, 0px);
    opacity: 0;
    transition: top 0.55s cubic-bezier(0.22, 1, 0.36, 1), height 0.55s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.4s ease;
  }
  .glass.is-on { opacity: 1; }

  .step {
    position: relative; display: block; text-align: left;
    opacity: 1; transform: none; min-height: 0;
    padding: 16px 16px 18px;
    margin-bottom: 6px;
    transition: none;
  }
  .step:last-child { margin-bottom: 0; }

  /* desktop timeline node (30px ring + 11px dot), centred on the rail and
     level with the STEP pill */
  .step::before {
    content: ""; position: absolute; z-index: 1;
    left: -32px; top: 15px;
    width: 30px; height: 30px; border-radius: 50%; box-sizing: border-box;
    background: radial-gradient(circle at 50% 50%, var(--ink-faint) 0 5.5px, transparent 6px), var(--bg);
    border: 1.5px solid var(--line);
    transition: border-color 0.35s ease, background 0.35s ease, box-shadow 0.35s ease;
  }
  .step.is-on::before {
    border-color: var(--accent);
    background: radial-gradient(circle at 50% 50%, var(--accent) 0 5.8px, transparent 6.3px), var(--bg);
    box-shadow: 0 0 0 4px rgba(239, 108, 35, 0.12);
  }

  .step__tag { margin-bottom: 12px; }
  .step__title { font-size: 20px; line-height: 1.25; margin: 0; }
  .step__body { font-size: 16px; line-height: 1.6; margin-top: 10px; }

  /* the reveal — until a step is reached only its STEP pill shows; the
     title and description open together (title first) */
  .hiw-wrap.js-reveal .step__tag { margin-bottom: 0; transition: margin-bottom 0.6s ease; }
  .hiw-wrap.js-reveal .step.is-revealed .step__tag { margin-bottom: 12px; }
  .hiw-wrap.js-reveal .step__title {
    max-height: 0; opacity: 0; transform: translateY(8px);
    overflow: hidden; visibility: hidden;
    transition: max-height 0.6s ease, opacity 0.55s ease, transform 0.55s ease, visibility 0s linear 0.6s;
  }
  .hiw-wrap.js-reveal .step.is-revealed .step__title {
    max-height: var(--th, 120px); opacity: 1; transform: none; visibility: visible;
    transition: max-height 0.6s ease, opacity 0.55s ease 0.05s, transform 0.55s ease 0.05s, visibility 0s;
  }
  .hiw-wrap.js-reveal .step__body {
    max-height: 0; margin-top: 0; opacity: 0; transform: translateY(8px);
    overflow: hidden; visibility: hidden;
    transition: max-height 0.6s ease, margin-top 0.6s ease, opacity 0.55s ease, transform 0.55s ease, visibility 0s linear 0.6s;
  }
  .hiw-wrap.js-reveal .step.is-revealed .step__body {
    max-height: var(--bh, 400px); margin-top: 10px; opacity: 1; transform: none; visibility: visible;
    transition: max-height 0.6s ease, margin-top 0.6s ease, opacity 0.55s ease 0.2s, transform 0.55s ease 0.2s, visibility 0s;
  }

  .cta { margin: 34px 22px 0; padding-bottom: 8px; flex-wrap: wrap; opacity: 1; transform: none; }
  .hiw-wrap.js-reveal .cta { opacity: 0; transform: translateY(18px); pointer-events: none; transition: opacity 0.7s ease, transform 0.7s ease; }
  .hiw-wrap.js-reveal .cta.is-revealed { opacity: 1; transform: none; pointer-events: auto; }
}
/* Dylan: the mock-up shows all four steps on one phone screen; the build
   hid each step's title and text until you scrolled to it, so only two showed.
   Every title now shows from the start, the text stays compact, and the
   rail, dots and glass highlight still follow your scroll. */
@media (max-width: 860px) {
  .hiw-wrap.js-reveal .step__tag { margin-bottom: 10px; }
  .hiw-wrap.js-reveal .step__title,
  .hiw-wrap.js-reveal .step__body {
    max-height: none; opacity: 1; transform: none; visibility: visible; overflow: visible;
  }
  .hiw-wrap.js-reveal .step__body { margin-top: 6px; }
  .step { padding: 12px 14px 14px; margin-bottom: 2px; }
  .step__title { font-size: 18px; }
  .step__body { font-size: 15px; line-height: 1.5; }
}
@media (max-width: 860px) and (prefers-reduced-motion: reduce) {
  .glass, .step::before, .hiw__rail-fill,
  .hiw-wrap.js-reveal .step__tag, .hiw-wrap.js-reveal .step__title, .hiw-wrap.js-reveal .step__body, .hiw-wrap.js-reveal .cta { transition: none !important; }
}
/* Lumart, 12 Nov: the heading sat left of centre on phones (its box was
   anchored 22px from the left edge rather than centred). */
@media (max-width: 860px) {
  .hiw__title { margin-left: auto; margin-right: auto; max-width: min(18ch, calc(100% - 44px)); text-wrap: balance; }
}

/* Lumart, 12 Nov: "scroll animation on mobile is clunky, make it sticky".
   Phones now pin the section like desktop does: the heading and all four
   step titles stay on screen while you scroll, the rail fills, and only the
   current step opens its description, so nothing jumps under your thumb.
   hiw.js adds .js-pin only when the pinned view fits the screen; small
   phones and reduced-motion keep the static list above. */
@media (max-width: 860px) {
  .hiw-wrap.js-pin { height: calc(100vh + var(--hiw-steps, 4) * 42vh); height: calc(100svh + var(--hiw-steps, 4) * 42svh); }
  .hiw-wrap.js-pin .hiw-sticky {
    position: sticky; top: 0; height: 100vh; height: 100svh;
    display: flex; flex-direction: column; justify-content: flex-start; /* top-anchored: the heading stays put as steps open */
    padding: 86px 0 16px; overflow: hidden;
  }
  .hiw-wrap.js-pin .badge { margin-bottom: 10px; }
  .hiw-wrap.js-pin .hiw__title { margin-bottom: 24px; }
  /* pill and title share one row so four steps fit a phone screen */
  .hiw-wrap.js-pin .step { display: grid; grid-template-columns: auto 1fr; column-gap: 10px; align-items: center; padding: 13px 14px; margin-bottom: 4px; }
  .hiw-wrap.js-pin .step__tag,
  .hiw-wrap.js-reveal.js-pin .step__tag { margin-bottom: 0; padding: 5px 11px; font-size: 11.5px; }
  .hiw-wrap.js-pin .step__title { font-size: 17px; line-height: 1.25; }
  .hiw-wrap.js-pin .step__body { grid-column: 1 / -1; }
  .hiw-wrap.js-reveal.js-pin .step .step__body {
    max-height: 0; margin-top: 0; opacity: 0; overflow: hidden; visibility: hidden;
    transition: max-height 0.45s ease, margin-top 0.45s ease, opacity 0.3s ease, visibility 0s linear 0.45s;
  }
  .hiw-wrap.js-reveal.js-pin .step.is-current .step__body {
    max-height: var(--bh, 200px); margin-top: 6px; opacity: 1; visibility: visible;
    transition: max-height 0.45s ease, margin-top 0.45s ease, opacity 0.35s ease 0.1s, visibility 0s;
  }
  .hiw-wrap.js-pin .step__title { transition: color 0.3s ease; color: var(--ink-faint, #8a8a8a); }
  .hiw-wrap.js-pin .step.is-on .step__title { color: var(--ink); }
  .hiw-wrap.js-pin .cta { margin-top: 26px; }
}
.hiw-wrap.hiw-measuring, .hiw-wrap.hiw-measuring * { transition: none !important; }
@media (max-width: 860px) { .hiw-wrap.js-pin .step::before { top: 11px; } }

/* Lumart, 12 Nov: pinned (phone) view.
   1. Spare screen height goes between the steps (hiw.js sets --hiw-xgap and
      --hiw-xtitle), so a tall phone isn't a tight cluster with gaps above and below.
   2. Timeline nodes are plain dots with a soft orange glow, not ringed circles.
      12px dot, top 20px → centre 26px, the same centre hiw.js uses (markC). */
@media (max-width: 860px) {
  .hiw-wrap.js-pin .hiw__title { margin-bottom: calc(24px + var(--hiw-xtitle, 0px)); }
  .hiw-wrap.js-pin .step { margin-bottom: calc(4px + var(--hiw-xgap, 0px)); }
  .hiw-wrap.js-pin .step:last-child { margin-bottom: 0; }
  .hiw-wrap.js-pin .step::before {
    left: -23px; top: 20px; width: 12px; height: 12px;
    border: 0; background: var(--ink-faint, #a3a3a3); box-shadow: none;
  }
  .hiw-wrap.js-pin .step.is-on::before {
    background: var(--accent);
    box-shadow: 0 0 0 4px rgba(239, 108, 35, 0.14), 0 0 14px 2px rgba(239, 108, 35, 0.45);
  }
}
/* Tall phones (e.g. iPhone Pro Max, 440×956): larger step type so the block
   fills more of the screen. */
@media (max-width: 860px) and (min-width: 420px) and (min-height: 820px) {
  .hiw-wrap.js-pin .step { padding: 16px 16px; }
  .hiw-wrap.js-pin .step__title { font-size: 19px; }
  .hiw-wrap.js-pin .step__tag,
  .hiw-wrap.js-reveal.js-pin .step__tag { font-size: 12.5px; padding: 6px 12px; }
  .hiw-wrap.js-pin .step__body { font-size: 16.5px; }
  .hiw-wrap.js-pin .step::before { top: 23px; } /* node centre 29px, see markC */
}
/* Pinned: the fill follows scroll every frame, so no height transition (its lag let it overshoot the last dot). */
@media (max-width: 860px) { .hiw-wrap.js-pin .hiw__rail-fill { transition: none; } }
/* Lumart, 12 Nov: pinned view, the STEP pill is smaller and sits above the
   heading instead of beside it. Dot centre stays level with the pill
   (dot top = step padding + half the pill − 6; hiw.js reads it via markC). */
@media (max-width: 860px) {
  .hiw-wrap.js-pin .step { display: block; }
  .hiw-wrap.js-pin .step__tag,
  .hiw-wrap.js-reveal.js-pin .step__tag { display: inline-flex; font-size: 10px; padding: 4px 9px; gap: 6px; margin-bottom: 7px; letter-spacing: 0.14em; }
  .hiw-wrap.js-pin .step__title { display: block; }
  .hiw-wrap.js-pin .step__body { margin-top: 6px; }
  .hiw-wrap.js-pin .step::before { top: 17px; }
}
@media (max-width: 860px) and (min-width: 420px) and (min-height: 820px) {
  .hiw-wrap.js-pin .step__tag,
  .hiw-wrap.js-reveal.js-pin .step__tag { font-size: 10.5px; padding: 4px 10px; }
  .hiw-wrap.js-pin .step::before { top: 20px; }
}
/* Short phones (≤ 700px tall, e.g. iPhone SE): tighter so the pinned view still fits. */
@media (max-width: 860px) and (max-height: 700px) {
  .hiw-wrap.js-pin .hiw-sticky { padding-top: 76px; }
  .hiw-wrap.js-pin .badge { display: none; }
  .hiw-wrap.js-pin .hiw__title { margin-bottom: calc(14px + var(--hiw-xtitle, 0px)); }
  .hiw-wrap.js-pin .step { padding: 9px 12px; }
  .hiw-wrap.js-pin .step__tag,
  .hiw-wrap.js-reveal.js-pin .step__tag { margin-bottom: 4px; }
  .hiw-wrap.js-pin .step__title { font-size: 16px; }
  .hiw-wrap.js-pin .step__body { font-size: 14.5px; line-height: 1.45; margin-top: 4px; }
  .hiw-wrap.js-pin .step::before { top: 13px; }
  .hiw-wrap.js-pin .cta { margin-top: 16px; }
}

/* Lumart, 12 Nov: calmer pinned steps on phones.
   - Each step gets more scroll (64svh, was 42), so the pause between steps is longer.
   - The rail no longer follows the finger between dots: at one scroll point it
     eases from one dot to the next by itself (hiw.js sets the target height).
   - The description, the glass box and the rail all move on one 0.6s ease-in-out,
     with no slide-up, so nothing overshoots or "bounces". */
@media (max-width: 860px) {
  .hiw-wrap.js-pin { height: calc(100vh + var(--hiw-steps, 4) * 64vh); height: calc(100svh + var(--hiw-steps, 4) * 64svh); }
  .hiw-wrap.js-pin .hiw__rail-fill { transition: height 0.6s ease-in-out; }
  .hiw-wrap.js-pin .glass { transition: top 0.6s ease-in-out, height 0.6s ease-in-out, opacity 0.4s ease; }
  .hiw-wrap.js-reveal.js-pin .step .step__body {
    transform: none;
    transition: max-height 0.6s ease-in-out, margin-top 0.6s ease-in-out, opacity 0.25s ease, visibility 0s linear 0.6s;
  }
  .hiw-wrap.js-reveal.js-pin .step.is-current .step__body {
    transform: none;
    transition: max-height 0.6s ease-in-out, margin-top 0.6s ease-in-out, opacity 0.4s ease 0.2s, visibility 0s;
  }
}
/* hiw.js tweens the rail and glass itself in the pinned view (in step with the
   text), so no CSS transitions on their size or position there. */
@media (max-width: 860px) {
  .hiw-wrap.js-pin .hiw__rail-fill { transition: none; }
  .hiw-wrap.js-pin .glass { transition: opacity 0.4s ease; }
}

/* Lumart, 12 Nov: full-bleed pin (see --barpad in style.css). */
@media (max-width: 860px) {
  .hiw-wrap.js-pin .hiw-sticky { height: 100vh; height: 100lvh; padding-bottom: calc(16px + var(--barpad, 0px)); }
}
/* Lumart, 12 Nov: on taller phones the steps spread down the screen instead
   of bunching under the heading (svh, so the gaps don't move as the toolbar
   shrinks and hiw.js's measurements stay put). */
@media (max-width: 860px) {
  .hiw-wrap.js-pin .hiw__title { margin-bottom: clamp(24px, calc((100svh - 600px) / 6), 44px); }
  .hiw-wrap.js-pin .step { margin-bottom: clamp(4px, calc((100svh - 620px) / 9), 22px); }
}

/* Lumart, 13 Nov: the heading is two lines on desktop. */
@media (min-width: 861px) {
  .hiw__title { max-width: 20ch; text-wrap: balance; }
}

/* Lumart, 27 Nov 10:05 (desktop): the timeline nodes are a single dot, no ring
   and no halo. Reached steps are orange, the rest stay grey. The node box keeps
   its 30px size so hiw.js and the rail positions are unchanged. */
.node,
.node.is-active { background: transparent; border: 0; box-shadow: none; }
.node::after { width: 14px; height: 14px; }
.node.is-active::after { transform: none; }
