/* Structure: the page skeleton every xerdi.* domain shares.
 *
 * Colours come from tokens.css, which is generated from shared/data/palette.yaml
 * and contrast-checked before it is written. There is no hex value in this file
 * and there must not be one -- a colour written here has not been through the
 * gate. Same for components.css.
 *
 * No webfont. The type is the system stack, which costs nothing to load and
 * cannot swap in halfway through and reflow the page. That is a deliberate
 * limit rather than a gap: a brand that depends on a downloaded face looks
 * wrong for the first second of every cold visit, and these are sales pages
 * where the first second is the one that matters.
 */

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

html {
  /* Fluid, and in rem throughout -- no px anywhere in this declaration.
   *
   * This used to read `clamp(16px, 0.95rem + 0.2vw, 19px)`, which quietly
   * capped the visitor's own browser setting: someone who had set their default
   * to 24px because they need 24px was handed 19px, and the larger they set it
   * the more the site took away. That is the opposite of what the setting is
   * for, and it is a WCAG 1.4.4 failure rather than a matter of taste.
   *
   * At the root, `rem` resolves against that setting, so every bound here
   * scales with it. The vw term still widens the type on a large screen; it can
   * no longer overrule the person reading. */
  font-size: clamp(1rem, 0.95rem + 0.25vw, 1.25rem);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  /* Explicit, not inherited. The background has to be painted by the page or a
   * viewer's own surface shows through wherever a band does not reach. */
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.6;
  font-synthesis-weight: none;
}

/* Headings and links read their colour from an inherited custom property, not
 * from a descendant selector. That is what makes a band able to recolour its
 * contents without outranking the components inside it -- see .band-brand. */
h1, h2, h3 {
  color: var(--heading-color, var(--brand-ink));
  line-height: 1.2;
  text-wrap: balance;
  margin: 0 0 0.5em;
}

h1 { font-size: clamp(2rem, 1.4rem + 2.4vw, 3.1rem); letter-spacing: -0.015em; }
h2 { font-size: clamp(1.5rem, 1.2rem + 1.1vw, 2.1rem); }
h3 { font-size: 1.15rem; }

p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }

a { color: var(--link-color, var(--brand-ink)); text-underline-offset: 0.2em; }
a:hover { text-decoration-thickness: 2px; }

/* One focus style for everything, and it is never removed. A visitor who
 * navigates by keyboard has no other way to know where they are. */
:where(a, button, input, textarea, select, summary):focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 2px;
}

img, svg { max-width: 100%; height: auto; }

/* -- containers ---------------------------------------------------------- */

.wrap {
  width: min(72rem, 100% - 2.5rem);
  margin-inline: auto;
}

/* A band is a full-width horizontal stripe; the wrap inside it holds the
 * measure. Splitting the two is what lets a section span the viewport while
 * its text still stops at a readable width. */
.band { padding: clamp(2.5rem, 6vw, 4.5rem) 0; }
.band-surface { background: var(--surface); }
/* A brand-coloured band recolours its contents by REDEFINING TOKENS, never with
 * descendant selectors.
 *
 * `.band-brand a { color: … }` looks equivalent and is not: at (0,1,1) it
 * outranks every single-class component rule inside the band, so a button that
 * sets its own colour loses. That produced a white "Write to Erik" button with
 * white text on it -- the background came from .btn-on-brand and the text from
 * the band, and neither rule was wrong on its own.
 *
 * Custom properties inherit instead of competing, so the band sets the default
 * for anything that did not ask for something else, and a component that did
 * ask still wins. There is no specificity to lose.
 */
.band-brand {
  background: var(--brand);
  color: var(--on-brand);
  --heading-color: var(--on-brand);
  --link-color: var(--on-brand);
  /* The focus ring too, and this one was a real failure rather than a nicety:
   * --focus is a dark blue chosen against the page background, and on the brand
   * band it came out at 1.36:1 -- invisible. The call-to-action lives on this
   * band, so a keyboard visitor lost the ring on the single most important
   * control of the page. Same inheritance trick, same reason it works. */
  --focus: var(--on-brand);
}

.prose { max-width: 62ch; }
.lede { max-width: 62ch; font-size: 1.1rem; color: var(--muted); }
.muted { color: var(--muted); }

/* -- header -------------------------------------------------------------- */

.skip {
  position: absolute;
  left: -9999px;
  background: var(--brand);
  color: var(--on-brand);
  padding: 0.6rem 1rem;
  z-index: 10;
}
.skip:focus { left: 0.5rem; top: 0.5rem; }

.site-header {
  border-bottom: 1px solid var(--rule);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 5;
}

.header-row {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  min-height: 4rem;
  flex-wrap: wrap;
}

.wordmark {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  text-decoration: none;
  font-weight: 650;
  margin-right: auto;
}
.wordmark img { align-self: center; }
.wordmark-name { color: var(--brand-ink); letter-spacing: -0.01em; }
/* The domain, small, beside the name. Three sites share a wordmark, so the
 * domain is the only thing on screen that says which one you are reading. */
.wordmark-domain { color: var(--muted); font-weight: 400; font-size: 0.82rem; }

.site-nav ul {
  display: flex;
  gap: 1.1rem;
  list-style: none;
  margin: 0;
  padding: 0;
  flex-wrap: wrap;
}
.site-nav a { text-decoration: none; color: var(--text); }
.site-nav a:hover { text-decoration: underline; }
.site-nav a[aria-current="page"] {
  color: var(--brand-ink);
  font-weight: 600;
  /* Not colour alone: the current page is also underlined, so it is
   * distinguishable without colour vision. */
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.35em;
}

/* -- footer -------------------------------------------------------------- */

.site-footer {
  border-top: 1px solid var(--rule);
  padding: 2.5rem 0;
  margin-top: 3rem;
  font-size: 0.92rem;
}
.footer-grid {
  display: grid;
  gap: 1.75rem;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
}
.footer-brand { font-weight: 650; color: var(--brand-ink); margin-bottom: 0.25rem; }
.footer-heading { font-weight: 650; margin-bottom: 0.4rem; }
.plain { list-style: none; margin: 0; padding: 0; }
.plain li { margin-bottom: 0.35rem; }
