/* ================================================================
   trialtree.health — "Through the forest"
   Locked palette · Instrument Sans only · daylight → night arc
   ================================================================ */

@font-face {
  font-family: 'Instrument Sans';
  src: url('fonts/instrument-sans-var.woff2') format('woff2');
  font-weight: 400 700;
  font-display: swap;
}

:root {
  /* --- brand greens: v4's 3-tier "matrix" system (landing-v4.html) --- */
  --forest-dark: #1A3D32; /* v4 --forest: buttons, skip-link, dark UI chrome */
  --forest-mid:  #245544; /* v4 --forest-mid: hover states, secondary accents */
  --forest:      #3C7340; /* v4 --forest-bright: numbers, bold emphasis, small badges (hex unchanged) */
  --teal:        #5B9C84; /* unchanged — already = v4's "worth confirming" tier color */
  --mint:        #96C8B4; /* v4's "matrix mint" — replaces the old --sage role */
  --sage:        var(--mint); /* alias: existing --sage usages pick up the mint accent */
  --slate:       #8B97B4; /* v4's --slate (also its "likely not" tier color) */
  --terra:       #E08A82; /* v4's invalid/error salmon — replaces the old terracotta role */

  /* --- gold (--gold-hope/--gold-soft hex already matched v4 exactly) --- */
  --gold-hope: #E9B44C;
  --gold-soft: #F2CE84;
  --gold-deep: #C6892A; /* new — v4's hover/focus gold */

  /* --- neutrals: v4's flat ink-based system (replaces the old cream/forest wash) --- */
  --ink:      #0C0C0C; /* v4 --ink */
  --ink-soft: #2A2A2A; /* v4 --ink-soft — body text */
  --ink-mute: #5C5C5C; /* v4 --ink-mute — secondary text */
  --canvas:   #F2F2F2; /* v4 --canvas — the page background */

  /* --- derived surfaces --- */
  --cream:       #FAF7F1; /* kept for the rare light-text-on-dark-button case */
  --sage-mist:   #EEF4EF; /* v4's on-dark-button mint */
  --sage-veil:   #E4EDE3; /* v4's "why" band mint wash */
  --forest-deep: #1A3D32; /* dark band bg — now = v4 --forest */
  --night:       #0C0C0C; /* now = v4 --ink; used for the how-it-works "prologue" dark card */
  --dusk:        #3F4C68; /* unused by current pages; left as-is */
  --terra-soft:  #F0B4AC; /* unchanged — already matched v4's form-status color */

  /* --- semantic --- */
  --text-heading: var(--ink);
  --text-body:    var(--ink-soft);
  --text-soft:    var(--ink-mute);
  --bg-page:      var(--canvas);
  --bg-calm:      var(--sage-veil);
  --cta-bg:       var(--forest-dark);

  /* --- spacing (playbook scale, exclusively) --- */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px;  --s-4: 16px;  --s-5: 24px;
  --s-6: 32px; --s-7: 48px; --s-8: 64px;  --s-9: 96px;  --s-10: 128px;

  /* --- type: Instrument Sans only --- */
  --font-body: 'Instrument Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --t-sm:   0.8125rem;
  --t-base: 1.125rem;
  --t-md:   1.3125rem;
  --t-lg:   1.5rem;
  --t-xl:   clamp(2rem, 3.4vw, 2.5rem);
  --t-hero: clamp(2.375rem, 5vw, 3.5rem);

  /* --- shape & depth: v4's chunkier, flatter radius language --- */
  --r-md: 16px;
  --r-lg: 24px;
  --r-pill: 999px;
  --shadow-leaf: 0 2px 8px rgb(60 115 64 / 0.06);
  --shadow-lift: 0 10px 28px rgb(60 115 64 / 0.11);

  /* --- motion (already matched v4's --ease exactly) --- */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--t-base);
  line-height: 1.7;
  color: var(--text-body);
  background: var(--bg-page);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 {
  font-family: var(--font-body);
  color: var(--text-heading);
  margin: 0;
}

p { margin: 0; }
a { color: var(--forest); }
img, svg, canvas { max-width: 100%; }

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

.skip-link {
  position: absolute;
  left: var(--s-4);
  top: calc(-1 * var(--s-9));
  z-index: 100;
  padding: var(--s-3) var(--s-5);
  background: var(--forest-dark);
  color: var(--cream);
  border-radius: var(--r-md);
  text-decoration: none;
  transition: top 180ms var(--ease-out);
}
.skip-link:focus-visible { top: var(--s-4); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: var(--s-3) var(--s-6);
  border: 0;
  border-radius: var(--r-pill);
  font-family: var(--font-body);
  /* 19px at weight 700 = "large bold" text, so white-on-teal (3.21:1) clears WCAG AA large (3:1) */
  font-size: 1.1875rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: transform 180ms var(--ease-out), box-shadow 180ms var(--ease-out), background-color 180ms var(--ease-out);
}
.btn-primary {
  background: var(--cta-bg);
  color: #fff;
}
.btn-primary:hover { background: var(--forest-mid); }
.btn-primary:active { transform: scale(0.98); }
/* keep header CTA at the same large-bold size so it clears AA large like the other buttons */
.btn-small { font-size: 1.1875rem; min-height: 44px; padding: var(--s-2) var(--s-5); background: var(--cta-bg); color: #fff; }
.btn-small:hover { background: var(--forest-mid); }
/* golden-hour halo: hope surrounds action */
.btn-gold-halo:hover,
.btn-gold-halo:focus-visible {
  box-shadow: 0 0 0 4px rgb(233 180 76 / 0.35), 0 8px 22px rgb(0 0 0 / 0.25);
}

/* ---------- header (matches landing's flat, non-sticky .logo-bar) ---------- */
.site-head {
  position: relative;
  z-index: 5;
  background: transparent;
  border-bottom: 0;
}
.site-head-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 16px var(--s-5) 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-5);
}
.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 1.05rem;
  font-weight: 580;
  letter-spacing: -0.01em;
  color: var(--text-heading);
  text-decoration: none;
}
.wordmark-dot { color: var(--forest-mid); font-weight: 450; }
.wordmark-leaf { flex: none; transform: rotate(-45deg); }

/* head-nav (unused now that we simplified to logo+button) — kept for future */
.head-nav { display: flex; align-items: center; gap: 22px; }
.head-link { color: var(--ink-mute); text-decoration: none; font-weight: 500; font-size: 0.95rem; }
.head-link:hover { color: var(--ink); }
@media (max-width: 560px) { .head-link { display: none; } }

/* .btn-small — flat, dark-forest pill matching landing */
.btn.btn-small {
  min-height: 40px;
  padding: 0 18px;
  font-size: 0.92rem;
  font-weight: 580;
  background: var(--forest-dark);
  color: #f5f7f5;
  border-radius: 999px;
  box-shadow: none;
}
.btn.btn-small:hover { background: var(--forest-mid); transform: none; box-shadow: none; }

/* ---------- hero — dusk ---------- */
.hero {
  position: relative;
  overflow: hidden;
  /* symmetric + gentle so there is no lighter/darker side, left or right */
  background: radial-gradient(150% 130% at 50% 12%, #414d69, var(--dusk) 45%, #37415a);
}
.hero :focus-visible { outline-color: var(--gold-hope); }
.hero-inner {
  position: relative;
  z-index: 1;
  max-width: 1120px;
  margin: 0 auto;
  padding: var(--s-9) var(--s-5) var(--s-10);
  /* let the cursor reach the tree behind; the copy re-enables events on itself */
  pointer-events: none;
}
.hero-copy { position: relative; max-width: 33rem; pointer-events: auto; }
.hero-copy h1 {
  font-size: var(--t-hero);
  font-weight: 640;
  line-height: 1.08;
  letter-spacing: -0.022em;
  max-width: 15ch;
  color: var(--cream);
}
.hero-sub {
  margin-top: var(--s-5);
  font-size: var(--t-md);
  line-height: 1.65;
  max-width: 50ch;
  color: rgb(250 247 241 / 0.92);
}
.hero-actions {
  margin-top: var(--s-6);
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-4);
}
.hero-proof {
  margin-top: var(--s-5);
  font-size: 0.9375rem;
  font-weight: 500;
  color: rgb(250 247 241 / 0.9);
  max-width: 44ch;
}
.hero-note {
  margin-top: var(--s-3);
  font-size: var(--t-sm);
  color: rgb(250 247 241 / 0.7);
  letter-spacing: 0.01em;
}

/* the living forest: a banner behind the copy, capped so it never stretches on wide screens */
.hero-forest {
  position: absolute;
  top: 0; bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 1440px;
  z-index: 0;
}
/* past the cap, fade the scene edges into the surrounding dusk (no hard seam) */
@media (min-width: 1441px) {
  .hero-forest {
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 7%, #000 93%, transparent);
    mask-image: linear-gradient(90deg, transparent, #000 7%, #000 93%, transparent);
  }
}
.hero-forest canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
.forest-gl {
  opacity: 0;
  transition: opacity 900ms var(--ease-out);
}
.forest-gl.is-live { opacity: 1; }

/* Bayer dissolve — the one section transition on the page */
.dither-dissolve {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 72px;
  pointer-events: none;
  background-repeat: repeat-x;
  background-size: 32px 72px;
  image-rendering: pixelated;
}

/* ---------- sections ---------- */
.section { position: relative; padding: var(--s-9) var(--s-5); scroll-margin-top: 80px; }
@media (min-width: 900px) { .section { padding: var(--s-10) var(--s-5); } }
.section-inner { position: relative; max-width: 1120px; margin: 0 auto; }
.section-narrow { max-width: 720px; text-align: center; }
.section-title {
  font-size: var(--t-xl);
  font-weight: 620;
  line-height: 1.15;
  letter-spacing: -0.015em;
}
.section-calm { background: var(--bg-calm); }
.prose-lead {
  margin-top: var(--s-5);
  font-size: var(--t-md);
  line-height: 1.7;
  max-width: 62ch;
  margin-left: auto;
  margin-right: auto;
}

/* ---------- long-form content pages (trust, privacy, future docs) ---------- */
.doc { max-width: 68ch; margin: 0 auto; text-align: left; }
.doc > * + * { margin-top: var(--s-5); }
.doc h2 { margin-top: var(--s-8); font-size: var(--t-lg); font-weight: 600; line-height: 1.25; letter-spacing: -0.01em; color: var(--text-heading); }
.doc h3 { margin-top: var(--s-6); font-size: 1.25rem; font-weight: 600; color: var(--text-body); }
.doc p, .doc li { font-size: var(--t-base); line-height: 1.7; color: var(--text-body); }
.doc a { color: var(--forest); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.doc a:hover { text-decoration-color: var(--forest-mid); }
.doc ul { padding-left: var(--s-5); list-style: none; }
.doc ul li { position: relative; }
.doc ul li::before { content: ""; position: absolute; left: calc(-1 * var(--s-5)); top: 0.62em; width: 6px; height: 6px; border-radius: 50%; background: var(--sage); }
.doc li + li { margin-top: var(--s-3); }
.doc strong { font-weight: 640; color: var(--forest); }
.doc-lead { font-size: var(--t-md); line-height: 1.65; }
.doc-meta { font-size: var(--t-sm); color: var(--text-soft); }
.doc-note {
  margin-top: var(--s-7);
  padding: var(--s-5);
  background: var(--sage-veil);
  border-radius: var(--r-lg);
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--text-body);
}
.doc-note strong { color: var(--forest); }

/* the abstract character-density field at the section's edges */
.density-field {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* ---------- how-it-works teaser (landing) ---------- */
.how-steps {
  list-style: none;
  margin: var(--s-7) 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr));
  gap: var(--s-5);
  text-align: left;
}
.how-steps li { display: flex; flex-direction: column; gap: var(--s-3); }
.how-num {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: var(--r-pill);
  background: var(--sage-veil);
  color: var(--forest);
  font-weight: 680;
  font-size: 1rem;
}
.how-steps p { font-size: 1rem; line-height: 1.55; color: var(--text-body); }
.how-steps strong { color: var(--forest); font-weight: 640; }
.how-more { margin-top: var(--s-7); }
.how-more a {
  color: var(--forest);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-thickness: 1.5px;
  text-decoration-color: var(--sage);
}
.how-more a:hover { text-decoration-color: var(--terra); }

/* ---------- the one verified stat ---------- */
.stat { margin-top: var(--s-8); }
.stat-number {
  font-size: clamp(3.5rem, 7vw, 5rem);
  font-weight: 660;
  line-height: 1;
  letter-spacing: -0.025em;
  color: var(--forest);
}
.stat-pct { font-size: 0.6em; font-weight: 600; }
.stat-context {
  margin-top: var(--s-3);
  font-size: var(--t-md);
  color: var(--text-body);
}
.stat-source {
  margin-top: var(--s-2);
  font-size: var(--t-sm);
  /* 0.95 alpha slate on sage-mist = 4.8:1 — AA at this small size (full --text-soft would fail) */
  color: rgb(84 100 135 / 0.95);
}

/* ---------- final CTA — golden hour ---------- */
.section-close {
  overflow: hidden;
  background: var(--forest-deep);
}
.gold-light {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  image-rendering: pixelated;
  animation: gold-breathe 10s ease-in-out infinite alternate;
}
@keyframes gold-breathe {
  from { opacity: 0.55; }
  to   { opacity: 0.95; }
}
.close-inner { position: relative; z-index: 1; }
/* CTA scene layers: flowers behind the copy, birds in front (both non-interactive) */
.cta-flora, .cta-birds {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.cta-flora { z-index: 0; }
.cta-birds { z-index: 2; }
.landed-leaf {
  display: block;
  margin: 0 auto var(--s-4);
  width: 76px;
  height: 64px;
}
.section-close .section-title { color: var(--cream); }
.section-close .prose-lead { color: rgb(250 247 241 / 0.92); }

/* ---------- waitlist form ---------- */
.waitlist { margin-top: var(--s-7); }
.waitlist-fields {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--s-4);
  margin-bottom: var(--s-5);
}
.field {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--s-2);
  text-align: left;
}
.field label {
  font-size: var(--t-sm);
  font-weight: 560;
  color: var(--gold-soft);
  letter-spacing: 0.01em;
}
.label-soft { font-weight: 420; color: rgb(250 247 241 / 0.75); }
.field input,
.field select {
  min-height: 48px;
  min-width: 260px;
  padding: var(--s-3) var(--s-4);
  border: 1.5px solid rgb(250 247 241 / 0.35);
  border-radius: var(--r-md);
  background: rgb(250 247 241 / 0.97);
  color: var(--slate);
  font-family: var(--font-body);
  font-size: var(--t-base);
  transition: border-color 180ms var(--ease-out), box-shadow 180ms var(--ease-out);
}
.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--gold-hope);
  box-shadow: 0 0 0 3px rgb(233 180 76 / 0.3);
}
.field input[aria-invalid="true"] { border-color: var(--terra-soft); box-shadow: 0 0 0 3px rgb(240 180 172 / 0.25); }
/* honeypot: invisible to people, present for bots */
.field-trap {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.form-status {
  min-height: 1.5em;
  margin-top: var(--s-4);
  font-size: var(--t-base);
  color: var(--terra-soft);
}
.form-status a { color: var(--gold-soft); }
.privacy-line {
  margin-top: var(--s-3);
  font-size: var(--t-sm);
  color: rgb(250 247 241 / 0.85);
}
.waitlist-done {
  margin-top: var(--s-7);
  font-size: var(--t-md);
  color: var(--cream);
}

/* ---------- footer — flat, on the page canvas (matches v4's .foot) ---------- */
.site-foot {
  background: transparent;
  color: var(--ink-mute);
}
.foot-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: var(--s-8) var(--s-5) var(--s-7);
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-3) var(--s-6);
  align-items: baseline;
  justify-content: space-between;
  text-align: left;
}
.foot-hand { font-size: var(--t-base); color: var(--ink-mute); }
.foot-hand a { color: var(--forest-mid); text-decoration: none; }
.foot-hand a:hover { color: var(--text-heading); }
.foot-nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-3) var(--s-5);
}
.foot-nav a {
  color: var(--ink-mute);
  text-decoration: none;
  transition: color 180ms var(--ease-out);
}
.foot-nav a:hover { color: var(--text-heading); }
.foot-small {
  width: 100%;
  font-size: var(--t-sm);
  color: rgb(12 12 12 / 0.42);
  max-width: 62ch;
  margin: 0;
}
.foot-small + .foot-small { margin-top: var(--s-2); }

/* fireflies came out at night — drifting on slow loops, glowing in and out */
.firefly {
  position: absolute;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--gold-soft);
  box-shadow: 0 0 6px 2px rgb(233 180 76 / 0.6), 0 0 13px 5px rgb(233 180 76 / 0.25);
  animation: firefly-drift 15s ease-in-out infinite alternate,
             firefly-glow 4s ease-in-out infinite;
}
.firefly:nth-child(1) { left: 10%; top: 34%; animation-duration: 15s, 3.6s; }
.firefly:nth-child(2) { left: 30%; top: 62%; animation-duration: 19s, 4.7s; animation-delay: -5s, -1.2s; }
.firefly:nth-child(3) { left: 54%; top: 26%; animation-duration: 13s, 3.1s; animation-delay: -8s, -0.6s; }
.firefly:nth-child(4) { left: 74%; top: 58%; animation-duration: 21s, 5.3s; animation-delay: -3s, -2.1s; }
.firefly:nth-child(5) { left: 88%; top: 32%; animation-duration: 17s, 4.2s; animation-delay: -11s, -3s; }
@keyframes firefly-drift {
  0%   { transform: translate(0, 0); }
  25%  { transform: translate(20px, -14px); }
  50%  { transform: translate(34px, 8px); }
  75%  { transform: translate(12px, 20px); }
  100% { transform: translate(-8px, 6px); }
}
@keyframes firefly-glow {
  0%, 100% { opacity: 0.2;  box-shadow: 0 0 4px 1px rgb(233 180 76 / 0.4); }
  50%      { opacity: 0.9;  box-shadow: 0 0 8px 3px rgb(233 180 76 / 0.8), 0 0 17px 6px rgb(233 180 76 / 0.3); }
}

/* ---------- reveals ---------- */
.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 650ms var(--ease-out), transform 650ms var(--ease-out);
  transition-delay: var(--reveal-delay, 0ms);
}
.reveal.in-view { opacity: 1; transform: none; }
.stat.reveal { --reveal-delay: 180ms; }

/* no-JS: never hide content behind a reveal that can't fire */
@media (scripting: none) {
  .reveal { opacity: 1; transform: none; }
}

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .hero-inner { padding: var(--s-8) var(--s-5) var(--s-6); }
  .hero-inner::before { display: none; }
  .hero-copy { max-width: none; }
  .hero-copy h1 { max-width: none; }
  /* on narrow screens the forest becomes a landscape band below the copy
     (relative, not static, so its absolutely-positioned canvases stay inside it) */
  .hero-forest {
    position: relative;
    left: auto;
    transform: none;
    max-width: none;
    z-index: auto;
    width: 100%;
    aspect-ratio: 16 / 11;
    margin-top: var(--s-6);
  }
}
@media (max-width: 640px) {
  .hero-actions .btn { width: 100%; }
  .field { width: 100%; }
  .field input, .field select { width: 100%; min-width: 0; }
  .waitlist-fields { flex-direction: column; }
}

/* ---------- reduced motion: everything settles, nothing is lost ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .reveal { opacity: 1; transform: none; }
  .btn-primary:hover { transform: none; }
  .gold-light { opacity: 0.75; }
  .firefly { opacity: 0.3; }
}
