/*!
 * theme-tokens.css — v1.0 (2026-05-11)
 *
 * The token contract. Any page that participates in the theme standard must:
 *   1. Link this stylesheet.
 *   2. Reference these tokens only — never hard-code color, font, or size.
 *
 * Themes (in themes.js) write to these tokens. That is the entire mechanism.
 */

:root {
  /* ---- surface ---------------------------------------------------------- */
  --bg: #0a1045;
  --bg-attachment: fixed;
  --card-meta-bg: rgba(10,16,69,0.92);
  --panel-bg: linear-gradient(180deg, rgba(18,26,103,0.55), rgba(10,16,69,0.85));
  --panel-blur: blur(14px);

  /* ---- ink (foreground text) ------------------------------------------- */
  --ink: #e9ecf7;
  --ink-2: #b6bde0;
  --ink-3: rgba(230,236,247,0.5);

  /* ---- structure -------------------------------------------------------- */
  --border: rgba(86,104,224,0.22);
  --border-strong: rgba(86,104,224,0.5);
  --panel-border: rgba(86,104,224,0.28);
  --radius: 14px;
  --radius-pill: 999px;

  /* ---- accent ----------------------------------------------------------- */
  --accent: #5668e0;
  --accent-2: #0006aa;

  /* ---- typography ------------------------------------------------------- */
  --font-display: 'Inter', system-ui, -apple-system, sans-serif;
  --font-body:    'Inter', system-ui, -apple-system, sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, monospace;

  --hero-size: 56px;
  --hero-weight: 600;
  --hero-lh: 1.06;
  --hero-tracking: -0.025em;
  --hero-style: normal;
  --hero-case: none;

  --body-size: 17px;
  --body-weight: 400;
  --body-tracking: -0.003em;

  --eyebrow-color: var(--accent);
  --eyebrow-tracking: 0.18em;

  /* ---- cta -------------------------------------------------------------- */
  --cta-bg: var(--accent-2);
  --cta-color: #fff;
  --cta-border: var(--accent-2);
  --cta-radius: 999px;
  --cta-shadow: 0 8px 24px rgba(0,6,170,0.4);

  /* ---- motion ----------------------------------------------------------- */
  --motion: 400ms;
}

/* ----- reset + base ------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { color-scheme: dark; }
body {
  background: var(--bg);
  background-attachment: var(--bg-attachment);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--body-size);
  font-weight: var(--body-weight);
  letter-spacing: var(--body-tracking);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  transition: background var(--motion) ease, color var(--motion) ease;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: var(--hero-weight);
  letter-spacing: var(--hero-tracking);
  font-style: var(--hero-style);
  text-transform: var(--hero-case);
  margin: 0 0 0.5em;
  transition: color var(--motion) ease;
}
h1 { font-size: var(--hero-size); line-height: var(--hero-lh); }
h2 { font-size: calc(var(--hero-size) * 0.6); line-height: 1.15; }
h3 { font-size: calc(var(--hero-size) * 0.4); line-height: 1.25; }

.eyebrow {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: var(--eyebrow-tracking);
  text-transform: uppercase;
  color: var(--eyebrow-color);
  transition: color var(--motion) ease;
}

.cta, button.cta, a.cta {
  display: inline-block;
  background: var(--cta-bg);
  color: var(--cta-color);
  border: 1px solid var(--cta-border);
  border-radius: var(--cta-radius);
  padding: 12px 22px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
  box-shadow: var(--cta-shadow);
  text-decoration: none;
  cursor: pointer;
  transition: transform 200ms ease, box-shadow 200ms ease, background var(--motion) ease;
}
.cta:hover { transform: translateY(-2px); }

/* ====================================================================
   THEME TOGGLER — auto-injected nav UI. Themed by the token contract.
   ==================================================================== */
[data-theme-toggle] {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
}
[data-theme-toggle].theme-toggle-floating {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9999;
}
.theme-toggle__cycle,
.theme-toggle__open {
  background: rgba(255,255,255,0.06);
  color: var(--ink);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1;
  padding: 8px 12px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  letter-spacing: 0.05em;
  transition: background var(--motion) ease, border-color var(--motion) ease, color var(--motion) ease, transform 150ms ease;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.theme-toggle__cycle:hover,
.theme-toggle__open:hover {
  background: rgba(255,255,255,0.12);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}
.theme-toggle__open { padding: 8px 10px; }
.theme-toggle__glyph { font-size: 14px; }
.theme-toggle__label {
  text-transform: capitalize;
  letter-spacing: 0;
  max-width: 16ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- picker overlay ---- */
.theme-picker {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
}
.theme-picker[hidden] { display: none; }
.theme-picker__scrim {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 200ms ease;
}
.theme-picker.is-open .theme-picker__scrim { opacity: 1; }
.theme-picker__panel {
  position: relative;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  backdrop-filter: var(--panel-blur);
  -webkit-backdrop-filter: var(--panel-blur);
  border-radius: 18px;
  padding: 24px;
  width: min(680px, 92vw);
  max-height: 80vh;
  overflow-y: auto;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 220ms ease, transform 220ms cubic-bezier(0.2,0.8,0.2,1);
}
.theme-picker.is-open .theme-picker__panel { opacity: 1; transform: none; }
.theme-picker__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  font: 500 11px/1 var(--font-mono);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--eyebrow-color);
}
.theme-picker__close {
  background: transparent;
  border: 0;
  color: var(--ink-2);
  cursor: pointer;
  font-size: 14px;
  padding: 4px 8px;
}
.theme-picker__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}
.theme-swatch {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--ink);
  padding: 12px;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  transition: border-color var(--motion) ease, background var(--motion) ease;
}
.theme-swatch:hover { border-color: var(--border-strong); background: rgba(255,255,255,0.04); }
.theme-swatch.is-active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.theme-swatch__chips {
  display: inline-flex;
  gap: 4px;
}
.theme-swatch__chips i {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.08);
}
.theme-swatch__name { letter-spacing: -0.005em; }

/* Honour prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
  body, h1, h2, h3, h4, .eyebrow, .cta,
  .theme-toggle__cycle, .theme-toggle__open,
  .theme-picker__scrim, .theme-picker__panel,
  .theme-swatch { transition: none !important; }
}
