@property --gap { syntax: "<length>"; inherits: true; initial-value: 22px; }
@property --drop { syntax: "<length>"; inherits: false; initial-value: 0px; }

/* Hero */
.hero-grid { flex: 1; display: grid; grid-template-columns: 1fr 1fr; align-items: center; gap: 24px; padding: 24px 0 72px; position: relative; z-index: 2; }
.hero-grid .display { font-size: clamp(52px, 7.6vw, 120px); margin-top: 18px; }
.hero-grid .lead { margin-top: 32px; font-size: 19px; max-width: 40ch; }
.hero-grid .btns { margin-top: 36px; display: flex; gap: 12px; flex-wrap: wrap; }
.hero-glow { position: absolute; width: 900px; height: 900px; right: -260px; top: -120px; background: radial-gradient(circle, rgba(255, 77, 46, .28), transparent 62%); pointer-events: none; }

/* The stack */
.stage { position: relative; height: 640px; }
.stack { position: absolute; left: 50%; top: 72%; width: 0; height: 0; perspective: 2200px; --gap: 22px; }
.layer {
  position: absolute; width: 220px; height: 380px; left: -110px; top: -190px;
  border-radius: 34px; padding: 24px 22px; display: flex; flex-direction: column; justify-content: flex-end;
  border: 1.5px solid rgba(255, 255, 255, .14);
  box-shadow: 0 40px 60px -30px rgba(0, 0, 0, .8), inset 0 1px 0 rgba(255, 255, 255, .08);
  transform: rotateX(58deg) rotateZ(-38deg) translateZ(calc(var(--i) * var(--gap) + var(--lift, 0px) + var(--drop))) translateX(var(--slide, 0px));
  transition: transform 1s var(--ease), opacity .6s, filter .6s;
  color: var(--paper);
}
.layer .ln { font: 700 11px/1 var(--sans); letter-spacing: .2em; opacity: .55; }
.layer .lt { font-family: var(--serif); font-size: 36px; line-height: 1; letter-spacing: -.02em; margin-top: 8px; }
.layer .ls { font-size: 12px; line-height: 1.35; opacity: .7; margin-top: 8px; }

.l-silicon { background: #121110 repeating-linear-gradient(0deg, transparent 0 19px, rgba(255, 255, 255, .05) 19px 20px), repeating-linear-gradient(90deg, transparent 0 19px, rgba(255, 255, 255, .05) 19px 20px); }
.l-silicon .chip {
  position: absolute; top: 70px; left: 50%; width: 96px; height: 96px; margin-left: -48px; border-radius: 16px;
  background: linear-gradient(135deg, #3a3633, #1b1918); border: 1.5px solid rgba(255, 255, 255, .2);
  display: grid; place-items: center; font: 800 20px var(--sans); letter-spacing: -.02em;
  box-shadow: 0 0 0 10px rgba(255, 194, 61, .06), 0 0 40px rgba(255, 194, 61, .25);
}
.l-silicon .chip::before, .l-silicon .chip::after { content: ""; position: absolute; inset: -16px 18px; border-block: 4px dotted rgba(255, 194, 61, .5); }
.l-silicon .chip::after { inset: 18px -16px; border-block: 0; border-inline: 4px dotted rgba(255, 194, 61, .5); }
.l-os { background: #1d1a18; }
.l-services { background: #29251f; }
.l-media { background: var(--sun); color: var(--ink); border-color: rgba(0, 0, 0, .15); }
.l-uikit { background: var(--paper); color: var(--ink); border-color: rgba(0, 0, 0, .1); }
.l-swiftui { background: var(--red); color: var(--ink); border-color: rgba(0, 0, 0, .15); }
.l-app { background: linear-gradient(180deg, #2a1410, #0f0d0c); border: 6px solid #000; padding: 18px 16px; justify-content: space-between; }
.l-app .mini-art { aspect-ratio: 1; border-radius: 18px; background: linear-gradient(135deg, var(--red), var(--sun)); }
.l-app .mini-bars { display: flex; gap: 3px; align-items: end; height: 26px; margin-top: 14px; }
.l-app .mini-bars i { flex: 1; border-radius: 2px; background: rgba(255, 255, 255, .35); }
.l-app .mini-bars i:nth-child(-n+6) { background: var(--red); }
.l-app .lt { font-size: 28px; }

/* Hero stack: drops in, then breathes */
.stack.auto { animation: breathe 5s 2.6s ease-in-out infinite alternate; }
.stack.auto .layer { animation: drop 1.1s var(--ease) both; animation-delay: calc(var(--i) * .16s + .3s); }
@keyframes drop { from { --drop: 520px; opacity: 0; } to { --drop: 0px; opacity: 1; } }
@keyframes breathe { from { --gap: 26px; } to { --gap: 80px; } }
.hero .stack { top: 80%; }
.hero .layer { width: 200px; height: 340px; left: -100px; top: -170px; padding: 0 20px 14px; transform: rotateX(55deg) rotateZ(-38deg) translateZ(calc(var(--i) * var(--gap) + var(--drop))); }
.hero .layer .ln, .hero .layer .ls { display: none; }
.hero .layer .lt { font-size: 30px; }
.hero .l-app { padding: 14px 14px 12px; }
.hero .l-silicon .chip { top: 60px; }

/* Anatomy: scroll peels layers */
.anatomy-grid { display: grid; grid-template-columns: 1.05fr .95fr; gap: 40px; }
.anatomy .sticky-stage { position: sticky; top: 0; height: 100vh; display: flex; align-items: center; }
.anatomy .stage { width: 100%; }
.anatomy .stack { --gap: 44px; top: 70%; }
.stack.focus .layer { opacity: .16; filter: saturate(.2); }
.stack.focus .layer.on { opacity: 1; filter: none; --slide: 120px; --lift: 24px; }
.lsteps { padding: 30vh 0; }
.lstep { min-height: 78vh; display: flex; flex-direction: column; justify-content: center; opacity: .25; transition: opacity .5s; }
.lstep.on { opacity: 1; }
.lstep .n { font: 700 13px var(--sans); letter-spacing: .2em; color: var(--red); }
.lstep h3 { font-family: var(--serif); font-weight: 400; font-size: clamp(44px, 5vw, 72px); line-height: 1; letter-spacing: -.03em; margin: 14px 0 18px; }
.lstep p { font-size: 18px; color: var(--fg-dim); max-width: 40ch; }
.lstep .chips { margin-top: 24px; }
.anatomy-head { padding-top: 140px; }

/* Process */
.procs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; counter-reset: p; }
.proc { background: var(--ink); color: var(--paper); border-radius: 32px; padding: 24px; display: flex; flex-direction: column; }
.proc .viz { height: 240px; border-radius: 22px; background: var(--ink-2); border: 1px solid var(--ink-line); position: relative; overflow: hidden; display: grid; place-items: center; }
.proc .cap { padding: 22px 8px 6px; }
.proc .cap span { font: 700 12px var(--sans); letter-spacing: .2em; color: var(--red); }
.proc h4 { font-family: var(--serif); font-weight: 600; font-size: 30px; letter-spacing: -.02em; margin: 6px 0 6px; }
.proc p { color: var(--fg-dim); font-size: 15px; }

/* 1 sketch */
.sk { width: 150px; height: 210px; }
.sk .d { fill: none; stroke: var(--paper); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1; stroke-dashoffset: 1; }
.sk .d.r { stroke: var(--red); }
.proc.play .sk .d { animation: draw .9s var(--ease) forwards; animation-delay: calc(var(--d) * .25s); }
.sk-note { position: absolute; right: 18px; top: 22px; font-family: var(--hand); font-size: 22px; color: var(--sun); transform: rotate(8deg); opacity: 0; }
.proc.play .sk-note { animation: fade .5s 2.2s forwards; }
@keyframes fade { to { opacity: 1; } }

/* 2 design */
.dz { width: 130px; height: 210px; border-radius: 22px; border: 2px solid rgba(255, 255, 255, .25); position: relative; padding: 14px; }
.blk { position: absolute; border-radius: 8px; opacity: 0; transform: translate(var(--fx), var(--fy)) rotate(var(--fr)); }
.proc.play .blk { animation: snap .8s var(--ease) forwards; animation-delay: calc(var(--d) * .2s + .2s); }
@keyframes snap { to { opacity: 1; transform: none; } }
.blk.a { left: 12px; right: 12px; top: 14px; height: 80px; background: linear-gradient(135deg, var(--red), var(--sun)); }
.blk.b { left: 12px; width: 70px; top: 104px; height: 10px; background: var(--paper); }
.blk.c { left: 12px; width: 50px; top: 122px; height: 8px; background: rgba(255, 255, 255, .4); }
.blk.e { left: 50%; margin-left: -20px; bottom: 16px; width: 40px; height: 40px; border-radius: 50%; background: var(--paper); }
.blk.f { left: 12px; right: 12px; top: 142px; height: 6px; background: var(--red); }
.cursor { position: absolute; width: 18px; height: 18px; left: 70%; top: 70%; opacity: 0; }
.proc.play .cursor { animation: cur 2.2s .2s var(--ease) forwards; }
@keyframes cur { 0% { opacity: 0; transform: translate(-80px, -120px); } 20% { opacity: 1; } 100% { opacity: 1; transform: none; } }

/* 3 code */
.code { width: 100%; height: 100%; padding: 18px 18px; font: 500 12.5px/1.6 ui-monospace, "SF Mono", Menlo, monospace; color: #d9d2c8; white-space: pre; overflow: hidden; text-align: left; align-self: start; justify-self: start; }
.code .k { color: #ff7a8a; } .code .t { color: var(--sun); } .code .s { color: #ff9a6e; } .code .a { color: #c39bff; }
.code .caret { display: inline-block; width: 7px; height: 14px; background: var(--red); vertical-align: -2px; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* 4 build */
.bld { width: 100%; padding: 22px; font: 500 12.5px/1.9 ui-monospace, "SF Mono", Menlo, monospace; align-self: start; }
.bld div { opacity: 0; color: var(--fg-dim); }
.proc.play .bld div { animation: fade .3s forwards; animation-delay: calc(var(--d) * .45s + .2s); }
.bld .bar { height: 6px; border-radius: 3px; background: var(--ink-line); margin: 10px 0; overflow: hidden; opacity: 1 !important; }
.bld .bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--red), var(--sun)); }
.proc.play .bld .bar i { animation: fill 2.2s .2s cubic-bezier(.5, 0, .3, 1) forwards; }
@keyframes fill { to { width: 100%; } }
.bld .ok { color: var(--sun) !important; font-weight: 700; font-size: 14px; }

/* 5 test */
.tst { width: 100%; padding: 20px 22px; font: 500 12.5px/1 ui-monospace, "SF Mono", Menlo, monospace; align-self: start; }
.tst div { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--ink-line); }
.tst b { width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid var(--ink-line); flex: none; display: grid; place-items: center; font-size: 11px; color: var(--ink); position: relative; }
.proc.play .tst b { animation: pass .35s forwards; animation-delay: calc(var(--d) * .45s + .4s); }
@keyframes pass { to { background: var(--sun); border-color: var(--sun); } }
.tst b::after { content: "✓"; opacity: 0; }
.proc.play .tst b::after { animation: fade .2s forwards; animation-delay: inherit; }
.tst .sum { border: 0; color: var(--sun); font-weight: 700; opacity: 0; }
.proc.play .tst .sum { animation: fade .4s 2.4s forwards; }

/* 6 ship */
.store { width: 86%; background: var(--paper); color: var(--ink); border-radius: 22px; padding: 16px; display: flex; align-items: center; gap: 14px; box-shadow: 0 20px 40px -10px rgba(0, 0, 0, .6); }
.store .ic { width: 58px; height: 58px; border-radius: 14px; background: linear-gradient(135deg, var(--red), var(--sun)); flex: none; display: grid; place-items: center; }
.store .ic svg { width: 28px; color: var(--ink); }
.store b { display: block; font-size: 16px; }
.store small { font-size: 12px; color: #6d655c; }
.get { margin-left: auto; position: relative; width: 74px; height: 32px; }
.get span { position: absolute; inset: 0; display: grid; place-items: center; border-radius: 999px; font: 800 13px var(--sans); }
.get .g1 { background: var(--ink); color: var(--paper); }
.get .g3 { background: var(--red); color: var(--ink); opacity: 0; }
.get svg { position: absolute; left: 50%; top: 50%; width: 30px; height: 30px; margin: -15px 0 0 -15px; opacity: 0; transform: rotate(-90deg); }
.get circle { fill: none; stroke: var(--ink); stroke-width: 3; stroke-dasharray: 1; stroke-dashoffset: 1; }
.proc.play .get .g1 { animation: out .3s 1s forwards; }
.proc.play .get svg { animation: fade .2s 1.2s forwards, out .2s 2.6s forwards; }
.proc.play .get circle { animation: draw 1.3s 1.3s ease-in-out forwards; }
.proc.play .get .g3 { animation: fade .3s 2.7s forwards; }
@keyframes out { to { opacity: 0; transform: scale(.6); } }
.confetti { position: absolute; inset: 0; pointer-events: none; }
.confetti i { position: absolute; left: 80%; top: 50%; width: 7px; height: 7px; border-radius: 2px; opacity: 0; }
.proc.play .confetti i { animation: pop 1s 2.7s var(--ease) forwards; }
@keyframes pop { 0% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translate(var(--x), var(--y)) rotate(200deg); } }

/* Toolbox */
.tools { overflow: hidden; padding: 8px 0; }
.tools-row { display: flex; width: max-content; gap: 12px; padding: 6px 0; animation: slide 40s linear infinite; }
.tools-row.rev { animation-direction: reverse; animation-duration: 48s; }
.tools-row span { font-weight: 700; font-size: clamp(16px, 2vw, 22px); padding: 14px 24px; border-radius: 999px; border: 2px solid var(--ink); white-space: nowrap; }
.tools-row span:nth-child(4n+1) { background: var(--ink); color: var(--paper); }
.tools-row span:nth-child(6n+3) { background: var(--red); border-color: var(--red); }
.tools-row span:nth-child(7n+5) { background: var(--sun); border-color: var(--sun); }

@media (max-width: 900px) {
  .hero-grid { grid-template-columns: 1fr; padding-bottom: 24px; }
  .hero .stage { height: 440px; margin-top: -10px; }
  .hero .stack { transform: scale(.72); top: 74%; }
  .anatomy-grid { grid-template-columns: 1fr; gap: 0; }
  .anatomy .sticky-stage { height: 50vh; z-index: 3; background: var(--ink); top: 0; }
  .anatomy .stage { height: 50vh; }
  .anatomy .stack { transform: scale(.55); top: 78%; }
  .stack.focus .layer.on { --slide: 60px; }
  .lsteps { padding: 0 0 20vh; }
  .lstep { min-height: 95vh; justify-content: start; }
  .lstep > * { position: sticky; }
  .lstep .n { top: calc(50vh + 12px); }
  .lstep h3 { top: calc(50vh + 34px); font-size: 44px; }
  .lstep p { top: calc(50vh + 96px); }
  .lstep .chips { top: calc(50vh + 220px); }
  .anatomy-head { padding-top: 96px; }
  .procs { grid-template-columns: 1fr; }
}
