/* ==========================================================================
   The Language Mill — base.css
   Reset, element defaults, typography, layout primitives, accessibility.
   Depends on tokens.css. No component styling lives here.
   ========================================================================== */

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

* { margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + var(--space-md));
}

body {
  min-height: 100vh;
  background-color: var(--paper);
  background-image: var(--paper-texture);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: var(--step-0);
  line-height: var(--lh-body);
  font-weight: var(--weight-regular);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

svg { fill: currentColor; }

input, button, textarea, select { font: inherit; color: inherit; }

button { background: none; border: none; cursor: pointer; }

ul[role="list"], ol[role="list"] { list-style: none; padding: 0; }

table { border-collapse: collapse; width: 100%; }

:target { scroll-margin-top: calc(var(--header-h) + var(--space-md)); }

/* --- Typography ---------------------------------------------------------- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  color: var(--heading);
  line-height: var(--lh-heading);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-tight);
  text-wrap: balance;
}

h1 { font-size: var(--step-5); line-height: var(--lh-tight); }
h2 { font-size: var(--step-4); }
h3 { font-size: var(--step-3); }
h4 { font-size: var(--step-2); }
h5 { font-size: var(--step-1); }
h6 {
  font-family: var(--font-ui);
  font-size: var(--step--1);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  color: var(--meta);
}

p { text-wrap: pretty; }

a {
  color: var(--link);
  text-decoration-color: color-mix(in srgb, var(--link) 40%, transparent);
  text-underline-offset: 0.15em;
  transition: color var(--transition), text-decoration-color var(--transition);
}
a:hover { color: var(--link-hover); text-decoration-color: currentColor; }

strong, b { font-weight: var(--weight-semibold); color: var(--ink); }

small { font-size: var(--step--1); }

hr {
  border: none;
  border-top: var(--hairline);
  margin: var(--space-lg) 0;
}

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

/* --- Layout primitives --------------------------------------------------- */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.container--narrow { max-width: var(--container-narrow); }

.section {
  padding-block: var(--space-section);
  background-color: var(--paper);
}
.section--alt { background-color: var(--paper-alt); }
.section--forest {
  background-color: var(--forest);
  color: var(--on-forest);
}
.section--ink {
  background-color: var(--ink);
  color: var(--paper);
}

.stack > * + * { margin-top: var(--flow, var(--space-md)); }

/* --- Utilities ----------------------------------------------------------- */
.eyebrow {
  display: inline-block;
  font-family: var(--font-ui);
  font-size: var(--step--1);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  color: var(--forest);
}

.lead {
  font-size: var(--step-1);
  line-height: var(--lh-snug);
  color: var(--ink-soft);
}

.text-forest { color: var(--forest); }
.text-mute { color: var(--meta); }
.center { text-align: center; }
.measure { max-width: 60ch; }
.measure-narrow { max-width: 40ch; }

/* Hairline rules that flank a centred statement */
.rule {
  border: none;
  border-top: var(--hairline);
  width: 100%;
}

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

:focus-visible {
  outline: var(--focus-width) solid var(--focus-ring);
  outline-offset: var(--focus-offset);
  border-radius: var(--radius-sm);
}
/* Remove default outline only where focus-visible is supported */
:focus:not(:focus-visible) { outline: none; }

.skip-link {
  position: absolute;
  left: var(--space-sm);
  top: -100%;
  z-index: calc(var(--z-header) + 1);
  background: var(--forest);
  color: var(--on-forest);
  padding: var(--space-2xs) var(--space-sm);
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: top var(--transition);
}
.skip-link:focus { top: var(--space-sm); color: var(--on-forest); }

/* --- Responsive gutters -------------------------------------------------- */
@media (min-width: 900px) {
  :root { --gutter: 40px; }
}

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