/**
 * Astral Archive — Global Styles
 * ---------------------------------------------------------------------------
 * The utility stylesheet is compiled ahead of time (see build-tools/). This file holds:
 *   - CSS custom properties (design tokens)
 *   - Custom utility classes for frosted glass, gradients and animations
 *   - Component overrides that are hard to express with utility classes alone
 *
 * Palette: dark space theme with low-saturation blue-violet accents.
 * Motion: slow, smooth fade-ins and subtle parallax. No flash or bounce.
 */

/* -------------------------------------------------------------------------- */
/* CSS Variables                                                              */
/* -------------------------------------------------------------------------- */
:root {
  --bg-space: #07080C;
  --bg-space-900: #0A0B12;
  --bg-space-800: #12141C;
  --bg-space-700: #1A1D29;

  --text-primary: #F5F6F8;
  --text-secondary: #9AA0AE;
  --text-tertiary: #6B7284;
  --text-muted: #565C6B;

  --brand-indigo: #7C86E8;
  --brand-violet: #A692F0;
  --brand-cyan: #8FB6DA;
  --brand-soft: #8C93EA;
  --brand-gradient: linear-gradient(135deg, #7C86E8 0%, #A692F0 100%);

  --glass-bg: rgba(18, 20, 30, 0.55);
  --glass-bg-strong: rgba(9, 10, 14, 0.72);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-border-soft: rgba(255, 255, 255, 0.14);
  --glass-highlight: rgba(255, 255, 255, 0.05);

  --radius-card: 22px;
  --radius-lg: 26px;
  --radius-pill: 9999px;

  --transition-slow: 1s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-base: 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-fast: 0.25s ease;
}

/* -------------------------------------------------------------------------- */
/* Base reset                                                                 */
/* -------------------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  background-color: var(--bg-space);
  color: var(--text-primary);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'SF Pro Display', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  /* Deliberately NOT painted. `html` above already carries `--bg-space` for the
     canvas, and repeating it here silently buried every layer that sits behind
     the content: a non-positioned body's background is painted *after*
     negative-z-index descendants, so `.stars` (-1) and `body::before` (-2)
     never reached a screen while this was set. Measured with a probe layer at
     z-index:-1 — 0 px visible with the colour here, 711,511 px without it, and
     the shortfall from a full viewport is content legitimately occluding it,
     which is exactly what "behind the content" has to mean. Keep it out. */
  background-color: transparent;
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* The faint star-field background on every page.
   The two broad washes at the top are the aurora; the two below them are the
   nebula, added with the star-field density pass. They live here rather than in
   `.stars` because a wash is a large fraction of the backdrop by definition,
   and `.stars` is held to being a minority of it — see the note on `.stars`. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background:
    radial-gradient(circle at 20% 30%, rgba(124, 134, 232, 0.12) 0%, transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(166, 146, 240, 0.08) 0%, transparent 45%),
    radial-gradient(circle at 62% 78%, rgba(96, 128, 200, 0.075) 0%, transparent 55%),
    radial-gradient(circle at 34% 12%, rgba(140, 120, 210, 0.055) 0%, transparent 50%),
    var(--bg-space);
}

/* Animated star dust layer. Like `.meteor-layer` it lives in the negative band
   so the drift can never run across the content. It only actually rendered once
   `body` stopped painting an opaque background — see the note on `body` above. */
.stars {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  /* Density: 48 discrete points, four of them 2px, alpha 0.15–0.6. Measured by
     verify-background against a 1440×900 viewport: the previous eight 1.5px
     points lit roughly 10 px and read as a defect rather than as restraint.
     This keeps the field a minority of the backdrop (well under the 5% the
     contract allows) while making it actually visible behind the glass.

     The points are enumerated rather than tiled. A repeated background-size
     would cover the viewport with fewer gradients, but at these sizes the
     repeat becomes a legible grid — the one thing a star field must not be.

     Broad washes deliberately do NOT live here. `.stars` is the discrete
     field, and verify-background judges it as a minority of the backdrop;
     a nebula is by definition a large fraction of it, so it belongs in
     `body::before` with the other ground layers, where it is not measured as
     if it were a sprinkle of points. */
  background-image:
    radial-gradient(1.5px 1.5px at 12% 25%, rgba(255,255,255,0.45) 50%, transparent 50%),
    radial-gradient(1.5px 1.5px at 58% 18%, rgba(255,255,255,0.35) 50%, transparent 50%),
    radial-gradient(1.5px 1.5px at 88% 42%, rgba(255,255,255,0.3) 50%, transparent 50%),
    radial-gradient(1.5px 1.5px at 35% 62%, rgba(255,255,255,0.25) 50%, transparent 50%),
    radial-gradient(1.5px 1.5px at 72% 84%, rgba(255,255,255,0.35) 50%, transparent 50%),
    radial-gradient(1.5px 1.5px at 5% 82%, rgba(255,255,255,0.2) 50%, transparent 50%),
    radial-gradient(1.5px 1.5px at 95% 8%, rgba(255,255,255,0.25) 50%, transparent 50%),
    radial-gradient(1.5px 1.5px at 44% 38%, rgba(255,255,255,0.2) 50%, transparent 50%),
    radial-gradient(1.5px 1.5px at 23% 9%, rgba(255,255,255,0.3) 50%, transparent 50%),
    radial-gradient(1.5px 1.5px at 67% 11%, rgba(255,255,255,0.22) 50%, transparent 50%),
    radial-gradient(2px 2px at 81% 29%, rgba(255,255,255,0.6) 50%, transparent 50%),
    radial-gradient(1.5px 1.5px at 47% 7%, rgba(255,255,255,0.18) 50%, transparent 50%),
    radial-gradient(1.5px 1.5px at 9% 48%, rgba(255,255,255,0.28) 50%, transparent 50%),
    radial-gradient(1.5px 1.5px at 29% 44%, rgba(255,255,255,0.16) 50%, transparent 50%),
    radial-gradient(1.5px 1.5px at 63% 35%, rgba(255,255,255,0.24) 50%, transparent 50%),
    radial-gradient(1.5px 1.5px at 91% 57%, rgba(255,255,255,0.2) 50%, transparent 50%),
    radial-gradient(1.5px 1.5px at 18% 71%, rgba(255,255,255,0.26) 50%, transparent 50%),
    radial-gradient(1.5px 1.5px at 52% 55%, rgba(255,255,255,0.17) 50%, transparent 50%),
    radial-gradient(2px 2px at 77% 63%, rgba(255,255,255,0.55) 50%, transparent 50%),
    radial-gradient(1.5px 1.5px at 38% 88%, rgba(255,255,255,0.22) 50%, transparent 50%),
    radial-gradient(1.5px 1.5px at 60% 76%, rgba(255,255,255,0.3) 50%, transparent 50%),
    radial-gradient(1.5px 1.5px at 86% 91%, rgba(255,255,255,0.19) 50%, transparent 50%),
    radial-gradient(1.5px 1.5px at 14% 92%, rgba(255,255,255,0.24) 50%, transparent 50%),
    radial-gradient(1.5px 1.5px at 3% 12%, rgba(255,255,255,0.21) 50%, transparent 50%),
    radial-gradient(1.5px 1.5px at 96% 71%, rgba(255,255,255,0.23) 50%, transparent 50%),
    radial-gradient(1.5px 1.5px at 41% 20%, rgba(255,255,255,0.15) 50%, transparent 50%),
    radial-gradient(1.5px 1.5px at 55% 47%, rgba(255,255,255,0.27) 50%, transparent 50%),
    radial-gradient(1.5px 1.5px at 70% 6%, rgba(255,255,255,0.19) 50%, transparent 50%),
    radial-gradient(1.5px 1.5px at 26% 33%, rgba(255,255,255,0.23) 50%, transparent 50%),
    radial-gradient(1.5px 1.5px at 84% 15%, rgba(255,255,255,0.17) 50%, transparent 50%),
    radial-gradient(2px 2px at 31% 76%, rgba(255,255,255,0.58) 50%, transparent 50%),
    radial-gradient(1.5px 1.5px at 66% 94%, rgba(255,255,255,0.21) 50%, transparent 50%),
    radial-gradient(1.5px 1.5px at 11% 59%, rgba(255,255,255,0.25) 50%, transparent 50%),
    radial-gradient(1.5px 1.5px at 49% 69%, rgba(255,255,255,0.18) 50%, transparent 50%),
    radial-gradient(1.5px 1.5px at 94% 33%, rgba(255,255,255,0.26) 50%, transparent 50%),
    radial-gradient(1.5px 1.5px at 20% 15%, rgba(255,255,255,0.16) 50%, transparent 50%),
    radial-gradient(1.5px 1.5px at 74% 45%, rgba(255,255,255,0.29) 50%, transparent 50%),
    radial-gradient(1.5px 1.5px at 57% 90%, rgba(255,255,255,0.2) 50%, transparent 50%),
    radial-gradient(2px 2px at 8% 36%, rgba(255,255,255,0.52) 50%, transparent 50%),
    radial-gradient(1.5px 1.5px at 88% 80%, rgba(255,255,255,0.24) 50%, transparent 50%),
    radial-gradient(1.5px 1.5px at 36% 52%, rgba(255,255,255,0.17) 50%, transparent 50%),
    radial-gradient(1.5px 1.5px at 1% 61%, rgba(255,255,255,0.22) 50%, transparent 50%),
    radial-gradient(1.5px 1.5px at 62% 27%, rgba(255,255,255,0.25) 50%, transparent 50%),
    radial-gradient(1.5px 1.5px at 45% 81%, rgba(255,255,255,0.19) 50%, transparent 50%),
    radial-gradient(1.5px 1.5px at 16% 41%, rgba(255,255,255,0.23) 50%, transparent 50%),
    radial-gradient(1.5px 1.5px at 79% 97%, rgba(255,255,255,0.18) 50%, transparent 50%),
    radial-gradient(1.5px 1.5px at 53% 12%, rgba(255,255,255,0.21) 50%, transparent 50%),
    radial-gradient(1.5px 1.5px at 98% 51%, rgba(255,255,255,0.2) 50%, transparent 50%);
  background-size: 100% 100%;
  opacity: 0.9;
  animation: drift 120s linear infinite;
}

@keyframes drift {
  from { transform: translateY(0); }
  to { transform: translateY(-40px); }
}

/* -------------------------------------------------------------------------- */
/* Atmosphere — sky fields behind the 3D stages, and meteors                  */
/* -------------------------------------------------------------------------- */
/* The interactive stages draw onto a transparent canvas, so whatever is behind
   them shows through. Without a field of their own they float on the flat page
   ground and read as a widget rather than as sky. This layer is that sky: a
   static gradient star field, inserted by assets/js/atmosphere.js, sitting
   behind the stage — never inside it, because the vendored globe renderer
   clears its container on mount and would delete a child. */
.atmosphere-frame {
  position: relative;
  display: block;
}

.atmosphere-stars {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  border-radius: inherit;
  background-size: 100% 100%;
  opacity: 0.85;
}

/* The stage must clear the field whichever way it was placed: as a sibling
   after the field, or as a child of the wrapper. Both cases are covered. */
.atmosphere-frame > [data-atmosphere='stars'],
.atmosphere-stars + [data-atmosphere='stars'],
.sky-stage > canvas,
.skymap-stage > canvas,
.orrery-stage > canvas,
.orbit-globe-stage > canvas {
  position: relative;
  z-index: 1;
}

/* The shower itself. One fixed, inert layer for the whole document; streaks
   are pooled in and out of it by the module and never receive pointer events.

   It sits in the negative band, i.e. *behind* the content, and that is the
   whole point of the layer: a streak crossing the viewport is decoration, and
   decoration has no business drawing over anything a visitor is reading or
   clicking. It used to be `z-index: 3`, which put a full-viewport animated
   layer above every unpositioned element in `<main>` — streaks travelled
   across body text and card edges.

   Ordering inside the band is DOM order, and the module appends this layer
   after `.stars`, so the shower stays in front of the star field while both
   remain behind the page. `main`/`footer` must NOT be given a background that
   covers the viewport, or this band is lost again. */
.meteor-layer {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.meteor {
  position: absolute;
  top: var(--my, 0);
  left: var(--mx, 0);
  width: 2px;
  height: 2px;
  border-radius: 999px;
  background: #fff;
  opacity: 0;
  will-change: transform, opacity;
  box-shadow: 0 0 6px 1px rgba(214, 224, 255, 0.7);
  animation: meteor-fall var(--mdur, 1.4s) cubic-bezier(0.22, 0.61, 0.36, 1) var(--mdelay, 0s) forwards;
}

/* The head is a dot; the tail is a gradient trailing back up the angle. The
   streak travels down and to the right, so the tail sits up and to the left. */
.meteor::before {
  content: '';
  position: absolute;
  top: 50%;
  right: 50%;
  width: 88px;
  height: 1px;
  transform-origin: right center;
  transform: translateY(-50%) rotate(135deg);
  background: linear-gradient(to left, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0));
  border-radius: 999px;
}

@keyframes meteor-fall {
  0% {
    opacity: 0;
    transform: translate3d(0, 0, 0) scale(0.4);
  }
  12% {
    opacity: 1;
  }
  70% {
    opacity: 0.9;
  }
  100% {
    opacity: 0;
    transform: translate3d(var(--mtravel, 30vh), calc(var(--mtravel, 30vh) * 0.62), 0) scale(1);
  }
}

/* -------------------------------------------------------------------------- */
/* Typography                                                                 */
/* -------------------------------------------------------------------------- */
h1, h2, h3, h4, h5, h6, p {
  margin: 0;
}

.text-gradient {
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* -------------------------------------------------------------------------- */
/* Frosted glass                                                              */
/* -------------------------------------------------------------------------- */
.glass {
  position: relative;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  box-shadow:
    0 40px 80px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.glass-strong {
  background: var(--glass-bg-strong);
  border-bottom: 1px solid var(--glass-border);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
}

/* Where the engine cannot blur at all (older Safari, or blur switched off for
   performance), a glass panel is just a 55%-opaque sheet over whatever happens
   to be behind it — which, now that the star field actually paints, is no
   longer a flat colour. Give it a solid ground instead so contrast survives
   the loss of the effect rather than degrading quietly. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass {
    background: rgba(14, 16, 24, 0.94);
  }

  .glass-strong {
    background: rgba(9, 10, 14, 0.96);
  }
}

.glass-border {
  border: 1px solid var(--glass-border);
}

.glass-border-soft {
  border: 1px solid var(--glass-border-soft);
}

/* A subtle inner glow for card tops. */
.glass::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255,255,255,0.04) 0%, transparent 35%);
}

/* -------------------------------------------------------------------------- */
/* Buttons                                                                    */
/* -------------------------------------------------------------------------- */
.btn-primary {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.875rem 1.75rem;
  border-radius: var(--radius-pill);
  background: var(--brand-gradient);
  color: #ffffff;
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: opacity var(--transition-fast), transform var(--transition-fast);
  box-shadow: 0 12px 32px rgba(124, 134, 232, 0.35);
}

.btn-primary:hover {
  opacity: 0.92;
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.875rem 1.75rem;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-primary);
  font-weight: 500;
  font-size: 0.95rem;
  text-decoration: none;
  border: 1px solid var(--glass-border-soft);
  cursor: pointer;
  transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.btn-secondary:hover {
  opacity: 0.85;
  transform: translateY(-1px);
}

/* -------------------------------------------------------------------------- */
/* Keyboard focus                                                             */
/* -------------------------------------------------------------------------- */
:focus-visible {
  outline: 2px solid var(--brand-soft);
  outline-offset: 3px;
  border-radius: 6px;
}

/* The dialog is modal, so the page behind it must not scroll. */
body.modal-open {
  overflow: hidden;
}

/* Header gains depth once the page has scrolled. */
.glass-strong.is-scrolled {
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.45);
}

/* The build step marks the current page's nav link; keep it readable against
   the frosted header without relying on hover only. */
.nav-link.is-active {
  color: #FFFFFF;
}

/* -------------------------------------------------------------------------- */
/* Scroll / fade reveal                                                       */
/* -------------------------------------------------------------------------- */
/* The hidden state is scoped to `.js`, which an inline head script sets before
   first paint. Without scripting the rules never apply, so the content stays
   visible instead of sitting at opacity 0 forever. */
.js .reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity var(--transition-slow), transform var(--transition-slow);
  will-change: opacity, transform;
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Stagger children when a parent reveals. */
.js .stagger-children > * {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.9s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.9s cubic-bezier(0.16, 1, 0.3, 1);
}

.stagger-children.visible > *:nth-child(1) { transition-delay: 0.00s; }
.stagger-children.visible > *:nth-child(2) { transition-delay: 0.08s; }
.stagger-children.visible > *:nth-child(3) { transition-delay: 0.16s; }
.stagger-children.visible > *:nth-child(4) { transition-delay: 0.24s; }
.stagger-children.visible > *:nth-child(5) { transition-delay: 0.32s; }
.stagger-children.visible > *:nth-child(6) { transition-delay: 0.40s; }
.stagger-children.visible > *:nth-child(7) { transition-delay: 0.48s; }
.stagger-children.visible > *:nth-child(8) { transition-delay: 0.56s; }

.stagger-children.visible > * {
  opacity: 1;
  transform: translateY(0);
}

/* -------------------------------------------------------------------------- */
/* Module badge                                                               */
/* -------------------------------------------------------------------------- */
.quality-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--brand-cyan);
  background: rgba(143, 182, 218, 0.1);
  border: 1px solid rgba(143, 182, 218, 0.22);
}

/* -------------------------------------------------------------------------- */
/* Library / search results                                                   */
/* -------------------------------------------------------------------------- */
.paper-card {
  padding: 1.25rem;
  border-radius: var(--radius-card);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--glass-border);
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.paper-card:hover {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.12);
}

.paper-title {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text-primary);
  text-decoration: none;
}

.paper-title:hover {
  color: var(--brand-soft);
}

/* Records are read in place, so a heading title must not hover like a link. */
h3.paper-title:hover {
  color: var(--text-primary);
}

.paper-authors {
  color: var(--text-tertiary);
  font-size: 0.85rem;
  margin-top: 0.35rem;
}

.paper-summary {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.55;
  margin-top: 0.65rem;
}

/* Record metadata row under an abstract. */
.paper-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.9rem;
  margin-top: 0.8rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  color: var(--text-tertiary);
  font-size: 0.75rem;
}

.paper-meta .paper-index {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.02em;
  color: var(--brand-soft);
}

/* Small text button used for expand and cite actions. */
.paper-action {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-tertiary);
  font-size: 0.72rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast),
              color var(--transition-fast);
}

.paper-action:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--glass-border-soft);
  color: var(--text-primary);
}

.paper-action[data-copied='true'] {
  border-color: rgba(143, 212, 180, 0.34);
  color: #8FD4B4;
}

/* Empty / error state for the result list. */
.paper-empty {
  padding: 2.5rem 1.5rem;
  border-radius: var(--radius-card);
  border: 1px dashed rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.02);
  text-align: center;
  color: var(--text-tertiary);
  font-size: 0.9rem;
  line-height: 1.6;
}

/* Recent searches, above the result list.
   The Library does not load planner.css — that sheet belongs to the observing
   forms — so the chips are styled here rather than borrowing .planner-chip
   from a stylesheet this page never fetches. Same visual language, local
   definition, no cross-page dependency. */
.library-recent-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.library-recent-chips {
  margin-top: 0.55rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.library-recent-chip {
  max-width: 100%;
  height: 28px;
  padding: 0 0.75rem;
  border-radius: 999px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast);
}

.library-recent-chip:hover {
  color: var(--text-primary);
  background: rgba(124, 134, 232, 0.12);
  border-color: rgba(124, 134, 232, 0.35);
}

.library-recent-chip:focus-visible {
  outline: 2px solid rgba(124, 134, 232, 0.8);
  outline-offset: 2px;
}

/* -------------------------------------------------------------------------- */
/* Utilities                                                                  */
/* -------------------------------------------------------------------------- */
.glow-purple {
  box-shadow: 0 0 80px rgba(124, 134, 232, 0.18);
}

.no-scrollbar::-webkit-scrollbar {
  display: none;
}
.no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* -------------------------------------------------------------------------- */
/* Missions / archive filters                                                 */
/* -------------------------------------------------------------------------- */
.field-select,
.field-input {
  height: 44px;
  padding: 0 1rem;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  font-size: 0.875rem;
  font-family: inherit;
  outline: none;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.field-input::placeholder {
  color: var(--text-tertiary);
}

.field-select:hover,
.field-input:hover {
  background: rgba(255, 255, 255, 0.07);
}

.field-select:focus,
.field-input:focus {
  border-color: rgba(124, 134, 232, 0.5);
  background: rgba(255, 255, 255, 0.07);
}

/* Native dropdown list needs its own colours on dark backgrounds. */
.field-select option {
  background: var(--bg-space-800);
  color: var(--text-primary);
}

/* -------------------------------------------------------------------------- */
/* Missions / record rows                                                     */
/* -------------------------------------------------------------------------- */
.mission-row {
  border-radius: var(--radius-card);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.mission-row:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
}

.mission-row[data-open="true"] {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(124, 134, 232, 0.32);
}

.mission-toggle {
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  padding: 1.15rem 1.25rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.mission-name {
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.mission-sub {
  margin-top: 0.3rem;
  font-size: 0.85rem;
  color: var(--text-tertiary);
}

.mission-chevron {
  flex-shrink: 0;
  color: var(--text-tertiary);
  transition: transform var(--transition-base), color var(--transition-fast);
}

.mission-row[data-open="true"] .mission-chevron {
  transform: rotate(90deg);
  color: var(--brand-soft);
}

/* Meta grid inside an expanded record. */
.mission-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem 1.5rem;
  padding: 0 1.25rem 1.25rem;
}

.mission-meta dt {
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.mission-meta dd {
  margin: 0.2rem 0 0;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--text-secondary);
}

.mission-outcome {
  margin: 0 1.25rem 1.25rem;
  padding: 0.9rem 1.1rem;
  border-radius: 16px;
  background: rgba(124, 134, 232, 0.08);
  border: 1px solid rgba(124, 134, 232, 0.22);
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text-primary);
}

/* Member-only payload manifest. */
.locked-block {
  margin: 0 1.25rem 1.25rem;
  padding: 0.9rem 1.1rem;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed rgba(255, 255, 255, 0.14);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

/* -------------------------------------------------------------------------- */
/* Status pills and agency chips                                              */
/* -------------------------------------------------------------------------- */
.pill {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 0.7rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 500;
  white-space: nowrap;
}

.pill-success {
  color: #8FD4B4;
  background: rgba(143, 212, 180, 0.1);
  border: 1px solid rgba(143, 212, 180, 0.26);
}

.pill-operational {
  color: var(--brand-cyan);
  background: rgba(143, 182, 218, 0.1);
  border: 1px solid rgba(143, 182, 218, 0.26);
}

.pill-partial {
  color: #E3C48D;
  background: rgba(227, 196, 141, 0.1);
  border: 1px solid rgba(227, 196, 141, 0.26);
}

.pill-failed {
  color: #E39BA4;
  background: rgba(227, 155, 164, 0.1);
  border: 1px solid rgba(227, 155, 164, 0.26);
}

.pill-progress {
  color: var(--brand-violet);
  background: rgba(166, 146, 240, 0.1);
  border: 1px solid rgba(166, 146, 240, 0.26);
}

.agency-chip {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 0.7rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  white-space: nowrap;
}

/* -------------------------------------------------------------------------- */
/* Reduced motion                                                             */
/* -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .stars {
    animation: none;
  }

  /* Meteors are decoration, and a streak crossing the viewport is exactly the
     kind of motion this preference is asking us to stop. The module does not
     mount the shower at all under this preference; hiding the layer too means
     the effect stays off even if it was mounted before the setting changed. */
  .meteor-layer {
    display: none;
  }

  /* Content must be readable without waiting for a scroll-triggered fade.
     Scoped to `.js` so it outranks the `.js .reveal` rule above. */
  .js .reveal,
  .js .stagger-children > * {
    opacity: 1;
    transform: none;
    transition: none;
  }

  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* -------------------------------------------------------------------------- */
/* Background decoration: what it is allowed to cost                          */
/* -------------------------------------------------------------------------- */
/* Everything above is optional in the dimensions that matter — legibility,
   input, and the frame budget — so each one is a door it can be shut behind
   rather than a fixed cost. Three of the four are pure CSS and need no script:
   `prefers-reduced-motion` above, viewport width here, and engine capability in
   the `@supports` fallback beside `.glass`. The fourth — a tab that is not on
   screen — is signalled by the module as `html[data-page-hidden]`. */

/* A 40px drift over two minutes is imperceptible on a phone and still keeps a
   full-viewport composited layer alive for the whole session. Not worth it. */
@media (max-width: 768px) {
  .stars {
    animation: none;
  }
}

/* Off-screen. A browser throttles a background tab but never fully stops it,
   and this is decoration: it should cost nothing while nobody is looking. The
   module stops spawning and clears its timer on the same signal. */
html[data-page-hidden] .stars {
  animation-play-state: paused;
}

html[data-page-hidden] .meteor-layer {
  display: none;
}

/* -------------------------------------------------------------------------- */
/* Responsive tweaks                                                          */
/* -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .btn-primary,
  .btn-secondary {
    width: 100%;
    justify-content: center;
  }

  .mission-meta {
    grid-template-columns: minmax(0, 1fr);
  }
}
