/* ==========================================================================
   MOTION LAYER — Vintage City Coffee
   Preloader · page curtain · scroll progress · marquee · stats · horizontal
   signatures · steam · nav letter-roll · Lenis smooth scroll.
   Everything here is progressive: without JS (or with reduced motion)
   the site renders fully and statically.
   Motion tokens: enter = expo.out 0.8–1.2s, exit ≈ 60% of enter,
   micro-interactions 250–400ms.
   ========================================================================== */

/* Lenis smooth scroll */
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }
.lenis.lenis-smooth [data-lenis-prevent] { overscroll-behavior: contain; }
.lenis.lenis-stopped { overflow: clip; }

/* Brand wordmark */
.brand__name em { font-style: italic; font-weight: 300; color: var(--color-brass-light); }
.hero__wordmark em { color: var(--on-dark-faint); }

/* ---------- scroll progress ---------- */
.scroll-progress { position: fixed; inset: 0 0 auto 0; height: 2px; z-index: 130; pointer-events: none; }
.scroll-progress span { display: block; height: 100%; background: linear-gradient(90deg, var(--color-caramel), var(--color-brass-light)); transform: scaleX(0); transform-origin: left; }
html:not(.motion) .scroll-progress { display: none; }

/* ---------- page curtain (between pages) ---------- */
.curtain { position: fixed; inset: 0; z-index: 140; pointer-events: none; }
.curtain__panel { position: absolute; inset: -2px 0; background: var(--color-espresso-deep); transform: translateY(101%); }
.curtain__panel::after { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 1px; background: var(--color-brass); opacity: .6; }
.curtain__mark { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: .9rem; color: var(--color-cream); opacity: 0; }
.curtain__mark .brand__emblem { width: 46px; height: 56px; color: var(--color-brass); }
.curtain__mark span { font-family: var(--font-display); font-size: 1.6rem; font-weight: 350; letter-spacing: -.01em; }
.curtain__mark em { font-style: italic; color: var(--color-brass-light); font-weight: 300; }
html.from-nav .curtain__panel { animation: curtain-out 1s var(--ease-in-out) .08s both; }
html.from-nav .curtain__mark { animation: mark-out .5s ease both; }
html.is-leaving .curtain { pointer-events: all; }
html.is-leaving .curtain__panel { animation: curtain-in .62s var(--ease-in-out) both; }
html.is-leaving .curtain__mark { animation: mark-in .5s ease .25s both; }
@keyframes curtain-in { from { transform: translateY(101%); } to { transform: translateY(0); } }
@keyframes curtain-out { from { transform: translateY(0); } to { transform: translateY(-101%); } }
@keyframes mark-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes mark-out { from { opacity: 1; } to { opacity: 0; } }

/* ---------- preloader (first visit to the homepage, once per session) ---------- */
.preloader { display: none; }
html.is-preloading .preloader {
  display: grid; place-items: center; position: fixed; inset: 0; z-index: 150; background: var(--color-espresso-deep); color: var(--color-cream);
  animation: preloader-failsafe .01s linear 6s forwards; /* never trap the page if JS fails */
}
html.is-preloading body { overflow: hidden; }
@keyframes preloader-failsafe { to { visibility: hidden; opacity: 0; } }
.preloader__inner { display: grid; justify-items: center; gap: 1.1rem; text-align: center; padding: 2rem; }
.preloader__emblem { width: 64px; height: 80px; color: var(--color-brass); overflow: visible; }
.preloader__emblem path { stroke-dasharray: 1; stroke-dashoffset: 1; }
.preloader__name { font-family: var(--font-display); font-weight: 320; font-size: clamp(2.2rem, 1.4rem + 3.6vw, 4.2rem); letter-spacing: -.03em; line-height: 1; margin-top: .6rem; }
.preloader__name em { font-style: italic; font-weight: 300; color: var(--color-brass-light); }
.preloader__sub { font-size: .66rem; letter-spacing: .34em; text-transform: uppercase; color: var(--on-dark-faint); font-weight: 600; }
.preloader__bar { width: min(220px, 50vw); height: 1px; background: rgba(243, 235, 221, .14); margin-top: 1rem; overflow: hidden; }
.preloader__bar i { display: block; height: 100%; background: var(--color-brass); transform: scaleX(0); transform-origin: left; }

/* ---------- nav letter roll ---------- */
.roll { position: relative; display: inline-block; overflow: hidden; vertical-align: top; line-height: 1.25; }
.roll > span { display: inline-block; transition: transform .45s var(--ease-out); }
.roll::after { content: attr(data-text); position: absolute; left: 0; top: 100%; color: var(--color-brass-light); transition: transform .45s var(--ease-out); }
a:hover > .roll > span, a:focus-visible > .roll > span, a:hover > .roll::after, a:focus-visible > .roll::after { transform: translateY(-100%); }

/* ---------- marquee ---------- */
.marquee { background: var(--color-espresso); color: var(--color-cream); padding: clamp(1.4rem, 3vw, 2.6rem) 0; overflow: hidden; border-top: 1px solid rgba(176, 141, 87, .25); border-bottom: 1px solid rgba(176, 141, 87, .25); }
.marquee__row { display: flex; overflow: hidden; white-space: nowrap; }
.marquee__row + .marquee__row { margin-top: .2rem; }
.marquee__track { display: flex; align-items: center; flex: none; will-change: transform; animation: marquee 60s linear infinite; }
.marquee__row[data-marquee="-1"] .marquee__track { animation-direction: reverse; }
.js-marquee .marquee__track { animation: none; }
.marquee__track span { font-family: var(--font-display); font-size: clamp(2.2rem, 1.2rem + 4.6vw, 5.6rem); font-weight: 300; letter-spacing: -.03em; line-height: 1.15; padding-inline: clamp(.8rem, 2vw, 1.8rem); }
.marquee__row--outline span { font-style: italic; color: transparent; -webkit-text-stroke: 1px rgba(205, 174, 120, .75); }
.marquee__star { width: clamp(18px, 2vw, 28px); height: auto; flex: none; fill: none; stroke: var(--color-brass); stroke-width: 1.2; }
@keyframes marquee { to { transform: translateX(-50%); } }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); margin: 0 auto clamp(3rem, 6vw, 5rem); max-width: 1080px; border-block: 1px solid var(--line-strong); }
.stats > div { padding: clamp(1.4rem, 3vw, 2.2rem) 1rem; text-align: center; display: grid; gap: .4rem; }
.stats > div + div { border-left: 1px solid var(--line); }
.stats__num { font-family: var(--font-display); font-weight: 300; font-style: italic; font-size: clamp(2.6rem, 1.6rem + 3.4vw, 4.6rem); line-height: 1; color: var(--color-mocha); font-variant-numeric: lining-nums tabular-nums; }
.stats__label { font-size: var(--text-label); letter-spacing: var(--tracking-label); text-transform: uppercase; font-weight: 600; color: var(--ink-soft); }
@media (max-width: 700px) { .stats { grid-template-columns: 1fr 1fr; } .stats > div:nth-child(3) { border-left: 0; } .stats > div:nth-child(n+3) { border-top: 1px solid var(--line); } }

/* ---------- signatures: progress + horizontal scroll (desktop, GSAP) ---------- */
.sig-progress { display: flex; align-items: center; gap: 1rem; margin-top: 2.2rem; color: var(--on-dark-faint); font-size: 1.05rem; max-width: 420px; }
.sig-progress i { flex: 1; height: 1px; background: rgba(243, 235, 221, .18); overflow: hidden; }
.sig-progress b { display: block; height: 100%; background: var(--color-brass); transform: scaleX(.1667); transform-origin: left; }
.sig-progress .num:first-child { color: var(--color-brass-light); }
html.sig-h .sig-section { min-height: 100vh; display: flex; align-items: center; padding-block: calc(var(--header-h) + 1.2rem) 2rem; }
html.sig-h .sig-section > .container { width: 100%; }
html.sig-h .sig-section .section-head { margin-bottom: clamp(1.4rem, 2.6vh, 2.4rem); }
html.sig-h .sig-section .h2 { font-size: clamp(2.2rem, 1.2rem + 2.4vw, 3.6rem); }
html.sig-h .sig-viewport { overflow: visible; }
html.sig-h .signatures { display: flex; gap: clamp(1.5rem, 2.6vw, 3rem); width: max-content; }
html.sig-h .signatures > * { flex: none; width: clamp(240px, min(24vw, calc((100vh - 470px) * .82)), 380px); transform: none; }
html.sig-h .signatures > :nth-child(even) { margin-top: clamp(1.2rem, 4vh, 2.8rem); }
html.sig-h .signature__media { aspect-ratio: 1 / 1.08; }
html.sig-h .signature__media img { width: 118%; max-width: none; margin-left: -9%; }
html.sig-h .signatures-foot { display: none; }
html.sig-h .sig-progress { margin-top: 1.4rem; }

/* 3D tilt surface */
[data-tilt] { transform-style: preserve-3d; will-change: transform; }

/* ---------- editorial drifting headline ---------- */
.editorial__big { overflow: hidden; white-space: nowrap; }
.editorial__big > span { display: inline-block; will-change: transform; }

/* ---------- steam wisps over the final CTA ---------- */
.steam { width: 64px; height: auto; margin: 0 auto -.6rem; color: var(--color-brass-light); overflow: visible; }
.steam path { stroke-width: 1.2; stroke-linecap: round; stroke-dasharray: 60 140; opacity: 0; animation: steam 4.2s ease-in-out infinite; }
.steam path:nth-child(2) { animation-delay: 1.3s; }
.steam path:nth-child(3) { animation-delay: 2.5s; }
@keyframes steam {
  0% { stroke-dashoffset: 200; opacity: 0; transform: translateY(8px); }
  30% { opacity: .75; }
  100% { stroke-dashoffset: 0; opacity: 0; transform: translateY(-14px); }
}

/* ---------- small ambient details ---------- */
.map-placeholder__pin { animation: pin-float 3.6s ease-in-out infinite; }
@keyframes pin-float { 50% { transform: translateY(-8px); } }
.faq details::details-content { transition: height .45s var(--ease-out), content-visibility .45s allow-discrete; height: 0; overflow: clip; }
.faq details[open]::details-content { height: auto; }
@supports (interpolate-size: allow-keywords) { :root { interpolate-size: allow-keywords; } }
.btn[data-magnetic] { will-change: transform; }

/* Split text helpers */
.split-char, .split-word { display: inline-block; will-change: transform; }
[data-split-chars] .line { overflow: visible !important; }
.footer-word .split-char { will-change: transform; }

@media (prefers-reduced-motion: reduce) {
  .marquee__track, .steam path, .map-placeholder__pin { animation: none !important; }
  .steam path { opacity: .5; stroke-dasharray: none; }
  .preloader, .curtain, .scroll-progress { display: none !important; }
}

/* Mobile menu: leave room for the sticky category bar when jumping to a chapter */
@media (max-width: 960px) { html:has(.menu-chips) { scroll-padding-top: calc(var(--header-h) + 128px); } }
