/* Motion layer. Everything here is an enhancement: with JavaScript off or reduced
   motion on, the page renders in its finished state. Behaviour lives in js/motion.js. */

/* Lenis smooth scrolling (required rules) */
html.lenis, html.lenis body { height: auto; }
.lenis:not(.lenis-autoToggle).lenis-stopped { overflow: clip; }
.lenis.lenis-smooth [data-lenis-prevent] { overscroll-behavior: contain; }

/* Page transition cover. `pt-cover` is set in <head> so the cover is there from the first paint. */
html.pt-cover::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 999;
  background: var(--ds-thunder);
}
.pt {
  position: fixed;
  inset: 0;
  z-index: 1000;
  pointer-events: none;
  visibility: hidden;
  overflow: clip;
}
.pt__panel {
  position: absolute;
  inset: 0;
  background: var(--ds-thunder);
}
/* curved leading and trailing edges */
.pt__panel::before,
.pt__panel::after {
  content: "";
  position: absolute;
  left: -15%;
  right: -15%;
  height: 22vh;
  background: inherit;
}
.pt__panel::before { bottom: calc(100% - 1px); border-radius: 50% 50% 0 0 / 100% 100% 0 0; }
.pt__panel::after { top: calc(100% - 1px); border-radius: 0 0 50% 50% / 0 0 100% 100%; }
.pt__brand {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.9rem;
  color: var(--ds-white);
  font: 700 clamp(2rem, 5vw, 3.25rem)/1 var(--ds-font-display);
  letter-spacing: var(--ds-tracking-display);
  visibility: hidden;
}
.pt__brand svg { width: 1.45em; height: 1.45em; overflow: visible; }
.pt__word { display: inline-flex; overflow: hidden; padding-block: 0.08em; }
.pt__word span { display: inline-block; }

/* Buttons: the label rolls letter by letter on hover (built by motion.js) */
.btn-roll { display: inline-flex; overflow: hidden; line-height: 1.3; }
.btn-roll__c {
  position: relative;
  display: inline-block;
  white-space: pre;
  transition: transform 0.5s cubic-bezier(0.625, 0.05, 0, 1);
  transition-delay: calc(var(--i, 0) * 14ms);
}
.btn-roll__c::after { content: attr(data-c); position: absolute; left: 0; top: 100%; }
a:hover > .btn-roll .btn-roll__c,
a:focus-visible > .btn-roll .btn-roll__c { transform: translateY(-100%); }

/* Marquee: one line that drifts, and speeds up with the scroll */
.marquee { overflow: clip; padding-block: clamp(var(--space-6), 5vw, var(--space-8)); border-block: 1px solid var(--ds-border); }
.marquee__track { display: flex; width: max-content; will-change: transform; }
.marquee__item {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 0.6em;
  padding-right: 0.6em;
  font: 700 clamp(2.5rem, 8vw, 6.5rem)/1.05 var(--ds-font-display);
  letter-spacing: var(--ds-tracking-display);
  white-space: nowrap;
  color: var(--ds-text);
}
.marquee__item::after { content: ""; width: 0.28em; height: 0.28em; border-radius: 50%; background: var(--ds-storm-blue); }

/* Statement: large text that sharpens word by word as it is scrolled through */
.statement p {
  max-width: 24ch;
  font: 500 clamp(1.75rem, 4.4vw, 3.5rem)/1.15 var(--ds-font-display);
  letter-spacing: var(--ds-tracking-display);
  color: var(--ds-text);
}

/* Stack: cards that pile up while scrolling (a sequence: each card is one step) */
.stack-cards { display: grid; gap: var(--space-6); counter-reset: card; }
.stack-card {
  counter-increment: card;
  position: sticky;
  top: calc(var(--header-h) + var(--space-5) + var(--n, 0) * 1.25rem);
  display: grid;
  gap: var(--space-5);
  min-height: min(26rem, 60vh);
  padding: clamp(1.5rem, 4vw, 3.5rem);
  border-radius: var(--ds-radius-lg);
  border: 1px solid var(--ds-border);
  background: var(--ds-surface);
  color: var(--ds-text);
  transform-origin: 50% 0;
  will-change: transform;
}
.stack-card:nth-child(2) { --n: 1; background: var(--ds-thunder); border-color: var(--ds-thunder); color: var(--ds-white); }
.stack-card:nth-child(3) { --n: 2; background: var(--ds-cloud); border-color: var(--ds-cloud); color: var(--ds-ink); }
.stack-card::before {
  content: counter(card);
  font: 700 clamp(3.5rem, 9vw, 7rem)/0.9 var(--ds-font-display);
  letter-spacing: var(--ds-tracking-display);
  opacity: 0.35;
}
.stack-card h3 { font: var(--ds-h2); letter-spacing: -0.02em; }
.stack-card p { margin-top: var(--space-3); font-size: 1.25rem; line-height: 1.5; max-width: 34ch; opacity: 0.85; }
@media (min-width: 48em) {
  .stack-card { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); align-items: end; }
}

/* Curved top edge on the call-to-action band; motion.js flattens it while it scrolls in (--arc: 1 -> 0) */
:root { --arc-max: clamp(2rem, 7vw, 6rem); }
.motion .cta-band {
  position: relative;
  z-index: 1;
  margin-top: calc(var(--arc-max) * -1);
  border-radius: 50% 50% 0 0 / calc(var(--arc, 0) * var(--arc-max)) calc(var(--arc, 0) * var(--arc-max)) 0 0;
}
.motion .section:has(+ .cta-band) { padding-bottom: calc(clamp(var(--space-8), 9vw, var(--space-9)) + var(--arc-max)); }

/* Tilted cards must not widen the page on small screens (clip keeps position: sticky working) */
.motion main { overflow-x: clip; }

/* Decode: text arrives as code and resolves into its final wording (built by motion.js).
   --dc-code sets the colour of the unresolved code; a product can override it in its tile.css. */
.dc__code { color: var(--dc-code, currentColor); opacity: 0.75; font-family: var(--ds-font-mono); font-size: 0.86em; letter-spacing: -0.02em; }
.is-decoding { overflow: hidden; }

/* Masked lines: leave room for descenders (g, y, p) so they are not clipped */
.line-mask { padding-bottom: 0.14em; margin-bottom: -0.14em; }
