/* Element defaults and shared text styles. Values come from tokens.css. */

/* ---------- Fonts (self-hosted, latin subset, variable weight; licences in /fonts/LICENSE.txt) ---------- */
@font-face {
  font-family: 'Fredoka';
  src: url('/fonts/fredoka.woff2') format('woff2');
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'DM Sans';
  src: url('/fonts/dm-sans.woff2') format('woff2');
  font-weight: 100 1000;
  font-style: normal;
  font-display: swap;
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  /* A section scrolled to from a link stops below the sticky header, not under it. */
  scroll-padding-top: 5.5rem;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink-soft);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.6;
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
}

/* Owner, 2026-11-13: page text is not selectable or copyable (no selection, no long-press callout on iOS).
   Deliberate exceptions, so nobody is stuck: email addresses, phone and text links (the crisis lines), and any
   field someone types into. This only discourages copying; it does not hide anything. */
/* Grain: a still film grain over everything, like paper under the colour. Above the page, never in the way of a tap,
   and gone where it would cost legibility (more contrast, forced colours, print). */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 70;
  background-image: var(--grain);
  background-size: 180px 180px;
  opacity: var(--grain-opacity);
  pointer-events: none;
}

@media (prefers-contrast: more), (forced-colors: active), print {
  body::after {
    display: none;
  }
}

body {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

a[href^='mailto:'],
a[href^='tel:'],
a[href^='sms:'],
input,
textarea,
.selectable {
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}

main {
  flex: 1;
  padding-bottom: var(--space-l);
}

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

/* ---------- Text ---------- */
h1,
h2,
h3 {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: -0.012em;
  text-wrap: balance;
}

h1 {
  font-size: var(--step-4);
}

h2 {
  font-size: var(--step-3);
}

h3 {
  font-size: var(--step-1);
  font-weight: 500;
  line-height: 1.25;
  letter-spacing: 0;
}

p,
ul,
ol,
dl {
  margin: 0;
}

p {
  text-wrap: pretty;
}

strong {
  color: var(--ink);
  font-weight: 600;
}

/* Links are underlined as if someone drew a line under them with a pen: an uneven stroke stretched to the link's
   width (never a repeating pattern), and neighbouring links get different strokes. It is a background, so a link that
   wraps gets a stroke under each line. A link styled as something else (a button, the brand, a nav item) sets
   `background-image: none` beside its `text-decoration: none`. `.squiggle` puts it on the words inside a link that is
   a tall box. */
a,
.squiggle {
  --underline: var(--underline-1);
  color: var(--ink);
  text-decoration: none;
  background-image: var(--underline);
  background-repeat: no-repeat;
  background-size: 100% 0.7em;
  background-position: 0 100%;
  padding-bottom: 0.4em;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  transition: color var(--dur) var(--ease-out);
}

a:nth-of-type(4n + 2),
.squiggle:nth-of-type(4n + 2) {
  --underline: var(--underline-2);
}

a:nth-of-type(4n + 3),
.squiggle:nth-of-type(4n + 3) {
  --underline: var(--underline-3);
}

a:nth-of-type(4n + 4),
.squiggle:nth-of-type(4n + 4) {
  --underline: var(--underline-4);
}

li:nth-child(even) > a {
  --underline: var(--underline-2);
}

@media (hover: hover) and (pointer: fine) {
  a:hover {
    color: var(--brand-ink);
  }
}

/* On hover a text link shimmers, like Claude's "working" text (owner, 2026-11-16): the words and their pen line dim a
   little and a bright band sweeps across them, over and over, while the pointer stays. A mask, so it needs no extra
   markup and leaves the text its own colour. Buttons, the brand and nav items never shimmer. */
@keyframes link-shimmer {
  from {
    -webkit-mask-position: 100% 0;
    mask-position: 100% 0;
  }

  to {
    -webkit-mask-position: 0% 0;
    mask-position: 0% 0;
  }
}

@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  a:not(.btn, .brand, .nav-link, .skip-link, .rail a, .country-nav a):hover {
    -webkit-mask-image: linear-gradient(100deg, rgb(0 0 0 / 0.45) 38%, #000 50%, rgb(0 0 0 / 0.45) 62%);
    mask-image: linear-gradient(100deg, rgb(0 0 0 / 0.45) 38%, #000 50%, rgb(0 0 0 / 0.45) 62%);
    -webkit-mask-size: 300% 100%;
    mask-size: 300% 100%;
    animation: link-shimmer 1.5s linear infinite;
  }
}

:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 3px;
  border-radius: 6px;
}

::selection {
  background: color-mix(in srgb, var(--brand) 30%, transparent);
}

.lede {
  max-width: 34ch;
  color: var(--ink-soft);
  font-size: var(--step-1);
  line-height: 1.45;
}

.meta {
  color: var(--muted);
  font-size: var(--step--1);
  line-height: 1.5;
}

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

.skip-link {
  position: absolute;
  top: var(--space-xs);
  left: var(--space-xs);
  z-index: 10;
  padding: 0.75rem 1.1rem;
  border-radius: 999px;
  background: var(--bg-raised);
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
  background-image: none;
  box-shadow: var(--shadow);
  transform: translateY(-200%);
}

.skip-link:focus-visible {
  transform: none;
}
