/* ==========================================================================
   Section 1 — Header
   Based on the original site's #header (glass bar, hamburger, mobile drawer),
   now with flat entry-point links and a theme toggle.
   Everything is prefixed .hd- and scoped to .hd / .hd-drawer.

   States (set by js/sections/header.js):
   .hd.is-scrolled    page scrolled past 10px      → frosted glass
   .hd.is-over-dark   a [data-header-tone="dark"]  → white-on-dark glass
                      section sits under the bar
   .hd.is-drawer-open mobile drawer open           → solid surface
   ========================================================================== */

.hd {
  /* Local tokens — light theme */
  --hd-bg:          rgba(255,255,255,0.12);
  --hd-bg-scrolled: rgba(255,255,255,0.72);
  --hd-bg-solid:    rgba(255,255,255,0.98);
  --hd-line:        rgba(0,0,0,0.05);
  --hd-link:        var(--text-secondary);
  --hd-link-hover:  var(--text-primary);
  --hd-link-bg:     rgba(10,47,107,0.06);   /* blue-800 tint — visible on white and on the glass */

  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: var(--z-header);
  height: var(--nav-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 var(--gutter);      /* aligns with the section container */
  background: var(--hd-bg);
  border-bottom: 1px solid transparent;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  transition:
    background var(--transition),
    border-color var(--transition),
    box-shadow var(--transition);
}

:root[data-theme="dark"] .hd {
  --hd-bg:          rgba(6,21,48,0.35);
  --hd-bg-scrolled: rgba(6,21,48,0.78);
  --hd-bg-solid:    rgba(6,21,48,0.98);
  --hd-line:        rgba(255,255,255,0.07);
  --hd-link-bg:     rgba(255,255,255,0.06);
}

/* Over a dark section (either theme) */
.hd.is-over-dark {
  --hd-bg:          rgba(6,26,64,0.35);
  --hd-bg-scrolled: rgba(6,26,64,0.35);
  --hd-line:        rgba(255,255,255,0.08);
  --hd-link:        rgba(255,255,255,0.8);
  --hd-link-hover:  #ffffff;
  --hd-link-bg:     rgba(255,255,255,0.08);
}

.hd.is-scrolled {
  background: var(--hd-bg-scrolled);
  border-bottom-color: var(--hd-line);
}

.hd.is-drawer-open {
  background: var(--hd-bg-solid);
  border-bottom-color: var(--border);
}

/* ─── Logo ──────────────────────────────────────────────────────────────
   Two images stacked: the brand wordmark, and a white version for dark
   theme / dark sections. CSS shows one.                                  */
.hd-logo {
  position: relative;
  display: block;
  flex-shrink: 0;
  line-height: 0;
  border-radius: var(--radius-sm);
}
.hd-logo img {
  height: 30px;
  width: auto;
  transition: opacity var(--transition);
}
.hd-logo-on-dark {
  position: absolute;
  top: 0; left: 0;
  opacity: 0;
}
:root[data-theme="dark"] .hd-logo-default,
.hd.is-over-dark .hd-logo-default { opacity: 0; }
:root[data-theme="dark"] .hd-logo-on-dark,
.hd.is-over-dark .hd-logo-on-dark { opacity: 1; }

/* ─── Desktop nav ─────────────────────────────────────────────────────── */
.hd-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
}

.hd-link {
  position: relative;
  display: flex;
  align-items: center;
  padding: 6px 12px;
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 400;
  white-space: nowrap;
  text-decoration: none;
  color: var(--hd-link);
  border-radius: var(--radius-sm);
  transition: background var(--transition), color var(--transition);
}
.hd-link:hover { background: var(--hd-link-bg); color: var(--hd-link-hover); }

/* Current page — small underline under the label */
.hd-link[aria-current="page"] { color: var(--hd-link-hover); font-weight: 500; }
.hd-link[aria-current="page"]::after {
  content: '';
  position: absolute;
  left: 12px; right: 12px; bottom: 1px;
  height: 1.5px;
  border-radius: 2px;
  background: currentColor;
}

.hd-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: 10px;
}

/* ─── Theme toggle ────────────────────────────────────────────────────── */
.hd-theme {
  position: relative;
  width: 34px; height: 34px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  padding: 0;
  color: var(--hd-link);
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  overflow: hidden;
  transition: color var(--transition), background var(--transition), border-color var(--transition);
}
.hd.is-over-dark .hd-theme { border-color: rgba(255,255,255,0.22); }
.hd-theme:hover { color: var(--hd-link-hover); background: var(--hd-link-bg); }

/* Both icons share the cell; the inactive one rotates out */
.hd-theme i {
  grid-area: 1 / 1;
  font-size: 17px;
  transition:
    transform 0.4s var(--ease-sweep),
    opacity 0.25s ease;
}
.hd-theme .hd-theme-sun  { opacity: 0; transform: rotate(-90deg) scale(0.6); }
.hd-theme .hd-theme-moon { opacity: 1; transform: none; }
:root[data-theme="dark"] .hd-theme .hd-theme-sun  { opacity: 1; transform: none; }
:root[data-theme="dark"] .hd-theme .hd-theme-moon { opacity: 0; transform: rotate(90deg) scale(0.6); }

/* ─── Hamburger ───────────────────────────────────────────────────────── */
.hd-burger {
  display: none;
  flex-direction: column;
  gap: 5px;
  padding: 6px;
  background: none;
  border: none;
  cursor: pointer;
}
.hd-burger span {
  display: block;
  width: 22px; height: 2px;
  border-radius: 2px;
  background: var(--hd-link-hover);
  transition: transform 0.22s ease, opacity 0.22s ease, background var(--transition);
}
.hd-burger[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hd-burger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.hd-burger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ─── Mobile drawer ───────────────────────────────────────────────────── */
.hd-drawer {
  position: fixed;
  top: var(--nav-height); left: 0; right: 0; bottom: 0;
  z-index: calc(var(--z-header) - 1);
  display: flex;
  flex-direction: column;
  padding: 16px var(--page-px) 40px;
  overflow-y: auto;
  background: var(--surface);
  border-top: 1px solid var(--border);

  /* closed — visibility also removes links from the tab order */
  visibility: hidden;
  opacity: 0;
  transform: translateY(-8px);
  transition:
    opacity 0.22s ease,
    transform 0.22s ease,
    visibility 0s linear 0.22s;
}
.hd-drawer.is-open {
  visibility: visible;
  opacity: 1;
  transform: translateY(0);
  transition-delay: 0s;
}

.hd-drawer-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 4px;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.3px;
  text-decoration: none;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
  transition: color var(--transition);
}
.hd-drawer-link i {
  font-size: 18px;
  color: var(--text-muted);
  transition: transform 0.26s var(--ease-sweep), color var(--transition);
}
.hd-drawer-link:hover { color: var(--accent-text); }
.hd-drawer-link:hover i { color: var(--accent-text); transform: translateX(4px); }
.hd-drawer-link[aria-current="page"] { color: var(--accent-text); }

.hd-drawer-cta { margin-top: 28px; padding: 14px 24px; font-size: 15px; }

/* ─── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 960px) {
  .hd-nav { display: none; }
  .hd-burger { display: flex; }
  .hd-actions { margin-left: auto; }
  .hd-actions .hd-cta { display: none; }
}
@media (min-width: 961px) {
  .hd-drawer { display: none; }
}
@media (max-width: 600px) {
  .hd-logo img { height: 26px; }
}
