/*
 * Shared site chrome: the header/nav/footer injected by /api/html for pages
 * carrying the qc:header / qc:footer markers (api/lib/partials.js).
 *
 * Built on the canonical tokens in style.css (--qc-* semantic aliases over
 * the AAA palette). Every color pairing here passes AAA on its surface —
 * see docs/accessibility-palette.md. Fallbacks keep the chrome usable on any
 * page that loads this sheet without style.css (e.g. future standalone
 * surfaces).
 */

/* ─────────────────────────── page frame ─────────────────────────── */

/* The header/footer full-bleed trick (`calc(50% - 50vw)`) measures 50vw
   INCLUDING the vertical scrollbar, so on browsers with classic (visible)
   scrollbars every chromed page overflowed ~8-16px to the right — a
   permanent horizontal scrollbar that also made centered content sit left
   of the scroll-canvas center. Clip the axis at the root: the bleed still
   reaches both visual edges, the overflow can never scroll. (`clip`, not
   `hidden` — it doesn't create a scroll container, so position: sticky
   inside the page keeps working.) */
html {
  overflow-x: clip;
}

/* Pin the footer to the true bottom on pages shorter than the viewport —
   otherwise the page background shows as a void below the footer. Flex
   column + main-grows keeps every longer page byte-identical (free space
   only exists on short pages). */
body:has(> footer.qc-chrome-footer) {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  /* Undo style.css's prelaunch scroll lock for shared-chrome pages. The
     footer accordions expand in-flow, so the body must remain vertically
     scrollable after a section opens. */
  overflow-y: auto;
  /* The footer is the terminal spacing now; page sheets that padded the
     body bottom (e.g. about) were creating a band BELOW the footer. */
  padding-bottom: 0;
  /* Several legacy pages scroll on the BODY (style.css pins html/body to
     100% and the page sheet sets `overflow: auto` on body) — the shorthand
     re-enabled a horizontal scrollbar there. Clip the x axis at the same
     specificity level (type selector inside :has outweighs the page-class
     shorthand) so only y scrolls. */
  overflow-x: clip;
}

body:has(> footer.qc-chrome-footer) > main {
  flex: 1 0 auto;
}

/* Same contract on the top edge: page sheets that pad the body (about,
   guide, bug-report pad 2-3rem) were pushing the sticky header down from
   the viewport top. The header's own margin-bottom supplies the content
   gap instead. */
body:has(> header.qc-chrome-header) {
  padding-top: 0;
}

/* ───────────────────────────── header ───────────────────────────── */

.qc-chrome-header {
  position: sticky;
  top: 0;
  z-index: 900; /* below modals (2147483646-class overlays), above content */
  /* Full-bleed even inside a padded/centered <body> (several tool pages pad
     the body directly): pull to the viewport edges from any content width. */
  margin: 0 calc(50% - 50vw) 1.25rem;
  background: rgba(5, 19, 26, 0.92);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--qc-border, rgba(47, 233, 255, 0.18));
  font-family: var(--font, monospace);
}

.qc-chrome-header__inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0.55rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.qc-chrome-logo {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--qc-text-strong, #f1fbff);
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  flex: none;
}

.qc-chrome-logo img {
  display: block;
  filter: drop-shadow(0 0 6px var(--qc-accent-glow, rgba(47, 233, 255, 0.38)));
}

.qc-chrome-logo__tld {
  color: var(--qc-accent, #2fe9ff);
}

/* Narrow-viewport menu button (2.5.1): opens the sitewide radial quick-nav
   dialog — the brand's signature interaction — instead of leaving mobile
   users a hidden-scrollbar swipe strip with no affordance. Ships [hidden];
   lib/radial-nav.js reveals it once the dialog can actually open, so no-JS
   visitors keep the scrollable link strip as their nav. Desktop never shows
   it. */
.qc-chrome-menu-btn {
  display: none;
  border: 1px solid var(--qc-border, rgba(47, 233, 255, 0.18));
  background: transparent;
  color: var(--qc-accent, #2fe9ff);
  font-family: var(--font, monospace);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}

.qc-chrome-menu-btn:hover {
  background: var(--qc-accent-glow-soft, rgba(47, 233, 255, 0.18));
}

.qc-chrome-menu-btn:focus-visible {
  outline: 2px solid var(--qc-focus, #f6fcff);
  outline-offset: 2px;
}

@media (max-width: 720px) {
  .qc-chrome-menu-btn:not([hidden]) {
    display: inline-block;
    order: 3;
    margin-left: 0.5rem;
  }

  /* With the menu button live, collapse the swipe strip to just the pricing
     CTA — the full link set lives one tap away in the dialog. (The :has()
     guard keeps the strip intact when JS never revealed the button.) The
     strip also stops being a scroller so the surviving CTA can't sit
     half-clipped behind the menu button. */
  .qc-chrome-header__inner:has(.qc-chrome-menu-btn:not([hidden])) .qc-chrome-nav a:not(.qc-chrome-nav__cta) {
    display: none;
  }

  .qc-chrome-header__inner:has(.qc-chrome-menu-btn:not([hidden])) .qc-chrome-nav {
    overflow: visible;
    flex: none;
  }
}

@media (max-width: 460px) {
  /* The logo mark keeps the brand (and the aria-label carries the name);
     the word doesn't fit beside CTA + MENU on small phones. Only collapse
     it when the menu button is actually live. */
  .qc-chrome-header__inner:has(.qc-chrome-menu-btn:not([hidden])) .qc-chrome-logo__word {
    display: none;
  }
}

.qc-chrome-nav {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  margin-left: auto;
  overflow-x: auto;
  scrollbar-width: none; /* the nav scrolls on narrow screens; keep it chromeless */
  -webkit-overflow-scrolling: touch;
}

.qc-chrome-nav::-webkit-scrollbar {
  display: none;
}

.qc-chrome-nav a {
  color: var(--qc-text-mid, #d4e9f4);
  text-decoration: none;
  font-size: 0.86rem;
  padding: 0.35rem 0.55rem;
  border-radius: 6px;
  white-space: nowrap;
}

.qc-chrome-nav a:hover {
  color: var(--qc-text-strong, #f1fbff);
  background: var(--qc-accent-glow-soft, rgba(47, 233, 255, 0.18));
}

.qc-chrome-nav a[aria-current='page'] {
  color: var(--qc-accent, #2fe9ff);
  background: var(--qc-accent-glow-soft, rgba(47, 233, 255, 0.18));
}

.qc-chrome-nav a:focus-visible,
.qc-chrome-logo:focus-visible,
.qc-chrome-footer a:focus-visible {
  outline: 2px solid var(--qc-focus, #f6fcff);
  outline-offset: 2px;
}

.qc-chrome-nav__cta {
  border: 1px solid var(--qc-accent, #2fe9ff);
  color: var(--qc-accent, #2fe9ff);
}

.qc-chrome-nav__cta:hover {
  background: var(--qc-accent, #2fe9ff);
  color: var(--qc-text-inverse, #04131a);
}

/* ───────────────────────────── footer ───────────────────────────── */

.qc-chrome-footer {
  position: static; /* several legacy sheets pin bare <footer> — never this one */
  pointer-events: auto;
  margin: 3rem calc(50% - 50vw) 0; /* full-bleed, same contract as the header */
  border-top: 1px solid var(--qc-border, rgba(47, 233, 255, 0.18));
  background: var(--qc-surface, #05131a);
  font-family: var(--font, monospace);
  font-size: 0.85rem;
  text-align: left; /* independent of page-level centering */
}

.qc-chrome-footer__grid {
  max-width: 1080px;
  margin: 0 auto;
  padding: 1.1rem 1rem 0.6rem;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1.25rem;
  align-items: start; /* an opened accordion must not stretch its siblings */
}

/* Each section is a closed-by-default accordion (<details>) so the footer
   reads as one compact row of headings; expanding a section reveals its
   links. Keeps the full link set in the DOM for crawlers and the site-walk
   suite. */
.qc-chrome-footer__col {
  margin: 0;
}

.qc-chrome-footer__heading {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--qc-text-dim, #adcdda);
  margin: 0 0 0.2rem;
  cursor: pointer;
  list-style: none; /* custom marker below */
  -webkit-user-select: none;
  user-select: none;
}

.qc-chrome-footer__heading::-webkit-details-marker {
  display: none;
}

.qc-chrome-footer__heading::before {
  content: '▸';
  display: inline-block;
  margin-right: 0.4rem;
  color: var(--qc-accent, #2fe9ff);
  transition: transform 0.15s ease;
}

.qc-chrome-footer__col[open] > .qc-chrome-footer__heading::before {
  transform: rotate(90deg);
}

.qc-chrome-footer__heading:hover,
.qc-chrome-footer__heading:focus-visible {
  color: var(--qc-accent, #2fe9ff);
}

.qc-chrome-footer__links {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0.35rem 0 0.2rem 1.05rem; /* align under the heading text, past the marker */
}

.qc-chrome-footer__links a {
  color: var(--qc-text-mid, #d4e9f4);
  text-decoration: none;
}

.qc-chrome-footer__links a:hover {
  color: var(--qc-accent, #2fe9ff);
  text-decoration: underline;
}

.qc-chrome-footer__legal {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0.8rem 1rem 1.4rem;
  color: var(--qc-text-dim, #adcdda);
  border-top: 1px solid rgba(47, 233, 255, 0.08);
}

.qc-chrome-footer__legal a {
  color: var(--qc-text-mid, #d4e9f4);
}

/* The floating account pill (styles/account-pill.css) docks top-right at
   12px; on chrome pages it must sit BELOW the sticky header, not on top of
   the nav. */
body:has(.qc-chrome-header) .qc-account-pill {
  top: 60px;
}

/* The Pro menu's viewport cap in account-pill.css budgets 72px for a pill
   docked at top:12px (12 top + pill + 8px gap + breathing room). With the
   pill pushed to 60px under the sticky header, re-budget the cap by the same
   48px shift, or the menu bottom lands past the viewport edge on short
   (landscape-phone) screens and the last items become unreachable. */
body:has(.qc-chrome-header) .qc-account-pill .qc-account-pill__menu {
  max-height: calc(100vh - 120px);
  max-height: calc(100dvh - 120px);
}

/* ─────────────── radial quick-nav overlay (lib/radial-nav.js) ─────────────── */

/* The menu svg (#radial-menu) and .radial-overlay carry their own fixed
   positioning + .visible animation in style.css; this root just owns the
   stacking context above the sticky header and the close affordance. */
.qc-radial-nav-root {
  position: fixed;
  inset: 0;
  z-index: 1500;
}

body.qc-radial-nav-open {
  overflow: hidden;
}

/* The shell sizes itself at min(118vmin, 94vw) for the old full-bleed
   homepage takeover; as a dialog it must FIT the viewport so every wedge
   stays clickable. */
.qc-radial-nav-root #radial-menu {
  width: min(88vmin, 94vw);
  height: min(88vmin, 94vh);
}

/* The shell's decorative blur-ring mask was cut for the old 6-wedge layout
   (60° spokes). The sitewide menu has 8 wedges, so keep the ring and drop
   the misaligned spokes. */
.qc-radial-nav-root #radial-menu::before {
  mask-image: radial-gradient(circle at 50% 50%, transparent 42%, #000 54%, #000 70%, transparent 74%);
  -webkit-mask-image: radial-gradient(circle at 50% 50%, transparent 42%, #000 54%, #000 70%, transparent 74%);
  mask-composite: add;
  -webkit-mask-composite: source-over;
}

.qc-radial-nav-close {
  position: fixed;
  top: 0.9rem;
  right: 1rem;
  z-index: 1600;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.6rem;
  height: 2.6rem;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--qc-border, rgba(47, 233, 255, 0.18));
  background: rgba(5, 19, 26, 0.9);
  color: var(--qc-text-strong, #f1fbff);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.qc-radial-nav-close:hover {
  background: var(--qc-accent-glow-soft, rgba(47, 233, 255, 0.18));
}

.qc-radial-nav-close:focus-visible {
  outline: 2px solid var(--qc-focus, #f6fcff);
  outline-offset: 2px;
}

@media (max-width: 720px) {
  .qc-chrome-footer__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 420px) {
  .qc-chrome-footer__grid {
    grid-template-columns: 1fr;
  }
}

/* Markets moved into the accordion grid (footer.html fifth column) — the
   old .qc-chrome-footer__markets strip added a full-width band of height
   to every page. Some page sheets centre the body's flex children
   (login.css sets align-items:center for its card layout); the chrome
   must not shrink with them — header and footer always span the row. */
body > .qc-chrome-header,
body > .qc-chrome-footer {
  align-self: stretch;
}
