/* ---------------------------------------------------------------
   Craft floor.

   Everything below is byte-identical in every page that gets it
   right, so it ships here rather than being re-typed from the
   rules each time. Replace the :root values with the page's own
   palette; do not delete the rules that consume them.
   --------------------------------------------------------------- */

:root {
  /* Placeholders. Replace all of these — a page that ships these
     exact values has not chosen a palette. */
  --ink: #1a1a1a;
  --ink-muted: #51555c;
  --bg: #ffffff;
  --surface: #f2f4f7;
  --rule: #d8dce2;
  --accent: #1f4ed8;
  --accent-ink: #ffffff;

  /* Under 80 rendered characters. ch is the width of a 0 and most
     letters are narrower, so 75ch measures nearer 95. */
  --measure: 60ch;

  scrollbar-color: var(--rule) transparent;
  caret-color: var(--accent);
  color-scheme: light dark;
}

/* The same seven properties, for readers whose OS is set to dark.
   Replace these alongside the light ones — a page that restyles
   :root and leaves this block holding the placeholder greys has a
   dark mode that belongs to a different design.

   Darken by desaturating and lifting, not by inverting: --bg wants a
   near-black carrying a little of the accent's hue, --ink a soft
   off-white rather than #fff, and --accent usually needs lightening
   to stay legible, since a colour tuned against white rarely clears
   4.5:1 against black. */
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e8e9ec;
    --ink-muted: #a2a8b4;
    --bg: #14161a;
    --surface: #1d2026;
    --rule: #2e333c;
    --accent: #7aa2ff;
    --accent-ink: #0b0d10;
  }
}

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

/* Prevent any overflowing element from widening the document past the
   viewport. Without this a single oversized heading or image at a
   narrow viewport stretches the scroll width, which makes every
   paragraph on the page measure as flush to the viewport edge. */
html {
  overflow-x: clip;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
}

main {
  max-width: var(--measure);
  margin-inline: auto;
  padding-inline: 1rem;
}

p {
  text-wrap: pretty;
}

h1,
h2,
h3 {
  text-wrap: balance;
}

/* The surfaces you did not draw, which otherwise ship with browser
   defaults belonging to no design system. */
::selection {
  background: var(--accent);
  color: var(--accent-ink);
}

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

a {
  color: var(--accent);
  text-underline-offset: 0.18em;
}

/* Put on any cell holding a figure, so columns of numbers line up. */
.num {
  font-variant-numeric: tabular-nums;
}

/* 44px is the smallest reliably tappable target. Anything the reader
   presses needs it; a link inside a paragraph does not, which is why
   this is not on `a`. */
button,
[role="button"],
summary,
input[type="checkbox"],
input[type="radio"] {
  min-height: 44px;
}

button {
  min-width: 44px;
}

/* A document is one column, so the only thing that reliably breaks it
   is content that cannot shrink: a wide table, a long URL, a code
   block. These make the narrow viewport survivable without needing a
   layout per breakpoint. */
img,
video,
canvas,
svg {
  max-width: 100%;
  height: auto;
}

pre {
  overflow-x: auto;
}

table {
  display: block;
  overflow-x: auto;
  max-width: 100%;
}

@media (max-width: 480px) {
  body {
    /* Thumbs cover the edges; text should not start underneath them. */
    padding-inline: 1rem;
  }
}

/* Motion only for readers who have not asked the OS to stop it. */
@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

@media print {
  body {
    background: #fff;
    color: #000;
  }
}
@media (max-width: 480px) {
  /* --impeccable-mobile-pad */
  body { padding-inline: max(1rem, 16px); }
  .container, [class*="container"], section, header, footer, nav, main, article {
    padding-inline: max(1rem, 16px);
  }
}
/* --impeccable-measure */
p, li, dt, dd, blockquote, figcaption, td, th { max-width: min(75ch, 100%); }
