/*
  Design tokens for every page, including the 404. DESIGN.md documents what each
  one is for; this file is the source of truth for the values. The build reads
  --surface-panel from the dark and light blocks below for the theme-color meta tags.
*/

/*
  Literata 400, subsetted to the characters the display face actually needs
  (see assets/literata-400.charset.txt). 14.7KB. Iowan Old Style stays next in
  the stack so macOS still gets a good face if the download fails.

  If you write a heading using a character outside that set it will fall back
  to Georgia for that glyph alone, which is visible mid-word. Re-cut the subset
  rather than living with it.
*/
@font-face {
  font-family: "Literata";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/assets/literata-400.woff2") format("woff2");
}

/*
  Tokens are roles, not a lightness scale: --surface is the page, --surface-panel
  sits on it (cards, header), --surface-inset is a mat or well (media frames, contact).
  Which of those is literally lighter flips between themes, so don't read the names
  as an ordering.

  Line alphas are deliberately different per theme: alpha compositing is not
  perceptually symmetric, so matching the numbers would leave the light theme
  much flatter. These land --line-strong at >= 3:1 on every surface in both themes.
*/
:root {
  color-scheme: dark;
  --surface: #101214;
  --surface-panel: #15181b;
  --surface-inset: #1b1f22;
  --text: #f1eee7;
  --text-muted: #b5b8b3;
  --text-on-accent: var(--surface);
  --line: rgba(241, 238, 231, .27);
  --line-strong: rgba(241, 238, 231, .36);
  --image-edge: rgba(241, 238, 231, .275);
  --blue: #4aa8ff;
  --blue-wash: rgba(74, 168, 255, .08);
  /* Phase Sync's pink, from its key art. >= 7.5:1 on panels here; dark text on it >= 7.9:1. */
  --pink: #ff7eb6;
  --focus-ring: var(--blue);
  --display: "Literata", "Iowan Old Style", "Baskerville", "Palatino Linotype", Georgia, serif;
  --sans: "Avenir Next", "Helvetica Neue", Helvetica, sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --measure: 72rem;
  /* Type roles. Label is the floor: nothing on the page is set smaller. */
  --type-label: .75rem;
  --type-chrome: .78rem;
  --type-action: .95rem;
  --type-fact: .94rem;
  --type-lead: 1.125rem;
  --ease: cubic-bezier(.22, .8, .24, 1);
}

[data-theme="light"] {
  color-scheme: light;
  --surface: #e2e6e9;
  --surface-panel: #eceff2;
  --surface-inset: #d8dbdf;
  --text: #15181b;
  --text-muted: #50565a;
  --line: rgba(21, 24, 27, .365);
  --line-strong: rgba(21, 24, 27, .485);
  --image-edge: rgba(21, 24, 27, .385);
  --blue: #005a9c;
  --blue-wash: rgba(0, 90, 156, .07);
  --pink: #a8155a;
  --focus-ring: var(--blue);
}

/*
  Without JS, data-theme is never set, so the system preference has to come from CSS.
  Values must stay in sync with [data-theme="light"] above.
*/
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    color-scheme: light;
    --surface: #e2e6e9;
    --surface-panel: #eceff2;
    --surface-inset: #d8dbdf;
    --text: #15181b;
    --text-muted: #50565a;
    --line: rgba(21, 24, 27, .365);
    --line-strong: rgba(21, 24, 27, .485);
    --image-edge: rgba(21, 24, 27, .385);
    --blue: #005a9c;
    --blue-wash: rgba(0, 90, 156, .07);
    --pink: #a8155a;
    --focus-ring: var(--blue);
  }
}

/* Borders carry the whole structure here, so this is where extra contrast goes. */
@media (prefers-contrast: more) {
  :root {
    --text-muted: #d6d8d4;
    --line: rgba(241, 238, 231, .36);
    --line-strong: rgba(241, 238, 231, .55);
    --image-edge: rgba(241, 238, 231, .4);
  }
  [data-theme="light"] {
    --text-muted: #3a3f43;
    --line: rgba(21, 24, 27, .485);
    --line-strong: rgba(21, 24, 27, .68);
    --image-edge: rgba(21, 24, 27, .5);
  }
}

/* The system-light case on its own: a bare :root:not([data-theme]) would also match a dark system. */
@media (prefers-contrast: more) and (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --text-muted: #3a3f43;
    --line: rgba(21, 24, 27, .485);
    --line-strong: rgba(21, 24, 27, .68);
    --image-edge: rgba(21, 24, 27, .5);
  }
}
