/* =========================================================
   HEADER — Frosted bar, underline-only active indicator
   ========================================================= */

/* ---------- Bar ---------- */
.site-header {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--header-h, 56px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(16px, 2vw, 32px);
  z-index: 100;

  background: color-mix(in srgb, var(--bg-primary) 72%, transparent);
  backdrop-filter: blur(14px) saturate(1.6);
  -webkit-backdrop-filter: blur(14px) saturate(1.6);
  border-bottom: 1px solid color-mix(in srgb, var(--border-primary) 50%, transparent);
}

/* ---------- Brand ---------- */
.brand {
  display: flex;
  align-items: center;
  text-decoration: none;
  color: var(--text-primary);
  flex-shrink: 0;
  padding: 6px 0;
}

.brand-name {
  font-family: var(--font-display, 'Syne', sans-serif);
  font-weight: 800;
  font-size: clamp(17px, 1.35vw, 22px);
  letter-spacing: -0.03em;
  line-height: 1;
  transition: color 0.15s ease;
}

.brand-dot {
  font-family: var(--font-display, 'Syne', sans-serif);
  font-weight: 800;
  font-size: clamp(17px, 1.35vw, 22px);
  color: var(--accent);
  line-height: 1;
}

.brand:hover .brand-name { color: var(--accent); }

.brand:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 4px;
}

/* ---------- Nav ---------- */
.nav {
  display: flex;
  align-items: center;
  gap: clamp(8px, 1.2vw, 20px);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 2px;
}

/* ---------- Nav link ---------- */
.nav-links a {
  position: relative;
  text-decoration: none;
  color: var(--text-muted);
  font-family: var(--font-body, 'Instrument Sans', sans-serif);
  font-size: clamp(12px, 0.88vw, 14px);
  font-weight: 500;
  padding: 6px 10px;
  border-radius: 6px;
  white-space: nowrap;
  transition: color 0.15s ease;
}

.nav-links a:hover {
  color: var(--text-primary);
}

.nav-links a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---- Active state: accent underline ---- */
.nav-links a::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 10px;
  right: 10px;
  height: 2px;
  background: var(--accent);
  border-radius: 1px;
  transform: scaleX(0);
  transition: transform 0.2s ease;
}

.nav-links a.is-active {
  color: var(--text-primary);
}

.nav-links a.is-active::after {
  transform: scaleX(1);
}

/* ---------- Actions (GitHub + divider + theme) ---------- */
.nav-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: clamp(4px, 0.8vw, 12px);
}

.nav-divider {
  width: 1px;
  height: 18px;
  background: var(--border-primary);
  margin: 0 4px;
  opacity: 0.5;
}

.nav-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  line-height: 0;
  color: var(--text-muted);
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.nav-icon-btn:hover {
  background: var(--hover-overlay);
  border-color: var(--border-primary);
  transform: translateY(-1px);
}

.nav-icon-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- GitHub ---------- */
.nav-github .gh {
  width: 18px;
  height: 18px;
  display: block;
  opacity: 0.7;
  transition: opacity 0.15s ease;
}
.nav-github:hover .gh { opacity: 1; }
:root[data-theme="light"] .nav-github .gh { filter: none; }
:root[data-theme="dark"] .nav-github .gh { filter: brightness(0) invert(1); }

/* ---------- Theme toggle (animated sun/moon) ---------- */
.theme-toggle {
  position: relative;
}

.theme-icon {
  width: 20px;
  height: 20px;
  color: var(--text-muted);
  transition: color 0.3s ease;
  overflow: visible;
}

.theme-toggle:hover .theme-icon {
  color: var(--text-primary);
}

/* Sun core → Moon body */
.theme-icon__core {
  fill: none;
  stroke: currentColor;
  transform-origin: center;
  transition: r 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
              transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
              fill 0.3s ease;
}

/* Sun rays */
.theme-icon__rays {
  stroke: currentColor;
  transform-origin: center;
  transition: opacity 0.25s ease, transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Moon crescent (clip illusion) */
.theme-icon__crescent {
  fill: var(--bg-primary);
  stroke: none;
  transform-origin: center;
  transition: cx 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
              r 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
              fill 0.3s ease;
}

/* ---- LIGHT MODE: Show sun ---- */
:root[data-theme="light"] .theme-icon__core {
  r: 5;
  transform: rotate(0deg) scale(1);
}

:root[data-theme="light"] .theme-icon__rays {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

:root[data-theme="light"] .theme-icon__crescent {
  cx: 24;
  r: 0;
}

/* ---- DARK MODE: Show moon ---- */
:root[data-theme="dark"] .theme-icon__core {
  r: 6;
  transform: rotate(-45deg) scale(1);
  fill: currentColor;
}

:root[data-theme="dark"] .theme-icon__rays {
  opacity: 0;
  transform: rotate(60deg) scale(0);
}

:root[data-theme="dark"] .theme-icon__crescent {
  cx: 16;
  r: 4;
  fill: var(--bg-primary);
}

/* ---------- Palette toggle ---------- */
.palette-toggle .icon-palette {
  width: 18px;
  height: 18px;
  opacity: 0.7;
  color: var(--text-muted);
  transition: opacity 0.15s ease, transform 0.3s ease;
}
.palette-toggle:hover .icon-palette {
  opacity: 1;
  transform: rotate(25deg);
}
:root[data-theme="dark"] .palette-toggle .icon-palette { color: var(--text-muted); }
:root[data-theme="light"] .palette-toggle .icon-palette { color: var(--text-muted); }