/*
  Shared colour palettes and font styles.
  Each page sets its defaults on <html data-palette="…" data-font="…">.
  theme-picker.js sets data-mode="light|dark" and lets the visitor override palette and font.
  Pages style themselves only with these variables, so every palette works on every page.
*/

:root {
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-display: var(--font-body);
}
:root[data-font="serif"] {
  --font-body: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --font-display: var(--font-body);
}
:root[data-font="rounded"] {
  --font-body: ui-rounded, "SF Pro Rounded", "Nunito", -apple-system, "Segoe UI", sans-serif;
  --font-display: var(--font-body);
}
:root[data-font="mono"] {
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-display: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

/* ocean (also the fallback when no palette is set) */
:root, :root[data-palette="ocean"] {
  --bg: #fbfaf8; --surface: #ffffff; --text: #1d1c1a; --muted: #6b6760;
  --border: #e7e3dc; --accent: #2f5d8a; --accent-ink: #ffffff; --tag: #eef2f6;
  color-scheme: light;
}
:root[data-mode="dark"], :root[data-palette="ocean"][data-mode="dark"] {
  --bg: #141413; --surface: #1c1c1a; --text: #ecebe7; --muted: #a19d95;
  --border: #2e2d2a; --accent: #8cb4dc; --accent-ink: #141413; --tag: #23282e;
  color-scheme: dark;
}

:root[data-palette="sage"] {
  --bg: #f6f7f2; --surface: #ffffff; --text: #1e231d; --muted: #5d665a;
  --border: #dfe3d8; --accent: #45663f; --accent-ink: #ffffff; --tag: #e6ede1;
}
:root[data-palette="sage"][data-mode="dark"] {
  --bg: #121511; --surface: #1a1e19; --text: #e8ece4; --muted: #9ea79a;
  --border: #2b3229; --accent: #9cc293; --accent-ink: #121511; --tag: #233021;
}

:root[data-palette="terracotta"] {
  --bg: #fbf6f1; --surface: #ffffff; --text: #2a1f1a; --muted: #6f5e54;
  --border: #ecdfd4; --accent: #a84b28; --accent-ink: #ffffff; --tag: #f6e6dc;
}
:root[data-palette="terracotta"][data-mode="dark"] {
  --bg: #17120f; --surface: #201915; --text: #f1e8e1; --muted: #b09c8f;
  --border: #352a23; --accent: #e8906b; --accent-ink: #17120f; --tag: #33241c;
}

:root[data-palette="plum"] {
  --bg: #faf7fb; --surface: #ffffff; --text: #231c27; --muted: #685d6e;
  --border: #e8e0ec; --accent: #74398a; --accent-ink: #ffffff; --tag: #f1e6f5;
}
:root[data-palette="plum"][data-mode="dark"] {
  --bg: #151118; --surface: #1d1821; --text: #eee7f1; --muted: #a99cb0;
  --border: #322a37; --accent: #c99ad9; --accent-ink: #151118; --tag: #2d2234;
}

:root[data-palette="mono"] {
  --bg: #ffffff; --surface: #f6f6f6; --text: #111111; --muted: #5f5f5f;
  --border: #e3e3e3; --accent: #111111; --accent-ink: #ffffff; --tag: #efefef;
}
:root[data-palette="mono"][data-mode="dark"] {
  --bg: #0d0d0d; --surface: #171717; --text: #f2f2f2; --muted: #9a9a9a;
  --border: #2a2a2a; --accent: #f2f2f2; --accent-ink: #0d0d0d; --tag: #222222;
}

/* ---------- theme picker widget ---------- */

.tp-toggle {
  position: fixed; right: 16px; bottom: 16px; z-index: 50;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: 600 14px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.12); cursor: pointer;
}
.tp-toggle .tp-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--accent); }

.tp-panel {
  position: fixed; right: 16px; bottom: 68px; z-index: 50;
  width: min(300px, calc(100vw - 32px));
  padding: 16px; border-radius: 14px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: 14px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  box-shadow: 0 12px 32px rgb(0 0 0 / 0.18);
}
.tp-panel[hidden] { display: none; }
.tp-panel h2 {
  margin: 0 0 8px; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); font-family: inherit;
}
.tp-group + .tp-group { margin-top: 14px; }
.tp-row { display: flex; flex-wrap: wrap; gap: 6px; }
.tp-panel button {
  font: inherit; color: var(--text); background: var(--bg); cursor: pointer;
  border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px;
}
.tp-panel button[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.tp-swatch { display: inline-flex; align-items: center; gap: 6px; }
.tp-swatch i { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.tp-reset { margin-top: 14px; width: 100%; }
.tp-hub { display: block; margin-top: 12px; text-align: center; color: var(--accent); font-weight: 600; text-decoration: none; }
.tp-hub:hover { text-decoration: underline; }
.tp-panel button:focus-visible, .tp-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media print { .tp-toggle, .tp-panel { display: none; } }
