/* Design tokens, reset, global typography, the starfield canvas, and
   accessibility primitives. Loaded first. */

:root {
  color-scheme: dark;
  /* v3.4 charcoal/graphite space theme — near-black base, low blue wash. */
  --bg-0: #07090d;  /* near-black */
  --bg-1: #0d0f14;  /* charcoal */
  --bg-2: #14171d;  /* graphite */
  --panel: rgba(22, 24, 30, 0.72);
  --panel-strong: rgba(18, 20, 26, 0.92);
  --panel-soft: rgba(255, 255, 255, 0.045);
  --text: #eef1f6;
  --muted: #9aa1ad;       /* neutral gray (was blue-gray) */
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.16);
  --accent: #73b6ff;      /* focal accent (focus rings, links) — not a wash */
  --accent-2: #9d7dff;
  --success: #62d7a3;
  --warning: #ffd166;
  --danger: #ff808e;

  /* Solid gray button surfaces (v3.4.1). Buttons are flat graphite rather than
     tinted/translucent gradients so the whole control layer reads as one solid,
     neutral system against the charcoal background. */
  --btn-bg: #24272e;
  --btn-bg-hover: #2e323a;
  --btn-bg-active: #1e2127;
  --btn-border: rgba(255, 255, 255, 0.12);
  --btn-border-hover: rgba(255, 255, 255, 0.22);
  /* Primary = same family, one step lighter, so hierarchy survives without color. */
  --btn-primary-bg: #333842;
  --btn-primary-bg-hover: #3d434e;
  --btn-primary-border: rgba(255, 255, 255, 0.2);
  /* Neutral focus ring (no blue) that still reads clearly on dark. */
  --focus-ring: rgba(226, 232, 240, 0.85);
  --focus-ring-glow: rgba(226, 232, 240, 0.22);

  /* Organization accent tokens — the single source of truth for badges, pills,
     overview tiles, and card edges. Chosen as DISTINCT visual families so every
     organization is recognizable at a glance; overridable per-user via
     js/org-theme.js (which rewrites these custom properties on :root). */
  --org-nasa: #ff7a90;        /* rose / coral */
  --org-spacex: #5aa0ff;      /* blue */
  --org-blueorigin: #ffcf5c;  /* gold / amber */
  --org-rocketlab: #51d8a8;   /* teal / green */
  --org-ula: #b69bff;         /* violet / purple */
  --org-firefly: #ff8a4c;     /* orange */
  --org-all: #8aa0d8;         /* neutral indigo / slate */
  --org-saved: #9fb3c8;       /* neutral (distinct from providers) */

  /* Spacing scale. */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;

  /* Radii. */
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 12px;
  --radius-pill: 999px;

  /* Borders + shadows. */
  --border-subtle: 1px solid var(--line);
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.38);
  --shadow-card: 0 10px 28px rgba(0, 0, 0, 0.28);
  --shadow-card-hover: 0 18px 40px rgba(0, 0, 0, 0.4);
  --shadow-overlay: 0 20px 60px rgba(0, 0, 0, 0.38);

  /* Centralized motion system. Restrained, reduced-motion-aware. */
  --motion-instant: 0ms;
  --motion-fast: 140ms;
  --motion-normal: 220ms;
  --motion-slow: 360ms;
  --motion-emphasis: 520ms;
  --ease-standard: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --stagger-step: 40ms;

  --max-width: 1320px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  /* Charcoal space gradient with only the faintest cool tint near the top, so
     the page reads as black/graphite rather than a blue wash. */
  background:
    radial-gradient(120% 80% at 50% -10%, rgba(120, 130, 150, 0.08), transparent 60%),
    linear-gradient(180deg, var(--bg-0), var(--bg-1) 55%, #06070a);
  overflow-x: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  color: inherit;
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  border: 0;
}

/* Lock background scroll while a modal/drawer overlay is open. */
body.overlay-open {
  overflow: hidden;
}

@keyframes shimmer {
  from { background-position: 200% 0; }
  to { background-position: -20% 0; }
}

@keyframes overlayFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modalPop {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes drawerSlide {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

/* The toast leaves the way it arrived: straight out to the right. */
@keyframes statusOut {
  from { opacity: 1; transform: translate3d(0, 0, 0); }
  to { opacity: 0; transform: translate3d(28px, 0, 0); }
}

/* ----- Centralized reusable motion classes ------------------------------- */
@keyframes motionRiseIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes motionScaleIn {
  from { opacity: 0; transform: translateY(6px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes motionHighlight {
  0% { box-shadow: 0 0 0 0 rgba(115, 182, 255, 0.5); }
  100% { box-shadow: 0 0 0 8px rgba(115, 182, 255, 0); }
}

.motion-fade-in { animation: overlayFade var(--motion-normal) var(--ease-out) both; }
.motion-rise-in { animation: motionRiseIn var(--motion-normal) var(--ease-out) both; }
.motion-scale-in { animation: motionScaleIn var(--motion-normal) var(--ease-out) both; }
.motion-spotlight-enter { animation: motionRiseIn var(--motion-slow) var(--ease-out) both; }
.motion-highlight { animation: motionHighlight var(--motion-emphasis) var(--ease-out); }

/* Card entrance with a capped per-card stagger (set via --card-index). */
.motion-card-enter {
  animation: motionRiseIn var(--motion-normal) var(--ease-out) both;
  animation-delay: calc(var(--card-index, 0) * var(--stagger-step));
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }

  /* Drop entrance transforms entirely so nothing animates into place. */
  .motion-rise-in,
  .motion-scale-in,
  .motion-card-enter,
  .motion-spotlight-enter {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
}
