/* ============================================================================
   XARQ — page shell: background stack, navigation, section frame, footer
   ========================================================================== */

/* ============================================================ background stack
   Two fixed layers behind everything:
     1  .bg-aurora  three slow blurred blobs on the brand ramp
     2  .bg-noise   film grain, which is what stops the gradients from banding
   Both are pointer-events:none and sit under --z-content. The grain is not
   decoration for its own sake: without it, blurs this large band visibly into
   concentric rings on an 8-bit display. */
.bg-stack {
  position: fixed;
  inset: 0;
  z-index: var(--z-bg);
  pointer-events: none;
  overflow: hidden;
}

.bg-aurora {
  position: absolute;
  inset: 0;
  opacity: var(--aurora-opacity);
  transition: opacity var(--dur-slow) var(--ease-out);
}

.bg-aurora span {
  position: absolute;
  display: block;
  border-radius: 50%;
  /* A blur this large is expensive to repaint, so each blob is promoted to its
     own layer and only ever moved by transform. */
  filter: blur(90px);
  will-change: transform;
  transform: translateZ(0);
}

.bg-aurora span:nth-child(1) {
  width: 46vw;
  height: 46vw;
  left: -8vw;
  top: -10vh;
  background: radial-gradient(circle, var(--violet) 0%, transparent 68%);
  opacity: 0.5;
  animation: drift-a 26s var(--ease-in-out) infinite alternate;
}
.bg-aurora span:nth-child(2) {
  width: 52vw;
  height: 52vw;
  right: -12vw;
  top: 8vh;
  background: radial-gradient(circle, var(--azure) 0%, transparent 68%);
  opacity: 0.45;
  animation: drift-b 32s var(--ease-in-out) infinite alternate;
}
.bg-aurora span:nth-child(3) {
  width: 40vw;
  height: 40vw;
  left: 28vw;
  bottom: -18vh;
  background: radial-gradient(circle, var(--cyan) 0%, transparent 68%);
  opacity: 0.38;
  animation: drift-c 24s var(--ease-in-out) infinite alternate;
}

.bg-noise {
  position: absolute;
  inset: -100%;
  width: 300%;
  height: 300%;
  opacity: var(--noise-opacity);
  /* Inline fractal-noise SVG: no network request, no image decode, and it
     scales to any DPR without resampling. */
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='3' stitchTiles='stitch'/></filter><rect width='200' height='200' filter='url(%23n)'/></svg>");
  animation: grain 6s steps(6) infinite;
}

/* ==================================================================== header */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: var(--z-nav);
  padding-block: clamp(0.7rem, 0.5rem + 0.6vw, 1.1rem);
  transition: transform var(--dur) var(--ease-out), background-color var(--dur) var(--ease-out),
    backdrop-filter var(--dur) var(--ease-out), border-color var(--dur) var(--ease-out);
  border-bottom: 1px solid transparent;
}

/* Condensed state, added by ui.js past the first viewport. */
.nav.is-stuck {
  background: var(--scrim);
  backdrop-filter: blur(var(--glass-blur)) saturate(150%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(150%);
  border-bottom-color: var(--line);
}

/* Hidden while scrolling down, restored on the first upward wheel. */
.nav.is-hidden {
  transform: translateY(-110%);
}

.nav__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-5);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}

.brand__mark {
  width: clamp(30px, 2.4vw, 38px);
  height: auto;
  transition: transform var(--dur-slow) var(--ease-spring), filter var(--dur) var(--ease-out);
  filter: drop-shadow(0 0 14px color-mix(in oklab, var(--azure) 45%, transparent));
}
.brand:hover .brand__mark {
  transform: rotate(180deg) scale(1.06);
}

.brand__word {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.1rem, 1rem + 0.5vw, 1.4rem);
  letter-spacing: 0.02em;
}

.brand__tag {
  display: none;
  font-family: var(--font-mono);
  font-size: 0.58rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--faint);
  margin-left: 0.55rem;
  padding-left: 0.7rem;
  border-left: 1px solid var(--line);
}
@media (min-width: 900px) {
  .brand__tag {
    display: inline-block;
  }
}

/* ------------------------------------------------------------ desktop links */
.nav__links {
  display: none;
  align-items: center;
  gap: 0.15rem;
  padding: 0.28rem;
  border-radius: var(--r-pill);
  background: var(--glass);
  border: 1px solid var(--glass-line);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
}
@media (min-width: 940px) {
  .nav__links {
    display: flex;
  }
}

.nav__link {
  position: relative;
  padding: 0.45rem 0.95rem;
  border-radius: var(--r-pill);
  font-size: var(--t-sm);
  font-weight: 500;
  color: var(--text-2);
  transition: color var(--dur-fast) var(--ease-out);
}
.nav__link::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--accent-soft);
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease-out);
}
.nav__link:hover,
.nav__link[aria-current='true'] {
  color: var(--text);
}
.nav__link:hover::before,
.nav__link[aria-current='true']::before {
  opacity: 1;
}
.nav__link span {
  position: relative;
}

.nav__actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Below this width the header cannot hold the mark, the toggle, a pill button
   and the burger without one of them leaving the screen. The CTA goes — it is
   the one item that is repeated twice more further down the page, and it is the
   last entry in the drawer. */
@media (max-width: 640px) {
  .nav__actions .btn--primary {
    display: none;
  }
}

/* -------------------------------------------------------------- theme toggle
   A single button that swaps two stacked icons. aria-pressed carries the state
   for assistive tech; the visual state is driven off [data-theme] on <html> so
   it can never disagree with the page. */
.toggle {
  position: relative;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: var(--r-pill);
  border: 1px solid var(--glass-line);
  background: var(--glass);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  color: var(--text-2);
  overflow: hidden;
  transition: color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-spring);
}
.toggle:hover {
  color: var(--text);
  border-color: var(--accent-line);
  transform: translateY(-1px);
}
.toggle svg {
  position: absolute;
  width: 18px;
  height: 18px;
  transition: transform 520ms var(--ease-spring), opacity 320ms var(--ease-out);
}
.toggle .i-sun {
  opacity: 0;
  transform: rotate(-90deg) scale(0.4);
}
.toggle .i-moon {
  opacity: 1;
  transform: rotate(0) scale(1);
}
:root[data-theme='light'] .toggle .i-sun {
  opacity: 1;
  transform: rotate(0) scale(1);
}
:root[data-theme='light'] .toggle .i-moon {
  opacity: 0;
  transform: rotate(90deg) scale(0.4);
}

/* ------------------------------------------------------------ mobile drawer */
.burger {
  width: 42px;
  height: 42px;
  display: grid;
  /* place-content, not place-items. place-items centres each bar inside its own
     row; the rows themselves still default to align-content: stretch and spread
     to fill the 42px button — so the bars sit ~14px apart, not the 6px the open
     state's translateY(6px) assumes, and the two strokes never meet. The result
     reads as a chevron instead of an X. place-content shrink-wraps the rows, so
     the spacing is exactly height + margin = 6px. */
  place-content: center;
  justify-items: center;
  border-radius: var(--r-pill);
  border: 1px solid var(--glass-line);
  background: var(--glass);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
}
@media (min-width: 940px) {
  .burger {
    display: none;
  }
}
.burger i {
  display: block;
  width: 17px;
  height: 1.5px;
  background: currentColor;
  border-radius: 2px;
  transition: transform var(--dur) var(--ease-spring), opacity var(--dur-fast) linear;
}
.burger i + i {
  margin-top: 4.5px;
}
.burger[aria-expanded='true'] i:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}
.burger[aria-expanded='true'] i:nth-child(2) {
  opacity: 0;
}
.burger[aria-expanded='true'] i:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

.drawer {
  position: fixed;
  inset: 0;
  z-index: var(--z-overlay);
  display: grid;
  align-content: center;
  gap: 0.35rem;
  padding: var(--gutter);
  background: color-mix(in oklab, var(--bg) 88%, transparent);
  backdrop-filter: blur(26px) saturate(140%);
  -webkit-backdrop-filter: blur(26px) saturate(140%);
  /* clip-path circle keeps the drawer out of the accessibility tree's way
     while still allowing a cheap GPU reveal from the burger corner. */
  clip-path: circle(0% at calc(100% - 46px) 42px);
  transition: clip-path 620ms var(--ease-out);
  visibility: hidden;
}
.drawer.is-open {
  clip-path: circle(150% at calc(100% - 46px) 42px);
  visibility: visible;
}

.drawer a {
  font-family: var(--font-display);
  font-size: var(--t-2xl);
  font-weight: 500;
  letter-spacing: var(--ls-tight);
  padding-block: 0.35rem;
  display: flex;
  align-items: baseline;
  gap: 1rem;
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 420ms var(--ease-out), transform 520ms var(--ease-out), color var(--dur-fast) linear;
}
.drawer.is-open a {
  opacity: 1;
  transform: none;
}
.drawer a:hover {
  color: var(--accent);
}
.drawer a em {
  font-family: var(--font-mono);
  font-style: normal;
  font-size: 0.7rem;
  color: var(--faint);
  letter-spacing: 0.2em;
}
/* Staggered entrance, one 60ms step per row. */
.drawer.is-open a:nth-child(1) { transition-delay: 90ms; }
.drawer.is-open a:nth-child(2) { transition-delay: 150ms; }
.drawer.is-open a:nth-child(3) { transition-delay: 210ms; }
.drawer.is-open a:nth-child(4) { transition-delay: 270ms; }
.drawer.is-open a:nth-child(5) { transition-delay: 330ms; }
.drawer.is-open a:nth-child(6) { transition-delay: 390ms; }

/* ============================================================= section frame */
.section {
  position: relative;
  z-index: var(--z-content);
  padding-block: var(--section-y);
}

.section--tight {
  padding-block: calc(var(--section-y) * 0.55);
}

.section__head {
  display: grid;
  gap: var(--sp-4);
  margin-bottom: clamp(2.5rem, 1.5rem + 3vw, 5rem);
  max-width: 46rem;
}

.section__title {
  font-size: var(--t-3xl);
  font-weight: 600;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-mono);
  font-size: var(--t-xs);
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 500;
}
.eyebrow::before {
  content: '';
  width: 26px;
  height: 1px;
  background: currentColor;
  opacity: 0.6;
}

/* ==================================================================== footer */
.footer {
  position: relative;
  z-index: var(--z-content);
  border-top: 1px solid var(--line);
  background: color-mix(in oklab, var(--surface) 70%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding-top: clamp(3rem, 2rem + 4vw, 6rem);
  /* Breathing room under the logo. The page used to end flush against the
     wordmark's clipped baseline; a closing mark needs air beneath it or it
     reads as cut off rather than placed. */
  padding-bottom: clamp(3rem, 2rem + 4vw, 6rem);
}

.footer__grid {
  display: grid;
  gap: var(--sp-7);
  grid-template-columns: 1fr;
}
@media (min-width: 760px) {
  .footer__grid {
    grid-template-columns: 1.6fr 1fr 1fr;
    gap: var(--sp-6);
  }
}

.footer h3 {
  font-family: var(--font-mono);
  font-size: var(--t-xs);
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  color: var(--faint);
  font-weight: 500;
  margin-bottom: var(--sp-4);
}

.footer__links {
  display: grid;
  gap: 0.7rem;
}
.footer__links a {
  color: var(--text-2);
  font-size: var(--t-sm);
  width: fit-content;
  transition: color var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
.footer__links a:hover {
  color: var(--accent);
  transform: translateX(3px);
}

.footer__bar {
  margin-top: clamp(2.5rem, 2rem + 2vw, 4rem);
  padding-block: var(--sp-5);
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-4);
  align-items: center;
  justify-content: space-between;
  font-size: var(--t-xs);
  color: var(--faint);
}

/* The logo that closes the page.
   Two files, one per theme: the lockup in assets/brand/ carries a white
   wordmark and the -light one a charcoal wordmark, so neither works on both
   grounds. background-image rather than <img> means only the needed file is
   ever downloaded — a hidden <img> is still fetched. contain handles the two
   files' slightly different aspect ratios without any per-file measurement. */
.footer__logo {
  margin-top: clamp(2rem, 1.4rem + 2vw, 3.5rem);
  height: clamp(72px, 6vw + 2rem, 132px);
  background-image: url('/assets/brand/xarq-lockup.png');
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  opacity: 0.85;
  user-select: none;
  transition: opacity var(--dur) var(--ease-out);
}
:root[data-theme='light'] .footer__logo {
  background-image: url('/assets/brand/xarq-lockup-light.png');
  opacity: 0.9;
}
