/* VELRIX — theme toggle + language switcher chrome.
 *
 * WHY THIS IS A FILE AND NOT A STRING IN theme-lang.js
 * ---------------------------------------------------
 * The backend control panel ships `style-src 'self'` (see site/_headers). An
 * inline <style> element — which is what `document.createElement("style")`
 * produces — is refused by that policy, so the controls used to render
 * unstyled on /backend while everything else looked fine. Moving the rules
 * here makes the element a same-origin stylesheet, which the policy allows,
 * and it lets the browser cache the rules across pages.
 *
 * Everything is expressed against the tonal tokens from tokens.css with a
 * sensible literal fallback, so the controls still look right on the few
 * pages that have not been migrated to the token system yet.
 */

/* ===========================================================================
   GLOBAL REDUCED-MOTION OVERRIDE — deliberately unconditional, see below
   ===========================================================================

   The site grew up as sixteen independently-authored pages, and each of them
   carries its own copy of a `prefers-reduced-motion: reduce` block. Two real
   bugs fell out of that:

     1. EVERY ONE OF THOSE COPIES SCOPED ITSELF WITH A BARE `*`. A bare `*`
        does not match pseudo-elements, so `::before` / `::after` rules kept
        animating for exactly the people who asked them not to. That is most
        of the page chrome here: hover glows, the `.nav-links a::after`
        underline, and the shimmer passes.

     2. IT IS DUPLICATED SIXTEEN TIMES, SO IT DRIFTS. Fixing it in one page
        fixes that page and silently leaves the other fifteen behind — and a
        new page starts with none at all.

   So the rule lives here instead: one copy, loaded on every page (preflight.mjs
   asserts theme-lang.css is linked everywhere), and written `*` + `::before` +
   `::after` so the pseudo-element gap cannot reopen.

   WHY THE MEDIA QUERY IS EXPRESSED AS `not (prefers-reduced-motion: no-preference)`
   -------------------------------------------------------------------------------
   Semantically identical in a modern browser, but it puts this block's
   `!important` declarations at the SAME specificity as the !important
   transition declarations in the per-page blocks, which lets source order
   decide. That matters: this file is loaded AFTER the inline page styles, so
   it wins. A plain `@media (prefers-reduced-motion: reduce)` block would sit
   in the same bucket and would have to rely on load order alone.

   `*/ ::before` is intentional, not a typo: passing a `revert` to a
   transition-duration is not a thing we want, and `!important` on the
   duration is the only way to beat a later `transition: ... !important`
   shorthand from generated CSS we do not control.

   The durations are `.01ms`, not `0s`, and the difference is load-bearing: a
   .01ms transition still fires `transitionend` / `animationend`, so any code
   awaiting those events (the splash teardown among them) keeps working. A
   literal `0s` removes the event entirely and leaves handlers hanging.
   =========================================================================== */
@media not (prefers-reduced-motion: no-preference) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0ms !important;
    scroll-behavior: auto !important;
  }
}

.vx-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  list-style: none;
}

/* PIN THE CONTROL CLUSTER TO DARK GLASS.
 *
 * The marketing pages are dark-only by design — their body is force-darkened
 * with an inline rule — but they do NOT set data-theme, so theme-boot lets the
 * OS/localStorage decide. On a light-mode machine that yields data-theme="light":
 * --surface flips light while the page content (and --text) stays white, so the
 * two .vx-cbtn buttons paint a white icon on a white background = blank squares.
 *
 * Rather than force every marketing page's data-theme, re-declare the dark token
 * values ON the cluster itself. Custom properties set directly on an element
 * beat the inherited theme tokens, so the buttons, the language popover and the
 * corner cluster are a consistent, high-contrast dark-glass island on EVERY page,
 * in either OS theme. (White icon on #131318 clears 4.5:1 for the a11y gate.) */
.vx-controls,
.vx-controls-fixed,
.vx-lang-pop {
  --bg: #0B0B0F;
  --surface: #131318;
  --surface-2: #1A1A21;
  --raised: #1A1A21;
  --text: #EDEDF2;
  --text-2: #C9C9D4;
  --text-muted: #A7A7B6;
  --text-faint: #8A8A99;
  --border: #26262E;
  --border-2: #2E2E38;
  --border-strong: #2E2E38;
  --accent: #7C5CFF;
  --accent-text: #A78BFA;
  --accent-hover: #9B82FF;
  --accent-contrast: #08080B;
  --focus: #ffffff;
  --r: 10px;
  --r-card: 12px;
  --dur-fast: 120ms;
  --ease-out: ease;
  --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.45);
  color: var(--text);
}

.vx-cbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  /* 44px, not 38px: WCAG 2.5.5 (Target Size) wants a 44x44 CSS-px minimum for
     a pointer target, and these two are the smallest controls on every page.
     verify-panel-a11y.mjs measures them, so a smaller value fails the deploy. */
  width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  margin: 0;
  border: 1px solid var(--border-strong, var(--border, #2E2E38));
  border-radius: var(--r, 10px);
  background: var(--surface, rgba(255, 255, 255, 0.04));
  color: var(--text, #EDEDF2);
  cursor: pointer;
  transition:
    background var(--dur-fast, 120ms) var(--ease-out, ease),
    border-color var(--dur-fast, 120ms) var(--ease-out, ease),
    color var(--dur-fast, 120ms) var(--ease-out, ease);
}
.vx-cbtn:hover {
  background: var(--surface-2, var(--raised, #1A1A21));
  border-color: var(--accent);
}
.vx-cbtn:focus-visible {
  outline: 2px solid var(--focus, #fff);
  outline-offset: 2px;
}
.vx-cbtn[aria-expanded="true"] {
  border-color: var(--accent);
  color: var(--accent-text, var(--accent));
}

/* corner cluster for pages with no nav */
.vx-controls-fixed {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 60;
  display: flex;
  gap: 6px;
  background: color-mix(in srgb, var(--bg, #0B0B0F) 82%, transparent);
  padding: 5px;
  border-radius: calc(var(--r, 10px) + 4px);
  border: 1px solid var(--border, #26262E);
  backdrop-filter: blur(8px);
}

/* the dropdown */
.vx-lang-pop {
  position: fixed;
  z-index: 70;
  width: min(340px, calc(100vw - 24px));
  background: var(--surface, #131318);
  border: 1px solid var(--border-strong, var(--border, #2E2E38));
  border-radius: var(--r-card, 12px);
  box-shadow: var(--shadow-card, 0 8px 32px rgba(0, 0, 0, 0.4));
  padding: 8px;
  display: none;
}
.vx-lang-pop[data-open="true"] {
  display: block;
}

.vx-lang-search {
  width: 100%;
  box-sizing: border-box;
  background: var(--bg, #0B0B0F);
  color: var(--text, #EDEDF2);
  border: 1px solid var(--border-strong, var(--border, #2E2E38));
  border-radius: calc(var(--r, 10px) - 2px);
  padding: 9px 11px;
  font: inherit;
  font-size: 14px;
  margin-bottom: 6px;
}
.vx-lang-search:focus {
  outline: 2px solid var(--focus, #fff);
  outline-offset: 1px;
  border-color: var(--accent);
}
.vx-lang-search::placeholder {
  color: var(--text-muted, #8A8A99);
  opacity: 1;
}

.vx-lang-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: min(58vh, 380px);
  overflow-y: auto;
}

.vx-lang-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
  border-radius: calc(var(--r, 10px) - 2px);
  cursor: pointer;
  color: var(--text, #EDEDF2);
  font-size: 14px;
  transition: background var(--dur-fast, 120ms) var(--ease-out, ease);
}
.vx-lang-item:hover,
.vx-lang-item:focus {
  background: var(--surface-2, var(--raised, #1A1A21));
  outline: none;
}
.vx-lang-item[aria-selected="true"] {
  color: var(--accent-text, var(--accent));
  font-weight: 600;
}
.vx-lang-native {
  font-weight: 500;
}
.vx-lang-en {
  color: var(--text-muted, #8A8A99);
  font-size: 12px;
  margin-left: 8px;
}
.vx-lang-tick {
  display: inline-flex;
  flex-shrink: 0;
}
.vx-lang-empty {
  padding: 14px;
  text-align: center;
  color: var(--text-muted, #8A8A99);
  font-size: 13px;
}

/* the pinned/primary entries get a hairline so the ordering is legible */
.vx-lang-sep {
  height: 1px;
  background: var(--border, #26262E);
  margin: 6px 4px;
  list-style: none;
}

@media (max-width: 480px) {
  .vx-lang-pop {
    width: calc(100vw - 16px);
  }
}

/* ── reduced motion ────────────────────────────────────────────────────────
 * tokens.css already zeroes --dur-fast under this media query, so the rules
 * above would go still on their own. This block is here anyway, on purpose:
 * the fallback in `var(--dur-fast, 120ms)` is what applies whenever tokens.css
 * has NOT loaded — a page the injector missed, or a fetch that failed — and in
 * that case the transition would run at 120ms for a user who asked for none.
 * Repeating it costs three lines and removes the dependency.
 *
 * The dropdown has no animation of its own (it toggles display), which is the
 * right default: a language picker is not a place for a flourish. */
@media (prefers-reduced-motion: reduce) {
  .vx-cbtn,
  .vx-lang-item {
    transition: none;
  }
}
