/**
 * PulseCheck — Base Stylesheet (base.css)
 * CSS Custom Properties, Modern Reset, Typography, Dark Mode, and Accessibility Utilities.
 */

:root {
  /* Core Surfaces */
  --bg-page: #f6f8fb;
  --bg-surface: #ffffff;
  --bg-surface-subtle: #f1f5f9;
  --bg-surface-hover: #f8fafc;
  --bg-glass: rgba(255, 255, 255, 0.86);

  /* Hero Dark Panel Palette */
  --hero-bg-start: #0b0f19;
  --hero-bg-end: #131b2e;
  --hero-glow-indigo: rgba(99, 102, 241, 0.22);
  --hero-glow-purple: rgba(139, 92, 246, 0.16);
  --hero-card-bg: rgba(255, 255, 255, 0.055);
  --hero-card-border: rgba(255, 255, 255, 0.12);
  --hero-text: #f8fafc;
  --hero-text-muted: #94a3b8;

  /* Text Hierarchy */
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-inverse: #ffffff;

  /* Borders & Dividers */
  --border-light: #e2e8f0;
  --border-subtle: #edf2f7;
  --border-focus: #4f46e5;

  /* Brand & Action Accents */
  --accent-primary: #4f46e5;
  --accent-primary-hover: #4338ca;
  --accent-primary-soft: rgba(79, 70, 229, 0.1);
  --accent-blue: #2563eb;

  /* Semantic Status Colors */
  --status-online: #10b981;
  --status-online-text: #047857;
  --status-online-bg: #ecfdf5;
  --status-online-border: #a7f3d0;

  --status-offline: #ef4444;
  --status-offline-text: #b91c1c;
  --status-offline-bg: #fef2f2;
  --status-offline-border: #fecaca;

  --status-slow: #f59e0b;
  --status-slow-text: #b45309;
  --status-slow-bg: #fffbeb;
  --status-slow-border: #fde68a;

  /* Radius & Elevation */
  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-pill: 9999px;

  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 4px 12px -2px rgba(15, 23, 42, 0.05), 0 2px 4px -2px rgba(15, 23, 42, 0.03);
  --shadow-md: 0 12px 28px -6px rgba(15, 23, 42, 0.08), 0 4px 10px -3px rgba(15, 23, 42, 0.04);
  --shadow-hero: 0 24px 48px -12px rgba(11, 15, 25, 0.28);

  /* Layout & Transitions */
  --container-max: 1240px;
  --nav-height: 68px;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --transition-fast: 150ms cubic-bezier(0.16, 1, 0.3, 1);
  --transition-smooth: 240ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* System Dark Mode Preference (when user hasn't forced light mode) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg-page: #090d16;
    --bg-surface: #111827;
    --bg-surface-subtle: #1e293b;
    --bg-surface-hover: #172033;
    --bg-glass: rgba(17, 24, 39, 0.86);

    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;

    --border-light: #1e293b;
    --border-subtle: #172033;

    --accent-primary: #6366f1;
    --accent-primary-hover: #818cf8;
    --accent-primary-soft: rgba(99, 102, 241, 0.16);

    --status-online-text: #34d399;
    --status-online-bg: rgba(16, 185, 129, 0.12);
    --status-online-border: rgba(16, 185, 129, 0.28);

    --status-offline-text: #f87171;
    --status-offline-bg: rgba(239, 68, 68, 0.12);
    --status-offline-border: rgba(239, 68, 68, 0.3);

    --status-slow-text: #fbbf24;
    --status-slow-bg: rgba(245, 158, 11, 0.12);
    --status-slow-border: rgba(245, 158, 11, 0.28);

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-sm: 0 4px 14px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 14px 30px rgba(0, 0, 0, 0.45);
  }
}

/* Explicit Manual Dark Mode Override */
:root[data-theme="dark"] {
  --bg-page: #090d16;
  --bg-surface: #111827;
  --bg-surface-subtle: #1e293b;
  --bg-surface-hover: #172033;
  --bg-glass: rgba(17, 24, 39, 0.86);

  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;

  --border-light: #1e293b;
  --border-subtle: #172033;

  --accent-primary: #6366f1;
  --accent-primary-hover: #818cf8;
  --accent-primary-soft: rgba(99, 102, 241, 0.16);

  --status-online-text: #34d399;
  --status-online-bg: rgba(16, 185, 129, 0.12);
  --status-online-border: rgba(16, 185, 129, 0.28);

  --status-offline-text: #f87171;
  --status-offline-bg: rgba(239, 68, 68, 0.12);
  --status-offline-border: rgba(239, 68, 68, 0.3);

  --status-slow-text: #fbbf24;
  --status-slow-bg: rgba(245, 158, 11, 0.12);
  --status-slow-border: rgba(245, 158, 11, 0.28);

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 4px 14px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 14px 30px rgba(0, 0, 0, 0.45);
}

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

html {
  font-family: var(--font-sans);
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  color-scheme: light dark;
}

body {
  background-color: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  transition: background-color var(--transition-smooth), color var(--transition-smooth);
  -webkit-font-smoothing: antialiased;
}

img,
svg {
  display: block;
  max-width: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: none;
}

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

ul,
ol {
  list-style: none;
}

/* Tabular numerals for latency metrics, status codes, and counters */
.tabular-nums {
  font-variant-numeric: tabular-nums;
}

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

/* Screen-reader only utility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

[hidden] {
  display: none !important;
}

@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;
  }
}
