/* Header, nav, footer and the search modal — every page wears these.
   Load after global.css, before the page's own stylesheet.

   Theme: dark glass. The header is a floating bar with a blurred, translucent
   ground; the brand is a small mark beside the wordmark; the nav is a row of
   pills. The footer is a three-column band closed by a hairline.

   This file exists so the chrome is defined once. docs.css and home.css both
   used to carry their own copy of the header and the two drifted. */

:root {
  --header-h: 64px;
  /* The header's own blur, and it must stay small. A blur this size is
     measured against the 15.5px dot grid: 24px (the kit's --blur-heavy)
     leaves 1% of the grid's contrast, 6px leaves 3%, 2px leaves 24%.
     The grid is the point of the backdrop, so the bar frosts it just
     enough to soften it and no further. */
  --blur-header: blur(2px) saturate(1.4);
}

/* ── tooltip ────────────────────────────────────────── */
/* Same rules as the settings core's header tooltips, so both surfaces match. */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%) translateY(-4px);
  padding: 5px 10px;
  border: var(--bw) solid var(--line);
  border-radius: var(--r-sm);
  background: var(--raised-2);
  box-shadow: var(--shadow);
  color: var(--ink);
  font-size: 0.72rem;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
  z-index: 30;
}

[data-tooltip]:hover::after,
[data-tooltip]:focus-visible::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Nav tooltips clear the pill, which sits a little below the label. */
.nav-link[data-tooltip]::after { top: calc(100% + 16px); }

/* The theme button is the last item in the header, so a centred bubble would
   stick out past the right edge. `opacity: 0` still counts toward scrollWidth,
   which added a permanent horizontal scrollbar on narrow windows — so this
   bubble anchors right instead of centre. */
.theme-toggle[data-tooltip]::after {
  left: auto;
  right: 0;
  transform: translateY(-4px);
}
.theme-toggle[data-tooltip]:hover::after,
.theme-toggle[data-tooltip]:focus-visible::after { transform: translateY(0); }
.nav-link.is-soon { cursor: default; }
.nav-link.is-soon:hover { color: var(--faint); }

/* ── filled brand marks ─────────────────────────────── */
.hdr-icon.is-filled { stroke: none; fill: var(--strong); }
.hdr-icon.is-filled:hover { stroke: none; fill: var(--accent-soft); }

/* ── header ─────────────────────────────────────────── */
/* A floating bar: translucent, blurred, closed by a hairline. It stays legible
   over the moving backdrop because the blur does the work, not an opaque fill. */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 22px;
  height: var(--header-h);
  padding: 0 32px;
  background: var(--header);
  -webkit-backdrop-filter: var(--blur-header);
  backdrop-filter: var(--blur-header);
  border-bottom: var(--bw) solid var(--line);
}

/* The brand is a mark beside a wordmark — no block, no rule. */
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  height: 40px;
  padding: 0;
  color: var(--ink);
  transition: opacity var(--t) var(--ease);
}
.brand:hover { opacity: 0.85; text-decoration: none; }
.brand img {
  height: 32px;
  width: 32px;
  object-fit: cover;
  border-radius: var(--r-pill);
  box-shadow: 0 0 0 1px var(--line);
}
.brand span {
  font-family: var(--display);
  font-size: 1.06rem;
  font-weight: 400;
  color: var(--ink);
  letter-spacing: -0.01em;
  line-height: 1;
}

.site-nav {
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0;
  font-size: 0.9rem;
  font-weight: 500;
}
/* Each tab is a pill. The lit one gets the accent tint, never a filled block. */
.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border: none;
  border-radius: var(--r-pill);
  background: none;
  font: inherit;
  color: var(--muted);
  cursor: pointer;
  transition: color var(--t) var(--ease), background var(--t) var(--ease);
}
.nav-link:hover { color: var(--ink); background: var(--accent-tint); text-decoration: none; }
.nav-link.is-active { color: var(--ink); background: var(--accent-wash); }
.nav-link.is-soon { color: var(--faint); cursor: default; }
.nav-link.is-soon:hover { color: var(--faint); background: none; }

/* The moving bar is retired — the lit pill is its own indicator now. It stays
   in the markup so chrome.js has nothing to special-case, but renders nothing. */
.nav-bar { display: none; }

.header-spacer { flex-grow: 1; }
.header-actions { display: flex; align-items: center; gap: 12px; }
.header-divider { width: var(--bw); height: 24px; background: var(--line); }

/* Language switch: a small segmented control — the lit half is the live one. */
.lang-switch {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border: var(--bw) solid var(--line);
  border-radius: var(--r-pill);
  background: var(--accent-tint);
}
.lang-btn {
  padding: 0 9px;
  height: 28px;
  border: none;
  border-radius: var(--r-pill);
  background: none;
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--muted);
  cursor: pointer;
  transition: color var(--t) var(--ease), background var(--t) var(--ease);
}
.lang-btn:hover { color: var(--ink); }
.lang-btn.is-on { color: var(--accent-on); background: var(--accent); }

.hdr-icon {
  opacity: 0.8;
  transition: opacity var(--t) var(--ease), transform var(--t) var(--ease);
}
.hdr-icon:hover { opacity: 1; transform: translateY(-1px); }

/* Theme switch: the same pill as the search box, icon only. */
.theme-toggle {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: var(--bw) solid var(--line);
  border-radius: var(--r-pill);
  background: var(--accent-tint);
  color: var(--ink);
  cursor: pointer;
  transition: background var(--t) var(--ease), border-color var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
.theme-toggle:hover { background: var(--accent-wash); border-color: var(--accent-line); box-shadow: var(--shadow-sm); }
.theme-toggle svg { transition: transform var(--t-slow) var(--glide); }
.theme-toggle:hover svg { transform: rotate(18deg); }
/* Only one glyph is ever shown — the pair swap on the root attribute. */
.theme-toggle .icon-moon { display: block; }
.theme-toggle .icon-sun { display: none; }
html[data-theme="light"] .theme-toggle .icon-moon { display: none; }
html[data-theme="light"] .theme-toggle .icon-sun { display: block; }

/* Before the theme script runs, hide both glyphs so neither flashes. */
html:not([data-theme]) .theme-toggle svg { visibility: hidden; }

.search-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  border: var(--bw) solid var(--line);
  border-radius: var(--r-pill);
  background: var(--accent-tint);
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  transition: background var(--t) var(--ease), border-color var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
.search-pill:hover {
  background: var(--accent-wash);
  border-color: var(--accent-line);
  box-shadow: var(--shadow-sm);
}
.search-pill kbd {
  padding: 1px 6px;
  border: var(--bw) solid var(--line);
  border-radius: 6px;
  background: var(--tab);
  font-family: var(--mono);
  font-size: 0.66rem;
  color: var(--muted);
}

/* ── docs dropdown ──────────────────────────────────── */
.nav-menu { position: relative; }
.nav-caret { transition: transform var(--t) var(--ease); }
/* The caret follows the panel, so it reads hover and unhover on its own. */
.nav-menu:hover .nav-caret,
.nav-menu.is-open .nav-caret { transform: rotate(180deg); }
.nav-menu.is-shut:hover .nav-caret { transform: none; }

.nav-pop {
  position: absolute;
  top: calc(100% + 20px);
  left: 0;
  z-index: 60;
  width: 320px;
  padding: 8px;
  border: var(--bw) solid var(--line);
  border-radius: var(--r);
  background: var(--raised-2);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity var(--t-fast) var(--ease), transform var(--t-fast) var(--glide);
}
/* Hover is the whole interaction: opens on enter, closes on leave, animating
   both ways. is-open is only for touch, where there is no hover to read. */
.nav-menu:hover .nav-pop,
.nav-menu.is-open .nav-pop { opacity: 1; transform: translateY(0); pointer-events: auto; }
/* Clicking the tab shuts the panel, until the pointer leaves and comes back. */
.nav-menu.is-shut:hover .nav-pop { opacity: 0; transform: translateY(-6px); pointer-events: none; }
/* Invisible bridge across the gap, so the pointer never leaves .nav-menu. */
.nav-pop::after {
  content: "";
  position: absolute;
  top: -20px;
  left: 0;
  right: 0;
  height: 20px;
}

.nav-pop-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 11px;
  border-radius: var(--r-sm);
  color: inherit;
  transition: background var(--t-fast) var(--ease);
}
.nav-pop-item:hover { background: var(--accent-tint); text-decoration: none; }
.nav-pop-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: var(--bw) solid var(--line);
  border-radius: var(--r-sm);
  background: var(--tab);
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
/* Whatever the icon file's own colours are — an Iconify fetch, a downloaded
   SVG, a PNG — this flattens it to cream, so the row never needs a palette. */
.nav-pop-icon img { filter: brightness(0) invert(1); opacity: 0.9; }
html[data-theme="light"] .nav-pop-icon img { filter: brightness(0); opacity: 0.72; }
.nav-pop-item:hover .nav-pop-icon { background: var(--accent-wash); border-color: var(--accent-line); }
.nav-pop-item:hover .nav-pop-icon img { opacity: 1; }
.nav-pop-text { display: flex; flex-direction: column; line-height: 1.35; min-width: 0; }
.nav-pop-name { font-size: 0.88rem; font-weight: 600; color: var(--strong); }
.nav-pop-eyebrow { font-size: 0.72rem; color: var(--faint); }
.nav-pop-arrow { margin-left: auto; opacity: 0; transition: opacity var(--t-fast) var(--ease), transform var(--t-fast) var(--ease); }
.nav-pop-item:hover .nav-pop-arrow { opacity: 1; transform: translateX(2px); }

.nav-pop-foot {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 4px;
  padding: 10px 11px 6px;
  border-top: var(--bw) solid var(--line-soft);
  font-size: 0.74rem;
  color: var(--faint);
  transition: color var(--t-fast) var(--ease);
}
.nav-pop-foot:hover { color: var(--accent-soft); text-decoration: none; }

/* Contact Me: a narrower panel — one block of copy and the invite button. */
.nav-pop-contact { width: 288px; padding: 16px; }
.contact-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.contact-head > svg { flex: none; margin-top: 2px; }
.contact-title { font-size: 0.95rem; font-weight: 600; color: var(--ink); }
.contact-sub { margin-top: 3px; font-size: 0.8rem; line-height: 1.5; color: var(--lede); }
.nav-pop-empty { padding: 6px 2px; font-size: 0.82rem; color: var(--faint); }

/* Discord invite button — used by the Contact Me panel. */
.contact-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  border: var(--bw) solid var(--line);
  border-radius: var(--r-pill);
  background: var(--discord, #5865f2);
  font-size: 0.86rem;
  font-weight: 600;
  color: #fff;
  transition: filter var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
.contact-cta:hover { filter: brightness(0.94); box-shadow: var(--shadow); color: #fff; text-decoration: none; }

/* ── footer ─────────────────────────────────────────── */
/* A band closed by a hairline: brand marks on the left, copyright on the right. */
.site-footer {
  margin-top: 80px;
  padding: 26px 0 32px;
  border-top: var(--bw) solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.soc-row { display: flex; align-items: center; gap: 10px; }
.soc {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: var(--bw) solid var(--line);
  border-radius: var(--r-pill);
  background: var(--accent-tint);
  color: var(--strong);
  transition: color var(--t) var(--ease), border-color var(--t) var(--ease),
              background var(--t) var(--ease), transform var(--t) var(--ease);
}
.soc:hover {
  color: var(--accent-on);
  background: var(--accent);
  border-color: var(--accent-line);
  transform: translateY(-2px);
  text-decoration: none;
}
.copyright {
  font-size: 0.82rem;
  color: var(--faint);
  text-align: right;
}

/* ── search modal ───────────────────────────────────── */
.search-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  justify-content: center;
  /* flex-start, not the default stretch: the panel has to sit at its own
     height. Stretched, an empty palette becomes a 66vh void with one row in it. */
  align-items: flex-start;
  padding: 12vh 20px 20px;
  background: rgba(8, 7, 10, 0.66);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  /* Closed state. visibility (not display) so both directions can animate. */
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-fast) var(--ease), visibility 0s var(--t-fast);
}
.search-modal.is-open {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
  transition: opacity var(--t-fast) var(--ease), visibility 0s;
}
.search-panel { transform: translateY(-10px); opacity: 0; transition: transform var(--t-fast) var(--ease), opacity var(--t-fast) var(--ease); }
.search-modal.is-open .search-panel { transform: translateY(0); opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .search-modal, .search-panel { transition-duration: 0.01s; }
  .search-panel { transform: none; }
}

.search-panel {
  width: 100%;
  max-width: 570px;
  max-height: 66vh;
  display: flex;
  flex-direction: column;
  border: var(--bw) solid var(--line);
  border-radius: var(--r-lg);
  background: var(--raised-2);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.search-field { display: flex; align-items: center; gap: 11px; padding: 15px 17px; border-bottom: var(--bw) solid var(--line-soft); }
.search-field input {
  flex: 1;
  min-width: 0;
  border: none;
  background: none;
  font-family: var(--sans);
  font-size: 1rem;
  color: var(--ink);
  outline: none;
}
.search-field input::placeholder { color: var(--faint); }
.search-field kbd {
  padding: 2px 7px;
  border: var(--bw) solid var(--line);
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 0.66rem;
  color: var(--muted);
}

.search-results { overflow-y: auto; padding: 8px 8px 20px; min-height: 96px; }
/* The group heading names the widget and, on the far side, where its rows go. */
.sr-group { display: flex; align-items: baseline; gap: 10px; padding: 12px 11px 6px; }
.sr-group-name { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--soft); }
.sr-group-hint { margin-left: auto; font-size: 0.68rem; color: var(--faint); }
.sr-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 11px;
  border-radius: var(--r-sm);
  color: inherit;
  transition: background var(--t-fast) var(--ease);
}
.sr-item.is-on, .sr-item:hover { background: var(--accent-wash); text-decoration: none; }
/* The leading glyph: the widget's own icon, or a kind glyph tinted by accent. */
.sr-icon { flex: none; }
.sr-kind { flex: none; display: flex; align-items: center; justify-content: center; width: 30px; height: 30px; border: var(--bw) solid var(--line); border-radius: var(--r-sm); background: var(--tab); }
.sr-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.sr-label { font-size: 0.9rem; color: var(--strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-label mark { background: none; color: var(--accent-soft); font-weight: 700; }
.sr-sub { font-size: 0.74rem; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* The trailing action: what Enter does to this row. */
.sr-act { margin-left: auto; flex: none; display: flex; color: var(--faint); transition: color var(--t-fast) var(--ease); }
.sr-item.is-on .sr-act, .sr-item:hover .sr-act { color: var(--accent-soft); }
.sr-empty { padding: 24px; text-align: center; font-size: 0.88rem; color: var(--faint); }



/* ── narrow ─────────────────────────────────────────── */
@media (max-width: 900px) {
  .site-header { gap: 14px; padding: 0 18px; }
  .site-nav, .search-pill .search-text, .search-pill kbd { display: none; }
  .site-footer { margin-top: 44px; flex-direction: column; gap: 16px; }
  .copyright { text-align: center; }
}

@media (max-width: 720px) {
  .site-header { gap: 10px; padding: 0 16px; height: 58px; }
  .brand img { height: 28px; width: 28px; }
  .brand span { font-size: 0.98rem; }
  .lang-btn { padding: 0 7px; height: 26px; }
}

/* Below ~430px the wordmark + three action buttons stop fitting at their
   default sizes, which pushed the header wider than the viewport. Everything
   is tightened instead of dropping the name, so the brand stays visible —
   the text still fits at 320px with no horizontal overflow. */
@media (max-width: 430px) {
  .site-header { gap: 8px; padding: 0 12px; }
  .brand { gap: 8px; }
  .brand img { height: 26px; width: 26px; }
  .brand span { font-size: 0.86rem; }
  .header-actions { gap: 6px; }
  .lang-switch { padding: 1px; gap: 1px; }
  .lang-btn { padding: 0 5px; height: 24px; font-size: 0.7rem; }
  .search-pill { height: 32px; padding: 0 9px; }
  .theme-toggle { width: 32px; height: 32px; }
}

/* ── navigation progress ────────────────────────────── */
/* Shown while nav.js holds the current page and warms the next one. */
.nav-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 200;
  background: var(--accent-soft);
  transform: scaleX(0);
  transform-origin: 0 50%;
  opacity: 0;
  pointer-events: none;
  transition: transform 1.6s cubic-bezier(0.12, 0.7, 0.2, 1), opacity 0.2s ease;
}
.nav-progress.is-on { opacity: 1; }
.nav-progress.is-done { transition: transform 0.18s ease, opacity 0.3s ease 0.12s; opacity: 0; }

/* The pointer says 'working' too, so the held page does not feel unresponsive. */
html:has(.nav-progress.is-on) a { cursor: progress; }

/* ── light ──────────────────────────────────────────── */
/* The chrome is glass on both grounds, so only the pieces that hardcode a
   light value need saying again here. */
html[data-theme="light"] .nav-pop-icon img { filter: brightness(0); opacity: 0.72; }
html[data-theme="light"] .search-modal { background: rgba(40, 33, 15, 0.34); }
html[data-theme="light"] .search-pill kbd,
html[data-theme="light"] .search-field kbd { background: var(--tab); }
