/* ───── Fonts ─────────────────────────────────────────────────────────── */

@font-face {
  font-family: "Source Serif 4";
  src: url("./fonts/SourceSerif4-VF.woff2") format("woff2");
  font-weight: 200 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Source Serif 4";
  src: url("./fonts/SourceSerif4-VF-Italic.woff2") format("woff2");
  font-weight: 200 900;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Mono";
  src: url("./fonts/IBMPlexMono-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Mono";
  src: url("./fonts/IBMPlexMono-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ───── Design tokens ─────────────────────────────────────────────────── */
/* Theme palette lives on :root.theme-light / :root.theme-dark; the
   inline head script picks one before the page renders (avoids FOUC).
   Component-owned colors (layer slots, --modifier) live in
   keyboard/keyboard.css — override here only if you want different
   keyboard colors. */

:root {
  --serif: "Source Serif 4", "Iowan Old Style", "Palatino", Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --text-base: 19px;
  --text-lead: 1.62;
  --measure: 68ch;

  --space-1: 0.5rem;
  --space-2: 1rem;
  --space-3: 1.5rem;
  --space-4: 2.5rem;
  --space-5: 4rem;
  --space-6: 6rem;
}

:root.theme-light {
  --paper: #f6f1e7;
  --ink: #1a1815;
  --accent: #a13e2a;
  --muted: #8a7f6d;
  --rule: #d9d1bf;
}

:root.theme-dark {
  --paper: #171412;
  --ink: #e8e1d2;
  --accent: #c26147;
  --muted: #8a7f6d;
  --rule: #2b2622;
}

/* ───── Reset ─────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
img, svg { display: block; max-width: 100%; }

/* ───── Base typography & layout ──────────────────────────────────────── */

html {
  font-size: var(--text-base);
  background: var(--paper);
  color: var(--ink);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--serif);
  line-height: var(--text-lead);
  font-weight: 400;
}

main {
  max-width: var(--measure);
  margin: 0 auto;
  padding: var(--space-5) var(--space-3);
}

h1, h2, h3 {
  font-family: var(--serif);
  font-weight: 650;
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin: var(--space-5) 0 var(--space-2);
}

h1 { font-size: 2.6rem; margin-top: 0; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.25rem; }

p, li { margin: 0 0 var(--space-2); }

a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}
a:hover { text-decoration-thickness: 2px; }

code, pre, .mono { font-family: var(--mono); }

code {
  background: var(--rule);
  padding: 0.1em 0.38em;
  border-radius: 3px;
  font-size: 0.88em;
}

pre {
  background: var(--rule);
  padding: var(--space-2);
  border-radius: 4px;
  overflow-x: auto;
  font-size: 0.92em;
}

pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
}

hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: var(--space-5) 0;
}

/* ───── Break-out containers ──────────────────────────────────────────── */

.wide {
  max-width: 920px;
  margin-left: auto;
  margin-right: auto;
}

/* Keyboard component styles live in keyboard/keyboard.css; the host
   page just provides the palette tokens (--paper, --ink, --rule,
   --mono, --modifier, --color-layer-0..N) and the kbd's outer margin. */

.kbd {
  margin: var(--space-3) auto;
}

.metrics-chart {
  display: block;
  width: 100%;
  height: auto;
  max-width: 580px;
  margin: var(--space-3) 0;
}

/* ───── Hero ──────────────────────────────────────────────────────────── */

#hero {
  text-align: center;
  padding: var(--space-5) 0 var(--space-4);
  border-bottom: 1px solid var(--rule);
}

#hero h1 {
  font-size: clamp(3rem, 10vw, 6rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: var(--space-1);
}

.tagline {
  font-size: 1.25rem;
  color: var(--muted);
  font-style: italic;
  margin-bottom: var(--space-4);
}

#hero .kbd-controls {
  margin-top: var(--space-2);
}

/* ───── Theme toggle ──────────────────────────────────────────────────── */

#theme-toggle {
  position: fixed;
  top: var(--space-2);
  left: var(--space-2);
  z-index: 100;
  width: 34px;
  height: 34px;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 120ms ease, border-color 120ms ease, transform 250ms ease;
}

#theme-toggle:hover {
  background: var(--rule);
  border-color: var(--ink);
  transform: rotate(180deg);
}

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

#theme-toggle svg {
  width: 16px;
  height: 16px;
}
