/* ============================================================
   ZIRYVO — the site that builds itself
   A scroll-scrubbed sequence: one progress number (--p, written by
   js/build.js) drives every element through its own window of that
   number. Each element declares --in and --out; --t is its local
   0→1 within that window, and everything else is derived from --t.

   Nothing here animates on a timer, so scrubbing backwards is as
   smooth as scrolling forwards, and a visitor who stops mid-way
   holds a coherent frame rather than a half-finished one.
   ============================================================ */

/* Local progress. clamp() with plain numbers keeps this to one line
   per element instead of a keyframe track each. */
.build [style*="--in"],
.build .bstep,
.build .blk,
.build .ln,
.build .pill,
.build .card,
.build .cursor,
.build .page__grid,
.build .dim,
.build .sel,
.build .prop,
.build .score,
.build .net {
  --t: clamp(0, (var(--p, 0) - var(--in, 0)) / (var(--out, 1) - var(--in, 0)), 1);
}

.build { padding-block: var(--sp-md) 0; }
.build__label { margin-bottom: clamp(24px, 3vw, 40px); }

/* The tall track is the scroll budget for the sequence; the sticky
   child is what the visitor actually looks at. */
.build__track { height: 320vh; position: relative; }
.build__stick {
  position: sticky;
  top: 0;
  height: 100svh;
  display: flex;
  align-items: center;
  overflow: hidden;
}
.build__in {
  display: grid;
  grid-template-columns: 1fr;
  gap: clamp(26px, 4vw, 60px);
  align-items: center;
  width: 100%;
}

/* ---------------------------------------------------------- steps */
.build__steps { list-style: none; display: grid; gap: clamp(10px, 1.4vh, 18px); }

.bstep {
  position: relative;
  padding-left: 30px;
  opacity: calc(0.22 + 0.78 * var(--t));
  transition: opacity 0.25s linear;
}
.bstep__mark {
  position: absolute;
  left: 0;
  top: 0.44em;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, calc(0.2 + 0.8 * var(--t)));
  background: rgba(184, 255, 61, var(--t));
  box-shadow: 0 0 calc(14px * var(--t)) rgba(184, 255, 61, calc(0.5 * var(--t)));
}
/* The rail that joins them, filled to the same progress. */
.build__steps::before {
  content: '';
  position: absolute;
  margin-top: 0.5em;
  width: 1px;
  height: calc(100% - 1em);
  background:
    linear-gradient(to bottom, var(--lime) calc(var(--p, 0) * 100%),
                    rgba(255, 255, 255, 0.1) calc(var(--p, 0) * 100%));
  transform: translateX(4px);
}
.build__steps { position: relative; }

.bstep b {
  display: block;
  font-size: clamp(1rem, 1.3vw, 1.2rem);
  font-weight: 500;
  letter-spacing: -0.018em;
  color: rgba(255, 255, 255, calc(0.6 + 0.4 * var(--t)));
}
.bstep i {
  display: block;
  margin-top: 4px;
  font-style: normal;
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--fg-soft);
  max-width: 42ch;
  /* Only the stage being read carries its sentence; the rest stay as
     titles, or six paragraphs shout at once. */
  opacity: calc(var(--t) * (1 - var(--t)) * 4);
  max-height: calc(var(--t) * (1 - var(--t)) * 4 * 6em);
  overflow: hidden;
  transition: opacity 0.2s linear;
}

/* ---------------------------------------------------------- browser */
.browser {
  position: relative;
  /* The page inside reflows for real when the frame narrows, so the
     layout rules below can ask the container how wide it is instead of
     asking the viewport. */
  container-type: inline-size;
  width: calc(100% * var(--squeeze, 1));
  margin-inline: auto;
  border: 1px solid rgba(255, 255, 255, calc(0.08 + 0.1 * var(--p, 0)));
  border-radius: clamp(10px, 1.1vw, 16px);
  background: #050505;
  overflow: hidden;
  box-shadow: 0 40px 120px -60px rgba(184, 255, 61, calc(0.3 * var(--p, 0)));
  transform: perspective(1400px) rotateY(calc((1 - var(--p, 0)) * -3deg)) translateZ(0);
  transition: transform 0.3s linear;
}

.browser__bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(255, 255, 255, 0.022);
}
.browser__dots { display: inline-flex; gap: 5px; }
.browser__dots i {
  width: 7px; height: 7px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
}
.browser__url {
  flex: 1;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  font-size: 0.68rem;
  letter-spacing: 0.02em;
  color: var(--fg-soft);
}
.browser__lock {
  width: 10px; height: 10px;
  color: var(--lime);
  opacity: var(--lock, 0);
  transition: opacity 0.3s linear;
}
.browser__host::after {
  content: '';
  display: inline-block;
  width: 1px;
  height: 0.9em;
  margin-left: 2px;
  background: var(--fg-soft);
  vertical-align: -2px;
  opacity: var(--caret, 0);
  animation: caret-blink 1s steps(1, end) infinite;
}
@keyframes caret-blink { 50% { opacity: 0; } }


/* ---------------------------------------------------------- the page */
.browser__page {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 10;
  padding: clamp(10px, 1.4vw, 20px);
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: clamp(8px, 1vw, 14px);
  background: #000;
}

/* Stage one: a drafting grid, nothing on it yet. */
.page__grid {
  --in: 0; --out: .1;
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right,  rgba(255,255,255,.07) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255,255,255,.07) 1px, transparent 1px);
  background-size: 34px 34px;
  opacity: calc(var(--t) * (1 - var(--p, 0) * 0.55));
}

/* Blocks arrive as wireframe outlines, then fill. */
.blk {
  position: relative;
  border: 1px dashed rgba(255, 255, 255, calc(0.22 * (1 - var(--fill, 0))));
  border-radius: calc(4px + 8px * var(--fill, 0));
  background: rgba(255, 255, 255, calc(0.03 * var(--fill, 0)));
  opacity: var(--t);
  transform: translateY(calc((1 - var(--t)) * 10px));
}
.blk--nav   { --in: .12; --out: .2; display: flex; align-items: center; gap: 10px; padding: 8px 10px;
              overflow: hidden; }
.blk--hero  { --in: .16; --out: .26; display: flex; flex-direction: column; justify-content: center; gap: 7px; padding: clamp(10px, 1.6vw, 22px); }
.blk--media { --in: .2;  --out: .3;  overflow: hidden; }
.blk--cards { --in: .24; --out: .34; display: grid; grid-template-columns: repeat(3, 1fr); gap: clamp(8px, 1vw, 14px); padding: 0; border: 0; }

.blk__mark {
  width: 14px; height: 14px; border-radius: 3px;
  background: rgba(255, 255, 255, calc(0.18 + 0.5 * var(--fill, 0)));
}

/* Text lines: grey bars that gain weight and, at design stage, colour. */
.ln {
  display: block;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, calc(0.1 + 0.26 * var(--fill, 0)));
  transform-origin: left center;
  transform: scaleX(var(--t));
}
.ln--nav { width: 34px; flex: 0 1 34px; height: 5px; --in: .3; --out: .4; }
.ln--h   { width: 76%;  height: clamp(10px, 1.5vw, 16px); --in: .3; --out: .42;
           background: rgba(255, 255, 255, calc(0.2 + 0.7 * var(--fill, 0))); }
.ln--h2  { width: 52%; --in: .33; --out: .45; }
.ln--sub { width: 40%; height: 6px; --in: .36; --out: .48; }

.pill {
  display: block;
  width: 54px; height: 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  margin-left: auto;
  opacity: var(--t);
  --in: .3; --out: .42;
}
.pill--cta {
  width: 82px; height: clamp(18px, 2.2vw, 26px);
  margin: 6px 0 0;
  --in: .4; --out: .52;
  /* The lime arrives here and nowhere earlier: colour is a decision,
     not a default. */
  background: color-mix(in srgb, var(--lime) calc(var(--fill, 0) * 100%), rgba(255,255,255,.12));
  box-shadow: 0 0 calc(24px * var(--fill, 0)) rgba(184, 255, 61, calc(0.35 * var(--fill, 0)));
}

.blk--media { background: linear-gradient(120deg, rgba(255,255,255,.06), rgba(255,255,255,.02)); }
.media__sheen {
  position: absolute;
  inset: 0;
  background: radial-gradient(60% 80% at 30% 40%, rgba(184,255,61,.16), transparent 70%);
  opacity: var(--fill, 0);
}

.card {
  --in: .42; --out: .56;
  border-radius: calc(3px + 6px * var(--fill, 0));
  background: rgba(255, 255, 255, calc(0.04 + 0.04 * var(--fill, 0)));
  border: 1px solid rgba(255, 255, 255, calc(0.06 + 0.06 * var(--fill, 0)));
  opacity: var(--t);
  transform: translateY(calc((1 - var(--t)) * 8px));
}
.card:nth-child(2) { --in: .45; --out: .59; }
.card:nth-child(3) { --in: .48; --out: .62; }


/* ---------------------------------------------------------- instruments
   Each of these is on screen for one stage and gone by the next: they
   are what that stage's work looks like, not ornaments left lying
   around. */

/* Width readout in the chrome — it counts down as the frame squeezes. */
.browser__w {
  font-size: .62rem;
  letter-spacing: .12em;
  color: var(--fg-faint);
  font-variant-numeric: tabular-nums;
  opacity: var(--w-on, 0);
  transition: opacity .3s linear;
}

/* Measurements: the structure stage, stated the way a drawing states it. */
.dim {
  --in: .16; --out: .3;
  position: absolute;
  color: var(--lime);
  font-size: .56rem;
  letter-spacing: .1em;
  font-variant-numeric: tabular-nums;
  /* Visible for its own stage and then gone: opacity peaks mid-window. */
  opacity: calc(4 * var(--t) * (1 - var(--t)));
}
.dim i { position: absolute; background: currentColor; }
.dim b { position: absolute; font-weight: 400; }

.dim--w { left: 8%; right: 8%; top: 27%; height: 1px; }
.dim--w i { inset: 0; }
.dim--w i::before, .dim--w i::after {
  content: ''; position: absolute; top: -3px; width: 1px; height: 7px; background: currentColor;
}
.dim--w i::before { left: 0; } .dim--w i::after { right: 0; }
.dim--w b { left: 50%; top: -14px; transform: translateX(-50%); background: #000; padding: 0 5px; }

.dim--h { left: 4%; top: 8%; bottom: 62%; width: 1px; }
.dim--h i { inset: 0; }
.dim--h i::before, .dim--h i::after {
  content: ''; position: absolute; left: -3px; width: 7px; height: 1px; background: currentColor;
}
.dim--h i::before { top: 0; } .dim--h i::after { bottom: 0; }
.dim--h b { left: 7px; top: 50%; transform: translateY(-50%); }

/* Selection frame: the design stage, as the tool shows it. */
.sel {
  --in: .34; --out: .5;
  position: absolute;
  inset: -6px;
  border: 1px solid rgba(184, 255, 61, .55);
  opacity: calc(4 * var(--t) * (1 - var(--t)));
  pointer-events: none;
}
.sel i {
  position: absolute; width: 6px; height: 6px;
  background: #000; border: 1px solid var(--lime);
}
.sel i:nth-child(1) { left: -3px; top: -3px; }
.sel i:nth-child(2) { right: -3px; top: -3px; }
.sel i:nth-child(3) { left: -3px; bottom: -3px; }
.sel i:nth-child(4) { right: -3px; bottom: -3px; }

.prop {
  --in: .36; --out: .52;
  position: absolute;
  top: -26px; left: -6px;
  padding: 3px 8px;
  border-radius: 5px;
  background: var(--lime);
  color: #0a0a0a;
  font-size: .56rem;
  letter-spacing: .04em;
  white-space: nowrap;
  opacity: calc(4 * var(--t) * (1 - var(--t)));
}

/* Launch: a score that counts up on a ring, and the three requests the
   page actually makes. */
.score {
  --in: .74; --out: .88;
  position: absolute;
  right: clamp(12px, 1.6vw, 22px);
  top: clamp(12px, 1.6vw, 22px);
  width: 52px; height: 52px;
  display: grid;
  place-items: center;
  opacity: var(--t);
  transform: scale(calc(.85 + .15 * var(--t)));
}
.score svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.score circle { fill: none; stroke-width: 2; }
.score__track { stroke: rgba(255, 255, 255, .1); }
.score__run {
  stroke: var(--lime);
  stroke-linecap: round;
  stroke-dasharray: 119.4;
  stroke-dashoffset: calc(119.4 * (1 - var(--t)));
}
.score b { font-size: .86rem; font-weight: 500; color: var(--lime); font-variant-numeric: tabular-nums; }

.net {
  --in: .78; --out: .92;
  position: absolute;
  left: clamp(12px, 1.6vw, 22px);
  bottom: 31%;
  width: min(190px, 34%);
  display: grid;
  gap: 5px;
  opacity: calc(4 * var(--t) * (1 - var(--t)));
}
.net__row { display: grid; grid-template-columns: 28px 1fr; align-items: center; gap: 7px; }
.net__row em {
  font-style: normal; font-size: .52rem; letter-spacing: .12em;
  text-transform: uppercase; color: var(--fg-faint);
}
.net__row i {
  height: 3px; border-radius: 2px; background: var(--lime);
  transform-origin: left center;
  /* Each bar starts a beat after the one above it, the way a waterfall
     chart actually stacks. */
  transform: scaleX(calc(var(--w) * clamp(0, (var(--t) - var(--d)) * 3, 1)));
}
.net__t {
  font-size: .56rem; letter-spacing: .1em; color: var(--fg-soft);
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------- reflow
   When the frame is squeezed to a phone width the page inside answers
   the way a real one does: the cards stack and the type steps down. */
@container (max-width: 460px) {
  .blk--cards { grid-template-columns: 1fr; }
  .ln--h { height: 9px; }
  .blk--hero { padding: 12px; }
  .sel, .prop, .dim { display: none; }
}

/* ---------------------------------------------------------- cursor */
.cursor {
  --in: .84; --out: 1;
  position: absolute;
  left: calc(22% + var(--t) * 12%);
  top: calc(74% - var(--t) * 12%);
  width: 15px; height: 15px;
  opacity: calc(var(--t) * 4);
  background: #fff;
  clip-path: polygon(0 0, 0 86%, 26% 66%, 44% 100%, 62% 92%, 44% 58%, 78% 56%);
  filter: drop-shadow(0 2px 6px rgba(0,0,0,.8));
}
/* The click lands at the very end, on the button it was heading for. */
.cursor::after {
  content: '';
  position: absolute;
  left: -14px; top: -14px;
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1px solid var(--lime);
  opacity: calc(max(0, var(--t) - 0.82) * 5.5);
  transform: scale(calc(0.3 + max(0, var(--t) - 0.82) * 3.8));
}

/* ---------------------------------------------------------- layout */
@media (min-width: 960px) {
  .build__in { grid-template-columns: minmax(260px, 0.8fr) 1.2fr; gap: clamp(40px, 5vw, 80px); }
}
@media (max-width: 959px) {
  .build__track { height: 280vh; }
  .bstep i { display: none; }
  .build__steps { gap: 8px; }
}

/* Without motion the sequence is simply shown finished: the same
   picture, minus the reason to scroll through it. */
@media (prefers-reduced-motion: reduce) {
  .build__track { height: auto; }
  .build__stick { position: static; height: auto; padding-block: clamp(40px, 6vw, 80px); }
  .bstep i { display: block; opacity: 1; max-height: none; }
}

/* ============================================================
   THE CALL — a recording the visitor scrubs
   Same engine as above: --p is the playhead, everything else is
   derived from it. The bars' heights are the one thing written
   from JS, because their shape depends on distance from the head.
   ============================================================ */
.talk { padding-block: var(--sp-lg) 0; }
.talk__head { text-align: center; margin-bottom: clamp(30px, 4vw, 54px); }
.talk__title { max-width: 20ch; margin-inline: auto; }

.talk__track { height: 300vh; position: relative; }
.talk__stick { position: sticky; top: 0; height: 100svh; display: flex; align-items: center; }
.talk__in { display: grid; gap: clamp(22px, 3vh, 40px); justify-items: center; width: 100%; }

.talk__meta { display: inline-flex; align-items: center; gap: 10px; color: var(--fg-soft); }
.talk__live {
  width: 7px; height: 7px; border-radius: 50%; background: var(--lime);
  box-shadow: 0 0 14px rgba(184, 255, 61, .8);
  animation: talk-blink 2s ease-in-out infinite;
}
@keyframes talk-blink { 50% { opacity: .35; } }
.talk__clock { font-variant-numeric: tabular-nums; letter-spacing: .1em; font-size: .85rem; }

.talk__wave {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(1.5px, .36vw, 3px);
  height: 118px;
  width: 100%;
  /* The ends fade out, so the recording reads as a section of a longer
     call rather than as a complete object with edges. */
  -webkit-mask-image: linear-gradient(to right, transparent, #000 8%, #000 92%, transparent);
          mask-image: linear-gradient(to right, transparent, #000 8%, #000 92%, transparent);
}
.talk__wave i {
  /* 64 bars at a fixed width are wider than a phone; they share the room
     instead, down to a hairline. */
  flex: 1 1 0;
  min-width: 1px;
  max-width: 3px;
  height: 5px;
  border-radius: 2px;
  background: rgba(255, 255, 255, .14);
  transition: background .25s linear;
}
.talk__wave i.is-said { background: rgba(255, 255, 255, .3); }
.talk__wave i.is-live { background: var(--lime); box-shadow: 0 0 14px rgba(184, 255, 61, .55); }

.talk__tape { list-style: none; display: grid; gap: clamp(14px, 2vh, 24px); width: min(760px, 100%); }
.say {
  --t: clamp(0, (var(--p, 0) - var(--in)) / (var(--out) - var(--in)), 1);
  display: grid;
  gap: 8px;
  max-width: 88%;
  opacity: var(--t);
  transform: translateY(calc((1 - var(--t)) * 12px));
}
.say--zy { justify-self: end; text-align: right; }
.say--zy .say__who { color: var(--lime); }
.say__line {
  font-size: clamp(1.02rem, 2vw, 1.5rem);
  line-height: 1.38;
  letter-spacing: -.02em;
}
.say:not(.say--zy) .say__line { color: var(--fg-soft); }

.talk__done {
  --t: clamp(0, (var(--p, 0) - var(--in)) / (var(--out) - var(--in)), 1);
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 11px 20px;
  border-radius: 999px;
  border: 1px solid rgba(184, 255, 61, .4);
  color: var(--lime);
  font-size: .92rem;
  opacity: var(--t);
  transform: scale(calc(.94 + .06 * var(--t)));
}

/* ============================================================
   CAPABILITIES — a rail the page pushes sideways
   ============================================================ */
.caps { padding-block: var(--sp-lg) 0; }
.caps__head { margin-bottom: clamp(40px, 5vw, 76px); }
.caps__head h2 { max-width: 18ch; }

.caps__track { height: 340vh; position: relative; }
.caps__stick { position: sticky; top: 0; height: 100svh; display: flex; flex-direction: column;
               justify-content: center; gap: clamp(26px, 4vh, 48px); overflow: hidden; }
.caps__viewport { width: 100%; overflow: hidden; }
.caps__rail {
  display: flex;
  gap: clamp(18px, 2.4vw, 34px);
  /* The first card starts where the page's text column starts, so the
     rail feels like part of the layout rather than a strip laid over it. */
  padding-inline: max(calc((100vw - 1240px) / 2), clamp(16px, 3vw, 48px));
  transform: translate3d(calc(var(--p, 0) * var(--travel, 0px) * -1), 0, 0);
  will-change: transform;
}
.capc {
  flex: none;
  width: min(430px, 76vw);
  padding: clamp(26px, 3vw, 44px);
  border-radius: clamp(14px, 1.6vw, 22px);
  border: 1px solid var(--line-soft);
  background: linear-gradient(160deg, rgba(255,255,255,.035), rgba(255,255,255,.008));
}
.capc__n { font-size: .72rem; letter-spacing: .24em; color: var(--lime); }
.capc__t { font-size: clamp(1.5rem, 2.6vw, 2.1rem); font-weight: 500; letter-spacing: -.03em; margin: 18px 0 12px; }
.capc__d { color: var(--fg-soft); line-height: 1.6; }

.caps__bar { display: block; width: min(1240px, calc(100% - clamp(32px, 6vw, 96px))); margin-inline: auto;
             height: 1px; background: rgba(255, 255, 255, .1); }
.caps__bar i { display: block; height: 100%; background: var(--lime); width: calc(var(--p, 0) * 100%); }

/* ---------------------------------------------------------- small screens */
@media (max-width: 899px) {
  /* Pinning a section on a phone steals the scroll for no benefit: the
     rail becomes a swipe list and the page keeps moving. */
  .caps__track { height: auto; }
  .caps__stick { position: static; height: auto; }
  .caps__rail {
    transform: none;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding-bottom: 6px;
    scrollbar-width: none;
  }
  .caps__rail::-webkit-scrollbar { display: none; }
  .capc { scroll-snap-align: start; }
  .caps__bar { display: none; }

  .talk__track { height: 260vh; }
  .talk__wave { height: 80px; }
  .say { max-width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .talk__track, .caps__track { height: auto; }
  .talk__stick, .caps__stick { position: static; height: auto; padding-block: clamp(40px, 6vw, 80px); }
  .talk__live { animation: none; }
  .caps__rail { transform: none; flex-wrap: wrap; justify-content: center; }
  .capc { width: min(430px, 100%); }
}
