/* ==========================================================================
   Full Thought - single-page site styles
   Order: 1) tokens  2) reset/base  3) layout primitives
          4) sections in scroll order  5) media queries collocated
   The :root token block is the page's single control surface - sections
   consume tokens only, never ad-hoc values.
   ========================================================================== */

/* ===== 1. Design tokens (architecture D1 / D5) ===== */

:root {
  /* Palette - near-monochrome neutrals + one warm accent.
     The two accent tokens are the ONLY chromatic colors on the page.
     Meaning never rides on hue alone (colorblind-safe hard rule). */
  --color-paper: #FAF8F5;          /* page background */
  --color-ink: #1A1D21;            /* body text on paper */
  --color-ink-soft: #4A4F55;       /* secondary text on paper */
  --color-slate: #22262B;          /* dark section background */
  --color-paper-on-slate: #FAF8F5; /* text on slate */
  --color-accent: #8A5A18;         /* accent on light backgrounds */
  --color-accent-bright: #D9A441;  /* accent on dark backgrounds */

  /* Fluid type scale, ~1.25 ratio. Body 16-18px, display ~40-64px. */
  --text-sm: clamp(0.875rem, 0.85rem + 0.125vw, 0.9375rem);
  --text-base: clamp(1rem, 0.956rem + 0.22vw, 1.125rem);
  --text-md: clamp(1.25rem, 1.195rem + 0.28vw, 1.4rem);
  --text-lg: clamp(1.5rem, 1.39rem + 0.55vw, 1.8rem);
  --text-xl: clamp(1.875rem, 1.69rem + 0.94vw, 2.4rem);
  --text-display: clamp(2.5rem, 1.96rem + 2.7vw, 4rem);

  /* Spacing scale, 8px base */
  --space-1: 0.5rem;
  --space-2: 1rem;
  --space-3: 1.5rem;
  --space-4: 2rem;
  --space-5: 3rem;
  --space-6: 4rem;
  --space-7: 6rem;
  --space-8: 8rem;

  /* Font stacks - zero font files by design (ADR-002) */
  --font-display: Georgia, 'Times New Roman', serif;
  --font-body: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

  /* Button hover surface - slate in light mode, dimmed ink in dark mode */
  --color-button-hover: var(--color-slate);

  /* Both schemes supported; UA chrome (scrollbars, form controls) follows */
  color-scheme: light dark;
}

/* Dawn-dark scheme (Josh, 2026-07-28): deep charcoal base, warm off-white
   text, dawn-gold accent. Token remap only - every structural distinction
   (underlines, borders, rules, numbering, position) is scheme-independent,
   so the colorblind-safe guarantees hold identically in both schemes.
   Contrast ratios for every pair in use are recorded in story 10-1. */
@media (prefers-color-scheme: dark) {
  :root {
    --color-paper: #16191D;          /* page background - dawn-cool charcoal */
    --color-ink: #ECE7DE;            /* body text - warm off-white */
    --color-ink-soft: #ADA89F;       /* secondary text */
    --color-slate: #242930;          /* band background - a step above page */
    --color-paper-on-slate: #ECE7DE; /* text on band */
    --color-accent: #D9A441;         /* dawn gold reads on all dark surfaces */
    --color-accent-bright: #D9A441;
    --color-button-hover: #C9C2B6;   /* dimmed ink - hover stays light */
  }
}

/* ===== 2. Reset / base ===== */

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

body {
  margin: 0;
  background: var(--color-paper);
  color: var(--color-ink);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  line-height: 1.15;
  margin: 0 0 var(--space-3);
  font-weight: 400;
}

h1 {
  font-size: var(--text-display);
}

h2 {
  font-size: var(--text-xl);
}

h3 {
  font-size: var(--text-md);
}

p {
  margin: 0 0 var(--space-2);
}

img {
  max-width: 100%;
  display: block;
}

/* Links: underline always present - affordance never rides on hue alone */
a {
  color: var(--color-accent);
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

a:hover {
  text-decoration-thickness: 2px;
}

/* Visible focus for every interactive element (keyboard-first rule) */
:focus-visible {
  outline: 3px solid var(--color-ink);
  outline-offset: 3px;
}

/* Screen-reader-only content */
.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;
}

/* Skip-to-content link: hidden until focused, then prominent */
.skip-link {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link:focus {
  position: fixed;
  top: var(--space-2);
  left: var(--space-2);
  width: auto;
  height: auto;
  padding: var(--space-1) var(--space-2);
  margin: 0;
  overflow: visible;
  clip: auto;
  white-space: normal;
  background: var(--color-ink);
  color: var(--color-paper);
  font-size: var(--text-base);
  font-family: var(--font-body);
  text-decoration: none;
  border-radius: 4px;
  z-index: 1000;
}

/* ===== 3. Layout primitives ===== */

.container {
  max-width: 68rem;
  margin-inline: auto;
  padding-inline: var(--space-3);
}

.container-narrow {
  max-width: 46rem;
  margin-inline: auto;
  padding-inline: var(--space-3);
}

/* Default vertical rhythm for content sections */
main > section {
  padding-block: var(--space-7);
}

/* ===== 4. Sections in scroll order ===== */

/* --- Section 0: Nav --- */

.site-header {
  border-bottom: 1px solid var(--color-ink-soft);
}

.site-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding-block: var(--space-2);
}

.nav-lockup {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  text-decoration: none;
  color: var(--color-ink);
  font-family: var(--font-display);
  font-size: var(--text-md);
}

.nav-lockup img {
  width: 36px;
  height: 36px;
}

.nav-links {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-3);
  list-style: none;
  margin: 0;
  padding: 0;
}

/* Nav links: ink-colored, affordance carried by position in the nav bar
   plus underline on hover/focus - never hue alone */
.nav-links a {
  color: var(--color-ink);
  text-decoration: none;
  font-weight: 500;
  font-size: var(--text-sm);
}

.nav-links a:hover,
.nav-links a:focus-visible {
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

/* CTA echo in the nav: border + shape carry the emphasis */
.nav-links a.nav-cta {
  border: 2px solid var(--color-ink);
  border-radius: 999px;
  padding: 0.35em 0.9em;
}

/* --- Section 1: Hero --- */

.hero {
  position: relative;
  display: grid;
  align-items: end;
  min-height: min(80svh, 52rem);
  padding-block: var(--space-6);
  overflow: hidden;
}

.hero-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* Bias toward the crest-and-figures area so narrow crops keep the subject */
  object-position: 50% 35%;
}

/* Paper-tinted scrim guarantees AA text contrast regardless of image region.
   Headline copy stays inside the near-opaque lower band. */
.hero-scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top,
    rgba(250, 248, 245, 0.97) 0%,
    rgba(250, 248, 245, 0.9) 38%,
    rgba(250, 248, 245, 0) 72%
  );
}

/* Dark scheme: scrim tints toward the dark page so hero text keeps AA */
@media (prefers-color-scheme: dark) {
  .hero-scrim {
    background: linear-gradient(
      to top,
      rgba(22, 25, 29, 0.97) 0%,
      rgba(22, 25, 29, 0.9) 38%,
      rgba(22, 25, 29, 0) 72%
    );
  }
}

.hero-content {
  position: relative;
  width: 100%;
}

.hero-content h1 {
  max-width: 22ch;
  margin-bottom: var(--space-2);
}

.hero-subhead {
  font-size: var(--text-md);
  color: var(--color-ink);
  max-width: 44ch;
  margin-bottom: var(--space-3);
}

/* Primary button: affordance carried by shape, size, and weight -
   ink-on-paper inversion reads identically in grayscale */
.button-primary {
  display: inline-block;
  background: var(--color-ink);
  color: var(--color-paper);
  text-decoration: none;
  font-weight: 600;
  font-size: var(--text-base);
  padding: 0.75em 1.6em;
  border-radius: 999px;
  border: 2px solid var(--color-ink);
}

.button-primary:hover {
  background: var(--color-button-hover);
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

/* --- Section 2: The problem (#why) --- */

/* Inverted band primitive - shared by any slate section */
.band-slate {
  background: var(--color-slate);
  color: var(--color-paper-on-slate);
}

/* Kicker label: identified by position, size, and letterspacing -
   the accent tint is atmosphere, not the signal */
.kicker {
  font-size: var(--text-sm);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 600;
  margin-bottom: var(--space-2);
}

.band-slate .kicker {
  color: var(--color-accent-bright);
}

#why h2 {
  max-width: 24ch;
}

#why p {
  max-width: 60ch;
  color: var(--color-paper-on-slate);
}

/* Closing beat: emphasis carried by face, size, and style - not hue */
.why-close {
  font-family: var(--font-display);
  font-style: italic;
  font-size: var(--text-md);
  margin-top: var(--space-4);
  margin-bottom: 0;
}

/* --- Section 3: The moat (#control) --- */

#control .kicker {
  color: var(--color-accent);
}

#control h2 {
  max-width: 24ch;
  margin-bottom: var(--space-5);
}

.feature {
  border-top: 2px solid var(--color-ink);
  padding-top: var(--space-3);
}

.feature h3 {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin-bottom: var(--space-2);
}

.glyph {
  width: 1.4rem;
  height: 1.4rem;
  flex: none;
}

.feature p {
  max-width: 60ch;
  color: var(--color-ink-soft);
  margin-bottom: 0;
}

/* Tent-pole feature gets the most weight: larger heading, more room */
.feature-lead {
  margin-bottom: var(--space-5);
}

.feature-lead h3 {
  font-size: var(--text-lg);
}

.feature-lead p {
  font-size: var(--text-md);
  max-width: 54ch;
  color: var(--color-ink);
}

.feature-pair {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-5) var(--space-6);
}

@media (min-width: 48rem) {
  .feature-pair {
    grid-template-columns: 1fr 1fr;
  }
}

/* Supporting cluster: visibly subordinate - smaller, softer, no card shape */
.feature-also {
  margin-top: var(--space-5);
  margin-bottom: 0;
  max-width: 64ch;
  font-size: var(--text-sm);
  color: var(--color-ink-soft);
}

/* --- Section 4: Memory that holds (#memory) --- */

#memory .kicker {
  color: var(--color-accent);
}

#memory h2 {
  max-width: 24ch;
}

/* Quiet panel: distinction carried by the rule line + indent, not hue */
.memory-panel {
  border-left: 3px solid var(--color-ink);
  padding-left: var(--space-3);
}

.memory-panel p {
  max-width: 56ch;
}

.memory-panel p:last-child {
  margin-bottom: 0;
}

/* --- Section 5: How it works (#how) --- */

#how .kicker {
  color: var(--color-accent);
}

#how h2 {
  max-width: 30ch;
  margin-bottom: var(--space-5);
}

/* Ordered steps: sequence carried by the list numbering + position */
.how-steps {
  list-style: none;
  counter-reset: step;
  margin: 0 0 var(--space-5);
  padding: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4) var(--space-5);
}

@media (min-width: 48rem) {
  .how-steps {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

.how-steps li {
  counter-increment: step;
  border-top: 2px solid var(--color-ink);
  padding-top: var(--space-2);
}

.how-steps h3::before {
  content: counter(step) ". ";
}

.how-steps p {
  color: var(--color-ink-soft);
  margin-bottom: 0;
}

/* Credibility aside: quiet, bordered, deliberately modest */
.credibility {
  border-left: 3px solid var(--color-ink);
  padding-left: var(--space-3);
  max-width: 60ch;
}

.credibility p {
  margin-bottom: 0;
}

/* --- Section 6: Closing CTA (#access) --- */

.access {
  text-align: center;
}

.access h2 {
  margin-inline: auto;
}

.access-invite {
  max-width: 44ch;
  margin-inline: auto;
  margin-bottom: var(--space-4);
}

/* Primary button inverts on slate: paper fill, ink text - same shape,
   same affordance, identical read in grayscale */
.band-slate .button-primary {
  background: var(--color-paper);
  color: var(--color-ink);
  border-color: var(--color-paper);
}

.band-slate .button-primary:hover {
  background: var(--color-paper-on-slate);
}

.band-slate :focus-visible {
  outline-color: var(--color-paper-on-slate);
}

/* Dark scheme: paper is now dark, so the paper-filled band button would
   vanish against the band. Use the standard light-pill button instead -
   same shape, same affordance, identical grayscale read. */
@media (prefers-color-scheme: dark) {
  .band-slate .button-primary {
    background: var(--color-ink);
    color: var(--color-paper);
    border-color: var(--color-ink);
  }

  .band-slate .button-primary:hover {
    background: var(--color-button-hover);
  }
}

/* --- Section 7: Footer --- */

.site-footer {
  border-top: 1px solid var(--color-ink-soft);
  padding-block: var(--space-4);
  font-size: var(--text-sm);
}

.footer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.footer-name {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-family: var(--font-display);
  font-size: var(--text-base);
  margin: 0;
}

.site-footer a {
  color: var(--color-ink);
}

/* ===== 5. Motion (enhancement-only, double-gated) =====
   Default state everywhere: fully visible. The hidden pre-reveal state
   exists ONLY under html.js AND no-preference - never the inverse. */

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }

  html.js [data-reveal] {
    opacity: 0;
    transform: translateY(1rem);
    transition: opacity 0.5s ease-out, transform 0.5s ease-out;
  }

  html.js [data-reveal].in-view {
    opacity: 1;
    transform: none;
  }
}

/* --- Section 6: Access form (Epic 12 / story 12-2) ---
   Replaces the old mailto CTA with a real waitlist form posting same-origin to
   /signup. Lives in the slate band, so text inherits paper-on-slate; the input
   is a light field for contrast. Status state is carried by a text prefix
   (checkmark / "Error:") AND a left-border position, never by hue alone. */

.access-form {
  max-width: 34rem;
  margin-inline: auto;
  text-align: left;
}

.access-form-label {
  display: block;
  font-weight: 600;
  margin-bottom: var(--space-1);
}

.access-form-controls {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.access-form-input {
  flex: 1 1 16rem;
  min-width: 0;
  font: inherit;
  font-size: var(--text-base);
  padding: 0.6em 0.8em;
  border: 2px solid var(--color-paper-on-slate);
  border-radius: 8px;
  background: var(--color-paper);
  color: var(--color-ink);
}

.access-form-input::placeholder {
  color: var(--color-ink-soft);
  opacity: 1;
}

.access-form-controls .button-primary {
  flex: 0 0 auto;
  cursor: pointer;
  border: 2px solid transparent;
  font: inherit;
  font-weight: 600;
}

.access-form-note {
  font-size: var(--text-sm);
  color: var(--color-paper-on-slate);
  margin-top: var(--space-2);
  margin-bottom: 0;
}

/* Honeypot: pulled off-screen rather than display:none, which many bots skip. */
.access-form-hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* JS status region. Hidden until the script writes an outcome into it. */
.access-form-status {
  margin-top: var(--space-3);
  margin-bottom: 0;
  padding: var(--space-2);
  border-left: 4px solid var(--color-paper-on-slate);
  font-size: var(--text-base);
  line-height: 1.5;
}

.access-form-status[data-state="ok"] {
  border-left-color: var(--color-accent-bright);
  font-weight: 600;
}

.access-form-status[data-state="error"] {
  border-left-color: var(--color-paper-on-slate);
}
