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

html, body {
  height: 100%;
}

/* The canvas itself stays theme-neutral (--color-bg-canvas); the ambient
   wash layered on top is the one place environment touches a large-area
   fill, and it's a ~5% mix at most — a hum, not a recolour. See
   docs/adr/0002-typography-and-ambient-environment-presence.md. */
body {
  margin: 0;
  background-color: var(--color-bg-canvas);
  background-image: radial-gradient(ellipse 100% 60% at top, var(--env-ambient-wash), transparent 70%);
  background-repeat: no-repeat;
  color: var(--color-text-primary);
  font-family: var(--font-sans);
  font-size: var(--text-md);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
  transition: background-color var(--duration-base) var(--ease), color var(--duration-base) var(--ease);
}

h1, h2, h3, h4, p, figure {
  margin: 0;
}

h1, h2, h3, h4 {
  font-family: var(--font-sans);
  font-weight: 650;
  line-height: var(--leading-tight);
  letter-spacing: -0.01em;
}

/* Body text is the one place the serif face runs — titles, labels, and UI
   chrome stay on the sans stack (the default on body). See
   docs/adr/0002-typography-and-ambient-environment-presence.md.

   Cormorant is a high-contrast display-lineage serif: its default stroke is
   thin and its glyphs run small, so prose is set a touch larger and at weight
   500 to hold colour and legibility at body sizes. */
p, .modal-body {
  font-family: var(--font-serif);
  font-size: 1.08em;
  font-weight: 500;
  line-height: var(--leading-normal);
}

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

code, pre, kbd {
  font-family: var(--font-mono);
}

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

/* Typography is safe to inherit on every control — it makes them match the
   page without touching the colour pairing. */
button, input, select, textarea {
  font: inherit;
}

/* Colour and background must be set together or not at all. A user agent
   gives every control a coherent pair (buttontext on buttonface); inheriting
   only the text colour keeps the UA's light background and paints the
   theme's light text onto it, which is illegible in dark mode — broken
   rather than merely unstyled.

   Text-entry controls take the theme pair here, because a bare <input> with
   no visible field still has to be readable while you type into it. .input
   in components.css then adds the full treatment (border, radius, padding).

   <button> and <select> are deliberately left with the user agent's own
   pair: a flat surface-coloured button with no border reads as neither
   button nor text, whereas a native-looking control is legible and is an
   honest signal that .btn / .select has not been applied yet. */
input:not([type="checkbox"]):not([type="radio"]), textarea {
  color: inherit;
  background-color: var(--color-bg-surface);
}

/* A single, environment-tinted focus treatment used everywhere — this is
   one of the "small functional elements" the environment accent is allowed
   to touch (see docs/adr/0001-functional-styling-tokens.md). */
:focus-visible {
  outline: 2px solid var(--env-accent);
  outline-offset: 2px;
}

::selection {
  background: var(--env-accent-ring);
}

/* Scrollbars get the same faint ambient tint as other chrome/hairlines —
   part of the "hint everywhere" pass, not a status signal on their own. */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--env-border-strong) transparent;
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-thumb {
  background: var(--env-border-strong);
  border-radius: var(--radius-full);
  border: 2px solid var(--color-bg-surface);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
