/* ==========================================================================
   INCLUSIV DESIGN SYSTEM — Base Styles, Tokens, Typography
   "Dark Precision" theme — dark-mode-first with brand navy (#1F3886)
   ========================================================================== */

/* ---------- Google Fonts ---------- */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700;800&family=DM+Sans:ital,wght@0,400;0,500;0,600;0,700;1,400&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

/* ---------- Design Tokens ---------- */
:root {
    /* Dark backgrounds */
    --color-bg: #0F1219;
    --color-surface: #1A1F2E;
    --color-surface-raised: #242A3D;
    --color-surface-hover: #2D3548;

    /* Brand primary */
    --color-primary: #1F3886;
    --color-primary-light: #2B4DAF;
    --color-primary-dark: #162860;
    --color-primary-surface: rgba(31, 56, 134, 0.12);

    /* Accent — golden amber */
    --color-accent: rgb(255, 202, 56);
    --color-accent-muted: #E6B020;
    --color-accent-dark: #C99600;
    --color-accent-surface: rgba(255, 202, 56, 0.12);

    /* Text on dark */
    --color-text: #F0F2F7;
    --color-text-secondary: #C8D0E2;
    --color-text-muted: #A8B3C8;
    --color-text-inverse: #0F1219;

    /* Semantic */
    --color-success: #34D399;
    --color-success-surface: rgba(52, 211, 153, 0.12);
    --color-warning: #FBBF24;
    --color-warning-surface: rgba(251, 191, 36, 0.12);
    --color-danger: #F87171;
    --color-danger-surface: rgba(248, 113, 113, 0.12);
    --color-info: #60A5FA;
    --color-info-surface: rgba(96, 165, 250, 0.12);

    /* Borders */
    --color-border: #2D3548;
    --color-border-strong: #1F3886;

    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;

    /* Radius */
    --border-radius-sm: 4px;
    --border-radius-md: 8px;
    --border-radius-lg: 12px;

    /* Shadows */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.4);

    /* Layout */
    --sidebar-width: 260px;
    --sidebar-collapsed: 72px;
    --topbar-height: 0px;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
    --transition-slow: 400ms ease;
}

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

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

body {
    margin: 0;
    padding: 0;
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--color-text);
    background-color: var(--color-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Dot-grid background pattern */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    background-image: radial-gradient(circle, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 24px 24px;
    pointer-events: none;
}

/* ---------- Typography ---------- */
h1, h2, h3, h4, h5, h6,
.iv-heading {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    color: var(--color-text);
    line-height: 1.3;
    margin-top: 0;
    margin-bottom: var(--space-md);
}

h1, .iv-h1 { font-size: 2rem; font-weight: 700; }
h2, .iv-h2 { font-size: 1.625rem; font-weight: 600; }
h3, .iv-h3 { font-size: 1.375rem; font-weight: 600; }
h4, .iv-h4 { font-size: 1.125rem; font-weight: 600; }
h5, .iv-h5 { font-size: 1rem; font-weight: 600; }
h6, .iv-h6 { font-size: 0.875rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }

p {
    margin-top: 0;
    margin-bottom: var(--space-md);
    color: var(--color-text-secondary);
}

a {
    color: var(--color-accent);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--color-accent-muted);
}

a:focus-visible {
    outline: 3px solid var(--color-accent);
    outline-offset: 2px;
    border-radius: 2px;
}

strong, b {
    font-weight: 600;
    color: var(--color-text);
}

small, .iv-small {
    font-size: 0.8125rem;
}

.iv-mono {
    font-family: 'JetBrains Mono', monospace;
}

.iv-stat-number {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    font-size: 1.75rem;
    line-height: 1.1;
    color: var(--color-text);
}

.iv-label {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-text-muted);
}

/* ---------- Selection ---------- */
::selection {
    background-color: var(--color-primary);
    color: white;
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--color-bg);
}

::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 4px;
}

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

/* ---------- Focus Indicators (WCAG) ---------- */
:focus-visible {
    outline: 3px solid var(--color-accent);
    outline-offset: 2px;
}

:focus:not(:focus-visible) {
    outline: none;
}

/* ---------- Screen Reader Only ---------- */
.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;
}

.sr-only-focusable:focus,
.sr-only-focusable:active {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip: auto;
    white-space: normal;
}

/* ---------- Skip Navigation Link ---------- */
.iv-skip-link {
    position: absolute;
    top: -100%;
    left: var(--space-md);
    z-index: 10000;
    padding: var(--space-sm) var(--space-lg);
    background: var(--color-accent);
    color: var(--color-text-inverse);
    font-weight: 600;
    border-radius: var(--border-radius-md);
    transition: top var(--transition-fast);
}

.iv-skip-link:focus {
    top: var(--space-md);
    outline: 3px solid var(--color-text);
    outline-offset: 2px;
}

/* ---------- Utility Classes ---------- */
.iv-text-accent { color: var(--color-accent); }
.iv-text-primary { color: var(--color-primary-light); }
.iv-text-muted { color: var(--color-text-muted); }
.iv-text-secondary { color: var(--color-text-secondary); }
.iv-text-success { color: var(--color-success); }
.iv-text-warning { color: var(--color-warning); }
.iv-text-danger { color: var(--color-danger); }
.iv-text-info { color: var(--color-info); }

.iv-bg-surface { background-color: var(--color-surface); }
.iv-bg-raised { background-color: var(--color-surface-raised); }

.iv-border { border: 2px solid var(--color-border); }
.iv-border-strong { border: 2px solid var(--color-border-strong); }
.iv-border-accent { border: 2px solid var(--color-accent); }

.iv-rounded-sm { border-radius: var(--border-radius-sm); }
.iv-rounded-md { border-radius: var(--border-radius-md); }
.iv-rounded-lg { border-radius: var(--border-radius-lg); }

/* ---------- Override Bootstrap dark-unfriendly defaults ---------- */
.text-muted {
    color: var(--color-text-muted) !important;
}

.text-dark {
    color: var(--color-text) !important;
}

hr {
    border-color: var(--color-border);
    opacity: 1;
}

code {
    color: var(--color-accent);
    background: var(--color-surface-raised);
    padding: 0.15em 0.4em;
    border-radius: var(--border-radius-sm);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.875em;
}

/* ---------- Bootstrap Override: Containers ---------- */
.container,
.container-fluid {
    color: var(--color-text);
}

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