/* Reset, document defaults, fixed background layers, shared type helpers and scroll-reveal state. */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: auto;
  max-width: 100%;
  overflow-x: hidden;
}

html.lenis {
  height: auto;
}

.lenis.lenis-smooth {
  scroll-behavior: auto !important;
}

body {
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  cursor: none;
  font-family: var(--ui);
  font-size: 17px;
  font-weight: 400;
  letter-spacing: -0.005em;
  color: var(--text);
  max-width: 100%;
  /* clip, not hidden: hidden would make body a scroll container and break position: sticky */
  overflow-x: clip;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: none;
}

::selection {
  background: var(--accent);
  color: #050505;
}

.serif {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

.aurora {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
}

/* The glow blobs used to be sharp gradients softened with `filter: blur(90px)`. Because their
   scale is animated, the browser re-ran that blur on two near-viewport-sized layers every frame,
   which was the single largest cost on the page. The softness is now baked into the gradient
   stops (and the boxes grown to fit the falloff), so the animation is a plain compositor
   transform + opacity with nothing to re-rasterise. The result looks the same. */
.aurora span {
  position: absolute;
  border-radius: 50%;
  will-change: transform, opacity;
  opacity: 0.09;
}

.aurora .a1 {
  width: calc(60vw + 360px);
  height: calc(60vw + 360px);
  right: calc(-25vw - 180px);
  top: calc(-10vh - 180px);
  animation: breathe 16s ease-in-out infinite alternate;
  background: radial-gradient(
    circle closest-side,
    rgba(170, 165, 255, 0.45) 0%,
    rgba(170, 165, 255, 0.34) 25%,
    rgba(170, 165, 255, 0.16) 46%,
    rgba(170, 165, 255, 0.06) 62%,
    rgba(170, 165, 255, 0.015) 78%,
    transparent 100%
  );
}

/*
 * The aurora's slow breathing pauses while the after-story wash covers it
 * (js/sections/story.js), while the page is scrolling (js/core/scroll.js) and
 * while a member card is hovered. Over a 16-20s cycle the pauses are invisible,
 * and Firefox no longer re-blends every layer above it on each of those frames.
 */
.bg-covered .aurora span,
.is-scrolling .aurora span,
html:has(.mcard:hover) .aurora span {
  animation-play-state: paused;
}

.aurora .a2 {
  width: calc(50vw + 360px);
  height: calc(50vw + 360px);
  left: calc(-20vw - 180px);
  bottom: calc(-25vh - 180px);
  animation: breathe 20s ease-in-out infinite alternate-reverse;
  background: radial-gradient(
    circle closest-side,
    rgba(92, 124, 255, 0.41) 0%,
    rgba(92, 124, 255, 0.31) 23%,
    rgba(92, 124, 255, 0.15) 43%,
    rgba(92, 124, 255, 0.055) 60%,
    rgba(92, 124, 255, 0.014) 78%,
    transparent 100%
  );
}

/* Film grain and vignette share one fixed layer: two full-screen layers would each be
   blended over the whole viewport on every frame. The grain's opacity lives inside the SVG. */
.noise {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background-image:
    radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.55) 100%),
    url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E");
}

main {
  position: relative;
  z-index: 6;
  /* Both axes: decorative glows (the closing halo breathes past the footer) must not
     add scroll height, or the end of the page keeps moving. Fixed/pinned layers are unaffected. */
  overflow: clip;
}

.after-story {
  position: relative;
  overflow-x: clip;
}

/*
 * The dark wash behind everything after the story. It used to be a gradient on
 * .after-story itself, a ~7000px translucent layer over the animated scene that
 * Firefox re-blended in full every frame (7fps at the events section). Now the
 * same gradient sits on a two-screen sticky layer: it fades in with the
 * section's top edge, sticks once the fade has scrolled past (top: -100vh), and
 * leaves with the section's bottom edge. The empty .after-wash box spans the
 * section exactly and is what keeps the sticky layer inside it.
 */
.after-wash {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}

.after-wash::before {
  content: "";
  display: block;
  position: sticky;
  top: -100vh;
  height: min(200vh, 100%);
  background: linear-gradient(180deg, rgba(5, 5, 5, 0) 0%, rgba(5, 5, 5, 0.86) 50%, rgba(5, 5, 5, 0.9) 100%);
}

.tag {
  text-transform: uppercase;
  display: block;
  margin-bottom: 1.6rem;
  font-family: var(--ui);
  font-size: 12px;
  letter-spacing: 0.22em;
  font-weight: 600;
  color: var(--accent-pale);
  opacity: 0.9;
}

.h-serif {
  font-family: var(--serif);
  font-weight: 400;
  letter-spacing: -0.02em;
  background: none;
  -webkit-text-fill-color: currentColor;
  color: var(--text);
  font-size: clamp(2.6rem, 6vw, 5rem);
  line-height: 1.02;
}

.h-serif i {
  font-family: var(--serif);
  font-style: italic;
  color: var(--accent-pale);
  opacity: 1;
}

/* Scroll reveal. The entrance itself is a compositor animation started from js/core/reveal.js;
   `.in` is the settled state it leaves behind. */
.rv {
  opacity: 0;
  transform: translateY(30px);
  filter: blur(6px);
}

.rv.in {
  opacity: 1;
  transform: none;
  filter: none;
}

/*
 * Faint 56px grid fading out from the top centre, over two soft colour washes
 * (events and members pages). One static layer: the grid is an SVG image with
 * the fade built in, because the same grid as a CSS mask was recomputed by
 * Firefox on every frame anything moved above it.
 */
.pixels {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='100%' height='100%'><defs><pattern id='g' width='56' height='56' patternUnits='userSpaceOnUse'><path d='M0 .5H56M.5 0V56' fill='none' stroke='%23fff' stroke-opacity='.014'/></pattern><radialGradient id='f' cx='.5' cy='.3' r='.86'><stop offset='0' stop-color='%23fff'/><stop offset='.7' stop-color='%23fff' stop-opacity='0'/></radialGradient><mask id='m'><rect width='100%' height='100%' fill='url(%23f)'/></mask></defs><rect width='100%' height='100%' fill='url(%23g)' mask='url(%23m)'/></svg>"),
    radial-gradient(ellipse at 20% 0%, rgba(170, 165, 255, 0.12), transparent 50%),
    radial-gradient(ellipse at 90% 100%, rgba(79, 143, 181, 0.14), transparent 50%);
}

.sub {
  font-size: 1.15rem;
  color: var(--text-2);
  margin-top: 0.9rem;
}

.scene-fallback {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 20%, rgba(170, 165, 255, 0.16), transparent 55%),
    radial-gradient(ellipse at 20% 90%, rgba(92, 124, 255, 0.12), transparent 50%);
}

@keyframes breathe {
  0% {
    transform: scale(1) translate(0, 0);
    opacity: 0.14;
  }
  100% {
    transform: scale(1.12) translate(-4%, 3%);
    opacity: 0.24;
  }
}

@media (hover: none) {
  body,
  button {
    cursor: auto;
  }
}

@media (max-width: 600px) {
  .h-serif {
    font-size: 2.4rem;
  }

  .sub {
    font-size: 1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }

  .rv {
    opacity: 1;
    transform: none;
    filter: none;
  }

  #scene {
    display: none;
  }
}
