/* ============================================================
   Tavla — waitlist site
   Self-hosted fonts, no external requests (privacy-first brand).
   Two theme layers:
     · site chrome  → crisp black/white + bright orange accent
     · app preview  → warm palette matched to app/Sources/Tavla/Theme.swift
   ============================================================ */

/* ---------- Fonts (self-hosted, no CDN) ---------- */
@font-face {
  font-family: "Clash Display";
  src: url("/assets/fonts/ClashDisplay-Regular.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Clash Display";
  src: url("/assets/fonts/ClashDisplay-Medium.woff2") format("woff2");
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Clash Display";
  src: url("/assets/fonts/ClashDisplay-Semibold.woff2") format("woff2");
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Clash Display";
  src: url("/assets/fonts/ClashDisplay-Bold.woff2") format("woff2");
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("/assets/fonts/InterVariable.woff2") format("woff2-variations");
  font-weight: 100 900; font-style: normal; font-display: swap;
}

/* ---------- Design tokens ---------- */
:root,
:root[data-theme="light"] {
  --bg:        #fbfbfa;   /* barely-warm white */
  --bg-2:      #f4f3f0;   /* recessed panels */
  --fg:        #171614;   /* warm near-black */
  --muted:     rgba(23, 22, 20, 0.62);
  --faint:     rgba(23, 22, 20, 0.10);
  --hairline:  rgba(23, 22, 20, 0.12);
  --accent:    #af5a1b;   /* brand orange E07F31, deepened for AA on near-white (4.7:1) */
  --accent-ink:#ffffff;
  --card:      #ffffff;
  --shadow:    0 24px 60px -28px rgba(23, 22, 20, 0.30), 0 2px 8px -4px rgba(23, 22, 20, 0.14);

  /* App-preview palette — light (from Theme.swift) */
  --app-canvas:     #fbfaf7;
  --app-ink:        #232220;
  --app-caret:      #4f6fa6;
  --app-selection:  rgba(79, 111, 166, 0.16);
  --app-sel:        rgba(224, 127, 49, 0.50);   /* soft brand orange — the "selected word" wash */
  --app-bar-fill:   rgba(255, 255, 255, 0.72);
  --app-bar-stroke: rgba(23, 22, 20, 0.10);
  --app-bar-text:   rgba(23, 22, 20, 0.92);
  --app-bar-muted:  rgba(23, 22, 20, 0.50);
  --app-shadow:     0 30px 80px -30px rgba(23, 22, 20, 0.45);
}

:root[data-theme="dark"] {
  --bg:        #0e0d0c;   /* warm near-black, a touch below the app canvas */
  --bg-2:      #171512;
  --fg:        #f2f0ea;   /* warm near-white */
  --muted:     rgba(242, 240, 234, 0.60);
  --faint:     rgba(242, 240, 234, 0.12);
  --hairline:  rgba(242, 240, 234, 0.14);
  --accent:    #e07f31;   /* brand orange, as given — 6.7:1 on dark */
  --accent-ink:#171310;
  --card:      #171512;
  --shadow:    0 30px 70px -30px rgba(0, 0, 0, 0.7), 0 2px 10px -4px rgba(0, 0, 0, 0.5);

  /* App-preview palette — dark (from Theme.swift) */
  --app-canvas:     #1b1a18;
  --app-ink:        #e7e3da;
  --app-caret:      #8fa6d6;
  --app-selection:  rgba(143, 166, 214, 0.22);
  --app-sel:        rgba(224, 127, 49, 0.58);   /* soft brand orange — a touch stronger on dark */
  --app-bar-fill:   rgba(52, 50, 47, 0.66);
  --app-bar-stroke: rgba(255, 255, 255, 0.12);
  --app-bar-text:   rgba(231, 227, 218, 0.95);
  --app-bar-muted:  rgba(231, 227, 218, 0.52);
  --app-shadow:     0 40px 90px -30px rgba(0, 0, 0, 0.85);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 72px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "cv05" 1, "ss01" 1; /* Inter refinements */
  transition: background-color .4s ease, color .4s ease;
}
h1, h2, h3 { margin: 0; font-family: "Clash Display", ui-sans-serif, system-ui, sans-serif; font-weight: 600; letter-spacing: -0.01em; line-height: 1.06; }
p { margin: 0; }
a { color: inherit; }
img, svg { display: block; max-width: 100%; }
button { font: inherit; cursor: pointer; }
input { font: inherit; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 100;
  background: var(--fg); color: var(--bg); padding: .7em 1.1em; border-radius: 0 0 10px 0;
  text-decoration: none;
}
.skip-link:focus { left: 0; }

/* ---------- Layout container widths ---------- */
.hero, .pillars, .promise, .price, .cloud { padding-left: 6vw; padding-right: 6vw; }

/* ---------- Header ---------- */
.site-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.4rem 6vw;
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.1) blur(12px);
  -webkit-backdrop-filter: saturate(1.1) blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color .3s ease, background-color .4s ease;
}
.site-header.scrolled { border-bottom-color: var(--hairline); }
.wordmark {
  font-family: "Clash Display", sans-serif; font-weight: 600; font-size: 1.4rem;
  letter-spacing: -0.02em; text-decoration: none; color: var(--fg);
}
.header-nav { display: flex; align-items: center; gap: 1.6rem; }
.header-link {
  text-decoration: none; color: var(--muted); font-size: .95rem; font-weight: 500;
  transition: color .2s ease;
}
.header-link:hover { color: var(--fg); }
@media (max-width: 560px) { .header-link { display: none; } }

.theme-toggle {
  display: inline-grid; place-items: center;
  width: 38px; height: 38px; border-radius: 50%;
  background: transparent; border: 1px solid var(--hairline); color: var(--fg);
  transition: background-color .2s ease, border-color .2s ease, transform .2s ease;
}
.theme-toggle:hover { background: var(--faint); }
.theme-toggle:active { transform: scale(.94); }
.theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: block; }

/* ---------- Hero (centered, single column) ---------- */
.hero {
  max-width: 860px; margin: 0 auto; text-align: center;
  display: flex; flex-direction: column; align-items: center;
  padding-top: clamp(2rem, 5vw, 3.5rem);
  padding-bottom: clamp(3rem, 7vw, 5rem);
}
.eyebrow {
  text-transform: uppercase; letter-spacing: .18em; font-size: .74rem; font-weight: 600;
  color: var(--muted); margin-bottom: 1.1rem;
}
.hero-title {
  font-size: clamp(2.15rem, 5.4vw, 4rem);
  font-weight: 600;
  margin: 0 auto 1.1rem;
  max-width: 18ch;
}
.hero-sub {
  color: var(--muted); font-size: clamp(1.02rem, 1.5vw, 1.18rem);
  max-width: 46ch; margin: 0 auto;
}

/* hand-drawn scribble accents — draw on when scrolled into view */
.underlined, .accent-word { position: relative; white-space: nowrap; }
.underlined .scribble {
  position: absolute; left: -2%; right: -2%; bottom: -0.28em; width: 104%; height: 0.42em;
  color: var(--accent); overflow: visible;
}
.scribble path { stroke-dasharray: 1; stroke-dashoffset: 1; }
[data-scribble].in-view .scribble path { animation: draw 0.9s ease forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) { .scribble path { stroke-dashoffset: 0; animation: none; } }

/* ---------- Waitlist form ---------- */
.waitlist { max-width: 34rem; width: 100%; margin: clamp(2rem, 4vw, 3rem) auto 0; text-align: left; }
.form-lede { font-size: 1rem; margin-bottom: 1rem; color: var(--fg); text-align: center; }
.form-lede strong { color: var(--accent); font-weight: 700; }
.field-row { display: flex; gap: .6rem; }
@media (max-width: 460px) { .field-row { flex-direction: column; } }
#email {
  flex: 1 1 auto; min-width: 0;
  padding: .85rem 1rem; border-radius: 12px;
  border: 1px solid var(--hairline); background: var(--card); color: var(--fg);
  transition: border-color .2s ease, box-shadow .2s ease;
}
#email::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
#email:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
#email.invalid { border-color: var(--accent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: .85rem 1.4rem; border-radius: 12px; border: 1px solid transparent;
  font-weight: 600; text-decoration: none; white-space: nowrap;
  transition: transform .15s ease, opacity .2s ease, background-color .2s ease;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn-primary { background: var(--fg); color: var(--bg); }
.btn-primary:hover { opacity: .88; }
.btn-primary[disabled] { opacity: .5; cursor: default; }
.btn-lg { padding: 1rem 1.8rem; font-size: 1.05rem; margin-top: 1.6rem; }

.check {
  display: flex; gap: .6rem; align-items: flex-start;
  margin-top: .9rem; font-size: .9rem; color: var(--muted); line-height: 1.5;
}
.check input { margin-top: .18em; width: 1.05em; height: 1.05em; accent-color: var(--accent); flex: none; }
.form-fine { margin-top: 1.1rem; font-size: .8rem; color: var(--muted); }
.quiet-link { color: var(--muted); text-underline-offset: 2px; }
.quiet-link:hover { color: var(--fg); }

.form-message { margin-top: 1rem; font-size: .95rem; padding: .8rem 1rem; border-radius: 10px; }
.form-message.ok { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--fg); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); }
.form-message.err { background: var(--bg-2); color: var(--fg); border: 1px solid var(--hairline); }

/* honeypot — visually gone, still in DOM for bots */
.hp-field { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- Interactive app preview ---------- */
.hero-preview { display: flex; flex-direction: column; align-items: center; gap: .9rem; width: 100%; margin-top: clamp(2rem, 4vw, 3rem); }
.device {
  margin: 0; width: 100%; max-width: 620px;
  border-radius: 18px;
  box-shadow: var(--app-shadow);
  overflow: hidden;
  border: 1px solid var(--app-bar-stroke);
  transition: box-shadow .4s ease;
}
.app {
  position: relative;
  aspect-ratio: 16 / 11;
  background: var(--app-canvas);
  color: var(--app-ink);
  transition: background-color .4s ease, color .4s ease;
  overflow: hidden;
  user-select: none; -webkit-user-select: none;   /* it's a demo, not a text field */
  cursor: default;
}
.app-canvas {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 12% 14% 18%;
}
.app-text {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; /* sans, as requested */
  font-size: clamp(0.95rem, 2.2vw, 1.35rem);
  line-height: 1.5;
  max-width: 34ch;
  letter-spacing: -0.003em;
}
.typed { white-space: pre-wrap; }
.caret {
  display: inline-block; width: 2px; height: 1.05em; margin-left: 1px;
  vertical-align: text-bottom; background: var(--app-caret);
  animation: blink 1.1s step-end infinite;
}
@keyframes blink { 0%, 50% { opacity: 1; } 50.01%, 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .caret { animation: none; } }

/* the looked-up word — shown as a soft text-selection highlight (like selecting on Mac),
   sweeping in left-to-right the way a real selection does */
.mark-word {
  white-space: nowrap; color: var(--app-ink);
  border-radius: 3px;
  padding: 0.12em 0.1em; margin: 0 -0.1em;
  background-image: linear-gradient(var(--app-sel), var(--app-sel));
  background-repeat: no-repeat;
  background-position: left center;
  background-size: 0% 100%;
  transition: background-size .45s cubic-bezier(.2,.7,.2,1);
}
.app.annotated .mark-word { background-size: 100% 100%; }
@media (prefers-reduced-motion: reduce) {
  .mark-word { transition: none; }
}

.lookup-pop {
  position: absolute; z-index: 3;
  display: inline-flex; flex-direction: column; gap: .12rem;
  padding: .5rem .7rem; border-radius: 10px;
  background: var(--app-bar-fill);
  -webkit-backdrop-filter: blur(18px) saturate(1.3);
  backdrop-filter: blur(18px) saturate(1.3);
  border: 1px solid var(--app-bar-stroke);
  box-shadow: 0 12px 30px -12px rgba(0,0,0,.4);
  font-family: ui-sans-serif, system-ui, sans-serif;
  opacity: 0; transform: translateY(6px); transition: opacity .3s ease, transform .3s ease;
  pointer-events: none;
}
.app.annotated .lookup-pop { opacity: 1; transform: translateY(0); }
.lookup-word { font-size: .72rem; color: var(--app-bar-muted); }
.lookup-syns { font-size: .86rem; color: var(--app-bar-text); font-weight: 500; }

/* floating bar */
.app-bar {
  position: absolute; left: 50%; bottom: 6%; transform: translateX(-50%);
  display: flex; align-items: center; gap: .55rem;
  padding: .5rem .7rem; border-radius: 14px;
  background: var(--app-bar-fill);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  backdrop-filter: blur(20px) saturate(1.4);
  border: 1px solid var(--app-bar-stroke);
  box-shadow: 0 14px 34px -16px rgba(0,0,0,.45);
  color: var(--app-bar-text);
  transition: background-color .4s ease, color .4s ease, border-color .4s ease;
}
.bar-cluster { display: inline-flex; align-items: center; gap: .35rem; padding: 0 .25rem; color: var(--app-bar-text); }
.bar-format { gap: .5rem; }
.fmt { font-size: .84rem; color: var(--app-bar-muted); line-height: 1; }
.fmt-b { font-weight: 700; }
.fmt-i { font-style: italic; font-family: Georgia, serif; }
.fmt-u { text-decoration: underline; text-underline-offset: 2px; }
.bar-divider { width: 1px; align-self: stretch; margin: .15rem 0; background: var(--app-bar-stroke); }
.bar-timer { font-size: .8rem; font-variant-numeric: tabular-nums; color: var(--app-bar-muted); }

.device-caption { font-size: .85rem; color: var(--muted); text-align: center; }

/* ---------- Section shared ---------- */
.section-title { font-size: clamp(1.7rem, 3.4vw, 2.6rem); text-align: center; max-width: 20ch; margin: 0 auto .8rem; }
.section-lede { text-align: center; color: var(--muted); max-width: 46ch; margin: 0 auto; font-size: clamp(1rem, 1.5vw, 1.15rem); }

/* ---------- Stacking-scroll blocks ---------- */
.stack { position: relative; z-index: 1; }
.block {
  position: sticky; top: 0;
  min-height: 100vh;
  display: grid; place-items: center;
  padding: clamp(4rem, 9vh, 7rem) 6vw;
  background: var(--bg);
}
.block:nth-child(odd) { background: var(--bg-2); }   /* alternate so the stack reads as it scrolls */
.block-inner { width: 100%; max-width: 1120px; margin: 0 auto; }
@media (max-width: 800px) {
  .block { position: static; min-height: auto; padding: clamp(3.5rem, 12vw, 5rem) 6vw; }  /* reduced version on mobile */
}

/* ---------- Pillars (borderless, flowing) ---------- */
.pillar-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: clamp(1.8rem, 3.5vw, 3rem) clamp(1.6rem, 3vw, 3rem);
  margin-top: clamp(2.2rem, 4vw, 3.2rem);
}
@media (max-width: 860px) { .pillar-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 540px) { .pillar-grid { grid-template-columns: 1fr; max-width: 26rem; margin-left: auto; margin-right: auto; } }
.pillar { background: transparent; border: none; padding: 0; }
.pillar-mark { display: inline-grid; place-items: center; color: var(--accent); margin-bottom: .85rem; }
.pillar-mark svg { width: 30px; height: 30px; }
.pillar h3 { font-size: 1.1rem; font-weight: 600; margin-bottom: .4rem; letter-spacing: -0.01em; }
.pillar p { color: var(--muted); font-size: .95rem; }

/* ---------- Promise ---------- */
.promise { max-width: 760px; margin: 0 auto; text-align: center; }
.promise-eyebrow { font-family: "Clash Display", sans-serif; font-weight: 500; font-size: clamp(1.4rem, 3vw, 2.1rem); color: var(--muted); }
.promise-line { font-family: "Clash Display", sans-serif; font-weight: 600; font-size: clamp(1.9rem, 4.5vw, 3.1rem); margin-bottom: 1.6rem; line-height: 1.1; }
.accent-word .scribble-sm { position: absolute; left: 0; right: 0; bottom: -0.22em; width: 100%; height: 0.36em; color: var(--accent); overflow: visible; }
.promise-body { color: var(--muted); font-size: clamp(1.02rem, 1.6vw, 1.2rem); max-width: 54ch; margin: 0 auto; }

/* ---------- No AI ---------- */
.noai { max-width: 48rem; margin: 0 auto; text-align: center; }
.noai-title { font-family: "Clash Display", sans-serif; font-weight: 600; font-size: clamp(1.9rem, 4.5vw, 3.1rem); line-height: 1.08; margin: .5rem 0 1rem; }
.noai-lede { color: var(--muted); font-size: clamp(1.02rem, 1.6vw, 1.2rem); max-width: 48ch; margin: 0 auto 2.4rem; }
.noai-points { list-style: none; padding: 0; margin: 0 auto 2.2rem; max-width: 40rem; text-align: left; display: grid; gap: 1.05rem; }
.noai-points li { color: var(--muted); font-size: 1.06rem; line-height: 1.5; padding-left: 1.5rem; position: relative; }
.noai-points li::before { content: ""; position: absolute; left: 0; top: .5em; width: .55rem; height: .55rem; border: 1.6px solid var(--accent); border-radius: 50%; }
.noai-points strong { color: var(--fg); font-weight: 600; }
.noai-commit { color: var(--fg); font-size: clamp(1.05rem, 1.9vw, 1.28rem); line-height: 1.55; max-width: 42rem; margin: 0 auto 1.5rem; }
.noai-emph { color: var(--accent); }
.noai-more { display: inline-block; font-weight: 500; }

/* ---------- Price (airy, no box) ---------- */
.price { max-width: 720px; margin: 0 auto; text-align: center; }
.price-sub { color: var(--muted); max-width: 46ch; margin: 0 auto 2rem; }
.price-ladder { list-style: none; margin: 0 0 1.2rem; padding: 0; display: flex; justify-content: center; gap: clamp(1.4rem, 5vw, 3.4rem); flex-wrap: wrap; }
.price-ladder li { display: flex; flex-direction: column; align-items: center; gap: .3rem; }
.price-ladder .amt { font-family: "Clash Display", sans-serif; font-weight: 600; font-size: clamp(1.7rem, 4vw, 2.5rem); }
.price-ladder li:first-child .amt { color: var(--accent); }
.price-ladder .tag { font-size: .82rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.price-note { font-weight: 500; }

/* ---------- Cloud ---------- */
.cloud { max-width: 640px; margin: 0 auto; text-align: center; }
.cloud-tag { text-transform: uppercase; letter-spacing: .18em; font-size: .74rem; font-weight: 600; color: var(--accent); margin-bottom: .6rem; }
.cloud-title { font-size: clamp(1.8rem, 4vw, 2.8rem); margin-bottom: 1rem; }
.cloud-body { color: var(--muted); font-size: 1.05rem; max-width: 46ch; margin: 0 auto; }

/* ---------- Footer ---------- */
.site-footer {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: 2.4rem 6vw; border-top: 1px solid var(--hairline);
  color: var(--muted); font-size: .9rem;
}
.footer-mark { font-size: 1.15rem; color: var(--fg); }
.footer-tag { flex: 1 1 auto; }
.footer-links { display: flex; gap: 1.2rem; }
@media (max-width: 560px) { .footer-tag { flex-basis: 100%; order: 3; } }
