:root {
  /* Quiet botanical ledger — paper canvas tokens */
  --canvas: #F7F4EF;
  --surface: #FFFFFF;
  --surface-raised: #EEE9E0;
  --ink: #1C1A17;
  --ink-2: #5A5449;
  --ink-3: #9A9188;
  --rule: #DDD9D0;
  --stem: #3D7A4A;
  --stem-deep: #2F5F3A;
  --stem-pale: #ECF4EE;
  --clay: #8B6B4A;
  --ochre: #C4963A;
  --cta-ink: #F4FBF5;

  /* Aliases for existing class references */
  --bg: var(--canvas);
  --bg-lift: var(--surface-raised);
  --ink-soft: var(--ink-2);
  --muted: var(--ink-3);
  --stem-bright: #4e9a5c;
  --stem-mist: var(--stem-pale);
  --line: color-mix(in srgb, var(--ink) 12%, transparent);
  --line-strong: color-mix(in srgb, var(--ink) 22%, transparent);
  --danger: #A63D32;
  --ok: #2F6B45;

  /* System font stack, same as savoir-ranger-bienetre (Tailwind v4 defaults).
     No web font: nothing blocks first render. --font-display keeps its own
     token so headings can carry their own weight and tracking. */
  --font-display: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
  --font: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --space: clamp(1.25rem, 4.5vw, 3rem);
  --measure: 38rem;
  --radius-card: 14px;
  --radius-sheet: 20px;
  --radius-input: 10px;
  --radius-cta: 8px;

  --z-stage: 0;
  --z-shell: 1;
  --z-sticky: 10;

  color-scheme: light;
}

/*
 * Dark tokens: manual toggle sets data-theme on <html>.
 * Without a stored choice, the head script mirrors prefers-color-scheme.
 * :root:not([data-theme]) keeps the system path working if JS is off.
 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --canvas: #131210;
    --surface: #1e1d1a;
    --surface-raised: #272420;
    --ink: #f0ede7;
    --ink-2: #b8b0a5;
    --ink-3: #6e6760;
    --rule: #2e2c28;
    --stem: #6fbf7e;
    --stem-deep: #4a9a5a;
    --stem-pale: #1a2e1d;
    --cta-ink: #0d1a10;

    --line: color-mix(in srgb, var(--ink) 10%, transparent);
    --line-strong: color-mix(in srgb, var(--ink) 18%, transparent);
    --ok: #6fbf7e;

    color-scheme: dark;
  }
}

:root[data-theme='dark'] {
  --canvas: #131210;
  --surface: #1e1d1a;
  --surface-raised: #272420;
  --ink: #f0ede7;
  --ink-2: #b8b0a5;
  --ink-3: #6e6760;
  --rule: #2e2c28;
  --stem: #6fbf7e;
  --stem-deep: #4a9a5a;
  --stem-pale: #1a2e1d;
  --cta-ink: #0d1a10;

  --line: color-mix(in srgb, var(--ink) 10%, transparent);
  --line-strong: color-mix(in srgb, var(--ink) 18%, transparent);
  --ok: #6fbf7e;

  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--canvas);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Stage — warm paper, no green fog */
.stage {
  position: fixed;
  inset: 0;
  z-index: var(--z-stage);
  pointer-events: none;
  overflow: hidden;
  background: var(--canvas);
}

.stage-field {
  position: absolute;
  inset: 0;
  background: radial-gradient(
    ellipse 55% 45% at 105% 8%,
    color-mix(in srgb, var(--stem-pale) 70%, transparent) 0%,
    transparent 65%
  );
}

/* Botanical stem glyph — quiet editorial motif, not a dominant watermark */
.stage-glyph {
  position: absolute;
  top: 50%;
  right: max(-4%, 0%);
  width: min(38vw, 400px);
  height: auto;
  color: var(--stem);
  opacity: 0.055;
  transform: translateY(-50%);
}

.stage-grain {
  position: absolute;
  inset: 0;
  opacity: 0.022;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.shell {
  position: relative;
  z-index: var(--z-shell);
  min-height: 100svh;
  display: flex;
  flex-direction: column;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem var(--space) 0.5rem;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  line-height: 0;
  text-decoration: none;
  border-radius: 0.5rem;
}

.brand-mark img {
  display: block;
  width: 2rem;
  height: 2rem;
}

.brand-mark:focus-visible {
  outline: 2px solid var(--stem);
  outline-offset: 4px;
}

/* Language toggle styling lives in LanguageSwitcher.astro (scoped). */

/* Hero */
.hero {
  flex: 1;
  display: grid;
  align-content: center;
  gap: clamp(1.5rem, 3.5vw, 2rem);
  padding: clamp(1.25rem, 3.5vw, 2.5rem) var(--space) 1.5rem;
  max-width: var(--measure);
}

.hero-copy {
  animation: settle 900ms var(--ease-out) both;
}

/* Brand wordmark — display stack, hero-level */
.brand {
  margin: 0 0 0.6rem;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(3.75rem, 13vw, 6.5rem);
  line-height: 0.92;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-wrap: balance;
  animation: brand-in 1100ms var(--ease-out) both;
}

.headline {
  margin: 0 0 0.7rem;
  font-family: var(--font);
  font-weight: 500;
  font-size: clamp(1.1rem, 2.8vw, 1.4rem);
  line-height: 1.35;
  letter-spacing: -0.015em;
  color: var(--ink-2);
  max-width: 28ch;
  text-wrap: balance;
}

.sub {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 400;
  color: var(--ink-3);
  max-width: 40ch;
  text-wrap: pretty;
}

/* Form — white surface card (raised-paper panel) */
.form {
  display: grid;
  gap: 1rem;
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sheet);
  max-width: 26rem;
  animation: settle 1000ms var(--ease-out) 120ms both;
}

.field {
  display: grid;
  gap: 0.35rem;
}

/* Labels: monospace uppercase — ledger column header feel */
.field label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* Inputs: surface-raised fill + rule border — raised paper field */
.field input {
  width: 100%;
  border: 1px solid var(--rule);
  border-radius: var(--radius-input);
  padding: 0.7rem 0.85rem;
  font-family: var(--font);
  font-size: 1rem;
  color: var(--ink);
  background: var(--surface-raised);
  transition:
    border-color 180ms var(--ease-out),
    box-shadow 180ms var(--ease-out),
    background 180ms var(--ease-out);
}

.field input::placeholder {
  color: var(--ink-3);
}

.field input:hover {
  border-color: color-mix(in srgb, var(--ink-3) 80%, transparent);
}

.field input:focus {
  outline: none;
  border-color: var(--stem);
  background: var(--surface);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--stem) 15%, transparent);
}

.hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.consent {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.75rem;
  align-items: start;
  font-size: 0.87rem;
  color: var(--ink-3);
  cursor: pointer;
}

.consent input {
  width: 1.1rem;
  height: 1.1rem;
  margin-top: 0.15rem;
  accent-color: var(--stem);
  cursor: pointer;
}

/* CTA — Stem solid, calm hover (slight deepen) */
.cta {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: start;
  min-height: 3rem;
  min-width: 12rem;
  border: 0;
  border-radius: var(--radius-cta);
  padding: 0.875rem 1.5rem;
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--cta-ink);
  background: var(--stem);
  cursor: pointer;
  transition:
    background 180ms var(--ease-out),
    transform 180ms var(--ease-out);
}

.cta:hover:not(:disabled) {
  background: var(--stem-deep);
  transform: translateY(-1px);
}

.cta:active:not(:disabled) {
  transform: translateY(0);
  background: var(--stem-deep);
}

.cta:focus-visible {
  outline: 2px solid var(--stem);
  outline-offset: 3px;
}

.cta:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

.cta.is-loading .cta-label {
  opacity: 0;
}

.cta-spinner {
  position: absolute;
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--cta-ink) 30%, transparent);
  border-top-color: var(--cta-ink);
  opacity: 0;
}

.cta.is-loading .cta-spinner {
  opacity: 1;
  animation: spin 700ms linear infinite;
}

.form-status {
  margin: 0;
  min-height: 1.25rem;
  font-size: 0.87rem;
  font-weight: 500;
}

.form-status.is-error {
  color: var(--danger);
}

.form-status.is-ok {
  color: var(--ok);
}

/* Secondary link — X follow */
.secondary {
  margin: 0;
  animation: settle 1000ms var(--ease-out) 180ms both;
}

.x-link {
  color: var(--ink-3);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 0.1rem;
  transition:
    color 180ms var(--ease-out),
    border-color 180ms var(--ease-out);
}

.x-link:hover {
  color: var(--clay);
  border-color: var(--clay);
}

.x-link:focus-visible {
  outline: 2px solid var(--stem);
  outline-offset: 4px;
}

/* Below-fold: 3 belief points as ruled ledger list */
.beliefs {
  padding: clamp(2rem, 5vw, 3.5rem) var(--space) 0;
  max-width: var(--measure);
  animation: settle 1000ms var(--ease-out) 250ms both;
}

.beliefs-label {
  display: block;
  margin-bottom: 1.25rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.belief-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--rule);
}

.belief-item {
  padding: 1.2rem 0;
  border-bottom: 1px solid var(--rule);
}

.belief-item-label {
  display: block;
  margin-bottom: 0.3rem;
  font-family: var(--font-display);
  font-size: clamp(1rem, 2.4vw, 1.2rem);
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
}

.belief-item-body {
  margin: 0;
  font-size: 0.93rem;
  color: var(--ink-3);
  max-width: 46ch;
  text-wrap: pretty;
}

/* Footer */
.foot {
  padding: 2rem var(--space) 1.75rem;
  margin-top: 1.5rem;
  animation: settle 1000ms var(--ease-out) 280ms both;
}

.foot p {
  margin: 0;
  max-width: 36rem;
  font-size: 0.85rem;
  color: var(--ink-3);
}

/* Thank-you page */
.thanks {
  flex: 1;
  display: grid;
  align-content: center;
  gap: 1.1rem;
  padding: clamp(1.5rem, 4vw, 3rem) var(--space) 3rem;
  max-width: 34rem;
  animation: settle 900ms var(--ease-out) both;
}

.thanks-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2rem, 6.5vw, 3.25rem);
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-wrap: balance;
}

.thanks-name {
  color: var(--stem);
}

.thanks-sub {
  margin: 0;
  font-size: 1.05rem;
  color: var(--ink-3);
  max-width: 36ch;
  text-wrap: pretty;
}

.thanks-link {
  justify-self: start;
  margin-top: 0.35rem;
  color: var(--ink-2);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  text-decoration: none;
  border-bottom: 1.5px solid var(--stem);
  padding-bottom: 0.15rem;
  transition:
    color 180ms var(--ease-out),
    border-color 180ms var(--ease-out);
}

.thanks-link:hover {
  color: var(--ink);
  border-color: var(--stem-deep);
}

.thanks-link:focus-visible {
  outline: 2px solid var(--stem);
  outline-offset: 4px;
}

/* Animations */
@keyframes brand-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes settle {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 720px) {
  .stage-glyph {
    right: -12%;
    top: 10%;
    width: min(55vw, 260px);
    transform: none;
    opacity: 0.038;
  }

  .form {
    padding: 1.25rem;
    border-radius: var(--radius-card);
  }
}

@media (min-width: 960px) {
  .hero {
    max-width: 40rem;
    padding-top: 2rem;
  }

  .stage-glyph {
    right: 4%;
    width: min(36vw, 460px);
    opacity: 0.06;
  }
}

@media (prefers-reduced-motion: reduce) {
  .stage-glyph,
  .cta-spinner,
  .brand,
  .hero-copy,
  .form,
  .secondary,
  .foot,
  .beliefs,
  .thanks {
    animation: none !important;
  }

  .cta:hover:not(:disabled) {
    transform: none;
  }
}
