/*
 * base.css is the single source of truth for the page sizing model and the
 * design tokens. Nothing else may declare a viewport height on html or body:
 * duplicates drift and reintroduce whole-page scrollbars. Enforced by
 * scripts/check-css.mjs.
 *
 * Visual design lives in component styles; this file establishes the frame,
 * the tokens, and the accessibility floor (contrast, focus, text size).
 */

:root {
  /* Type. Body text never drops below 1.125rem: the audience skews older. */
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: Georgia, "Times New Roman", serif;
  --text-base: 1.125rem;
  --text-small: 1rem;

  --space: 1rem;
  --radius: 0.5rem;
  --measure: 42rem;
}

:root[data-theme="light"] {
  --paper: #fbf9f4;
  --card: #ffffff;
  --ink: #1c1a17;
  --ink-soft: #4a453d;
  --rule: #ddd6c8;
  --accent: #7a3b12;
  --accent-ink: #ffffff;
  --link: #1f4e8c;
  --focus: #1f4e8c;
}

:root[data-theme="dark"] {
  --paper: #171614;
  --card: #211f1c;
  --ink: #f2efe8;
  --ink-soft: #b8b1a4;
  --rule: #3a352e;
  --accent: #e0895a;
  --accent-ink: #171614;
  --link: #8fbcf0;
  --focus: #8fbcf0;
}

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

html {
  /* The one viewport-height declaration in the project. */
  min-height: 100dvh;
  color-scheme: light dark;
}

body {
  min-height: 100dvh;
  margin: 0;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.55;
}

main {
  flex: 1;
  width: 100%;
  max-width: var(--measure);
  margin: 0 auto;
  padding: var(--space);
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  line-height: 1.2;
  text-wrap: balance;
}

a {
  color: var(--link);
}

/*
 * Visible focus on everything focusable, in both themes. Removing this fails
 * the JAWS checklist and strands keyboard users.
 */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Reachable by keyboard, out of the way until focused. */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  padding: 0.5rem 1rem;
  background: var(--card);
  color: var(--ink);
  z-index: 10;
}

.skip-link:focus {
  left: 0;
}

button {
  font: inherit;
  min-height: 2.75rem;
  padding: 0.5rem 1rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
}

input,
textarea,
select {
  font: inherit;
  color: inherit;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 0.5rem;
}

dialog {
  max-width: min(32rem, calc(100% - 2rem));
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--ink);
  padding: var(--space);
}

dialog::backdrop {
  background: rgb(0 0 0 / 50%);
}

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