/* ============================================================
   SPIRARE — design tokens & theme
   "to breathe" — quiet, unhurried, tech-forward monochrome
   ============================================================ */

/* ---- Fonts ---- */
@import url('https://fonts.googleapis.com/css2?family=Hanken+Grotesk:ital,wght@0,300..800;1,300..800&family=IBM+Plex+Mono:ital,wght@0,300;0,400;0,500;0,600;1,400&family=Newsreader:ital,opsz,wght@0,6..72,300..600;1,6..72,300..600&family=Spectral:ital,wght@0,300;0,400;0,500;1,400&display=swap');

:root {
  /* accent is injected by JS (tweakable); fallback electric lime */
  --accent: #d8e84a;

  /* type families — overridden per pairing */
  --font-body: 'Hanken Grotesk', system-ui, sans-serif;
  --font-ui: 'IBM Plex Mono', ui-monospace, monospace;
  --font-display: 'IBM Plex Mono', ui-monospace, monospace;

  --reading-width: 40rem;       /* ~640px reading column */
  --page-width: 60rem;
  --pad-x: clamp(1.25rem, 5vw, 3rem);
}

/* ============================================================
   THEMES
   ============================================================ */
[data-theme="dark"] {
  --bg:        #0b0c0e;
  --bg-deep:   #08090a;
  --surface:   #111316;
  --surface-2: #16181c;
  --hairline:  rgba(255,255,255,0.09);
  --hairline-strong: rgba(255,255,255,0.16);
  --ink:       #e9eaec;
  --ink-soft:  #b6b9be;
  --ink-muted: #7d8086;
  --ink-faint: #54575c;
  --accent-text: var(--accent);
  --trace:     rgba(216,232,74,0.0);  /* set via intensity */
  color-scheme: dark;
}

[data-theme="light"] {
  --bg:        #f5f6f7;
  --bg-deep:   #eceef0;
  --surface:   #ffffff;
  --surface-2: #fafbfc;
  --hairline:  rgba(10,12,16,0.11);
  --hairline-strong: rgba(10,12,16,0.20);
  --ink:       #14161a;
  --ink-soft:  #3b3f45;
  --ink-muted: #62666d;
  --ink-faint: #9b9fa6;
  --accent-text: color-mix(in srgb, var(--accent) 62%, #16180a);
  --trace:     rgba(216,232,74,0.0);
  color-scheme: light;
}

/* circuit-trace visibility scales with intensity tweak */
[data-circuit="whisper"]   { --trace-strong: 0.32; --trace-soft: 0.10; --node-on: 0; }
[data-circuit="subtle"]    { --trace-strong: 0.55; --trace-soft: 0.18; --node-on: 1; }
[data-circuit="signature"] { --trace-strong: 0.85; --trace-soft: 0.30; --node-on: 1; }

/* ============================================================
   TYPE PAIRINGS (tweakable)
   ============================================================ */
[data-pairing="grotesk"] {
  --font-body: 'Hanken Grotesk', system-ui, sans-serif;
  --font-ui: 'IBM Plex Mono', ui-monospace, monospace;
  --font-display: 'IBM Plex Mono', ui-monospace, monospace;
  --display-tracking: -0.02em;
  --display-weight: 500;
  --body-size: 1.1875rem;
  --body-lh: 1.72;
}
[data-pairing="serif"] {
  --font-body: 'Spectral', Georgia, serif;
  --font-ui: 'IBM Plex Mono', ui-monospace, monospace;
  --font-display: 'IBM Plex Mono', ui-monospace, monospace;
  --display-tracking: -0.01em;
  --display-weight: 500;
  --body-size: 1.25rem;
  --body-lh: 1.74;
}
[data-pairing="editorial"] {
  --font-body: 'Newsreader', Georgia, serif;
  --font-ui: 'Hanken Grotesk', system-ui, sans-serif;
  --font-display: 'Newsreader', Georgia, serif;
  --display-tracking: -0.015em;
  --display-weight: 500;
  --body-size: 1.3125rem;
  --body-lh: 1.7;
}

/* ============================================================
   RESET / BASE
   ============================================================ */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
::selection { background: var(--accent); color: #0b0c0e; }

a { color: inherit; text-decoration: none; }

.app {
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  transition: background 0.5s ease, color 0.5s ease;
  position: relative;
  overflow-x: clip;
}

/* faint ambient grain/vignette for atmosphere */
.app::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(120% 80% at 50% -10%, rgba(255,255,255,0.025), transparent 60%);
  z-index: 0;
}
[data-theme="light"] .app::before {
  background: radial-gradient(120% 80% at 50% -10%, rgba(10,12,16,0.03), transparent 60%);
}

.shell {
  position: relative;
  z-index: 1;
  max-width: var(--page-width);
  margin: 0 auto;
  padding: 0 var(--pad-x);
}

/* ============================================================
   HEADER
   ============================================================ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(14px) saturate(120%);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  border-bottom: 1px solid var(--hairline);
}
.site-header__inner {
  max-width: var(--page-width);
  margin: 0 auto;
  padding: 1.05rem var(--pad-x);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

/* circuit trace running under the header */
.header-trace {
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 22px;
  pointer-events: none;
  color: var(--accent);
}
.header-trace svg { width: 100%; height: 100%; display: block; }

/* ---- wordmark ---- */
.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-ui);
  font-weight: 500;
  letter-spacing: 0.02em;
  font-size: 1.02rem;
  color: var(--ink);
  cursor: pointer;
}
.wordmark__node {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 60%, transparent);
  flex: none;
}
[data-wordmark="dot"] .wordmark__bracket { display: none; }
[data-wordmark="bracket"] .wordmark__node { display: none; }
[data-wordmark="bracket"] .wordmark__bracket {
  color: var(--accent);
  font-weight: 400;
  opacity: 0.9;
}
[data-wordmark="stamp"] .wordmark__node { display: none; }
[data-wordmark="stamp"] .wordmark__bracket { display: none; }
[data-wordmark="stamp"] .wordmark__name {
  border: 1px solid var(--hairline-strong);
  padding: 0.22rem 0.6rem;
  border-radius: 3px;
  letter-spacing: 0.16em;
  text-transform: lowercase;
  font-size: 0.82rem;
}
.wordmark__name { transition: letter-spacing 0.4s ease; line-height: 1; }
.wordmark__tag {
  font-size: 0.62rem;
  line-height: 1;
  color: var(--ink-faint);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  margin-left: 0.1rem;
  position: relative;
  top: 0.5px;
}
@media (max-width: 560px) { .wordmark__tag { display: none; } }

/* breathing animation on the node */
@media (prefers-reduced-motion: no-preference) {
  .wordmark__node {
    animation: breathe 5.5s ease-in-out infinite;
  }
}
@keyframes breathe {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent); opacity: 0.92; }
  50%      { box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 0%, transparent); opacity: 1; }
}

/* ---- nav ---- */
.nav {
  display: flex;
  align-items: center;
  gap: clamp(0.9rem, 3vw, 1.9rem);
  font-family: var(--font-ui);
  font-size: 0.82rem;
  letter-spacing: 0.02em;
}
.nav a {
  color: var(--ink-muted);
  position: relative;
  padding: 0.2rem 0;
  transition: color 0.25s ease;
}
.nav a:hover { color: var(--ink); }
.nav a.is-active { color: var(--ink); }
.nav a.is-active::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -2px;
  height: 2px;
  background: var(--accent);
}

/* ---- theme toggle (a node that switches state) ---- */
.toggle {
  --w: 52px; --h: 26px;
  width: var(--w); height: var(--h);
  border-radius: 999px;
  border: 1px solid var(--hairline-strong);
  background: var(--surface-2);
  position: relative;
  cursor: pointer;
  padding: 0;
  flex: none;
  transition: border-color 0.3s ease, background 0.3s ease;
}
.toggle:hover { border-color: var(--accent); }
.toggle__knob {
  position: absolute;
  top: 50%;
  left: 3px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--ink-soft);
  transform: translateY(-50%);
  transition: left 0.35s cubic-bezier(.6,.1,.3,1), background 0.3s ease;
  display: grid;
  place-items: center;
}
[data-theme="light"] .toggle__knob { left: calc(var(--w) - 21px); background: var(--accent); }
.toggle__knob::after {
  content: "";
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--bg);
}
.toggle__track-line {
  position: absolute;
  top: 50%; left: 26px; right: 7px;
  height: 1px;
  transform: translateY(-50%);
  background: repeating-linear-gradient(90deg, var(--ink-faint) 0 3px, transparent 3px 6px);
  opacity: 0.6;
}
[data-theme="light"] .toggle__track-line { left: 7px; right: 26px; }

/* ============================================================
   GENERIC: section divider with circuit node
   ============================================================ */
.trace-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 3.5rem 0;
  color: var(--accent);
}
.trace-divider::before, .trace-divider::after {
  content: "";
  height: 1px;
  flex: 1;
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--ink) 18%, transparent),
    color-mix(in srgb, var(--ink) 5%, transparent));
}
.trace-divider__node {
  width: 7px; height: 7px;
  border: 1px solid var(--accent);
  border-radius: 50%;
  opacity: calc(0.4 + var(--node-on) * 0.6);
}
.trace-divider__node--filled { background: var(--accent); opacity: var(--node-on); }

/* divider — wave glyph */
.trace-divider .divider-glyph { display: block; }
/* divider — measure ticks */
.divider-measure { display: inline-flex; align-items: flex-end; gap: 3px; height: 12px; }
.divider-measure i { width: 1px; height: 7px; background: var(--accent); opacity: 0.55; }
.divider-measure i.maj { height: 12px; opacity: calc(0.55 + var(--node-on)*0.45); }
/* divider — minimal diamond */
.divider-diamond {
  width: 6px; height: 6px; background: var(--accent);
  transform: rotate(45deg);
  opacity: calc(0.45 + var(--node-on)*0.55);
}

.label {
  font-family: var(--font-ui);
  font-size: 0.7rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
