/*
 * Scroll-driven effects for the home and features pages. app.js sets a progress
 * value, --p from 0 to 1, on each [data-scroll] section as it scrolls, and these
 * rules turn it into motion. Only transform and opacity move, so it stays smooth.
 * Without the script, or with reduced motion, everything simply sits in place.
 */

/* A thin vermilion line across the top that fills as you read down the page. */
.scroll-progress {
  position: fixed; inset: 0 0 auto 0; height: 3px; z-index: 20; pointer-events: none;
  background: var(--accent); transform-origin: 0 50%; transform: scaleX(var(--progress, 0));
}

/* ── Hero parallax ─────────────────────────────────────────────────────────── */
.hero-band { --p: 0; }
.hero-ghost {
  position: absolute; right: -4%; top: 4%; z-index: 0; pointer-events: none; user-select: none;
  font: 700 clamp(160px, 30vw, 380px)/1 var(--serif); color: var(--accent); opacity: 0.06;
  transform: translateY(calc(var(--p) * 180px)) rotate(calc(var(--p) * -6deg));
}
.hero-grid { position: relative; z-index: 1; }
.hero-copy { transform: translateY(calc(var(--p) * -60px)); opacity: calc(1 - var(--p) * 0.9); }
.phone-stage.parallax { transform: translateY(calc(var(--p) * 90px)) scale(calc(1 - var(--p) * 0.08)); }
.hero-copy .badge { margin-top: 20px; }
.scroll-cue {
  position: absolute; left: 50%; bottom: 70px; z-index: 2; translate: -50% 0; display: grid; justify-items: center; gap: 6px;
  color: var(--muted); font-size: 12px; letter-spacing: 0.15em; text-transform: uppercase; opacity: calc(1 - var(--p) * 4);
}
.scroll-cue span { width: 22px; height: 34px; border: 2px solid var(--muted); border-radius: 12px; position: relative; }
.scroll-cue span::after {
  content: ''; position: absolute; left: 50%; top: 6px; width: 4px; height: 8px; margin-left: -2px; border-radius: 2px;
  background: var(--accent); animation: cue 1.6s ease-in-out infinite;
}
@keyframes cue { 0% { transform: translateY(0); opacity: 1; } 80% { transform: translateY(12px); opacity: 0; } 100% { opacity: 0; } }

/* ── Kanji marquee ─────────────────────────────────────────────────────────── */
.marquee { padding: 28px 0; overflow: hidden; display: grid; gap: 12px; mask-image: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent); }
.marquee-row { overflow: hidden; }
.marquee-track { display: flex; gap: 12px; width: max-content; animation: marquee 60s linear infinite; }
.marquee-row.reverse .marquee-track { animation-direction: reverse; animation-duration: 70s; }
.marquee:hover .marquee-track { animation-play-state: paused; }
.marquee-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--rule); white-space: nowrap;
}
.marquee-item b { font: 700 28px/1 var(--serif); color: var(--ink); }
.marquee-item span { font-size: 13px; color: var(--muted); }
.marquee-item i { font: 700 10px/1 var(--sans); font-style: normal; color: var(--accent); border: 1px solid var(--accent); border-radius: 5px; padding: 2px 4px; }
@keyframes marquee { to { transform: translateX(-50%); } }

/* ── Words that light up ───────────────────────────────────────────────────── */
.reveal-text-band { height: 260vh; position: relative; }
.reveal-text-band .sticky { position: sticky; top: 0; height: 100vh; display: grid; place-items: center; padding: 0 20px; }
.reveal-text {
  max-width: 900px; margin: 0; text-align: center;
  font: 700 clamp(30px, 6vw, 60px)/1.25 var(--serif); letter-spacing: -0.01em;
}
.reveal-text .word { color: var(--ink); opacity: 0.14; transition: opacity 0.25s ease, color 0.25s ease; }
.reveal-text .word.lit { opacity: 1; }
.reveal-text .word.key.lit { color: var(--accent); }

/* ── Sticky story ──────────────────────────────────────────────────────────── */
.story { padding: 40px 0 80px; }
.story-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 56px; align-items: start; }
.story-stage { position: sticky; top: 15vh; height: 70vh; display: grid; place-items: center; }
.story-screens { position: relative; width: 100%; height: 420px; display: grid; place-items: center; }
.story-screen {
  position: absolute; inset: 0; display: grid; place-items: center;
  opacity: 0; transform: translateY(30px) scale(0.94); transition: opacity 0.5s ease, transform 0.5s ease; pointer-events: none;
}
.story-screen.active { opacity: 1; transform: none; }
.story-dots { position: absolute; bottom: 0; display: flex; gap: 8px; }
.story-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--rule); transition: background 0.3s, width 0.3s; }
.story-dots i.active { width: 24px; border-radius: 4px; background: var(--accent); }
.story-steps { list-style: none; margin: 0; padding: 0; }
.story-step { min-height: 70vh; display: flex; flex-direction: column; justify-content: center; opacity: 0.25; transition: opacity 0.4s ease; }
.story-step.active { opacity: 1; }
.story-step h3 { font: 700 clamp(26px, 4vw, 36px)/1.15 var(--serif); margin: 6px 0 10px; }
.story-step p { color: var(--muted); font-size: 18px; margin: 0; max-width: 28em; }
.step-num { font: 700 14px var(--sans); color: var(--accent); letter-spacing: 0.1em; }

/* ── The tilted screen that lies flat as it arrives ───────────────────────── */
.tilt-band { --p: 0; padding: 72px 0 40px; perspective: 1200px; overflow-x: clip; }
.tilt-frame {
  width: min(880px, calc(100% - 40px)); margin: 0 auto; padding: 14px; border-radius: 28px;
  background: linear-gradient(145deg, #2a2724, #0f0e0d); box-shadow: var(--shadow);
  transform: rotateX(calc((1 - var(--p)) * 28deg)) scale(calc(0.86 + var(--p) * 0.14)) translateY(calc((1 - var(--p)) * 40px));
  transform-origin: 50% 0;
}
.tilt-screen { border-radius: 18px; background: var(--paper); padding: clamp(18px, 4vw, 36px); }
.tp-head { display: flex; gap: 24px; align-items: center; }
.tp-glyph { font: 700 clamp(90px, 14vw, 140px)/1 var(--serif); }
.tp-mean { font-size: 22px; font-weight: 700; margin: 6px 0 2px; }
.tp-reads { display: flex; gap: 24px; flex-wrap: wrap; font: 18px var(--serif); padding: 14px 0; margin: 14px 0; border-block: 1px solid var(--rule); }
.tp-reads b { color: var(--accent); font-weight: 400; margin-right: 6px; }
.tp-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.tp-grid div { background: var(--surface); border: 1px solid var(--rule); border-radius: 12px; padding: 10px 12px; display: grid; }
.tp-grid b { font: 700 22px var(--serif); }
.tp-grid span { color: var(--muted); font-size: 13px; }
.tp-grid i { font-style: normal; font-size: 14px; }
.tp-sentence { margin: 16px 0 0; font: 19px/1.6 var(--serif); }

/* ── Cards that tilt towards the pointer, with a soft spotlight ────────────── */
.tilt-card, .spotlight { position: relative; overflow: hidden; }
.tilt-card { transform: perspective(800px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)); transition: transform 0.15s ease, box-shadow 0.2s, border-color 0.2s; will-change: transform; }
.tilt-card::after, .spotlight::after {
  content: ''; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity 0.3s;
  background: radial-gradient(260px circle at var(--mx, 50%) var(--my, 50%), color-mix(in srgb, var(--accent) 16%, transparent), transparent 70%);
}
.tilt-card:hover::after, .spotlight:hover::after { opacity: 1; }

/* ── Prints that slide sideways while you scroll down ──────────────────────── */
.hscroll { height: 320vh; position: relative; }
.hscroll .sticky { position: sticky; top: 0; height: 100vh; overflow: hidden; display: flex; flex-direction: column; justify-content: center; }
.hscroll-track { display: flex; gap: 24px; padding: 0 max(20px, calc((100vw - 1080px) / 2)); width: max-content; transform: translateX(var(--hx, 0px)); will-change: transform; }
.hscroll-track figure { margin: 0; flex: none; width: min(560px, 80vw); }
.hscroll-track figure.tall { width: min(300px, 55vw); }
.hscroll-track img { width: 100%; height: min(56vh, 420px); object-fit: cover; border-radius: 18px; box-shadow: var(--shadow); display: block; }
.hscroll-track figcaption { color: var(--muted); font-size: 14px; margin-top: 10px; }

/* ── Features page: a beam that fills down the side as you read ───────────── */
.beam { position: fixed; left: max(12px, calc((100vw - 1080px) / 2 - 28px)); top: 0; bottom: 0; width: 2px; background: var(--rule); z-index: 5; pointer-events: none; }
.beam::after {
  content: ''; position: absolute; left: 0; top: 0; width: 100%; height: calc(var(--progress, 0) * 100%);
  background: linear-gradient(var(--accent), color-mix(in srgb, var(--accent) 30%, transparent));
}
.beam::before {
  content: ''; position: absolute; left: -5px; top: calc(var(--progress, 0) * 100%); width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 25%, transparent);
}
.js .feature-row .feature-visual { transform: translateX(-40px); opacity: 0; transition: transform 0.8s ease, opacity 0.8s ease; }
.js .feature-row.flip .feature-visual { transform: translateX(40px); }
.js .feature-row.seen .feature-visual { transform: none; opacity: 1; }

@media (max-width: 820px) {
  .story-grid { grid-template-columns: 1fr; gap: 0; }
  .story-stage { top: 64px; height: 46vh; z-index: 2; background: color-mix(in srgb, var(--paper) 92%, transparent); }
  .story-screens { height: 40vh; transform: scale(0.82); }
  .story-step { min-height: 60vh; }
  .reveal-text-band { height: 200vh; }
  .hscroll { height: 260vh; }
  .beam { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .hero-ghost, .hero-copy, .phone-stage.parallax, .tilt-frame { transform: none !important; opacity: 1 !important; }
  .reveal-text-band { height: auto; }
  .reveal-text-band .sticky { position: static; height: auto; padding: 80px 20px; }
  .reveal-text .word { opacity: 1; }
  .hscroll { height: auto; }
  .hscroll .sticky { position: static; height: auto; padding: 60px 0; }
  .hscroll-track { transform: none !important; width: auto; overflow-x: auto; }
  .story-screen { transition: none; }
}
