/**
 * Shared site header: the one top bar every public page renders (lib/qxr-site-head.php).
 * // _qxr.web
 *
 * Isolation contract. Public pages load different stylesheets (qxr-studio.css on home and
 * about, styles.css + qxr-studio-live.css + page sheets elsewhere), and those sheets style bare
 * elements and shared class names like .btn, .site-nav, and .nav-toggle. If the header reused
 * any of those names it would render differently on every page. So:
 *   - every class here is prefixed qxr-head and every rule is scoped under .qxr-head (two class
 *     specificity), which outranks the element and single-class rules in page sheets;
 *   - tokens are private custom properties on .qxr-head, not :root, so pages cannot retheme it;
 *   - every property a page sheet might set on a, ul, li, img, svg, or button is set explicitly.
 * The look matches the scrolled state of the home page header and never changes on scroll, so
 * the only per-page difference is the underline under the current page.
 */

@font-face {
  font-family: "QXR Head Display";
  src:
    url("/assets/fonts/qxr-display/Sora-SemiBold.woff2") format("woff2"),
    url("/assets/fonts/qxr-display/QXRDisplay.ttf") format("truetype");
  font-weight: 500 700;
  font-style: normal;
  font-display: swap;
}

.qxr-head {
  --qh-bg: #15141b;
  --qh-panel: #1a1922;
  --qh-ink: #f3f2f7;
  --qh-ink-secondary: #b8b5c7;
  --qh-line-soft: rgba(255, 255, 255, 0.075);
  --qh-line: rgba(255, 255, 255, 0.13);
  /* Control borders need 3:1 against the bar for WCAG 2.2 1.4.11; this lands at about 3.1:1. */
  --qh-line-control: rgba(255, 255, 255, 0.34);
  --qh-accent: #8b7ce8;
  --qh-accent-ink: #14131a;
  --qh-accent-quiet: rgba(139, 124, 232, 0.14);
  --qh-font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --qh-font-display: "QXR Head Display", "Sora", "Inter", system-ui, sans-serif;
  --qh-height: 4.5rem;
  --qh-gutter: clamp(1.25rem, 5vw, 4rem);
  --qh-max: 78rem;
  --qh-tap: 44px;
  --qh-motion: 0.22s ease;

  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  /* Above page content; below skip links (200), dialogs (160+), cart drawer (300), modals (900). */
  z-index: 150;
  display: block;
  width: 100%;
  margin: 0;
  padding: env(safe-area-inset-top, 0px) 0 0;
  background: rgba(21, 20, 27, 0.94);
  border: 0;
  border-bottom: 1px solid var(--qh-line-soft);
  box-shadow: none;
  color: var(--qh-ink);
  font-family: var(--qh-font-body);
  font-size: 16px;
  font-weight: 400;
  font-style: normal;
  line-height: 1.4;
  letter-spacing: normal;
  text-align: left;
  text-transform: none;
  -webkit-font-smoothing: antialiased;
}

@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .qxr-head {
    background: rgba(21, 20, 27, 0.9);
    -webkit-backdrop-filter: blur(14px) saturate(1.1);
    backdrop-filter: blur(14px) saturate(1.1);
  }
}

/*
 * Hardest Simpsons Quiz pages (/hardestSimpsons/): the same bar in Simpsons yellow. Only the
 * tokens change. Dark ink on #ffd90f is about 13:1; control borders at 0.55 ink land near 3.4:1.
 * Two classes plus the @supports override below keep this above the blurred dark background.
 */
.qxr-head.qxr-head--simpsons {
  --qh-bg: #ffd90f;
  --qh-panel: #ffd90f;
  --qh-ink: #15141b;
  --qh-ink-secondary: rgba(21, 20, 27, 0.78);
  --qh-line-soft: rgba(21, 20, 27, 0.14);
  --qh-line: rgba(21, 20, 27, 0.24);
  --qh-line-control: rgba(21, 20, 27, 0.55);
  --qh-accent: #15141b;
  --qh-accent-ink: #ffd90f;
  --qh-accent-quiet: rgba(21, 20, 27, 0.08);

  background: #ffd90f;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .qxr-head.qxr-head--simpsons {
    background: #ffd90f;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}

.qxr-head,
.qxr-head *,
.qxr-head *::before,
.qxr-head *::after {
  box-sizing: border-box;
}

.qxr-head .qxr-head__inner {
  display: flex;
  align-items: center;
  gap: clamp(1rem, 3vw, 2.5rem);
  width: 100%;
  max-width: calc(var(--qh-max) + 2 * var(--qh-gutter));
  min-height: var(--qh-height);
  margin: 0 auto;
  padding: 0 max(var(--qh-gutter), env(safe-area-inset-right, 0px)) 0
    max(var(--qh-gutter), env(safe-area-inset-left, 0px));
}

.qxr-head a {
  text-decoration: none;
  text-transform: none;
  box-shadow: none;
  filter: none;
  transform: none;
}

.qxr-head .qxr-head__brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex: 0 0 auto;
  margin: 0 auto 0 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--qh-ink);
}

.qxr-head .qxr-head__mark {
  display: block;
  width: 32px;
  height: 32px;
  max-width: none;
  margin: 0;
  border: 0;
  border-radius: 6px;
}

.qxr-head .qxr-head__name {
  display: inline-flex;
  align-items: baseline;
  margin: 0;
  color: var(--qh-ink);
  font-family: var(--qh-font-display);
  font-size: 1.0625rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

/* The Q glyph sits on the text baseline: the 112-unit artboard puts the ring base at y 86. */
.qxr-head .qxr-head__q {
  display: block;
  width: 1.02em;
  height: 1.02em;
  margin: 0 -0.04em 0 0;
  overflow: visible;
  transform: translateY(0.232em);
}

.qxr-head .qxr-head__q-ring,
.qxr-head .qxr-head__q-tail {
  fill: none;
  stroke: currentColor;
  stroke-linecap: butt;
}

.qxr-head .qxr-head__q-ring {
  stroke-width: 15;
}

.qxr-head .qxr-head__q-tail {
  stroke-width: 16;
}

.qxr-head .qxr-head__q-index {
  fill: none;
  stroke: var(--qh-accent);
  stroke-width: 10;
  stroke-linecap: round;
}

.qxr-head .qxr-head__nav {
  display: block;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
}

.qxr-head .qxr-head__list {
  display: flex;
  gap: clamp(1rem, 2.2vw, 1.85rem);
  margin: 0;
  padding: 0;
  list-style: none;
}

.qxr-head .qxr-head__item {
  display: block;
  margin: 0;
  padding: 0;
  list-style: none;
}

.qxr-head .qxr-head__item::before,
.qxr-head .qxr-head__item::marker {
  content: none;
}

.qxr-head .qxr-head__item--compact {
  display: none;
}

.qxr-head .qxr-head__link {
  position: relative;
  display: inline-block;
  margin: 0;
  padding: 0.4rem 0;
  border: 0;
  background: none;
  color: var(--qh-ink-secondary);
  font-family: var(--qh-font-body);
  font-size: 0.9375rem;
  font-weight: 400;
  line-height: 1.4;
  letter-spacing: normal;
  white-space: nowrap;
  transition: color var(--qh-motion);
}

.qxr-head .qxr-head__link::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: var(--qh-accent);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform var(--qh-motion);
}

.qxr-head .qxr-head__link:hover,
.qxr-head .qxr-head__link[aria-current="page"] {
  color: var(--qh-ink);
}

.qxr-head .qxr-head__link:hover::after,
.qxr-head .qxr-head__link[aria-current="page"]::after {
  transform: scaleX(1);
}

.qxr-head .qxr-head__actions {
  display: flex;
  align-items: center;
  flex: 0 1 auto;
  gap: 0.5rem;
  min-width: 0;
  margin: 0;
}

.qxr-head .qxr-head__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 40px;
  /* 16rem fits a 25-character display name, spaces included, without an ellipsis. */
  max-width: 16rem;
  margin: 0;
  padding: 0.45rem 0.95rem;
  border: 1px solid var(--qh-line-control);
  border-radius: 2px;
  background: transparent;
  color: var(--qh-ink);
  font-family: var(--qh-font-body);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: 0.01em;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--qh-motion), border-color var(--qh-motion);
}

.qxr-head .qxr-head__btn-label {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.qxr-head .qxr-head__btn:hover {
  border-color: var(--qh-accent);
  background: var(--qh-accent-quiet);
  color: var(--qh-ink);
}

.qxr-head .qxr-head__btn--solid {
  border-color: var(--qh-accent);
  background: var(--qh-accent);
  color: var(--qh-accent-ink);
  font-weight: 600;
}

.qxr-head .qxr-head__btn--solid:hover {
  border-color: var(--qh-accent);
  background: var(--qh-accent);
  color: var(--qh-accent-ink);
  filter: brightness(1.1);
}

.qxr-head .qxr-head__toggle {
  display: none;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: var(--qh-tap);
  height: var(--qh-tap);
  min-width: var(--qh-tap);
  min-height: var(--qh-tap);
  margin: 0;
  padding: 0;
  border: 1px solid var(--qh-line-control);
  border-radius: 2px;
  background: transparent;
  box-shadow: none;
  color: var(--qh-ink);
  font: inherit;
  cursor: pointer;
  transition: border-color var(--qh-motion), background var(--qh-motion);
}

.qxr-head .qxr-head__toggle:hover {
  border-color: var(--qh-accent);
  background: var(--qh-accent-quiet);
}

.qxr-head .qxr-head__bars {
  display: grid;
  gap: 4px;
  width: 18px;
}

.qxr-head .qxr-head__bars > span {
  display: block;
  height: 1.5px;
  background: currentColor;
  transition: transform var(--qh-motion), opacity var(--qh-motion);
}

.qxr-head .qxr-head__toggle[aria-expanded="true"] .qxr-head__bars > span:nth-child(1) {
  transform: translateY(5.5px) rotate(45deg);
}

.qxr-head .qxr-head__toggle[aria-expanded="true"] .qxr-head__bars > span:nth-child(2) {
  opacity: 0;
}

.qxr-head .qxr-head__toggle[aria-expanded="true"] .qxr-head__bars > span:nth-child(3) {
  transform: translateY(-5.5px) rotate(-45deg);
}

.qxr-head .qxr-head__sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.qxr-head a:focus-visible,
.qxr-head button:focus-visible {
  outline: 2px solid var(--qh-accent);
  outline-offset: 2px;
}

/* Tablet and phone: the six destinations move into a drop-down panel behind the toggle. */
@media (max-width: 860px) {
  .qxr-head .qxr-head__toggle {
    display: inline-flex;
    order: 3;
  }

  .qxr-head .qxr-head__actions {
    order: 2;
    margin-left: auto;
  }

  .qxr-head .qxr-head__btn {
    min-height: var(--qh-tap);
  }

  .qxr-head .qxr-head__nav {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    max-height: calc(100vh - var(--qh-height));
    max-height: calc(100dvh - var(--qh-height));
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0.5rem max(var(--qh-gutter), env(safe-area-inset-right, 0px)) 1rem
      max(var(--qh-gutter), env(safe-area-inset-left, 0px));
    background: var(--qh-panel);
    border-bottom: 1px solid var(--qh-line);
  }

  .qxr-head.is-open .qxr-head__nav {
    display: block;
  }

  .qxr-head .qxr-head__list {
    display: grid;
    gap: 0;
  }

  .qxr-head .qxr-head__item + .qxr-head__item {
    border-top: 1px solid var(--qh-line-soft);
  }

  .qxr-head .qxr-head__link {
    display: flex;
    align-items: center;
    min-height: var(--qh-tap);
    padding: 0.5rem 0;
    color: var(--qh-ink);
    font-size: 1rem;
  }

  .qxr-head .qxr-head__link::after {
    display: none;
  }

  /* Without the underline, the current page needs a non-colour marker in the panel. */
  .qxr-head .qxr-head__link[aria-current="page"] {
    padding-left: 0.75rem;
    box-shadow: inset 2px 0 0 var(--qh-accent);
  }
}

/* Small phones: the mark carries the brand; the link keeps its name from .qxr-head__sr. */
@media (max-width: 560px) {
  .qxr-head .qxr-head__name {
    display: none;
  }

  .qxr-head .qxr-head__inner {
    gap: 0.75rem;
  }

  /* 8.5rem keeps mark + name + Contact + toggle inside a 375 px phone with the longest label. */
  .qxr-head .qxr-head__btn {
    max-width: 8.5rem;
    padding: 0.45rem 0.8rem;
  }
}

/* Narrowest phones (320 to 374 px): Contact moves from the bar into the menu panel. */
@media (max-width: 374px) {
  .qxr-head .qxr-head__btn--contact {
    display: none;
  }

  .qxr-head .qxr-head__item--compact {
    display: block;
  }

  .qxr-head .qxr-head__btn {
    max-width: 10rem;
  }
}

/*
 * First-party privacy notice. site.js inserts it directly after the header on every page, but
 * only styles.css used to style it, so studio-styled pages (axion-suite) showed it raw. The
 * sibling selector keeps it identical everywhere and outranks the styles.css rule.
 */
.qxr-head + .qxr-privacy-notice {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  box-sizing: border-box;
  width: calc(100% - 2rem);
  max-width: 78rem;
  margin: 1rem auto 0;
  padding: 1rem 1.5rem;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 8px;
  background: rgba(17, 14, 30, 0.96);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
  color: #b8b5c7;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.qxr-head + .qxr-privacy-notice .qxr-privacy-notice__body {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 13px;
  line-height: 1.5;
}

.qxr-head + .qxr-privacy-notice .qxr-privacy-notice__body strong {
  color: #f3f2f7;
}

.qxr-head + .qxr-privacy-notice .qxr-privacy-notice__actions {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 0.5rem;
}

@media (max-width: 640px) {
  .qxr-head + .qxr-privacy-notice {
    flex-direction: column;
    align-items: stretch;
    padding: 1rem;
  }

  .qxr-head + .qxr-privacy-notice .qxr-privacy-notice__actions {
    flex-wrap: wrap;
  }
}

@media (prefers-reduced-motion: reduce) {
  .qxr-head .qxr-head__link,
  .qxr-head .qxr-head__link::after,
  .qxr-head .qxr-head__btn,
  .qxr-head .qxr-head__toggle,
  .qxr-head .qxr-head__bars > span {
    transition: none;
  }
}

@media print {
  .qxr-head {
    position: static;
  }

  .qxr-head .qxr-head__toggle {
    display: none;
  }
}
