/* ============================================
   THEME — dark-mode token overrides + toggle UI
   Light values live inline in each page's :root;
   this file carries only what changes at night.
   ============================================ */

:root { color-scheme: light; }

html[data-theme="dark"] {
  color-scheme: dark;
  --paper: #121216;
  --panel: #1A1A20;
  --panel-tint: #16161B;
  --ink: #EDEDEA;
  --ink-soft: #C6C6CC;
  --ink-muted: #9A9AA3;
  --hairline: #26262C;
  --hairline-strong: #34343C;
  --signal: #7B96FF;
  --signal-soft: rgba(123, 150, 255, 0.14);
  --ok: #2FBD87;
  --ok-soft: rgba(47, 189, 135, 0.35);
  --grid-major: rgba(235, 235, 234, 0.045);
  --grid-minor: rgba(235, 235, 234, 0.025);
  --nav-frost: rgba(18, 18, 22, 0.82);
  --selection-ink: #121216;
  --recess: #1F1F26;
  --shadow-rgb: 0, 0, 0;
  --stamp-border: rgba(123, 150, 255, 0.55);
  --stamp-bg: rgba(18, 18, 22, 0.7);
}

/* ============================================
   TOGGLE
   ============================================ */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ink-muted);
  transition: color 0.25s ease;
}

.theme-toggle:hover { color: var(--ink); }

/* Some pages only style a:focus-visible — give the button its own ring */
.theme-toggle:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 3px;
  border-radius: 2px;
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Light shows the moon (what you'd switch to), dark shows the sun.
   data-theme is set pre-paint, so the right icon renders first try. */
html[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
html:not([data-theme="dark"]) .theme-toggle .icon-sun { display: none; }

/* Groups a minimal nav's back-link with the toggle so the
   two-child space-between layout on blog pages is preserved */
.nav-actions {
  display: flex;
  align-items: center;
  gap: 1.1rem;
}

/* 404 has no nav — pin the toggle to the corner instead */
.theme-toggle--floating {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1000;
  background: var(--panel);
  border: 1px solid var(--hairline-strong);
  border-radius: 2px;
}

/* ============================================
   UTILITIES — shared by every page
   ============================================ */

/* Visually hidden, still read by screen readers.
   Used for the "(opens in new tab)" cue on target="_blank" links. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
