/* Ascend motion. Rules: transform and opacity only; native scroll; nothing loops; complete and readable without JS
 * (every rule below is gated by .js) and with prefers-reduced-motion (gated by no-preference). Tokens: tokens.css. */

@media (prefers-reduced-motion: no-preference) {

  /* 1. Entrance choreography: elements marked data-rise settle in sequence on load. Order set with style="--i:N". */
  .js [data-rise] { animation: m-rise var(--dur-4) var(--ease-out) both; animation-delay: calc(var(--i, 0) * var(--stagger) + 80ms); }
  @keyframes m-rise { from { opacity: 0; transform: translate3d(0, 18px, 0); } to { opacity: 1; transform: none; } }
  .js [data-rise="fade"] { animation-name: m-fade; }
  @keyframes m-fade { from { opacity: 0; } to { opacity: 1; } }

  /* 2. Scroll-driven (CSS scroll timelines, compositor thread). Browsers without support keep the static final state. */
  @supports (animation-timeline: view()) {
    /* Section content rises as it enters. */
    .js [data-scroll="rise"] { animation: m-lift linear both; animation-timeline: view(); animation-range: entry 0% entry 55%; }

    /* Product stage: tilts in perspective and settles flat as it reaches the middle of the viewport. */
    .js .stage-3d { perspective: 1400px; }
    .js .stage-3d > .stage-plane { animation: m-tilt linear both; animation-timeline: view(); animation-range: entry 10% cover 45%; transform-origin: 50% 100%; }
    @keyframes m-tilt { from { transform: rotateX(14deg) translate3d(0, 40px, 0) scale(.94); } to { transform: none; } }
    /* Scroll-driven motion never changes opacity, so text keeps full contrast at every scroll position. */
    @keyframes m-lift { from { transform: translate3d(0, 28px, 0); } to { transform: none; } }

    /* Controlled parallax: bounded by --parallax-max. */
    .js [data-drift] { animation: m-drift linear both; animation-timeline: view(); animation-range: cover; }
    @keyframes m-drift { from { transform: translate3d(0, calc(var(--parallax-max) * -1), 0); } to { transform: translate3d(0, var(--parallax-max), 0); } }
  }

  /* 3. Hover and press: one lift, one underline, one arrow nudge. */
  .lift { transition: transform var(--dur-2) var(--ease-out), border-color var(--dur-2) var(--ease-out); }
  .lift:hover { transform: translate3d(0, -3px, 0); border-color: var(--hairline-strong); }
}

/* 4. Sticky product story: copy steps scroll, the stage stays; JS marks the active step (data-active on .story). */
.story { display: grid; gap: var(--sp-7); }
.story-stage { position: sticky; top: calc(var(--header-h) + var(--sp-3)); z-index: 2; height: 260px; align-self: start; border: 1px solid var(--hairline-strong); border-radius: 14px; background: var(--surface-0); overflow: hidden; }
.story-panel { position: absolute; inset: 0; padding: var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-3); }
.story-steps { display: grid; gap: var(--sp-7); }
.story-step { min-height: 38vh; padding-block: var(--sp-4); border-left: 2px solid var(--hairline); padding-left: var(--sp-5); }
.story-step h3 { font-size: var(--fs-5); font-weight: 600; letter-spacing: -.025em; margin-bottom: var(--sp-3); }
.story-step p { color: var(--fg-2); max-width: 32em; }
@media (min-width: 900px) {
  .story { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: var(--sp-8); align-items: start; }
  .story-stage { grid-column: 2; grid-row: 1; height: min(420px, calc(100vh - var(--header-h) - var(--sp-8))); top: calc(var(--header-h) + var(--sp-5)); }
  .story-steps { grid-column: 1; grid-row: 1; gap: 0; }
  .story-step { min-height: 62vh; display: flex; flex-direction: column; justify-content: center; }
}

.js .story-panel { opacity: 0; visibility: hidden; }
.js .story[data-active="0"] [data-panel="0"], .js .story[data-active="1"] [data-panel="1"], .js .story[data-active="2"] [data-panel="2"], .js .story[data-active="3"] [data-panel="3"], .js .story[data-active="4"] [data-panel="4"] { opacity: 1; visibility: visible; }
.js .story-step { border-left-color: var(--hairline); }
.js .story-step h3 { color: var(--fg-2); }
.js .story-step p { color: var(--fg-3); }
.js .story[data-active="0"] [data-step="0"], .js .story[data-active="1"] [data-step="1"], .js .story[data-active="2"] [data-step="2"], .js .story[data-active="3"] [data-step="3"], .js .story[data-active="4"] [data-step="4"] { border-left-color: var(--blue); }
.js .story-step.is-on h3, .js .story[data-active="0"] [data-step="0"] h3, .js .story[data-active="1"] [data-step="1"] h3, .js .story[data-active="2"] [data-step="2"] h3, .js .story[data-active="3"] [data-step="3"] h3, .js .story[data-active="4"] [data-step="4"] h3 { color: var(--fg); }
.js .story[data-active="0"] [data-step="0"] p, .js .story[data-active="1"] [data-step="1"] p, .js .story[data-active="2"] [data-step="2"] p, .js .story[data-active="3"] [data-step="3"] p, .js .story[data-active="4"] [data-step="4"] p { color: var(--fg-2); }
@media (prefers-reduced-motion: no-preference) {
  .js .story-panel { transition: opacity var(--dur-3) var(--ease-out), visibility 0s linear var(--dur-3); transform: translate3d(0, 10px, 0); }
  .js .story[data-active] .story-panel { transition-property: opacity, transform, visibility; }
  .js .story[data-active="0"] [data-panel="0"], .js .story[data-active="1"] [data-panel="1"], .js .story[data-active="2"] [data-panel="2"], .js .story[data-active="3"] [data-panel="3"], .js .story[data-active="4"] [data-panel="4"] { transform: none; transition-delay: 0s; }
  .js .story-step, .js .story-step h3, .js .story-step p { transition: color var(--dur-3) var(--ease-out), border-color var(--dur-3) var(--ease-out); }
}
/* Without JS every step reads at full strength and the stage shows the first panel only. */
html:not(.js) .story-panel:not([data-panel="0"]) { display: none; }
.story-panel > .chip { align-self: flex-start; }

/* Hero stage: already in view at load, so it only settles from a slight tilt (never hidden). */
@media (prefers-reduced-motion: no-preference) {
  @supports (animation-timeline: view()) {
    .js .stage-3d.is-hero > .stage-plane { animation-name: m-tilt-hero; animation-range: cover 0% cover 40%; }
    @keyframes m-tilt-hero { from { transform: rotateX(9deg) scale(.97); } to { transform: none; } }
  }
}

/* ======================= Cinematic layer =======================
 * Everything below is decoration over complete content: gated by .js and no-preference, transform/clip/colour only. */

/* Scroll progress: a hairline under the header that fills as the page is read. */
.site-header { position: relative; }
@media (prefers-reduced-motion: no-preference) {
  @supports (animation-timeline: scroll()) {
    .js .site-header::after { content: ""; position: absolute; left: 0; bottom: -1px; width: 100%; height: 2px; background: var(--blue); transform-origin: 0 50%; animation: m-progress linear both; animation-timeline: scroll(root); }
    @keyframes m-progress { from { transform: scaleX(0); } to { transform: scaleX(1); } }
  }

  /* Headline words rise out of a mask, one after another. */
  .js .w { display: inline-block; overflow: hidden; vertical-align: top; padding: .08em .1em .14em; margin: -.08em -.1em -.14em; }
  .js .w > span { display: inline-block; animation: m-word var(--dur-4) var(--ease-out) both; animation-delay: calc(var(--w, 0) * 70ms + 140ms); }
  @keyframes m-word { from { transform: translate3d(0, 108%, 0); } to { transform: none; } }

  /* Hero floor: a hairline plane in perspective under the product frame. */
  .hero-floor { animation: m-fade var(--dur-4) var(--ease-out) 600ms both; }

  /* Floating fragments: depth layers around the hero frame. */
  .js .float { animation: m-rise var(--dur-4) var(--ease-out) both; animation-delay: calc(900ms + var(--i, 0) * 120ms); }

  /* Manifesto: each word lights up as the line scrolls through. */
  @supports (animation-timeline: view()) {
    .js .manifesto-text.is-lit .lit-w { color: #8F8A7C; animation: m-lit linear both; animation-timeline: view(); animation-range: entry calc(8% + var(--i) * 3.4%) entry calc(30% + var(--i) * 3.4%); }
    @keyframes m-lit { from { color: #8F8A7C; } to { color: var(--sand); } }

    /* Paper section opens like a curtain: inset and rounded at first, full-bleed once in view. */
    .js .on-paper { animation: m-paper linear both; animation-timeline: view(); animation-range: entry 0% entry 55%; }
    @keyframes m-paper { from { clip-path: inset(0 var(--gutter) 0 var(--gutter) round 28px); } to { clip-path: inset(0 0 0 0 round 0); } }

    /* Floating fragments drift at different depths. */
    .js .float[data-depth="1"] { --parallax-max: 18px; }
    .js .float[data-depth="2"] { --parallax-max: 44px; }
    .js .float[data-depth="3"] { --parallax-max: 72px; }
  }

  /* Story panels: rows slide in, bars grow, when their step becomes active. */
  .js .frag-bar i { transform: scaleX(0); transform-origin: 0 50%; transition: transform var(--dur-4) var(--ease-out); }
  .js .story[data-active="0"] [data-panel="0"] .frag-bar i, .js .story[data-active="1"] [data-panel="1"] .frag-bar i, .js .story[data-active="2"] [data-panel="2"] .frag-bar i, .js .story[data-active="3"] [data-panel="3"] .frag-bar i { transform: none; }
  .js .frag-bar:nth-child(2) i { transition-delay: 80ms; } .js .frag-bar:nth-child(3) i { transition-delay: 160ms; } .js .frag-bar:nth-child(4) i { transition-delay: 240ms; }
  .js .story[data-active="0"] [data-panel="0"] .frag-row, .js .story[data-active="1"] [data-panel="1"] .frag-row { animation: m-rise var(--dur-3) var(--ease-out) both; }
  .js .story[data-active] .frag-row:nth-child(2) { animation-delay: 90ms; } .js .story[data-active] .frag-row:nth-child(3) { animation-delay: 180ms; }
}

/* Static (no-motion / no-JS) look of the same elements. */
.hero-floor { position: absolute; left: -10%; right: -10%; bottom: 0; height: min(52vw, 520px); pointer-events: none; z-index: 0;
  background: repeating-linear-gradient(90deg, rgba(216, 203, 179, .1) 0 1px, transparent 1px 88px), repeating-linear-gradient(0deg, rgba(216, 203, 179, .1) 0 1px, transparent 1px 88px);
  transform: perspective(520px) rotateX(64deg); transform-origin: 50% 100%;
  -webkit-mask-image: linear-gradient(to top, #000 0%, transparent 85%); mask-image: linear-gradient(to top, #000 0%, transparent 85%); }
.hero2 > .wrap { position: relative; z-index: 1; }
.float { position: absolute; display: none; align-items: center; gap: 10px; padding: 10px 14px; border: 1px solid var(--hairline-strong); border-radius: 12px; background: var(--surface-2); box-shadow: var(--shadow-float); font-size: var(--fs-1); color: var(--fg); white-space: nowrap; z-index: 3; pointer-events: none; }
.float small { display: block; font-size: 11.5px; color: var(--fg-3); }
.float .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none; }
.float .dot-warn { background: var(--warn); }
.float .dot-blue { background: var(--blue); }
@media (min-width: 1100px) { .float { display: flex; } .hero2-stage { position: relative; } }
.float-a { left: -28px; top: 18%; }
.float-b { right: -32px; top: 40%; }
.float-c { left: 7%; bottom: 28px; }

.manifesto { padding: var(--sp-9) 0; }
.manifesto-text { font-family: var(--font-display); font-weight: 600; font-size: var(--fs-7); line-height: 1.08; letter-spacing: -.04em; color: var(--sand); max-width: 17em; text-wrap: balance; }
.manifesto-text .serif { color: var(--accent-text); }
