/*
 * Tokens mirror pnyx-native/src/theme/tokens.ts — warm neutral, monochrome
 * chrome. Colour only appears where it carries meaning: grid colours, crests,
 * and the up/down vote semantics.
 */
:root {
  color-scheme: light;
  --bg: #eeece8;
  --app: #f2f0ec;
  --surface: #faf9f6;
  --surface2: #f0eeea;
  --surface3: #e6e3dd;
  --line: #dcd9d2;
  --line-soft: #e8e5df;
  --text: #161513;
  --text-dim: #4b4945;
  --text-faint: #67645e;
  --up: #3fbf8f;
  --up-soft: rgba(63, 191, 143, 0.14);
  --down: #e5626f;
  --down-soft: rgba(229, 98, 111, 0.14);
  --error: #b23a46;

  --r-sm: 12px;
  --r-md: 16px;
  --r-lg: 24px;

  --display: "Familjen Grotesk", ui-sans-serif, system-ui, sans-serif;
  --body: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, Menlo, Consolas, monospace;

  --gutter: clamp(16px, 4vw, 48px);
  --max: 1160px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  /* What shows if WebGL is unavailable, and for the instant before the first
     frame: a grey from the middle of the FLOW gradient's range (flow.js). */
  background: #c4c7cb;
  color: var(--text);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, p, dl, dd, ol, figure, blockquote { margin: 0; padding: 0; }

/* ── FLOW backdrop (flow.js) ────────────────────────────
 * Text straight on the gradient uses the app's backdrop inks (tokens.ts
 * backdropDim / backdropFaint): the gradient swings as dark as ~#9f9f9f, where
 * the normal dim/faint greys drop below AA. Painted surfaces reset to the
 * normal ramp — the same split as useInk() and Card in the app. */
.flow {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  pointer-events: none;
}
body {
  --text-dim: #282725;
  --text-faint: #373532;
  --line: rgba(22, 21, 19, 0.16);
  --line-soft: rgba(22, 21, 19, 0.1);
  --error: #7e1622;
}
.step, .countdown, .signup-row, .signup.is-done .signup-note, .top-link {
  --text-dim: #4b4945;
  --text-faint: #67645e;
  --line: #dcd9d2;
  --line-soft: #e8e5df;
  --error: #b23a46;
}
ol { list-style: none; }
a { color: inherit; }
button, input { font: inherit; color: inherit; }

.wrap { width: 100%; max-width: calc(var(--max) + 2 * var(--gutter)); margin-inline: auto; padding-inline: var(--gutter); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

.label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
}

:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; border-radius: 4px; }

/* ── Header ─────────────────────────────────────────── */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-block: 24px;
}
.wordmark {
  font-family: var(--display);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: 0.24em;
  text-decoration: none;
}
.wordmark--sm { font-size: 15px; }
.top-meta { display: flex; align-items: center; gap: 24px; font-size: 13px; }
.top-date { color: var(--text-faint); font-variant-numeric: tabular-nums; }
.top-link {
  text-decoration: none;
  font-weight: 600;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  transition: border-color 160ms var(--ease), background-color 160ms var(--ease);
}
.top-link:hover { border-color: var(--text-faint); }
@media (max-width: 560px) { .top-date { display: none; } }

/* ── Hero ───────────────────────────────────────────── */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: clamp(32px, 5vw, 80px);
  align-items: center;
  padding-block: clamp(40px, 8vw, 112px) clamp(56px, 8vw, 120px);
}
.hero-copy { display: grid; gap: 24px; }
h1 {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(42px, 6.4vw, 84px);
  line-height: 0.98;
  letter-spacing: -0.028em;
  text-wrap: balance;
  max-width: 13ch;
}
.lede { font-size: 17px; line-height: 1.6; color: var(--text-dim); max-width: 46ch; }

/* Two app screens: Home behind, the reels feed in front. */
.hero-phones {
  position: relative;
  width: 100%;
  max-width: 480px;
  aspect-ratio: 440 / 660;
  justify-self: end;
}
.hero-phones .phone { position: absolute; }
.phone--back { left: 0; top: 0; width: 56%; }
.phone--front { right: 0; top: 11%; width: 62%; }

@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; }
  .hero-phones { justify-self: center; max-width: 360px; }
}

/* ── Phone frame ────────────────────────────────────── */
.phone {
  background: #161513;
  padding: 2.6%;
  border-radius: 14% / 6.5%;
  box-shadow: 0 30px 60px -20px rgba(22, 21, 19, 0.45), 0 2px 6px rgba(22, 21, 19, 0.2);
}
.phone img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 11.8% / 5.4%;
}

/* ── Crest (web port of components/Crest.tsx) ───────── */
.crest {
  --size: 44px;
  width: var(--size);
  height: var(--size);
  border-radius: calc(var(--size) * 0.28);
  position: relative;
  overflow: hidden;
  flex: none;
  background: var(--shadow, #25253a);
  transition: opacity 220ms var(--ease);
}
.crest::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.crest-layer {
  position: absolute;
  inset: 0;
  -webkit-mask-size: contain; mask-size: contain;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
  -webkit-mask-position: center; mask-position: center;
}
.crest.is-fading { opacity: 0; }

/* ── Signup ─────────────────────────────────────────── */
.signup { display: grid; gap: 10px; max-width: 480px; }
.signup-row {
  display: flex;
  gap: 6px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  transition: border-color 160ms var(--ease);
}
.signup-row:focus-within { border-color: var(--text-faint); }
.signup input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 10px 12px;
  font-size: 16px;
  outline: none;
}
.signup input::placeholder { color: var(--text-faint); }
.signup button {
  border: 0;
  background: var(--text);
  color: #fff;
  font-weight: 600;
  font-size: 15px;
  padding: 12px 20px;
  border-radius: var(--r-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 160ms var(--ease), transform 120ms var(--ease);
}
.signup button:hover { background: #33312d; }
.signup button:active { transform: scale(0.98); }
.signup button[disabled] { cursor: progress; background: linear-gradient(135deg, #aeb4bf, #767c88); }
.signup-note { font-size: 13px; color: var(--text-faint); padding-inline: 4px; }
.signup-note.is-error { color: var(--error); font-weight: 600; }
.signup.is-done .signup-row { display: none; }
.signup.is-done .signup-note {
  font-size: 15px;
  color: var(--text);
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.signup--center { margin-inline: auto; }
@media (max-width: 420px) {
  .signup-row { flex-direction: column; }
  .signup button { padding-block: 14px; }
}

/* ── Countdown (same card as widget.html) ────────────── */
.countdown {
  container-type: inline-size;
  max-width: 480px;
  margin-top: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 16px 18px;
  display: grid;
  gap: 14px;
}
.countdown-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.countdown-date { font-size: 13px; font-weight: 600; color: var(--text-dim); white-space: nowrap; }
.clock { display: grid; grid-template-columns: repeat(4, 1fr); }
.unit { display: grid; gap: 2px; padding-inline: 14px; border-left: 1px solid var(--line-soft); }
.unit:first-child { border-left: 0; padding-left: 0; }
.unit:last-child { padding-right: 0; }
.num {
  font-family: var(--display);
  font-weight: 500;
  font-size: 40px;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.unit-label { font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-faint); font-weight: 600; }
.clock-live { font-family: var(--display); font-size: 24px; font-weight: 600; line-height: 1.15; }
.countdown [hidden] { display: none; }
@container (max-width: 360px) {
  .num { font-size: 34px; }
  .unit { padding-inline: 12px; }
}
@container (max-width: 290px) {
  .num { font-size: 30px; }
  .unit { padding-inline: 10px; }
  .unit-label { font-size: 9px; letter-spacing: 0.06em; }
  .countdown-date { display: none; }
}

/* ── Sections ───────────────────────────────────────── */
.how, .principles { padding-block: clamp(72px, 10vw, 136px) 0; }
h2 {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(32px, 4.2vw, 52px);
  line-height: 1.02;
  letter-spacing: -0.024em;
  text-wrap: balance;
  margin-bottom: clamp(28px, 4vw, 48px);
}

/* ── How it works ───────────────────────────────────── */
.steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  counter-reset: none;
}
@media (max-width: 1080px) { .steps { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) { .steps { grid-template-columns: 1fr; } }

.step {
  display: grid;
  grid-template-rows: auto auto auto 1fr;
  gap: 8px;
  align-content: start;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  padding: 12px 12px 24px;
}
.step-visual {
  height: 280px;
  margin-bottom: 12px;
  border-radius: var(--r-md);
  background: var(--surface2);
  overflow: hidden;
  display: grid;
  place-items: center;
}
/* Screens show their top half and run off the bottom of the panel. */
.step-visual .phone--sm { width: 170px; align-self: start; margin-top: 28px; }
/* The photo viewer's top third is black chrome — start at the photo instead. */
.step-visual .phone--crop { margin-top: -72px; }
.step-num { font-family: var(--mono); font-size: 12px; color: var(--text-faint); padding-inline: 8px; }
.step h3 {
  font-family: var(--display);
  font-weight: 600;
  font-size: 22px;
  letter-spacing: -0.01em;
  padding-inline: 8px;
}
.step p { color: var(--text-dim); padding-inline: 8px; }

/* Step 2: the feed's two reaction buttons, as in VoteControls. */
.react-demo { display: grid; gap: 20px; justify-items: center; }
.react-row { display: flex; gap: 10px; }
.react-btn {
  display: grid;
  place-items: center;
  width: 92px;
  height: 48px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
}
.react-btn svg { width: 22px; height: 22px; fill: none; stroke: var(--text); stroke-width: 1.6; stroke-linejoin: round; }
.react-key { display: grid; gap: 6px; font-size: 14px; }
.react-key div { display: flex; gap: 10px; }
.react-key dt { width: 40px; font-weight: 600; }
.react-key dd { color: var(--text-dim); }

/* Step 3: the identity crest. */
.type-demo { display: grid; justify-items: center; gap: 14px; }
.crest--lg { --size: 140px; }
.crest-name { font-family: var(--display); font-weight: 600; font-size: 18px; }

/* ── Principles ─────────────────────────────────────── */
.principle-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 1px solid var(--line);
}
.principle-list > div {
  padding: 28px 32px 32px 0;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 8px;
  align-content: start;
}
.principle-list > div:nth-child(even) { padding-left: 32px; padding-right: 0; border-left: 1px solid var(--line); }
.principle-list dt { font-family: var(--display); font-weight: 600; font-size: 22px; letter-spacing: -0.01em; }
.principle-list dd { color: var(--text-dim); max-width: 44ch; }
@media (max-width: 720px) {
  .principle-list { grid-template-columns: 1fr; }
  .principle-list > div, .principle-list > div:nth-child(even) { padding: 24px 0; border-left: 0; }
}

/* ── Closing ────────────────────────────────────────── */
.closing {
  display: grid;
  justify-items: center;
  text-align: center;
  gap: 16px;
  padding-block: clamp(96px, 12vw, 168px);
}
.closing h2 { max-width: 16ch; margin-bottom: 0; }
.closing-sub { color: var(--text-dim); font-size: 16px; margin-bottom: 12px; }
.closing .signup { width: 100%; }

/* ── Footer ─────────────────────────────────────────── */
.foot { padding-block: 0 32px; }
.foot-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 24px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--text-faint);
}
.foot .wordmark { color: var(--text); }
