/* Luxify Home — the home scroll story (index.html [data-story], driven by js/scroll-story.js).
   Five chapters over photoreal images: 1 the slab story (hero, LCP photo), 2 pieces laid on the real slab (SVG cut
   lines over a photo of the slab), 3 the design drawing wiping into the photoreal room, 4 Eli by WhatsApp, 5 the CTA.
   Contract: WITHOUT .is-live (no JS, reduced motion) every chapter is a plain, static, readable screen in its final
   state. js/scroll-story.js adds .is-live (motion allowed): chapters grow tall, their stage pins (sticky) and each
   chapter gets --p (0..1, its scroll progress); everything below is transform / opacity / clip-path only. */

.story { position: relative; background: var(--obsidian); }
.ch { position: relative; }
.ch-pin { position: relative; min-height: 100svh; display: flex; align-items: center; overflow: hidden; isolation: isolate; }
.ch .wrap { position: relative; z-index: 2; width: 100%; }
.ch-veil { position: absolute; inset: 0; pointer-events: none; }
.ch-title, .kinetic { font-size: clamp(2.6rem, 6.4vw, 6.6rem); line-height: 0.98; letter-spacing: -0.025em; }
.kw { display: inline-block; }
.kw-gold { color: var(--gold); font-style: italic; }
.ch-lede { max-width: 46ch; margin: 22px 0 28px; color: var(--muted); font-size: clamp(1rem, 1.3vw, 1.15rem); }
.story-tag { position: absolute; right: var(--gutter); bottom: 22px; z-index: 3; padding: 5px 10px; border-radius: 999px; background: rgba(3, 5, 4, 0.6); color: var(--gold-soft); font: 700 0.62rem/1.4 var(--sans); letter-spacing: 0.12em; text-transform: uppercase; }
.story-dots { display: none; }

/* 1 — every stone has a story */
.ch1-media, .ch1-photo, .ch1-photo img { position: absolute; inset: 0; width: 100%; height: 100%; }
.ch1-media { z-index: 0; }
.ch1-photo img { object-fit: cover; object-position: 62% 50%; }
.ch-1 .ch-veil { background: linear-gradient(90deg, rgba(3, 5, 4, 0.92) 0%, rgba(3, 5, 4, 0.7) 34%, rgba(3, 5, 4, 0.12) 64%, rgba(3, 5, 4, 0) 78%), linear-gradient(0deg, rgba(3, 5, 4, 0.85) 0%, rgba(3, 5, 4, 0) 32%), linear-gradient(180deg, rgba(3, 5, 4, 0.6) 0%, rgba(3, 5, 4, 0) 22%); }
.ch1-copy { padding-top: calc(var(--header-h) + 48px); padding-bottom: 110px; }
.ch-1 h1 { max-width: 9.5em; font-size: clamp(3rem, 8.6vw, 9rem); line-height: 0.94; letter-spacing: -0.03em; }
.ch-1 h1 .kw-gold { display: block; }
@media (prefers-reduced-motion: no-preference) {
  .ch-1 h1 .kw { animation: st-rise 1.1s cubic-bezier(0.2, 0.7, 0.1, 1) both; }
  .ch-1 h1 .kw-gold { animation-delay: 0.14s; }
}
@keyframes st-rise { from { transform: translate3d(0, 0.32em, 0); } to { transform: none; } }

/* 2 — the veins tell the story */
.ch-2 .ch-pin { flex-direction: column; justify-content: center; gap: clamp(18px, 3vh, 40px); padding: calc(var(--header-h) + 24px) 0 64px; background: radial-gradient(ellipse at 50% 70%, #17140f 0%, var(--obsidian) 70%); }
.ch2-copy .ch-title { font-size: clamp(2.2rem, 5vw, 5.2rem); max-width: 14em; }
.ch2-stage { position: relative; z-index: 1; width: min(88vw, 1120px, calc((100svh - var(--header-h) - 300px) * 2)); margin: 0 auto; perspective: 1400px; }
.slab-svg { width: 100%; height: auto; overflow: visible; transform-origin: 50% 100%; }
.slab-ghost { opacity: 0.26; }
.slab-edge { fill: none; stroke: rgba(232, 207, 156, 0.4); stroke-width: 2; stroke-dasharray: 10 8; }
.piece { transform-box: view-box; filter: drop-shadow(0 18px 24px rgba(0, 0, 0, 0.55)); }
.piece-line { fill: none; stroke: var(--gold); stroke-width: 3; }
.seam { stroke: #fff6e2; stroke-width: 3; stroke-dasharray: 1; stroke-dashoffset: 0; }
.vein { fill: none; stroke: #ffe7b3; stroke-opacity: 0.9; stroke-width: 4; stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: 0; filter: drop-shadow(0 0 6px rgba(255, 210, 140, 0.9)); }
.vein-dot { fill: none; stroke: #fff6e2; stroke-width: 3; transform-box: fill-box; transform-origin: center; }
.ch2-notes { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; margin-top: 14px; color: var(--gold-soft); font: 700 0.72rem/1.4 var(--sans); letter-spacing: 0.14em; text-transform: uppercase; }
.note::before { content: ""; display: inline-block; width: 18px; height: 1px; margin: 0 10px 0.25em 0; background: var(--gold); vertical-align: middle; }

/* 3 — design it online, see it in your home */
.ch3-stage { position: absolute; inset: 0; z-index: 0; perspective: 1600px; overflow: hidden; }
.ch3-tilt, .ch3-tilt img { position: absolute; inset: 0; width: 100%; height: 100%; }
.ch3-tilt img { object-fit: cover; object-position: 40% 50%; }
.ch3-draw { display: none; }
.ch3-scan { display: none; }
.ch-3 .ch-veil { background: linear-gradient(90deg, rgba(3, 5, 4, 0.88) 0%, rgba(3, 5, 4, 0.55) 38%, rgba(3, 5, 4, 0) 66%), linear-gradient(0deg, rgba(3, 5, 4, 0.7) 0%, rgba(3, 5, 4, 0) 30%); }
.ch3-copy { padding-top: calc(var(--header-h) + 40px); padding-bottom: 90px; }
.ch3-copy .ch-title { max-width: 8.5em; }
.ch3-copy .kw { display: block; }
.ch-3 .tag-draw { max-width: 60vw; }

/* 4 — no app, no forms, just a message */
.ch-4 .ch-pin { background: radial-gradient(ellipse at 80% 60%, rgba(217, 173, 92, 0.12), transparent 55%), var(--obsidian); padding: calc(var(--header-h) + 24px) 0 64px; }
.ch-4 .ch-pin { display: grid; grid-template-columns: minmax(0, 1fr); align-content: center; }
.ch4-words { font: 800 clamp(2.6rem, 6.6vw, 7rem)/0.94 var(--sans); letter-spacing: -0.035em; text-transform: uppercase; }
.w4 { display: block; position: relative; width: fit-content; }
.w4-3 { color: var(--gold); font: italic 400 1.02em/1 var(--serif); text-transform: none; letter-spacing: -0.02em; }
.chat { list-style: none; margin: 34px auto 0; padding: 0 var(--gutter); width: 100%; max-width: 560px; display: grid; gap: 10px; }
.msg { max-width: 86%; padding: 11px 15px; border-radius: 16px; font-size: 0.95rem; line-height: 1.4; }
.msg.me { justify-self: end; background: #1f3b2c; color: #eef5ef; border-bottom-right-radius: 4px; }
.msg.eli { justify-self: start; background: #1b1c1b; color: var(--text); border: 1px solid var(--line); border-bottom-left-radius: 4px; }

/* 5 — your stone is waiting */
.ch5-media, .ch5-media img { position: absolute; inset: 0; width: 100%; height: 100%; }
.ch5-media img { object-fit: cover; object-position: 70% 50%; }
.ch-5 .ch-veil { background: radial-gradient(ellipse at 30% 55%, rgba(3, 5, 4, 0.86) 0%, rgba(3, 5, 4, 0.55) 45%, rgba(3, 5, 4, 0.2) 80%); }
.ch5-copy { padding-top: calc(var(--header-h) + 40px); padding-bottom: 90px; }
.ch5-title { font-size: clamp(3rem, 9vw, 9.4rem); line-height: 0.94; letter-spacing: -0.03em; }
.ch5-title span { display: block; }
.ch5-copy .btn-row { align-items: center; }
.ways { list-style: none; display: flex; flex-wrap: wrap; gap: 10px; margin: 26px 0 0; padding: 0; }
.ways li { display: flex; align-items: center; gap: 10px; padding: 10px 16px 10px 12px; border: 1px solid rgba(232, 207, 156, 0.32); border-radius: 999px; background: rgba(3, 5, 4, 0.55); color: var(--text); font: 600 0.92rem/1.2 var(--sans); }
.ways li span { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--gold); color: var(--obsidian); font: 800 0.7rem/1 var(--sans); }
.ch5-copy .ch5-way { margin-bottom: 0; }

@media (min-width: 900px) {
  .ch-4 .ch-pin { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); align-items: center; }
  .chat { margin: 0; padding-right: var(--gutter); }
}
@media (max-aspect-ratio: 21/20) and (max-width: 700px) {
  .ch-1 .ch-pin { align-items: flex-end; }
  .ch-1 .ch-veil { background: linear-gradient(0deg, rgba(3, 5, 4, 0.96) 0%, rgba(3, 5, 4, 0.82) 42%, rgba(3, 5, 4, 0) 70%); }
  .ch1-photo img { object-position: 50% 30%; }
  .ch1-copy { padding-bottom: 64px; }
  .ch-lede { margin: 14px 0 20px; }
  .ch-3 .ch-veil { background: linear-gradient(0deg, rgba(3, 5, 4, 0.94) 0%, rgba(3, 5, 4, 0.6) 50%, rgba(3, 5, 4, 0.1) 80%); }
  .ch-3 .ch-pin, .ch-5 .ch-pin { align-items: flex-end; }
  .ch2-notes { justify-content: flex-start; }
  .story-tag { top: calc(var(--header-h) + 12px); bottom: auto; }
}

/* ---------- live: scroll-linked (js/scroll-story.js sets .is-live and --p on each chapter) ---------- */
.story.is-live .ch { height: var(--len, 220vh); }
.story.is-live .ch-pin { position: sticky; top: 0; height: 100vh; height: 100svh; min-height: 0; }
.story.is-live .ch-1 { --len: 190vh; }
.story.is-live .ch-2 { --len: 330vh; }
.story.is-live .ch-3 { --len: 270vh; }
.story.is-live .ch-4 { --len: 280vh; }
.story.is-live .ch-5 { --len: 170vh; }
.story.is-live .story-dots { position: fixed; right: 18px; top: 50%; z-index: 20; display: grid; gap: 10px; transform: translateY(-50%); color: rgba(241, 237, 229, 0.4); font: 700 0.62rem/1 var(--sans); letter-spacing: 0.1em; transition: opacity 0.4s; }
.story.is-live .story-dots span.is-on { color: var(--gold); }
.story.is-live.is-out .story-dots { opacity: 0; }

/* 1 */
.is-live .ch-1 { --q: clamp(0, calc(var(--p, 0) * 1.4), 1); }
.is-live .ch1-media { clip-path: inset(calc(var(--q) * 7%) calc(var(--q) * 7%) round calc(var(--q) * 28px)); transform: scale(calc(1 - var(--q) * 0.06)); will-change: transform, clip-path; }
.is-live .ch1-photo img { transform: scale(calc(1.02 + var(--q) * 0.1)) translate3d(0, calc(var(--q) * -3%), 0); will-change: transform; }
.is-live .ch-1 h1 { transform: translate3d(0, calc(var(--q) * -8vh), 0) scale(calc(1 + var(--q) * 0.16)); transform-origin: 0 60%; opacity: clamp(0, calc(1.6 - var(--q) * 1.8), 1); }
.is-live .ch-1 h1 .kw-gold { translate: calc(var(--q) * 9vw) 0; }
.is-live .ch1-copy .eyebrow, .is-live .ch1-copy .ch-lede, .is-live .ch1-copy .btn-row, .is-live .ch-1 .scroll-cue { opacity: clamp(0, calc(1 - var(--q) * 3), 1); }

/* 2 — JS also places each .piece (transform) and sets --t (title), --lay (slab lays down), --seam, --vein */
.is-live .ch2-copy .kw { translate: calc((1 - var(--t, 1)) * -30vw) 0; opacity: var(--t, 1); }
.is-live .ch2-copy .kw-gold { translate: calc((1 - var(--t, 1)) * 30vw) 0; }
.is-live .slab-svg { transform: rotateX(calc((1 - var(--lay, 1)) * 32deg)) scale(calc(0.84 + var(--lay, 1) * 0.16)); will-change: transform; }
.is-live .piece { will-change: transform; }
.is-live .seam { stroke-dashoffset: calc(1 - var(--seam, 1)); }
.is-live .vein { stroke-dashoffset: calc(1 - var(--vein, 1)); }
.is-live .vein-dot { opacity: var(--vein, 1); transform: scale(calc(0.4 + var(--vein, 1) * 0.6)); }
.is-live .n-size { opacity: var(--lay, 1); }
.is-live .n-seam { opacity: var(--seam, 1); }
.is-live .n-best { opacity: var(--vein, 1); }

/* 3 — the drawing first, then the photoreal room wipes over it (--r), with a perspective settle (--tilt) */
.is-live .ch3-draw, .is-live .ch3-scan { display: block; }
.is-live .ch3-tilt { transform: rotateX(calc(var(--tilt, 0) * 10deg)) rotateY(calc(var(--tilt, 0) * -8deg)) scale(calc(1.02 + var(--tilt, 0) * 0.1)); transform-origin: 50% 60%; will-change: transform; }
.is-live .ch3-room { clip-path: inset(0 calc((1 - var(--r, 1)) * 100%) 0 0); will-change: clip-path; }
.is-live .ch3-scan { position: absolute; top: 0; bottom: 0; left: calc(var(--r, 1) * 100%); width: 2px; background: var(--gold-soft); box-shadow: 0 0 24px 6px rgba(255, 210, 140, 0.55); opacity: calc(1 - var(--r, 1) * var(--r, 1) * var(--r, 1)); }
.is-live .ch3-a { opacity: clamp(0.6, calc(1.6 - var(--r, 1) * 1.5), 1); }
.is-live .ch3-b { opacity: clamp(0, calc((var(--r, 1) - 0.35) * 3), 1); translate: 0 calc((1 - clamp(0, calc((var(--r, 1) - 0.35) * 3), 1)) * 0.4em); }
.is-live .ch3-copy .ch-lede, .is-live .ch3-copy .btn { opacity: clamp(0, calc((var(--r, 1) - 0.7) * 4), 1); }

/* 4 — one word at a time, each fading back as the next lands, then the chat (--w1..--w3, --s1, --s2, --m1..--m4, --c) */
.is-live .w4-1 { opacity: calc(var(--w1, 1) - var(--s1, 0) * 0.6); translate: 0 calc((1 - var(--w1, 1)) * 0.5em); }
.is-live .w4-2 { opacity: calc(var(--w2, 1) - var(--s2, 0) * 0.6); translate: 0 calc((1 - var(--w2, 1)) * 0.5em); }
.is-live .w4-3 { opacity: var(--w3, 1); scale: calc(0.9 + var(--w3, 1) * 0.1); transform-origin: 0 50%; }
.is-live .msg { opacity: var(--m, 1); translate: 0 calc((1 - var(--m, 1)) * 24px); }
.is-live .msg:nth-child(1) { --m: var(--m1, 1); }
.is-live .msg:nth-child(2) { --m: var(--m2, 1); }
.is-live .msg:nth-child(3) { --m: var(--m3, 1); }
.is-live .msg:nth-child(4) { --m: var(--m4, 1); }
.is-live .ch4-copy .ch-lede, .is-live .ch4-copy .btn-row { opacity: var(--c, 1); }

/* 5 — the slab gallery opens through a growing circle, the line settles */
.is-live .ch5-media { clip-path: circle(calc(14% + var(--o, 1) * 76%) at 62% 50%); will-change: clip-path; }
.is-live .ch5-media img { transform: scale(calc(1.14 - var(--o, 1) * 0.12)); will-change: transform; }
.is-live .ch5-title { letter-spacing: calc(-0.03em + (1 - var(--o, 1)) * 0.18em); opacity: clamp(0, calc(var(--o, 1) * 2), 1); }
.is-live .ch5-copy .ch-lede, .is-live .ch5-copy .btn-row, .is-live .ch5-copy .eyebrow { opacity: clamp(0, calc((var(--o, 1) - 0.6) * 3), 1); }

/* WebGL layer (js/story-gl.js, only when storyPolicy().gl): one fixed, aria-hidden canvas behind the chapters. A media
   box gets .gl-own only once the canvas draws its real photos; until then (and on any fallback) nothing changes. */
.story-gl { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
.is-live .gl-own img { visibility: hidden; }
.is-live .ch3-tilt.gl-own { transform: none; }
.is-live .ch3-tilt.gl-own .ch3-scan { display: none; }
.story.is-live.gl-dust .ch-2 .ch-pin { background: radial-gradient(ellipse at 50% 70%, rgba(23, 20, 15, 0.55) 0%, rgba(3, 5, 4, 0) 70%); }
.story.is-live.gl-dust .ch-2 .slab-ghost { opacity: calc(var(--solid, 1) * 0.26); }
.story.is-live.gl-dust .ch-2 .slab-edge, .story.is-live.gl-dust .ch-2 .piece { opacity: var(--solid, 1); }
.is-live .ways li { opacity: clamp(0, calc((var(--o, 1) - 0.45) * 3), 1); translate: 0 calc((1 - clamp(0, calc((var(--o, 1) - 0.45) * 3), 1)) * 14px); }

/* phones: shorter chapters, no tilt, no shrinking window (the story stays, the heavy parts go) */
@media (max-width: 760px) {
  .story.is-live .ch-1 { --len: 150vh; }
  .story.is-live .ch-2 { --len: 250vh; }
  .story.is-live .ch-3 { --len: 210vh; }
  .story.is-live .ch-4 { --len: 220vh; }
  .story.is-live .ch-5 { --len: 140vh; }
  .story.is-live .story-dots { display: none; }
  .is-live .ch1-media { clip-path: none; transform: none; }
  .is-live .ch3-tilt, .is-live .slab-svg { transform: none; }
  .piece { filter: none; }
  .vein { filter: none; }
}
@media (max-width: 760px) and (max-height: 760px) { .msg:nth-child(n+3) { display: none; } .ch4-copy .ch-lede { display: none; } }
@media print { .story-dots, .scroll-cue { display: none !important; } }
