/* ==========================================================================
   UI Style Vault — Base CSS: Reset, Tokens, Fallback Fonts & Scales
   Offline-first, Zero External Dependencies, WCAG 2.2 AA Compliant
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Modern Comprehensive CSS Reset
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  line-height: 1.5;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  -moz-tab-size: 4;
  tab-size: 4;
  height: 100%;
}

body {
  min-height: 100%;
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  font-family: var(--font-sans-modern);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  position: relative;
}

/* Responsive media defaults */
img,
picture,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
  height: auto;
}

/* Typography elements baseline */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.25;
  letter-spacing: -0.02em;
}

p, ul, ol, dl, blockquote {
  margin: 0;
  padding: 0;
}

ul, ol {
  list-style: none;
}

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

table {
  border-collapse: collapse;
  border-spacing: 0;
  width: 100%;
}

/* Form controls baseline */
input,
button,
textarea,
select {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  outline: none;
}

button {
  cursor: pointer;
  user-select: none;
}

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

/* Accessible focus ring */
:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

/* Monospace preformatted text */
pre,
code,
kbd,
samp {
  font-family: var(--font-mono-code);
  font-size: 0.9em;
}

/* Reduced motion preference */
@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;
  }
}

/* Custom modern dark scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-prominent) transparent;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background-color: var(--border-prominent);
  border-radius: var(--radius-full);
  border: 2px solid transparent;
  background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
  background-color: var(--text-tertiary);
}

/* --------------------------------------------------------------------------
   2. Design Tokens (:root)
   -------------------------------------------------------------------------- */
:root {
  /* --- Dark Neutral Background Palette --- */
  --bg-canvas: #0c0d12;
  --bg-surface: #12141c;
  --bg-surface-elevated: #161822;
  --bg-surface-sunken: #08090d;
  --bg-surface-glass: rgba(18, 20, 28, 0.75);
  --bg-surface-glass-elevated: rgba(22, 24, 34, 0.88);

  /* --- Border & Divider Tokens --- */
  --border-subtle: #1c1f2d;
  --border-default: #222533;
  --border-prominent: #2f3347;
  --border-focus: #6366f1;
  --border-glass: rgba(255, 255, 255, 0.08);

  /* --- Text Color Hierarchy --- */
  --text-primary: #f1f3f9;
  --text-secondary: #a1a7bb;
  --text-tertiary: #626880;
  --text-disabled: #3f4358;
  --text-inverse: #0c0d12;

  /* --- Accent Highlights & Glows --- */
  --accent-primary: #6366f1;
  --accent-primary-hover: #4f46e5;
  --accent-primary-active: #4338ca;
  --accent-primary-subtle: rgba(99, 102, 241, 0.12);
  --accent-primary-glow: rgba(99, 102, 241, 0.35);

  --accent-cyan: #06b6d4;
  --accent-cyan-subtle: rgba(6, 182, 212, 0.12);
  --accent-amber: #f59e0b;
  --accent-amber-subtle: rgba(245, 158, 11, 0.12);
  --accent-rose: #f43f5e;
  --accent-rose-subtle: rgba(244, 63, 94, 0.12);
  --accent-emerald: #10b981;
  --accent-emerald-subtle: rgba(16, 185, 129, 0.12);
  --accent-violet: #8b5cf6;

  /* --- Status Colors --- */
  --status-success: #10b981;
  --status-warning: #f59e0b;
  --status-error: #f43f5e;
  --status-info: #06b6d4;

  /* --- 10 System / OS Fallback Font Stacks --- */
  --font-sans-modern: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-sans-geometric: 'Century Gothic', 'Tw Cen MT', Futura, 'Trebuchet MS', sans-serif;
  --font-sans-humanist: 'Segoe UI', Optima, Candara, Calibri, sans-serif;
  --font-serif-editorial: 'Didot', 'Bodoni MT', 'Cinzel', Georgia, serif;
  --font-serif-literary: 'Charter', 'Baskerville', 'Palatino Linotype', 'Book Antiqua', Georgia, serif;
  --font-serif-news: 'Times New Roman', 'Times', 'Cambria', serif;
  --font-mono-code: 'Cascadia Code', 'Fira Code', 'Consolas', 'Courier New', monospace;
  --font-mono-retro: 'VT323', 'Fixedsys', 'Lucida Console', 'Courier New', monospace;
  --font-display-grotesk: 'Impact', 'Arial Black', 'Haettenschweiler', sans-serif;
  --font-handwritten: 'Segoe Script', 'Bradley Hand', 'Comic Sans MS', cursive;

  /* --- Spacing Scale --- */
  --space-3xs: 2px;
  --space-2xs: 4px;
  --space-xs: 6px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 24px;
  --space-2xl: 32px;
  --space-3xl: 48px;
  --space-4xl: 64px;
  --space-5xl: 80px;

  /* --- Border Radius Scale --- */
  --radius-xs: 3px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* --- Box Shadows & Glows --- */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.55);
  --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.65);
  --shadow-glow-accent: 0 0 24px rgba(99, 102, 241, 0.35);
  --shadow-glow-cyan: 0 0 24px rgba(6, 182, 212, 0.35);
  --shadow-glow-amber: 0 0 24px rgba(245, 158, 11, 0.35);
  --shadow-inner-sunken: inset 0 2px 4px rgba(0, 0, 0, 0.5);

  /* --- Motion Curves & Transition Timing --- */
  --transition-instant: 80ms ease;
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 400ms cubic-bezier(0.16, 1, 0.3, 1);
  --transition-spring: 500ms cubic-bezier(0.34, 1.56, 0.64, 1);

  /* --- Z-Index Layer Architecture --- */
  --z-deep: -1;
  --z-base: 1;
  --z-card: 2;
  --z-card-hover: 5;
  --z-dropdown: 10;
  --z-sticky-category: 90;
  --z-sticky-header: 100;
  --z-compare-tray: 500;
  --z-modal-backdrop: 900;
  --z-modal: 1000;
  --z-toast: 2000;
  --z-tooltip: 3000;
}

/* --------------------------------------------------------------------------
   3. Global Utility Classes
   -------------------------------------------------------------------------- */
.sr-only,
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.is-hidden,
[hidden] {
  display: none !important;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.text-mono {
  font-family: var(--font-mono-code);
}
