/*
 * This site's look: every colour, font, corner and space, as CSS variables.
 * site.css uses only var(--...) from here, so a new look is a change to this file alone.
 *
 * Themes: each block below is one. A page names the site's own theme on <html data-theme="...">;
 * the visitor can pick another from "Theme" in the header (js/theme.js remembers it). "Like this
 * device" removes the attribute, and the first two blocks follow the device's light or dark setting.
 * To add a theme: copy a block, rename it, change its values, and add it to the <select> in each
 * page's header (npm run sync copies index.html's header to every page).
 */

/* Shared by every theme: type, shape and space. */
:root {
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-heading: var(--font-body);
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* Type sizes grow with the screen, from phone to desktop, in rem so the browser's text size scales them. */
  --step--1: clamp(0.83rem, 0.8rem + 0.15vw, 0.9rem);
  --step-0: clamp(1rem, 0.96rem + 0.2vw, 1.125rem);
  --step-1: clamp(1.2rem, 1.1rem + 0.45vw, 1.45rem);
  --step-2: clamp(1.45rem, 1.25rem + 0.9vw, 1.9rem);
  --step-3: clamp(1.75rem, 1.4rem + 1.6vw, 2.6rem);
  --step-4: clamp(2.1rem, 1.5rem + 2.8vw, 3.6rem);
  --leading: 1.6;

  /* The box a run-<app>.html page builds in: white on black in every theme, like a terminal. */
  --color-console-bg: #000;
  --color-console-text: #fff;

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2.5rem;
  --space-7: clamp(2.5rem, 1.5rem + 5vw, 5rem);

  --radius: 0.5rem;
  --radius-lg: 1rem;
  --page: 72rem;      /* widest the page gets */
  --measure: 40rem;   /* widest a column of reading text gets */
  --gutter: clamp(1rem, 0.5rem + 2.5vw, 2rem);
}

/* Paper: light. Also the device's light setting. */
:root,
[data-theme="paper"] {
  color-scheme: light;
  --color-bg: #fbfaf7;
  --color-surface: #f0eee8;
  --color-text: #1c1c1a;
  --color-muted: #5a5a55;
  --color-border: #d9d6cc;
  --color-accent: #1f5f8b;
  --color-on-accent: #ffffff;
  --color-focus: #c2410c;
}

/* Night: dark. Also the device's dark setting, when the page names no theme. */
[data-theme="night"] {
  color-scheme: dark;
  --color-bg: #121416;
  --color-surface: #1d2125;
  --color-text: #e8e6e1;
  --color-muted: #a5a39d;
  --color-border: #33383d;
  --color-accent: #7cb8e4;
  --color-on-accent: #0b0c0d;
  --color-focus: #fdba74;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --color-bg: #121416;
    --color-surface: #1d2125;
    --color-text: #e8e6e1;
    --color-muted: #a5a39d;
    --color-border: #33383d;
    --color-accent: #7cb8e4;
    --color-on-accent: #0b0c0d;
    --color-focus: #fdba74;
  }
}

/* Forest: greens and a serif for headings. */
[data-theme="forest"] {
  color-scheme: light;
  --color-bg: #f5f7f2;
  --color-surface: #e6ece0;
  --color-text: #1b2a1f;
  --color-muted: #4d5f50;
  --color-border: #c7d3c0;
  --color-accent: #2d6a3e;
  --color-on-accent: #ffffff;
  --color-focus: #a16207;
  --font-heading: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}

/* Ember: warm and dark. */
[data-theme="ember"] {
  color-scheme: dark;
  --color-bg: #1a1411;
  --color-surface: #261d18;
  --color-text: #f3e9e1;
  --color-muted: #bfae9f;
  --color-border: #44352c;
  --color-accent: #f29a5c;
  --color-on-accent: #1a1411;
  --color-focus: #fde68a;
  --radius: 0.25rem;
  --radius-lg: 0.5rem;
}

/* Contrast: black on white, heavy lines, for reading in bright light or with low vision. */
[data-theme="contrast"] {
  color-scheme: light;
  --color-bg: #ffffff;
  --color-surface: #ffffff;
  --color-text: #000000;
  --color-muted: #222222;
  --color-border: #000000;
  --color-accent: #0000c8;
  --color-on-accent: #ffffff;
  --color-focus: #c80000;
  --radius: 0;
  --radius-lg: 0;
}
