/* The design tokens: every color, face, size and space on the site comes from here. A variant picks a
   palette and a type pairing with data-palette and data-type on <html>; the playground's panel changes them
   live. Text tokens are chosen to clear 7:1 (WCAG AAA) on --paper, since many readers are past 40. */

@font-face {
  font-family: 'Cooper';
  src: url('fonts/cooper-medium.woff2') format('woff2');
  font-weight: 400 700;
  font-display: swap;
}
@font-face {
  font-family: 'Cooper';
  src: url('fonts/cooper-medium-italic.woff2') format('woff2');
  font-weight: 400 700;
  font-style: italic;
  font-display: swap;
}

:root {
  /* Color */
  --paper: #fbf5ec; /* the page */
  --paper-2: #efe4d3; /* a quiet band or box on the page */
  --ink: #1c2721; /* body text and headings */
  --ink-2: #3f3d36; /* secondary text */
  --ink-3: #4d4a43; /* dates, labels, captions */
  --accent: #0d3c2a; /* links, the one button, small marks */
  --accent-ink: #fff1e3; /* text on the accent */
  --rule: #e2d6c4; /* hairlines */

  /* Type */
  --font-display: 'Cooper', Georgia, serif;
  --font-body: Georgia, 'Times New Roman', serif;
  --font-mono: ui-monospace, 'SF Mono', Menlo, monospace;
  --display-weight: 500;
  --display-tracking: -0.01em;
  --text-base: 20px; /* body size on a desktop; phones step down 2px */
  --scale: 1.25; /* each heading step is this much larger than the last */
  --leading: 1.6;
  --measure: 34rem; /* the column's widest line */

  /* Space and shape */
  --space: 1.5rem; /* the rhythm unit: paragraphs, gaps */
  --gutter: 16px; /* the side margin on a phone */
  --radius: 4px;

  /* Derived: don't set these, set the ones above */
  --step-1: calc(1rem * var(--scale));
  --step-2: calc(var(--step-1) * var(--scale));
  --step-3: calc(var(--step-2) * var(--scale));
  --step-4: calc(var(--step-3) * var(--scale));
  --step--1: calc(1rem / var(--scale) * 1.1);
}

/* ---- Palettes ------------------------------------------------------------------------------------------ */

/* Pine: the current site's pine and cream */
[data-palette='pine'] {
  --paper: #fbf5ec; --paper-2: #efe4d3; --ink: #1c2721; --ink-2: #3f3d36; --ink-3: #4d4a43;
  --accent: #0d3c2a; --accent-ink: #fff1e3; --rule: #e2d6c4;
}
/* Paper: white paper, black ink, a blue-black fountain-pen accent */
[data-palette='paper'] {
  --paper: #fafaf7; --paper-2: #efeee8; --ink: #161616; --ink-2: #393937; --ink-3: #4a4a46;
  --accent: #1d3461; --accent-ink: #fafaf7; --rule: #dedcd4;
}
/* Jade: from the 2024 photos, the jade plant against the pale blue wall */
[data-palette='jade'] {
  --paper: #f4f2e8; --paper-2: #e2e9ea; --ink: #1f241d; --ink-2: #3a3f36; --ink-3: #454a40;
  --accent: #344d24; --accent-ink: #f4f2e8; --rule: #d9dcd0;
}
/* Clay: warm terracotta on oat */
[data-palette='clay'] {
  --paper: #f5ede4; --paper-2: #eedfd0; --ink: #2a1f1a; --ink-2: #47382f; --ink-3: #4f4038;
  --accent: #6e311d; --accent-ink: #fbf3ea; --rule: #e0cfbd;
}
/* Mustard: the yellow couch, toned down for a whole page */
[data-palette='mustard'] {
  --paper: #f7efd9; --paper-2: #ecdfb8; --ink: #24201a; --ink-2: #413a2e; --ink-3: #4b4335;
  --accent: #5a4410; --accent-ink: #f7efd9; --rule: #e3d6b0;
}
/* Dusk: dark, for an evening feel */
[data-palette='dusk'] {
  --paper: #191c1b; --paper-2: #232826; --ink: #ece6dc; --ink-2: #cfc9bf; --ink-3: #bdb8af;
  --accent: #d9c08f; --accent-ink: #191c1b; --rule: #343a37;
}

/* Indigo: ai-zome blue, cool and quiet */
[data-palette='indigo'] {
  --paper: #eef1f4; --paper-2: #dfe5ec; --ink: #141b26; --ink-2: #2f3846; --ink-3: #434c5a;
  --accent: #22356b; --accent-ink: #eef1f4; --rule: #d3dae3;
}
/* Sage: soft grey-green, an unhurried room */
[data-palette='sage'] {
  --paper: #eef0e8; --paper-2: #e0e5d8; --ink: #1e221c; --ink-2: #363c33; --ink-3: #474e44;
  --accent: #3d4f34; --accent-ink: #eef0e8; --rule: #d5dacb;
}

/* ---- Type pairings ------------------------------------------------------------------------------------- */

/* Cooper and Georgia: the current site */
[data-type='cooper'] {
  --font-display: 'Cooper', Georgia, serif; --font-body: Georgia, 'Times New Roman', serif;
  --display-weight: 500; --display-tracking: -0.01em;
}
/* Newsreader: one face throughout, bookish and quiet */
[data-type='newsreader'] {
  --font-display: 'Newsreader', Georgia, serif; --font-body: 'Newsreader', Georgia, serif;
  --display-weight: 400; --display-tracking: -0.015em;
}
/* Fraunces and Source Serif: soft, a little old-fashioned */
[data-type='fraunces'] {
  --font-display: 'Fraunces', Georgia, serif; --font-body: 'Source Serif 4', Georgia, serif;
  --display-weight: 400; --display-tracking: -0.02em;
}
/* Instrument Serif and Public Sans: a modern pairing, serif headings over a plain sans */
[data-type='instrument'] {
  --font-display: 'Instrument Serif', Georgia, serif; --font-body: 'Public Sans', system-ui, sans-serif;
  --display-weight: 400; --display-tracking: 0;
}
/* Plex Mono: a typewritten page */
[data-type='mono'] {
  --font-display: 'IBM Plex Mono', var(--font-mono); --font-body: 'IBM Plex Mono', var(--font-mono);
  --display-weight: 500; --display-tracking: 0;
}
/* Literata: made for long reading on screens */
[data-type='literata'] {
  --font-display: 'Literata', Georgia, serif; --font-body: 'Literata', Georgia, serif;
  --display-weight: 500; --display-tracking: -0.01em;
}
/* EB Garamond: a book face, old and literary */
[data-type='garamond'] {
  --font-display: 'EB Garamond', Garamond, Georgia, serif; --font-body: 'EB Garamond', Garamond, Georgia, serif;
  --display-weight: 500; --display-tracking: -0.01em;
}
/* Young Serif and Source Serif: a warm, sturdy heading over an easy text face */
[data-type='young'] {
  --font-display: 'Young Serif', Georgia, serif; --font-body: 'Source Serif 4', Georgia, serif;
  --display-weight: 400; --display-tracking: -0.01em;
}
/* DM Serif Display and DM Sans: high-contrast headings over a friendly sans */
[data-type='dm'] {
  --font-display: 'DM Serif Display', Georgia, serif; --font-body: 'DM Sans', system-ui, sans-serif;
  --display-weight: 400; --display-tracking: -0.005em;
}

/* ---- Textures ------------------------------------------------------------------------------------------ */

/* A texture (data-texture) is one of the estate's Japan backdrop sets: a fine grain over a page color taken
   from the texture itself. It replaces the palette's paper, band and hairline colors, and keeps its ink and
   accent. Each set's values are generated into the page by the build (lib.mjs textureCss). */
html:not([data-texture='none']) {
  --paper: var(--tex-page, #fff);
  --paper-2: var(--tex-paper-2, #eee);
  --rule: var(--tex-rule, #ddd);
}
html:not([data-texture='none']) body { background: transparent; }
html:not([data-texture='none']) body::before {
  content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: var(--tex-page) var(--tex-wide) center / cover no-repeat;
}
@media (max-aspect-ratio: 1 / 1) {
  html:not([data-texture='none']) body::before { background-image: var(--tex-tall); }
}
