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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: auto;
  transition: background-color 30s linear;
}

html[data-time-grade="morning"]   { --color-bg: #2D2520; }
html[data-time-grade="midday"]    { --color-bg: #2B2219; }
html[data-time-grade="afternoon"] { --color-bg: #2A2018; }
html[data-time-grade="evening"]   { --color-bg: #2A1E14; }
html[data-time-grade="night"]     { --color-bg: #271B12; }

body { transition: background-color 30s linear; }

body {
  font-family: var(--font-sans);
  font-size: var(--type-body);
  line-height: 1.5;
  color: var(--color-fg);
  background: var(--color-bg);
  min-height: 100svh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, picture, video, canvas, svg { display: block; max-width: 100%; }
input, button, textarea, select { font: inherit; color: inherit; background: none; border: 0; }
button { cursor: pointer; }
p, h1, h2, h3, h4, h5, h6 { overflow-wrap: break-word; }
ul, ol { list-style: none; }

/* === Typography === */
.chapter__title,
.cold-open__line,
.outro__wordmark {
  font-family: var(--font-serif);
  font-weight: 350;
  line-height: 1.05;
  letter-spacing: -0.02em;
  font-variation-settings: 'opsz' 96;
}

.chapter__title       { font-size: var(--type-h1); margin-bottom: var(--space-lg); }
.cold-open__line      { font-size: var(--type-display); max-width: 24ch; font-weight: 300; }
.outro__wordmark      { font-size: var(--type-h1); }

.eyebrow {
  font-family: var(--font-sans);
  font-size: var(--type-micro);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-weight: 500;
  color: var(--color-fg-muted);
  margin-bottom: var(--space-md);
}

.chapter__body {
  max-width: var(--inner-max);
  font-size: var(--type-body);
  line-height: 1.65;
  color: var(--color-fg);
  margin-bottom: var(--space-md);
}

.chapter__body--lede {
  font-family: var(--font-serif);
  font-size: var(--type-lede);
  font-weight: 300;
  line-height: 1.35;
  letter-spacing: -0.005em;
  color: var(--color-fg);
  margin-bottom: var(--space-lg);
}

/* === Chapter primitives === */
.chapter {
  position: relative;
  min-height: 100svh;
  overflow: hidden;
  display: grid;
  align-content: center;
  /* All padding (vertical + horizontal) lives on .chapter__inner now,
     so content flows naturally and the chapter grows when content exceeds 100svh */
}

.chapter__inner {
  max-width: var(--inner-max);
  margin: 0 auto;
  padding-top: var(--space-3xl);
  padding-bottom: var(--space-3xl);
  padding-left: max(var(--gutter), env(safe-area-inset-left));
  padding-right: max(var(--gutter), env(safe-area-inset-right));
  position: relative;
  z-index: var(--z-fg);
  width: 100%;
}

.chapter__inner--wide { max-width: 64rem; }

.layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.layer--bg  { z-index: var(--z-bg); }
.layer--mid { z-index: var(--z-mid); }

/* fg holds the content — flow naturally so the chapter grows with it */
.layer--fg  {
  position: relative;
  inset: auto;
  z-index: var(--z-fg);
  pointer-events: auto;
}

/* === Cold open === */
.chapter--cold-open {
  display: grid;
  place-content: center;
  text-align: center;
  min-height: 100svh;
  padding-top: var(--space-3xl);
  padding-bottom: var(--space-3xl);
  padding-left: max(var(--gutter), env(safe-area-inset-left));
  padding-right: max(var(--gutter), env(safe-area-inset-right));
}

/* === Accessibility === */
:focus-visible {
  outline: 2px solid var(--color-accent-warm);
  outline-offset: 4px;
  border-radius: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}