/* ───────────────────────────────────────────────────────────────────────────
   PHC 2026 — shared sub-page header ("chrome")

   Used by /phc2026/{bento,figures,organic,immersive}. One harmonised bar: the
   signature gradient logo-mark (links home to /phc2026/), the page name, and a
   slot of page-specific icon controls (theme toggle, fullscreen, lens chip …).

   Self-contained + theme-reactive: it follows each page's html[data-theme] and
   carries its own copy of the signature gradient, so the logo always renders
   even on pages that don't define --phc-grad. Link this AFTER the page's own
   stylesheet so .phc-subhead-btn wins over each page's original button chrome.
   ───────────────────────────────────────────────────────────────────────── */

:root {
  /* the official Planetary Health Check signature gradient */
  --phc-grad: linear-gradient(
    to right,
    #006837 0%, #8cc63f 25%, #ffe657 25.01%, #fcce17 30%,
    #df711c 40%, #c31920 60%, #871e5e 80%, #3d1e5e 100%
  );
}

/* ── colour tokens — dark default, flipped under [data-theme="light"] ──────── */
.phc-subhead {
  --_fg: rgba(255, 255, 255, 0.92);
  --_btn-bg: rgba(255, 255, 255, 0.06);
  --_btn-bg-hover: rgba(255, 255, 255, 0.13);
  --_btn-border: rgba(255, 255, 255, 0.16);
}
html[data-theme="light"] .phc-subhead {
  --_fg: #0d1b2a;
  --_btn-bg: rgba(13, 27, 42, 0.04);
  --_btn-bg-hover: rgba(13, 27, 42, 0.09);
  --_btn-border: rgba(13, 27, 42, 0.16);
}

/* ── bar ──────────────────────────────────────────────────────────────────── */
.phc-subhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px clamp(16px, 4vw, 44px);
  color: var(--_fg);
}

/* fixed-overlay variant (immersive) — floats over the page with a soft scrim */
.phc-subhead[data-pos="fixed"] {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 30;
  background: linear-gradient(to bottom, rgba(4, 8, 16, 0.78), rgba(4, 8, 16, 0));
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
html[data-theme="light"] .phc-subhead[data-pos="fixed"] {
  background: linear-gradient(to bottom, rgba(244, 247, 251, 0.86), rgba(244, 247, 251, 0));
}

/* ── brand cluster: gradient logo-mark + page name ────────────────────────── */
.phc-subhead-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}
.phc-subhead-home {
  position: relative;
  display: block;
  width: 80px;
  height: 24px;
  flex: 0 0 auto;
  border-radius: 6px;
  text-decoration: none;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.35);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.phc-subhead-home:hover { transform: translateY(-1px); }
.phc-subhead-home:focus-visible { outline: 2px solid var(--_fg); outline-offset: 3px; }

.phc-subhead-logo {
  position: absolute;
  inset: 0;
  border-radius: 6px;
  overflow: hidden;
}
.phc-subhead-logo-band {
  position: absolute;
  inset: 0;
  background: var(--phc-grad);
}
.phc-subhead-logo-handle {
  position: absolute;
  top: 50%;
  left: 14%;
  right: 38%;
  height: 3px;
  transform: translateY(-50%);
  background: #fff;
  border-radius: 2px;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.4);
}
.phc-subhead-logo-dot {
  position: absolute;
  top: 50%;
  left: 30%;
  width: 8px;
  height: 8px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: #2b8fe6;
  box-shadow: 0 0 0 2px #fff, 0 0 6px rgba(43, 143, 230, 0.9);
  transition: left 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}
.phc-subhead-home:hover .phc-subhead-logo-dot { left: 44%; }

.phc-subhead-title {
  font-family: "Alcyone", system-ui, sans-serif;
  font-weight: 500;
  font-size: clamp(0.92rem, 1.6vw, 1.06rem);
  letter-spacing: 0.01em;
  color: var(--_fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── actions — page buttons take .phc-subhead-btn for a unified look ───────── */
.phc-subhead-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}
.phc-subhead-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 10px;
  border: 1px solid var(--_btn-border);
  background: var(--_btn-bg);
  color: var(--_fg);
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s, transform 0.18s;
}
.phc-subhead-btn:hover {
  background: var(--_btn-bg-hover);
  transform: translateY(-1px);
}
.phc-subhead-btn:focus-visible { outline: 2px solid var(--_fg); outline-offset: 2px; }
/* Size only — must NOT set `display`, or it would override a page's own
   icon-toggle rules (e.g. figures' hidden .fig-fs-close) and show both icons. */
.phc-subhead-btn svg { width: 20px; height: 20px; }

/* ── responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 560px) {
  .phc-subhead { padding: 12px 16px; gap: 10px; }
  .phc-subhead-home { width: 64px; height: 20px; }
  .phc-subhead-btn { width: 36px; height: 36px; border-radius: 9px; }
  .phc-subhead-btn svg { width: 18px; height: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  .phc-subhead-home,
  .phc-subhead-logo-dot,
  .phc-subhead-btn { transition: none; }
}
