/* CSS Reset and Base Styles */
*,
*::before,
*::after {
    box-sizing: border-box;
}

* {
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    line-height: 1.6;
    color: var(--color-text);
    background: var(--color-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* CSS Custom Properties */
:root {
    /* Brand — source tokens */
    --brand-blue-500: #05aadc;
    --brand-blue-600: #0698c5; /* darker shade */
    --brand-blue-700: #0586ae; /* darker shade */
    --brand-green-500: #19af6e; /* base */
    --brand-green-500-alt: #19af69; /* hover/alt */
    --brand-green-600: #169d63;
    --brand-green-700: #128a57;
    --brand-navy-900: #0a1e32; /* primary navy */
    --brand-navy-800: #0f1e32; /* alt navy */

    /* Extended palette (derived by taste from brand) */
    --blue-50:  #e6f9fe;
    --blue-100: #cff3fb;
    --blue-200: #9fe6f7;
    --blue-800: #066c8f;
    --blue-900: #055471;

    --green-50:  #e8f9f1;
    --green-100: #d3f2e4;
    --green-200: #a8e6d1;
    --green-800: #0f6f46;
    --green-900: #0c5838;

    /* Neutrals (paired with navy) */
    --ink-900: #0f172a;
    --ink-800: #1e293b;
    --ink-700: #334155;
    --ink-600: #475569;
    --ink-500: #64748b;
    --surface-0: #ffffff;
    --surface-50: #f8fafc;
    --surface-100:#f1f5f9;

    /* Semantic aliases */
    --color-bg: var(--surface-0);
    --color-bg-muted: var(--surface-50);
    --color-text: var(--ink-900);
    --color-text-muted: var(--ink-600);
    --color-link: var(--brand-blue-500);
    --color-link-hover: var(--brand-blue-600);
    --color-primary: var(--brand-blue-500);
    --color-primary-pressed: var(--brand-blue-700);
    --color-success: var(--brand-green-500);
    --color-success-hover: var(--brand-green-500-alt);
    --color-navy: var(--brand-navy-900);
    --color-border: #e2e8f0;
    --color-focus: var(--brand-blue-500);

    /* Gradients & shadows */
    --grad-hero: linear-gradient(180deg, rgba(10,30,50,.92) 0%, rgba(10,30,50,.75) 40%, rgba(5,170,220,.45) 100%);
    --shadow-sm: 0 1px 2px rgba(2,8,23,.06), 0 1px 1px rgba(2,8,23,.04);
    --shadow-md: 0 6px 24px rgba(2,8,23,.08);

    /* Legacy aliases for backward compatibility */
    --bg: var(--color-bg);
    --ink: var(--color-text);
    --muted: var(--color-text-muted);
    --brand: var(--color-primary);
    --accent: var(--color-success);
    --warn: #f59e0b;
    --danger: #ef4444;
    --surface: var(--surface-0);
    --card: var(--surface-50);
    
    /* Semantic colors */
    --text-primary: var(--color-text);
    --text-secondary: var(--color-text-muted);
    --text-inverse: var(--surface-0);
    --bg-primary: var(--color-bg);
    --bg-secondary: var(--color-bg-muted);
    --bg-inverse: var(--color-navy);
    --border: var(--color-border);
    --border-focus: var(--color-focus);
    --shadow: rgba(0, 0, 0, 0.1);
    --shadow-hover: rgba(0, 0, 0, 0.15);
    
    /* Typography */
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 1.875rem;
    --font-size-4xl: 2.25rem;
    --font-size-5xl: 3rem;
    
    --font-weight-normal: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;
    
    --line-height-tight: 1.25;
    --line-height-normal: 1.5;
    --line-height-relaxed: 1.75;
    
    /* Spacing */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
    --space-16: 4rem;
    --space-20: 5rem;
    --space-24: 6rem;
    
    /* Border radius */
    --radius-sm: 0.25rem;
    --radius-md: 0.375rem;
    --radius-lg: 0.5rem;
    --radius-xl: 0.75rem;
    --radius-2xl: 1rem;
    --radius-full: 9999px;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 var(--shadow);
    --shadow-md: 0 4px 6px -1px var(--shadow), 0 2px 4px -1px var(--shadow);
    --shadow-lg: 0 10px 15px -3px var(--shadow), 0 4px 6px -2px var(--shadow);
    --shadow-xl: 0 20px 25px -5px var(--shadow), 0 10px 10px -5px var(--shadow);
    
    /* Transitions */
    --transition-fast: 120ms cubic-bezier(0.2, 0.7, 0.2, 1);
    --transition-normal: 150ms cubic-bezier(0.2, 0.7, 0.2, 1);
    --transition-slow: 220ms cubic-bezier(0.2, 0.7, 0.2, 1);
    
    /* Z-index scale */
    --z-dropdown: 1000;
    --z-sticky: 1020;
    --z-fixed: 1030;
    --z-modal-backdrop: 1040;
    --z-modal: 1050;
    --z-popover: 1060;
    --z-tooltip: 1070;
    --z-toast: 1080;
}

/* Dark theme */
@media (prefers-color-scheme: dark) {
    :root {
        --color-bg: #0b1220;
        --color-bg-muted: #0e1729;
        --color-text: #e6edf5;
        --color-text-muted: #b8c3d1;
        --color-border: #1f2a3a;
        --grad-hero: linear-gradient(180deg, rgba(10,30,50,1) 0%, rgba(10,30,50,.9) 35%, rgba(5,170,220,.35) 100%);
        
        /* Update legacy aliases for dark mode */
        --bg: var(--color-bg);
        --ink: var(--color-text);
        --muted: var(--color-text-muted);
        --surface: var(--color-bg);
        --card: var(--color-bg-muted);
    }
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: var(--font-weight-bold);
    line-height: var(--line-height-tight);
    color: var(--text-primary);
    margin-bottom: var(--space-4);
}

h1 {
    font-size: var(--font-size-4xl);
}

h2 {
    font-size: var(--font-size-3xl);
}

h3 {
    font-size: var(--font-size-2xl);
}

h4 {
    font-size: var(--font-size-xl);
}

h5 {
    font-size: var(--font-size-lg);
}

h6 {
    font-size: var(--font-size-base);
}

p {
    margin-bottom: var(--space-4);
    color: var(--text-secondary);
}

a {
    color: var(--color-link);
    text-decoration: none;
    text-decoration-thickness: 2px;
    text-underline-offset: 2px;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--color-link-hover);
}

a:focus {
    outline: 2px solid var(--color-focus);
    outline-offset: 2px;
}

/* Lists */
ul, ol {
    margin-bottom: var(--space-4);
    padding-left: var(--space-6);
}

li {
    margin-bottom: var(--space-2);
}

/* Images */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Form elements */
input, textarea, select {
    font-family: inherit;
    font-size: var(--font-size-base);
    line-height: var(--line-height-normal);
}

button {
    font-family: inherit;
    font-size: var(--font-size-base);
    cursor: pointer;
    border: none;
    background: none;
}

/* Focus styles */
:focus-visible {
    outline: 3px solid color-mix(in oklab, var(--color-focus) 80%, white);
    outline-offset: 2px;
    transition: outline-color .12s ease;
}

:focus:not(:focus-visible) {
    outline: none;
}

/* Skip link for accessibility */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: var(--color-primary);
    color: var(--text-inverse);
    padding: var(--space-2) var(--space-4);
    text-decoration: none;
    border-radius: var(--radius-md);
    z-index: var(--z-tooltip);
    transition: top var(--transition-fast);
}

.skip-link:focus {
    top: 6px;
}

/* Screen reader only content */
.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;
}

/* Visually hidden but accessible to screen readers */
.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Reduced motion preferences */
@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;
    }
}
