/* ========================================
   PAGE HEADER / SITE NAV
   Single bar used on every page:
     .header-home    — logo → index.html
     .header-wordmark — "Howdy, Stranger" (hidden on small screens)
     .header-nav     — page-title links (Numbers / Media / Docs)
     .dark-mode-toggle — sun/moon button
   Active page link gets aria-current="page" + .active class.
   ======================================== */

.page-header {
  position: sticky;
  top: 0;
  z-index: 5000;
  display: flex;
  align-items: center;
  width: 100%;
  background: var(--bg-primary);
  padding-inline: var(--content-padding, 1rem);
  padding-top: clamp(0.6rem, 1.8vw, 0.9rem);
  padding-bottom: clamp(0.6rem, 1.8vw, 0.9rem);
  max-width: 100%;
  /* needed so absolute .header-nav centers against the full bar */
  isolation: isolate;
}

/* ── Logo ── */
.header-home {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  text-decoration: none;
  border-radius: 50%;
}

.header-home img {
  display: block;
  border-radius: 50%;
  width: clamp(32px, 5.5vw, 42px);
  height: clamp(32px, 5.5vw, 42px);
  border: 2px solid var(--border-color);
  transition: border-color 0.2s ease;
}

.header-home:hover img,
.header-home:focus-visible img {
  border-color: var(--color-secondary, #d4822a);
}

.header-home:focus-visible { outline: none; }

/* ── Wordmark ── */
.header-wordmark {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(0.8rem, 2vw, 0.95rem);
  font-weight: 700;
  color: var(--text-secondary);
  letter-spacing: 0.01em;
  white-space: nowrap;
  flex-shrink: 1;
  min-width: 0;
}

/* ── Nav links (page titles) — absolutely centered in bar ── */
.header-nav {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: clamp(0.15rem, 1vw, 0.5rem);
  list-style: none;
  margin: 0;
  padding: 0;
  pointer-events: auto;
}

.header-nav-link {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.5rem;
  border-radius: var(--control-radius, 6px);
  text-decoration: none;
  font-family: var(--font-mono, monospace);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-secondary);
  transition: color 0.15s ease;
  white-space: nowrap;
}

.header-nav-link img {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  opacity: 0.75;
  flex-shrink: 0;
}

.header-nav-link:hover {
  color: var(--text-primary);
  opacity: 1;
}

.header-nav-link:hover img {
  opacity: 1;
}

.header-nav-link.active {
  color: var(--text-primary);
  position: relative;
}

.header-nav-link.active img {
  opacity: 1;
}

/* Active underline */
.header-nav-link.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0.5rem;
  right: 0.5rem;
  height: 2px;
  background: var(--color-secondary, #d4822a);
  border-radius: 1px;
}

.header-nav-link:focus-visible {
  outline: 2px solid var(--color-secondary, #d4822a);
  outline-offset: 2px;
}

/* ── Dark mode toggle — far right ── */
.dark-mode-toggle {
  flex-shrink: 0;
  margin-left: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  min-width: 44px;
  padding: 0.25rem;
  border: none;
  border-radius: var(--control-radius, 8px);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
}

.dark-mode-toggle-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  width: clamp(24px, 4.5vw, 30px);
  height: clamp(24px, 4.5vw, 30px);
  border: 1.5px solid var(--border-color);
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.dark-mode-toggle-icon svg {
  width: 14px;
  height: 14px;
}

.dark-mode-toggle:hover .dark-mode-toggle-icon,
.dark-mode-toggle:focus-visible .dark-mode-toggle-icon {
  border-color: var(--color-secondary, #d4822a);
  transform: scale(1.08);
}

.dark-mode-toggle:focus-visible { outline: none; }

/* Sun/moon swap */
.dark-mode-toggle-icon .sun-icon,
.dark-mode-toggle-icon .moon-icon {
  transition: opacity 0.25s ease;
}
.dark-mode-toggle-icon .sun-icon  { opacity: 1; }
.dark-mode-toggle-icon .moon-icon { opacity: 0; }
html.dark-mode .dark-mode-toggle-icon .sun-icon  { opacity: 0; }
html.dark-mode .dark-mode-toggle-icon .moon-icon { opacity: 1; }

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 540px) {
  .header-wordmark { display: none; }
  .header-nav-link img { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .dark-mode-toggle-icon .sun-icon,
  .dark-mode-toggle-icon .moon-icon,
  .dark-mode-toggle-icon,
  .header-home img { transition: none; }
}
