/*
  Gild waitlist. Every value resolves through the elaya landing-page-design skill
  (github.com/elayadesign/ai-design-skills, skills/landing-page-design/SKILL.md):
  B1 type styles, B2 spacing, B3 Tailwind radii, B4 flat backgrounds, B5 hero gradient
  text, B7 motion curve. Don't add values outside these tables.

  One exception, on purpose: the .judge post card is a replica of X's Lights out theme, so it
  uses X's font stack, sizes and colours instead of this system. Everything outside it follows it.

  The look: a gouache night plate. UI is cream paper labels (the plate's own border colour)
  with ink text, and the lantern ember is the one accent. No translucency or blur anywhere.
*/

:root {
  /* B2 spacing */
  --s-25: 2px; --s-50: 4px; --s-75: 8px; --s-100: 12px; --s-200: 16px; --s-300: 24px;
  --s-400: 32px; --s-500: 40px; --s-600: 48px; --s-700: 64px; --s-800: 80px; --s-900: 96px;

  /* B3 radii (Tailwind steps) */
  --r-sm: 4px; --r-md: 6px; --r-lg: 8px; --r-xl: 12px; --r-2xl: 16px; --r-full: 9999px;

  /* B7 motion */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --dur-move: 500ms;
  --dur-fade: 300ms;

  --font: "Geist", ui-sans-serif, system-ui, sans-serif;

  --bg: #131209;                 /* B4 dark list */
  --text: #ffffff;               /* type set directly on the painting */
  --text-2: rgb(255 255 255 / 0.8);
  --text-3: rgb(255 255 255 / 0.6);
  --line: rgb(243 231 218 / 0.22);

  --paper: #f3e7da;              /* sampled from the plate border */
  --ink: #1a1712;
  --ink-2: rgb(26 23 18 / 0.74);
  --ink-3: rgb(26 23 18 / 0.56);
  --paper-edge: rgb(26 23 18 / 0.18);
  --lift: 0 12px 32px rgb(5 7 16 / 0.45), 0 1px 0 rgb(5 7 16 / 0.5);

  --cta-bg: #e9a65a;             /* lantern ember */
  --cta-hover: #f0b673;
  --cta-text: #1a1712;
  --accent: #b9661f;             /* ember, darkened for use on paper */
  --focus: #e9a65a;
  --danger: #a3341f;
  --grad-from: #ffffff;          /* B5 dark */
  --grad-to: #9b9b9b;
  --text-halo: 0 1px 12px rgb(8 10 22 / 0.65);

  color-scheme: dark;
}

/* B1 text styles. Only these. */
.heading-1 { font-size: 3.75rem; line-height: 1; font-weight: 600; }
.heading-3 { font-size: 2.25rem; line-height: 2.5rem; font-weight: 600; }
.title-3 { font-size: 1rem; line-height: 1.5rem; font-weight: 500; }
.body-3 { font-size: 1rem; line-height: 1.5rem; font-weight: 400; }
.body-6 { font-size: 0.875rem; line-height: 1.25rem; font-weight: 400; }
.button-md { font-size: 1rem; line-height: 1.5rem; font-weight: 600; }
.button-sm { font-size: 0.875rem; line-height: 1.25rem; font-weight: 600; }
.caption-4 { font-size: 0.75rem; line-height: 1rem; font-weight: 500; }
.caption-5 { font-size: 0.75rem; line-height: 1rem; font-weight: 400; }

h1, h2, h3 { text-wrap: balance; margin: 0; }
p { text-wrap: pretty; margin: 0; }

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { background: var(--bg); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: inherit; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.skip {
  position: absolute; left: var(--s-200); top: var(--s-200); z-index: 50;
  padding: var(--s-75) var(--s-100); border-radius: var(--r-lg);
  background: var(--cta-bg); color: var(--cta-text); text-decoration: none;
  transform: translateY(-200%);
  transition: transform var(--dur-move) var(--ease);
}
.skip:focus-visible { transform: translateY(0); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Paper: every UI surface is an opaque sheet sitting on the illustration. */
.paper {
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--paper-edge);
  box-shadow: var(--lift);
}

/* ---------- Buttons (B9 states) ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-75);
  border: 0; border-radius: var(--r-lg); cursor: pointer; text-decoration: none;
  font-family: inherit; white-space: nowrap;
  background: var(--cta-bg); color: var(--cta-text);
  padding: var(--s-75) var(--s-100);           /* B2 main buttons */
  transition: background-color var(--dur-fade) var(--ease), transform var(--dur-move) var(--ease), opacity var(--dur-fade) var(--ease);
}
.btn:hover { background: var(--cta-hover); }
.btn:active { transform: scale(0.98); }
.btn[disabled] { cursor: progress; opacity: 0.72; }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn-inset { border-radius: var(--r-sm); }      /* B3: 8 outer minus 4 gap */

/* ---------- Nav (B7: floating, sized to content) ---------- */

.nav-wrap {
  position: fixed; inset: var(--s-200) 0 auto; z-index: 40;
  display: flex; justify-content: center; pointer-events: none;
  padding: 0 var(--s-200);
}
.nav {
  pointer-events: auto;
  display: flex; align-items: center; gap: var(--s-400);
  padding: var(--s-50) var(--s-50) var(--s-50) var(--s-200);
  border-radius: var(--r-lg);
}
.brand {
  display: inline-flex; align-items: center; gap: var(--s-75);
  text-decoration: none; color: var(--ink);
}
.brand svg { width: 20px; height: 20px; }

/* ---------- Hero ---------- */

.hero {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  overflow: hidden;
  isolation: isolate;
}

.hero-art {
  position: absolute; inset: 0; z-index: -1;
  background: var(--bg);
  overflow: hidden;
}

/* The scene is the painting at object-fit: cover size, placed by main.js (sceneBox). Layers fill
   it; the sky and foreground are slightly oversized so parallax never shows an edge. */
.scene { position: absolute; left: 0; top: 0; width: 100%; height: 100%; }
.layer { position: absolute; inset: 0; will-change: transform; }
.layer img { display: block; width: 100%; height: 100%; object-fit: cover; }
.layer-base { width: 100%; height: 100%; object-fit: cover; }
.layer-sky, .layer-fg { opacity: 0; transition: opacity 800ms var(--ease); }
.scene.is-layered .layer-sky, .scene.is-layered .layer-fg { opacity: 1; }
.layer-sky { inset: -6% -6% -24%; }   /* extra below: it rises on scroll */
.layer-sky img { animation: sky-drift 48s cubic-bezier(0.45, 0, 0.55, 1) infinite alternate; }
@keyframes sky-drift { from { transform: translateX(-2.5%); } to { transform: translateX(2.5%); } }
.layer-fg { inset: -2%; }

/* Lantern light: a warm pool around the lantern (64.5% across, 52% down the painting) that
   breathes and flickers. It lives on the foreground layer so it moves with the lantern. */
.lantern-glow {
  position: absolute; left: 64.5%; top: 52%;
  width: 34%; aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(closest-side, rgb(255 190 110 / 0.34), rgb(255 160 70 / 0.12) 45%, rgb(255 150 60 / 0) 100%);
  mix-blend-mode: screen;
  pointer-events: none;
  animation: lantern-flicker 3.7s cubic-bezier(0.45, 0, 0.55, 1) infinite;
}
@keyframes lantern-flicker {
  0%   { opacity: 0.85; transform: translate(-50%, -50%) scale(1); }
  9%   { opacity: 0.7;  transform: translate(-50%, -50%) scale(0.97); }
  17%  { opacity: 0.95; transform: translate(-50%, -50%) scale(1.03); }
  31%  { opacity: 0.78; transform: translate(-50%, -50%) scale(0.99); }
  44%  { opacity: 1;    transform: translate(-50%, -50%) scale(1.04); }
  52%  { opacity: 0.74; transform: translate(-50%, -50%) scale(0.98); }
  68%  { opacity: 0.9;  transform: translate(-50%, -50%) scale(1.02); }
  81%  { opacity: 0.72; transform: translate(-50%, -50%) scale(0.97); }
  100% { opacity: 0.85; transform: translate(-50%, -50%) scale(1); }
}

.hero-inner {
  position: relative;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: var(--s-900) var(--s-700) var(--s-600);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: center;
  gap: var(--s-500);
}

.hero-copy {
  max-width: 600px;
  min-width: 0;
  display: flex; flex-direction: column; align-items: flex-start;
}

.hero-title,
.bye-lead {
  background: linear-gradient(90deg, var(--grad-from), var(--grad-to));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  padding-bottom: var(--s-50); /* keeps descenders inside the clipped gradient */
}

/* Headline experiment: only one h1 renders. */
[data-variant="goodbye"] { display: none; }
[data-hero="goodbye"] [data-variant="baseline"] { display: none; }
[data-hero="goodbye"] [data-variant="goodbye"] { display: block; }

.bye-lead { display: inline-block; }
.bye-slot {
  display: block;
  height: 1.1em;              /* one line of the heading, plus room for descenders */
  overflow: hidden;
  white-space: nowrap;
}
.bye-word {
  display: inline-block;
  color: var(--cta-bg);
  /* The strike: a 4px ember-dark line drawn across the word by growing its width. */
  background: linear-gradient(var(--text), var(--text)) no-repeat 0 58% / 0% 4px;
  transition: background-size 450ms var(--ease);
}
.bye-word.is-struck { background-size: 100% 4px; }
.bye-word.is-out { transform: translateY(-110%); opacity: 0; transition: transform var(--dur-move) var(--ease), opacity var(--dur-move) var(--ease), background-size 450ms var(--ease); }
.bye-word.is-in { transform: translateY(110%); opacity: 0; transition: none; }

.hero-sub {
  max-width: 480px;
  margin-top: var(--s-300);
  color: var(--text-2);
  text-shadow: var(--text-halo);
}

/* ---------- Waitlist form ---------- */

.waitlist { margin-top: var(--s-500); width: 100%; max-width: 480px; }

.field {
  display: flex; align-items: center; gap: var(--s-50);
  padding: var(--s-50);
  border-radius: var(--r-lg);
  transition: border-color var(--dur-fade) var(--ease);
}
.field:focus-within { border-color: var(--accent); }
.field[data-invalid="true"] { border-color: var(--danger); }

.field input {
  flex: 1; min-width: 0; width: 0;
  border: 0; background: transparent; outline: none;
  color: var(--ink); font-family: inherit;
  padding: var(--s-75) var(--s-100);
}
.field input::placeholder { color: var(--ink-3); }

/* Turnstile only takes space when it has to show a challenge. */
.turnstile:empty { display: none; }
.turnstile { margin-top: var(--s-100); }

.form-note { margin-top: var(--s-100); color: var(--text-3); text-shadow: var(--text-halo); }
.form-error {
  margin-top: var(--s-100);
  display: inline-block;
  padding: var(--s-25) var(--s-75);
  border-radius: var(--r-sm);
  background: var(--paper);
  color: var(--danger);
}
.form-error:empty { display: none; }

.waitlist-done {
  margin-top: var(--s-500);
  max-width: 480px;
  display: flex; align-items: flex-start; gap: var(--s-100);
  padding: var(--s-100) var(--s-200);
  border-radius: var(--r-lg);
  color: var(--ink-2);
}
.waitlist-done svg { width: 20px; height: 20px; color: var(--accent); flex: none; margin-top: var(--s-25); }
.waitlist-done strong { color: var(--ink); font-weight: 500; }

/* ---------- The judge: one post at a time, read and then kept or filtered ----------
   The post itself is a replica of X's Lights out theme, so inside .judge the font, sizes and
   colours are X's, not this system's. Everything outside .judge follows the skill. */

.judge {
  --x-bg: #000000;
  --x-line: #2f3336;
  --x-text: #e7e9ea;
  --x-muted: #71767b;
  --x-blue: #1d9bf0;
  --x-red: #f4212e;
  --x-green: #00ba7c;
  --x-raised: #16181c;
  --x-font: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;

  align-self: end;
  width: 400px;
  margin: 0;
  color: var(--x-text);
  font-family: var(--x-font);
  font-size: 15px; line-height: 20px;
  -webkit-font-smoothing: antialiased;
}
.judge svg { fill: currentColor; }   /* the sprite symbols carry no fill of their own */

.judge-card {
  background: var(--x-bg);
  border: 1px solid var(--x-line);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 16px 48px rgb(5 7 16 / 0.55);
}

.judge-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--x-line);
  font-size: 13px; line-height: 16px;
  color: var(--x-muted);
}
.judge-who { display: inline-flex; align-items: center; gap: 8px; color: var(--x-text); font-weight: 700; }
.judge-who svg.mark { width: 16px; height: 16px; }
.judge-state { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.judge-state::before { content: ""; width: 6px; height: 6px; border-radius: 9999px; background: currentColor; }
.judge-state[data-state="reading"] { color: #e9a65a; }
.judge-state[data-state="reading"]::before { animation: judge-pulse 1s cubic-bezier(0.22, 1, 0.36, 1) infinite alternate; }
.judge-state[data-state="filtered"] { color: var(--x-red); }
.judge-state[data-state="kept"] { color: var(--x-green); }
@keyframes judge-pulse { from { opacity: 0.25; } to { opacity: 1; } }
.judge-count { font-variant-numeric: tabular-nums; }

/* The stage animates its height when a post folds: a deliberate exception to "transform and
   opacity only", on one small element, because the fold is the whole point of the demo. */
.judge-stage {
  position: relative;
  overflow: hidden;
  transition: height 500ms cubic-bezier(0.22, 1, 0.36, 1);
}

.tw {
  display: flex; gap: 12px;
  padding: 12px 16px;
  transition: opacity 500ms cubic-bezier(0.22, 1, 0.36, 1), transform 500ms cubic-bezier(0.22, 1, 0.36, 1);
}
.tw.is-enter { opacity: 0; transform: translateY(16px); }
.tw.is-exit { opacity: 0; transform: translateY(-16px); }
.tw-avatar {
  flex: none; width: 40px; height: 40px; border-radius: 9999px;
  display: grid; place-items: center;
  font-size: 15px; font-weight: 700; color: #0f1419;
}
.tw-body { flex: 1; min-width: 0; }
.tw-meta { display: flex; align-items: center; gap: 4px; white-space: nowrap; min-width: 0; }
.tw-name { flex: none; max-width: 45%; font-weight: 700; overflow: hidden; text-overflow: ellipsis; }
.tw-badge { width: 18px; height: 18px; color: var(--x-blue); flex: none; }
.tw-handle { flex: 0 1 auto; min-width: 0; color: var(--x-muted); overflow: hidden; text-overflow: ellipsis; }
.tw-more { margin-left: auto; width: 18px; height: 18px; color: var(--x-muted); flex: none; }
.tw-text { margin-top: 2px; overflow-wrap: anywhere; }
.tw-text span {
  /* Strike: a line grows across each line of the post in reading order. */
  background: linear-gradient(var(--x-red), var(--x-red)) no-repeat 0 60% / 0% 2px;
  transition: background-size 900ms cubic-bezier(0.22, 1, 0.36, 1), color 600ms cubic-bezier(0.22, 1, 0.36, 1);
}
.tw.is-struck .tw-text span { background-size: 100% 2px; color: var(--x-muted); }

.tw-actions {
  display: flex; justify-content: space-between;
  max-width: 425px; margin-top: 12px;
  color: var(--x-muted); font-size: 13px; line-height: 16px;
}
.tw-actions span { display: inline-flex; align-items: center; gap: 4px; }
.tw-actions svg { width: 18px; height: 18px; }
.tw-actions .tw-end { gap: 12px; }

/* Verdict pills in the name row: they take no room until the verdict lands. */
.tw-flag, .tw-kept {
  flex: none;
  display: none;
  align-items: center; gap: 4px;
  margin-left: auto;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 13px; line-height: 16px; font-weight: 600;
}
.tw-flag { background: rgb(244 33 46 / 0.14); color: var(--x-red); }
.tw-kept { background: rgb(0 186 124 / 0.14); color: var(--x-green); }
.tw.is-struck .tw-flag, .tw.is-kept .tw-kept { display: inline-flex; animation: tw-pill-in 500ms cubic-bezier(0.22, 1, 0.36, 1) both; }
@keyframes tw-pill-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.tw-flag + .tw-kept + .tw-more, .tw-kept + .tw-more { margin-left: 4px; }

/* The folded state: shaped like X's own "post from a muted account" placeholder. */
.tw-fold {
  padding: 12px 16px;
  transition: opacity 500ms cubic-bezier(0.22, 1, 0.36, 1), transform 500ms cubic-bezier(0.22, 1, 0.36, 1);
}
.tw-fold.is-enter { opacity: 0; }
.tw-fold.is-exit { opacity: 0; transform: translateY(-16px); }
.tw-fold-box {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px;
  border-radius: 16px;
  background: var(--x-raised);
  color: var(--x-muted);
}
.tw-fold-box b { color: var(--x-text); font-weight: 400; }
.tw-fold-box button {
  border: 0; background: none; padding: 0; cursor: pointer;
  color: var(--x-blue); font: inherit;
}
.tw-fold-box button:hover { text-decoration: underline; }

/* ---------- Footer (below the fold) ---------- */

.footer { border-top: 1px solid var(--line); background: var(--bg); }
.footer-inner {
  padding: var(--s-400) var(--s-700);
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-300);
  color: var(--text-3);
}
.footer nav { display: flex; gap: var(--s-300); }
.footer a { text-decoration: none; color: var(--text-2); transition: color var(--dur-fade) var(--ease); }
.footer a:hover { color: var(--text); }

/* ---------- Plain pages (privacy, 404) ---------- */

.page {
  max-width: 680px; margin: 0 auto;
  padding: calc(var(--s-900) + var(--s-600)) var(--s-300) var(--s-900);
}
.page h1 { margin-bottom: var(--s-300); }
.page p, .page li { color: var(--text-2); }
.page p + p { margin-top: var(--s-200); }
.page ul { padding-left: var(--s-300); margin: var(--s-200) 0; }
.page li + li { margin-top: var(--s-75); }
.page .btn { margin-top: var(--s-500); }

/* ---------- Responsive ---------- */

@media (max-width: 1100px) and (min-width: 901px) {
  .hero-inner { padding-left: var(--s-500); padding-right: var(--s-500); }
  .hero-title.heading-1, .hero-bye.heading-1 { font-size: 3rem; line-height: 1; }
}

/* Desktop: the card floats beside the guardian's lantern, as if it were reading the post
   (main.js places it and adds .is-placed). With no room beside the lantern it stays stacked
   under the form instead. */
@media (min-width: 901px) {
  .hero-inner { position: static; }   /* the placed card positions against the whole hero */
  .judge { justify-self: start; align-self: start; width: 480px; }
  .judge:not(.is-ready) { visibility: hidden; }   /* until main.js has decided where it goes */
  .judge.is-placed { position: absolute; z-index: 1; left: 0; top: 0; will-change: transform; }
  .judge.is-placed .judge-card { box-shadow: 0 16px 48px rgb(5 7 16 / 0.55), 24px 0 64px rgb(233 166 90 / 0.28); }
}

/* Phone and small tablet: copy first, then the art as a framed plate, then the post card
   overlapping the plate's lower edge. */
@media (max-width: 900px) {
  .hero { flex-direction: column; min-height: 0; }
  .hero-inner { display: contents; }
  .hero-copy { order: 1; max-width: none; padding: calc(var(--s-900) + var(--s-200)) var(--s-200) 0; }
  .hero-sub, .form-note { text-shadow: none; }
  .hero-art {
    order: 3;
    position: relative; inset: auto; z-index: 0;
    height: 360px;
    margin: var(--s-500) var(--s-200) 0;
    border-radius: var(--r-xl);
    border: 1px solid var(--line);
  }
  .judge {
    order: 4;
    position: relative; z-index: 1;
    width: auto; max-width: 440px;
    margin: calc(var(--s-800) * -1) var(--s-300) var(--s-400);
    align-self: stretch;
  }
  .footer-inner { flex-direction: column; align-items: flex-start; padding: var(--s-400) var(--s-200); }
}
@media (min-width: 489px) and (max-width: 900px) { .judge { align-self: center; width: 440px; } }

@media (max-width: 640px) {
  .hero-title.heading-1, .hero-bye.heading-1 { font-size: 2.25rem; line-height: 2.5rem; } /* Heading 3 */
  .nav { gap: var(--s-300); }
}

@media (max-width: 360px) {
  .field { flex-direction: column; align-items: stretch; }
  .field .btn { width: 100%; }
}

/* B7: reduced motion swaps movement for a plain opacity change */
@media (prefers-reduced-motion: reduce) {
  .btn, .skip { transition: opacity var(--dur-fade) var(--ease) !important; transform: none !important; }
  .bye-word.is-out, .bye-word.is-in { transform: none; }
  .tw.is-enter, .tw.is-exit, .tw-fold.is-exit { transform: none; }
  .judge-stage { transition: none; }
  .layer-sky img, .lantern-glow { animation: none; }
}
