/* ==========================================================================
   base.css — design tokens, reset, typography
   Dark theme only. Every value below is a token: nothing hard-codes a colour,
   radius, shadow or duration anywhere else in the codebase.
   ========================================================================== */

:root {
  /* --- Surfaces --------------------------------------------------------- */
  --bg: #09090b;
  --bg-sidebar: #0c0c0f;
  --surface: #18181b;
  --surface-2: #111827;
  --surface-3: #1f1f23;

  /* Glass: translucent fill + blur, used by every card, panel and popover. */
  --glass: rgba(24, 24, 27, 0.62);
  --glass-strong: rgba(12, 12, 15, 0.82);
  --blur: blur(16px) saturate(160%);

  /* --- Lines ------------------------------------------------------------ */
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.12);
  /* Gradient hairline used on premium cards (mask-composite trick). */
  --border-gradient: linear-gradient(140deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.02) 42%, rgba(139, 92, 246, 0.22));

  /* --- Text (contrast tested against --bg) ------------------------------- */
  --text: #fafafa;        /* 18.4:1 */
  --text-secondary: #d4d4d8;
  --text-muted: #a1a1aa;  /* 7.4:1  — passes AA for body text */
  --text-subtle: #71717a; /* decorative / disabled only */

  /* --- Brand ------------------------------------------------------------ */
  --primary: #4f8cff;
  --primary-hover: #6b9dff;
  --primary-soft: rgba(79, 140, 255, 0.14);
  --primary-glow: rgba(79, 140, 255, 0.35);
  --secondary: #8b5cf6;
  --secondary-soft: rgba(139, 92, 246, 0.14);
  --gradient: linear-gradient(135deg, #4f8cff 0%, #8b5cf6 100%);
  --gradient-soft: linear-gradient(135deg, rgba(79, 140, 255, 0.16), rgba(139, 92, 246, 0.16));

  /* --- Semantic --------------------------------------------------------- */
  --success: #34d399;
  --success-soft: rgba(52, 211, 153, 0.13);
  --warning: #fbbf24;
  --warning-soft: rgba(251, 191, 36, 0.13);
  --danger: #f43f5e;
  --danger-hover: #fb5a75;
  --danger-soft: rgba(244, 63, 94, 0.13);

  /* --- Radius (16–20px on cards, scaled down for controls) --------------- */
  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius: 12px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-xl: 22px;
  --radius-pill: 999px;

  /* --- Elevation: soft, wide, low-opacity ------------------------------- */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-sm: 0 2px 8px -2px rgba(0, 0, 0, 0.4);
  --shadow: 0 12px 32px -12px rgba(0, 0, 0, 0.7);
  --shadow-lg: 0 24px 60px -20px rgba(0, 0, 0, 0.8);
  --shadow-glow: 0 8px 28px -10px var(--primary-glow);
  --ring: 0 0 0 3px rgba(79, 140, 255, 0.4);

  /* --- Motion: one easing, three durations ------------------------------ */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --t-fast: 0.15s var(--ease);
  --t: 0.25s var(--ease);
  --t-slow: 0.4s var(--ease);

  /* --- Spacing scale (4px base) ----------------------------------------- */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;

  /* --- Metrics ---------------------------------------------------------- */
  --sidebar-w: 264px;
  --sidebar-w-collapsed: 76px;
  --header-h: 68px;
  --gap: var(--space-6);
  --content-max: 1360px;

  /* --- Type ------------------------------------------------------------- */
  --font: "Inter", "Plus Jakarta Sans", ui-sans-serif, system-ui, -apple-system,
    "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", "Cascadia Code", Consolas, monospace;

  --text-xs: 11.5px;
  --text-sm: 12.5px;
  --text-base: 14px;
  --text-md: 15px;
  --text-lg: 17px;
  --text-xl: 20px;
  --text-2xl: 24px;
  --text-3xl: clamp(26px, 2.6vw, 34px);

  --icon: 20px;
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  color-scheme: dark;
}

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--text-base);
  line-height: 1.6;
  letter-spacing: -0.006em;
  font-feature-settings: "cv02", "cv03", "cv04", "ss01";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden; /* nothing may scroll the page sideways */
}

/* Ambient brand light — the only decorative gradient in the app. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(900px 500px at 75% -10%, rgba(79, 140, 255, 0.12), transparent 65%),
    radial-gradient(700px 420px at 12% 0%, rgba(139, 92, 246, 0.09), transparent 65%);
}

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

/* --- Typography scale ----------------------------------------------------- */
h1, h2, h3, h4 {
  font-weight: 600;
  line-height: 1.22;
  letter-spacing: -0.022em;
  text-wrap: balance;
}
h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }
h4 { font-size: var(--text-md); }
p { text-wrap: pretty; }

.display {
  font-size: var(--text-3xl);
  font-weight: 650;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.text-muted { color: var(--text-muted); }
.text-gradient {
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.mono { font-family: var(--font-mono); font-variant-ligatures: none; }

/* --- Icons: one size, one stroke, always optically centred ---------------- */
.icon {
  width: var(--icon);
  height: var(--icon);
  flex: none;
  stroke-width: 2;
  vertical-align: middle;
}
.icon--sm { width: 16px; height: 16px; }
.icon--lg { width: 24px; height: 24px; }

/* --- Focus: visible, consistent, never removed ---------------------------- */
:focus { outline: none; }
:focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-radius: var(--radius-sm);
}

::selection { background: var(--primary-soft); color: var(--text); }

/* --- Scrollbars ----------------------------------------------------------- */
* { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.14) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-pill);
}
*::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.22); }
*::-webkit-scrollbar-track { background: transparent; }

.skip-link {
  position: fixed;
  top: -60px;
  left: var(--space-4);
  z-index: 200;
  padding: 10px 16px;
  border-radius: var(--radius);
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  transition: top var(--t);
}
.skip-link:focus { top: var(--space-4); }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

[hidden] { display: none !important; }

/* --- Shared entrance animations ------------------------------------------- */
@keyframes fade-in { from { opacity: 0; } }
@keyframes slide-up { from { opacity: 0; transform: translateY(12px); } }
@keyframes scale-in { from { opacity: 0; transform: scale(0.96); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { to { background-position: 200% 0; } }

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