/* ============================================================
   HOMEBOUND — main.css
   Design tokens, base styles, type scale, layout primitives
   ============================================================ */

:root {
  /* Palette */
  --paper: #F2F1ED;
  --ink: #1A1917;
  --concrete: #C6C4BD;
  --stamp-blue: #2B4FA0;
  --stamp-green: #3A6B35;
  --stamp-crimson: #8E2F27;
  /* #FF0000 is RESERVED for .mj-placeholder. Never use it elsewhere. */

  /* Type families */
  --font-display: 'Archivo Black', sans-serif;
  --font-editorial: 'Newsreader', serif;
  --font-ui: 'Instrument Sans', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;

  /* Fluid type scale */
  --text-xs: clamp(0.6875rem, 0.65rem + 0.15vw, 0.75rem);   /* mono captions */
  --text-sm: clamp(0.8125rem, 0.78rem + 0.2vw, 0.875rem);   /* mono data, small UI */
  --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);     /* UI body */
  --text-editorial: clamp(1.125rem, 1.05rem + 0.4vw, 1.375rem); /* Newsreader body */
  --text-lg: clamp(1.375rem, 1.2rem + 0.8vw, 1.875rem);     /* deks, sub-heads */
  --text-xl: clamp(1.75rem, 1.4rem + 1.8vw, 3rem);          /* section titles */
  --text-2xl: clamp(2.5rem, 1.8rem + 3.5vw, 5rem);          /* page titles */
  --text-hero: clamp(3rem, 10vw, 9rem);                     /* animal names */

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 1rem;
  --space-4: 1.5rem;
  --space-5: 2.5rem;
  --space-6: 4rem;
  --space-7: clamp(4rem, 10vw, 8rem);   /* section rhythm */

  /* Misc */
  --hairline: 1px solid var(--ink);
  --hairline-soft: 1px solid var(--concrete);
  --gutter: clamp(1rem, 4vw, 2.5rem);
  --max-content: 72rem;
  --max-prose: 42rem;
}

/* ---------- Reset / base ---------- */

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

html {
  scroll-behavior: smooth;
}

html.lenis, html.lenis body {
  height: auto;
}
.lenis.lenis-smooth {
  scroll-behavior: auto !important;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: var(--text-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

img, video {
  display: block;
  max-width: 100%;
  height: auto;
}

a {
  color: var(--stamp-blue);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

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

::selection {
  background: var(--ink);
  color: var(--paper);
}

/* ---------- Typography ---------- */

h1, h2, h3, .display {
  font-family: var(--font-display);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: -0.02em;
  line-height: 0.95;
}

h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }

.hero-name {
  font-size: var(--text-hero);
  letter-spacing: -0.03em;
}

.editorial {
  font-family: var(--font-editorial);
  font-size: var(--text-editorial);
  line-height: 1.65;
  font-weight: 400;
  max-width: var(--max-prose);
}
.editorial p + p {
  margin-top: 1em;
}

.mono {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.6;
}

.mono-caption {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.dek {
  font-family: var(--font-editorial);
  font-size: var(--text-lg);
  font-style: italic;
  line-height: 1.4;
  font-weight: 400;
}

/* ---------- Layout primitives ---------- */

.container {
  width: 100%;
  max-width: var(--max-content);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.section {
  padding-block: var(--space-7);
}

.rule {
  border: 0;
  border-top: var(--hairline);
}
.rule--soft {
  border-top: var(--hairline-soft);
}

/* Section-opener rule: standard breathing room below */
.rule--space {
  margin-bottom: var(--space-5);
}

/* Eyebrow: small blue mono label above a section */
.eyebrow {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--stamp-blue);
  margin-bottom: var(--space-2);
}

/* Draw-in rule: JS reveals scale it from 0 → 1 */
.rule--draw {
  transform-origin: left center;
}

/* Dark inversion — story pages only */
.inverted {
  background: var(--ink);
  color: var(--paper);
}
.inverted ::selection {
  background: var(--paper);
  color: var(--ink);
}

/* ---------- Media wrapper ----------
   Locks aspect ratio for placeholder AND the real asset that
   replaces it. Set style="--ratio: 16/9" (or 4/5, 3/2, 1/1). */
.media {
  position: relative;
  overflow: hidden;
  aspect-ratio: var(--ratio, 16/9);
  width: 100%;
}
.media > img,
.media > video,
.media > .mj-placeholder {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ---------- Utilities ---------- */

.u-mt-2 { margin-top: var(--space-2); }
.u-mt-4 { margin-top: var(--space-4); }

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

/* ---------- Reveal states (JS sets finals; CSS holds initial) ---------- */
/* Applied only when JS is running — html.js gate avoids invisible content
   if scripts fail. */
html.js .reveal-media {
  clip-path: inset(0 0 100% 0);
}
html.js .reveal-fade {
  opacity: 0;
  transform: translateY(24px);
}
html.js .reveal-rule {
  transform: scaleX(0);
  transform-origin: left center;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  html.js .reveal-media { clip-path: none; }
  html.js .reveal-fade { transform: none; }
  html.js .reveal-rule { transform: none; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
