/* ==========================================================================
   Void Walkers — Global
   Reset, space backdrop, typography, layout primitives, page transitions.
   ========================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  background: var(--bg);
}

body {
  min-height: 100vh;
  background: transparent;
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

img, svg, canvas { display: block; max-width: 100%; }
[hidden] { display: none !important; }
a { color: inherit; text-decoration: none; }
button, input, textarea { font: inherit; color: inherit; background: none; border: none; }
button { cursor: pointer; }
ul, ol { list-style: none; }

/* ---- Space backdrop: nebula + galactic band (stars are drawn by js/starfield.js) ---- */

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -3;
  pointer-events: none;
  background:
    radial-gradient(1100px 640px at 80% -8%, rgb(var(--accent-rgb) / 0.075), transparent 62%),
    radial-gradient(900px 620px at 6% 34%, rgba(84, 72, 210, 0.11), transparent 62%),
    radial-gradient(1000px 760px at 62% 112%, rgba(24, 64, 150, 0.13), transparent 62%),
    linear-gradient(156deg, transparent 33%, rgba(140, 130, 255, 0.04) 45%, rgba(255, 255, 255, 0.05) 50%, rgba(140, 130, 255, 0.04) 55%, transparent 67%),
    linear-gradient(#04050b, #060815);
}

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

/* ---- Film grain: fine noise overlay that kills gradient banding and gives
   the dark surfaces a velvet, filmic finish (pure texture, no UI surface) ---- */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.045;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---- Aurora bloom: a very slow, low-alpha accent breathing layer behind the
   nebula — keeps the void "alive" even on static pages ---- */
html::before {
  content: "";
  position: fixed;
  inset: -14%;
  z-index: -4;
  pointer-events: none;
  background: radial-gradient(42% 34% at 21% 16%, rgb(var(--accent-rgb) / 0.06), transparent 70%);
  animation: aurora-drift 26s ease-in-out infinite alternate;
}

@keyframes aurora-drift {
  from { opacity: 0.5; transform: translate3d(-2%, -1.5%, 0) scale(1); }
  to   { opacity: 1;   transform: translate3d(2%, 1.5%, 0) scale(1.08); }
}

/* ---- Typography ---- */

h1, h2, .display {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.015em;
  text-transform: uppercase;
  line-height: 1.02;
  color: var(--text);
}

h1, h2 { text-wrap: balance; }
h1 { font-size: var(--fs-hero); line-height: var(--lh-tight); }
h2 { font-size: var(--fs-h2); }
h3, h4 { font-weight: 600; line-height: 1.3; letter-spacing: -0.005em; }
h3 { font-size: var(--fs-md); }

p { color: var(--text-2); text-wrap: pretty; }

.label {
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  font-weight: 400;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-3);
}

.text-secondary { color: var(--text-2); }
.text-tertiary { color: var(--text-3); font-size: var(--fs-xs); }

/* Section kicker — numbered HUD label above section heads, e.g. ⟨01⟩ Domains */
.section-kicker {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: var(--space-3);
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  font-weight: 400;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-3);
}

.section-kicker::before { content: ""; width: 26px; height: 1px; flex-shrink: 0; background: linear-gradient(90deg, rgb(var(--accent-rgb) / 0.9), rgb(var(--accent-rgb) / 0)); }
.section-kicker b {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 24px;
  padding-inline: 8px;
  font-weight: 400;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  border: 1px solid rgb(var(--accent-rgb) / 0.35);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgb(255 255 255 / 0.06), rgb(255 255 255 / 0) 55%),
    rgb(var(--accent-rgb) / 0.07);
  box-shadow: inset 0 0 14px rgb(var(--accent-rgb) / 0.06);
  text-shadow: 0 0 12px rgb(var(--accent-rgb) / 0.6);
}
.section-kicker span { color: var(--text-2); }
.section-kicker::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, var(--line), transparent); }

.text-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.06em;
  color: var(--text);
  border-bottom: 1px solid var(--line-3);
  padding-bottom: 2px;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

.text-link:hover { color: var(--accent); border-color: var(--accent); }

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

:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: var(--radius-sm); }

.skip-link {
  position: absolute;
  top: -56px;
  left: var(--space-4);
  z-index: 300;
  padding: var(--space-2) var(--space-4);
  background: var(--accent);
  color: var(--on-accent);
  border-radius: var(--radius-pill);
  font-size: var(--fs-xs);
  font-weight: 600;
  transition: top var(--dur-fast) var(--ease);
}
.skip-link:focus { top: var(--space-4); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---- Layout ---- */

main { display: block; padding-top: var(--nav-height); }
main.main--hero { padding-top: 0; }

.container { width: 100%; max-width: var(--max-width); margin-inline: auto; padding-inline: var(--gutter); }
.container--narrow { max-width: calc(var(--max-width-narrow) + var(--gutter) * 2); }
.container--prose { max-width: calc(var(--max-width-prose) + var(--gutter) * 2); }

section { padding-block: var(--space-9); }
.section--flush-top { padding-top: 0; }
.section--flush-bottom { padding-bottom: 0; }
.section--tight { padding-block: var(--space-5) var(--space-8); }
.section--end { padding-block: 0 var(--space-9); }

.section-head { position: relative; max-width: var(--max-width-prose); margin-bottom: var(--space-7); }

/* Ghost chapter number — huge outline numeral hovering above the section head.
   Pure decoration fed from data-idx attributes; the visible markup text is untouched. */
.section-head::after {
  content: attr(data-idx);
  position: absolute;
  top: -0.42em;
  right: 0;
  z-index: -1;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2.8rem, 7.5vw, 6rem);
  line-height: 1;
  letter-spacing: 0.04em;
  color: rgb(var(--accent-rgb) / 0.1);
  pointer-events: none;
  user-select: none;
}
@supports (-webkit-text-stroke: 1px #000) {
  .section-head::after { color: transparent; -webkit-text-stroke: 1.25px rgb(255 255 255 / 0.09); }
}
.section-head--flush { margin-bottom: 0; }
.section-head .section-kicker:only-child { margin-bottom: var(--space-3); }
.section-head p { margin-top: var(--space-4); font-size: var(--fs-md); max-width: 62ch; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 999px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--accent-mid); }

/* ---- Staggered reveal ----
   fill-mode "backwards" (not "forwards") so the element returns to its normal
   styles afterwards and hover transforms still work. Elements below the fold
   get .is-pending from main.js and stay paused until scrolled into view. */

[data-reveal] {
  animation: reveal-in var(--dur-slow) var(--ease) backwards;
  animation-delay: calc(var(--i, 0) * 80ms + 120ms);
}

[data-reveal="1"] { --i: 1; }
[data-reveal="2"] { --i: 2; }
[data-reveal="3"] { --i: 3; }
[data-reveal="4"] { --i: 4; }

.is-pending { animation-play-state: paused !important; }

@keyframes reveal-in { from { opacity: 0; transform: translateY(20px); filter: blur(8px); } }

.section--intro { padding-bottom: var(--space-6); }
.section--band { padding-block: var(--space-8); }
.section--tail { padding-block: 0 var(--space-8); }

/* ---- Page transitions ----
   Browsers with cross-document View Transitions (Chrome 126+, Safari 18.2+)
   crossfade natively and keep the navbar + starfield fixed in place.
   Everything else uses js/transitions.js (html.is-leaving) as a fallback. */

@view-transition { navigation: auto; }

.navbar { view-transition-name: navbar; }
#starfield { view-transition-name: starfield; }

::view-transition-group(navbar),
::view-transition-group(starfield) { animation-duration: 0s; }

::view-transition-old(root) { animation: vt-out 320ms var(--ease) both; }
::view-transition-new(root) { animation: vt-in 520ms var(--ease) both; }

@keyframes vt-out { to { opacity: 0; transform: translateY(-10px); filter: blur(4px); } }
@keyframes vt-in { from { opacity: 0; transform: translateY(14px); filter: blur(4px); } }

html.is-leaving main,
html.is-leaving .footer {
  opacity: 0;
  transform: translateY(-10px);
  filter: blur(4px);
  transition: opacity 280ms var(--ease), transform 280ms var(--ease), filter 280ms var(--ease);
}

/* ---- Reduced motion (OS setting or Settings → Visual effects: Reduced) ---- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  @view-transition { navigation: none; }
  [data-reveal], .member-card { animation: none !important; }
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

html[data-fx="reduced"] [data-reveal],
html[data-fx="reduced"] .member-card { animation: none !important; }
html[data-fx="reduced"] { scroll-behavior: auto; }
html[data-fx="reduced"] .skeleton-line,
html[data-fx="reduced"] .data-table__skeleton-cell { animation: none; }
html[data-fx="reduced"] ::view-transition-group(*),
html[data-fx="reduced"] ::view-transition-old(*),
html[data-fx="reduced"] ::view-transition-new(*) { animation: none !important; }

@media (max-width: 640px) {
  section { padding-block: var(--space-8); }
}
