@import url("fonts.css");

/* TaleStitch site. Mirrors the app's design system (talestitch-rn/theme/ds.js):
   quiet monochrome dark UI in Inter, Newsreader reserved for story voice,
   one accent: the streak-card orange.
   Shape rule: interactive = full pill, media & cards = 24px, phones = 44px. */
:root {
  --bg: #0e0e10;
  --surface: #151517;
  --elevated: #1c1c1f;
  --line: rgba(255, 255, 255, 0.08);
  --text: #f3f1ec;
  --muted: #a1a1a9;
  --accent: #fe993d;
  --radius: 24px;
  --max: 1200px;
  --gutter: clamp(20px, 4vw, 40px);
  --serif: "Newsreader", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, sans-serif;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 17px/1.6 var(--sans); -webkit-font-smoothing: antialiased;
}
img, video { display: block; max-width: 100%; height: auto; }
a { color: inherit; }
h1, h2, h3 { font-family: var(--serif); font-weight: 500; letter-spacing: -0.02em; margin: 0; }
p { margin: 0; }
em { font-style: italic; color: var(--accent); }
.wrap { width: 100%; max-width: var(--max); margin: 0 auto; padding: 0 var(--gutter); }
.muted { color: var(--muted); }
.lede { font-size: 1.1875rem; color: var(--muted); max-width: 34ch; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 8px; }

/* grain on a fixed, non-interactive layer only */
body::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 100; opacity: 0.035;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

/* ---------- nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 50; height: 68px;
  background: rgba(14, 14, 16, 0.72); backdrop-filter: blur(16px) saturate(140%); -webkit-backdrop-filter: blur(16px) saturate(140%);
  border-bottom: 1px solid var(--line);
}
.nav .wrap { height: 100%; display: flex; align-items: center; gap: 32px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-family: var(--serif); font-size: 1.45rem; font-weight: 500; letter-spacing: -0.01em; }
.brand img { width: 34px; height: 34px; border-radius: 9px; box-shadow: 0 0 0 1px var(--line); }
.nav-links { display: flex; gap: 28px; margin-left: auto; }
.nav-links a { text-decoration: none; color: var(--muted); font-size: 0.9375rem; font-weight: 500; transition: color 0.2s; }
.nav-links a:hover { color: var(--text); }
.play-badge { display: inline-block; line-height: 0; border-radius: 12px; transition: transform 0.25s var(--ease); }
.play-badge img { height: 56px; width: auto; }
.play-badge:hover { transform: translateY(-2px); }
.play-badge:active { transform: translateY(0) scale(0.98); }
.nav .play-badge img { height: 40px; }

/* ---------- hero ---------- */
.hero { padding: clamp(48px, 7vw, 88px) 0 clamp(64px, 8vw, 112px); overflow: hidden; }
.hero .wrap { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 48px; align-items: center; }
.hero h1 { font-size: clamp(2.8rem, 4.9vw, 4.4rem); line-height: 1.06; padding-bottom: 0.08em; max-width: 14ch; text-wrap: balance; }
.hero .lede { margin-top: 24px; }
.hero-cta { display: flex; align-items: center; gap: 20px; margin-top: 36px; flex-wrap: wrap; }
.link-arrow { font-weight: 500; font-size: 0.975rem; text-decoration: none; color: var(--text); padding: 14px 22px; border-radius: 999px; box-shadow: inset 0 0 0 1px var(--line); transition: background 0.2s, transform 0.2s var(--ease); }
.link-arrow:hover { background: var(--elevated); }
.link-arrow:active { transform: scale(0.98); }

.stage { position: relative; height: clamp(520px, 52vw, 680px); }
.stage::before { content: ""; position: absolute; inset: 10% 0 0 10%; background: radial-gradient(closest-side, rgba(254, 153, 61, 0.16), transparent); filter: blur(10px); }
.phone {
  position: relative; aspect-ratio: 720 / 1560; border-radius: 44px; padding: 9px;
  background: linear-gradient(160deg, #2a2a2e, #0b0b0c 45%, #1b1b1e);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1), 0 50px 90px -30px rgba(0, 0, 0, 0.85);
}
.phone img { width: 100%; height: 100%; object-fit: cover; border-radius: 36px; }
.stage .phone { position: absolute; width: min(300px, 42%); }
.stage .p1 { left: 6%; top: 4%; transform: rotate(-5deg); }
.stage .p2 { right: 4%; top: 14%; transform: rotate(4deg); }
.stage .float-cover { position: absolute; width: 27%; left: 38%; bottom: 0; border-radius: 18px; box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.9), 0 0 0 1px var(--line); transform: rotate(-3deg); }

/* ---------- sections ---------- */
section { position: relative; }
.section { padding: clamp(80px, 11vw, 160px) 0; }
.section h2 { font-size: clamp(2.4rem, 4.6vw, 4rem); line-height: 1.06; padding-bottom: 0.06em; }
.section .lede { margin-top: 20px; }

/* scrollytelling: sticky phone, steps scroll past */
.story { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(32px, 6vw, 96px); }
.story-phone { position: sticky; top: calc(50vh - 290px); height: 580px; display: grid; place-items: center; }
.story-phone .phone { width: 268px; }
.story-phone .phone img { position: absolute; inset: 9px; width: calc(100% - 18px); height: calc(100% - 18px); opacity: 0; transition: opacity 0.5s var(--ease), transform 0.6s var(--ease); transform: scale(0.985); }
.story-phone .phone img.on { opacity: 1; transform: none; }
.step { min-height: 72vh; display: flex; flex-direction: column; justify-content: center; }
.step h3 { font-size: clamp(2rem, 3.4vw, 3rem); line-height: 1.08; }
.step p { margin-top: 16px; color: var(--muted); max-width: 36ch; font-size: 1.125rem; }
.step .step-shot { display: none; }
.step-row { display: flex; gap: 12px; margin-top: 28px; }
.step-row img { width: 96px; border-radius: 14px; box-shadow: 0 0 0 1px var(--line); }
.step-row img.picked { box-shadow: 0 0 0 2px var(--accent); }

/* cover wall (the page's one marquee) */
.covers { padding: 0 0 clamp(80px, 10vw, 140px); overflow: hidden; }
.covers h2 { font-size: clamp(2.2rem, 4vw, 3.4rem); max-width: 20ch; text-wrap: balance; }
.marquee { margin-top: 48px; display: flex; gap: 20px; width: max-content; animation: drift 48s linear infinite; }
.marquee:hover { animation-play-state: paused; }
.marquee img { height: clamp(220px, 26vw, 340px); width: auto; border-radius: 18px; box-shadow: 0 0 0 1px var(--line); }
@keyframes drift { to { transform: translateX(calc(-50% - 10px)); } }

/* together: stitched chapter cards */
.together { background: linear-gradient(180deg, var(--bg), var(--surface) 30%, var(--surface) 70%, var(--bg)); }
.together .wrap { display: grid; grid-template-columns: 0.9fr 1.1fr; gap: 64px; align-items: center; }
.chain { position: relative; display: grid; gap: 30px; }
.chain img { border-radius: 26px; box-shadow: 0 30px 60px -30px rgba(0, 0, 0, 0.9); width: 88%; }
.chain img:nth-of-type(2) { justify-self: end; }
.chain .chapter-btn { width: min(300px, 60%); justify-self: center; border-radius: 999px; box-shadow: 0 20px 40px -20px rgba(0, 0, 0, 0.9); }
.chain svg { position: absolute; left: 6%; right: 6%; top: 32%; width: 88%; height: 70px; overflow: visible; pointer-events: none; }
.chain path { fill: none; stroke: var(--accent); stroke-width: 3; stroke-dasharray: 10 9; stroke-linecap: round; }
.chain .next {
  justify-self: center; display: flex; align-items: center; gap: 14px; padding: 14px 24px 14px 14px; border-radius: 999px;
  background: var(--text); color: var(--bg); font-weight: 600; text-decoration: none; margin-top: 8px;
}
.authors { display: flex; margin-top: 32px; }
.authors img { width: 52px; height: 52px; border-radius: 50%; box-shadow: 0 0 0 3px var(--surface); margin-left: -10px; }
.authors img:first-child { margin-left: 0; }

/* bento: exactly three cells */
.bento { display: grid; grid-template-columns: 1.35fr 1fr; grid-template-rows: auto auto; gap: 20px; margin-top: 56px; }
.cell { border-radius: var(--radius); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); padding: 32px; overflow: hidden; position: relative; }
.cell h3 { font-size: 1.9rem; line-height: 1.1; }
.cell p { color: var(--muted); margin-top: 10px; max-width: 34ch; }
.cell-listen { grid-row: span 2; display: flex; flex-direction: column; gap: 28px; }
.cell-listen .art { border-radius: 18px; width: 100%; }
.wave { display: flex; align-items: center; gap: 5px; height: 64px; }
.wave i { flex: 1; border-radius: 3px; background: #5d5d64; height: 30%; animation: eq 1.1s var(--ease) infinite alternate; animation-delay: calc(var(--i) * -0.13s); }
.wave i:nth-child(-n + 14) { background: var(--accent); }
@keyframes eq { to { height: 100%; } }
.cell-streak { display: flex; flex-direction: column; gap: 24px; }
.cell-streak img { width: min(100%, 340px); border-radius: 22px; box-shadow: 0 24px 48px -24px rgba(255, 122, 46, 0.55); }
.cell-readers .engage { margin-top: 24px; border-radius: 14px; width: 100%; }
.cell-readers .authors img { box-shadow: 0 0 0 3px var(--surface); }

/* film */
.film .wrap { display: grid; grid-template-columns: auto 1fr; gap: clamp(40px, 7vw, 110px); align-items: center; }
.film video { width: min(340px, 80vw); aspect-ratio: 9 / 16; border-radius: 32px; background: #000; box-shadow: 0 0 0 1px var(--line), 0 60px 100px -40px rgba(0, 0, 0, 0.9); }

/* partners */
.partners { padding: 0 0 clamp(64px, 8vw, 100px); }
.partners h2 { font-family: var(--sans); font-size: 0.95rem; font-weight: 500; letter-spacing: 0; color: var(--muted); text-align: center; }
.logos { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 28px 48px; margin-top: 28px; }
.logos img { height: 30px; width: auto; opacity: 0.6; filter: grayscale(1); transition: opacity 0.2s; }
.logos img:hover { opacity: 0.95; }

/* final cta */
.final { text-align: center; padding: clamp(96px, 12vw, 180px) 0; border-top: 1px solid var(--line); }
.final h2 { font-size: clamp(2.6rem, 5.4vw, 4.6rem); line-height: 1.05; max-width: 14ch; margin: 0 auto; padding-bottom: 0.06em; }
.final .play-badge { margin-top: 40px; }

/* footer */
.foot { border-top: 1px solid var(--line); padding: 40px 0 56px; font-size: 0.9rem; color: var(--muted); }
.foot .wrap { display: flex; flex-wrap: wrap; gap: 16px 40px; align-items: center; }
.foot .brand { color: var(--text); font-size: 1.2rem; }
.foot nav { display: flex; flex-wrap: wrap; gap: 8px 24px; margin-left: auto; }
.foot a { text-decoration: none; }
.foot a:hover { color: var(--text); }

/* legal pages */
.legal-head, .legal { max-width: calc(72ch + 2 * var(--gutter)); }
.legal-head { padding-top: clamp(56px, 8vw, 104px); padding-bottom: 32px; }
.legal-head h1 { font-size: clamp(2.4rem, 5vw, 3.8rem); line-height: 1.05; }
.legal-head p { margin-top: 12px; color: var(--muted); }
.legal { padding-bottom: 120px; color: #d9d6cf; }
.legal h2 { font-size: 1.9rem; margin: 56px 0 14px; color: var(--text); }
.legal h3 { font-family: var(--sans); font-size: 1.1rem; font-weight: 600; letter-spacing: 0; margin: 32px 0 10px; color: var(--text); }
.legal p { margin-bottom: 14px; line-height: 1.75; }
.legal ul, .legal ol { padding-left: 22px; margin: 0 0 18px; }
.legal li { margin-bottom: 8px; line-height: 1.7; }
.legal a { color: var(--accent); }
.legal strong { color: var(--text); }

/* reveal on scroll (motion = sequencing the story, nothing loops except the cover wall and waveform) */
.reveal { opacity: 0; transform: translateY(28px); transition: opacity 0.9s var(--ease), transform 0.9s var(--ease); transition-delay: var(--d, 0s); }
.reveal.in { opacity: 1; transform: none; }
.hero .rise { animation: rise 1s var(--ease) both; animation-delay: var(--d, 0s); }
@keyframes rise { from { opacity: 0; transform: translateY(36px) rotate(var(--r, 0deg)); } }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
  .hero .rise, .wave i { animation: none; }
  .wave i { height: 60%; }
  .marquee { animation: none; width: auto; overflow-x: auto; }
  .covers .marquee [aria-hidden="true"] { display: none; }
}

/* ---------- mobile ---------- */
@media (max-width: 900px) {
  .nav-links { display: none; }
  .nav .wrap { justify-content: space-between; }
  .hero .wrap, .together .wrap, .film .wrap { grid-template-columns: 1fr; }
  .hero { text-align: left; }
  .stage { height: 520px; }
  .stage .phone { width: 48%; }
  .story { grid-template-columns: 1fr; }
  .story-phone { display: none; }
  .step { min-height: 0; padding: 40px 0; }
  .step .step-shot { display: block; width: min(260px, 70vw); margin-top: 28px; }
  .bento { grid-template-columns: 1fr; }
  .cell-listen { grid-row: auto; }
  .film video { margin: 0 auto; }
  .foot nav { margin-left: 0; }
}
@media (max-width: 520px) {
  body { font-size: 16px; }
  .cell-streak img { width: 100%; }
  .stage { height: 440px; }
  .play-badge img { height: 50px; }
  .nav .play-badge img { height: 36px; }
  .cell { padding: 24px; }
}
