/*
 * Exam Analytics (Beta) v1.0.0
 * Base Styles: Resets, CSS Variables, Tokens
 * License: Self-contained, no external dependencies
 */

/* ==================== CSS Reset ==================== */
*, *::before, *::after {
    box-sizing: border-box;
}

* {
    margin: 0;
    padding: 0;
}

html {
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

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

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

p, h1, h2, h3, h4, h5, h6 {
    overflow-wrap: break-word;
}

/* ==================== CSS Custom Properties ==================== */
:root {
    /* Color Tokens - Light Mode */
    --color-primary: #0B5ED7;
    --color-primary-hover: #0A52C2;
    --color-primary-light: #E7F1FF;
    --color-accent: #10B981;
    --color-accent-hover: #0EA472;
    --color-background: #F8FAFC;
    --color-surface: #FFFFFF;
    --color-surface-secondary: #F1F5F9;
    --color-text: #0F172A;
    --color-text-secondary: #475569;
    --color-text-muted: #94A3B8;
    --color-border: #E2E8F0;
    --color-border-strong: #CBD5E1;
    --color-error: #DC2626;
    --color-warning: #F59E0B;
    --color-success: #10B981;
    --color-info: #3B82F6;

    /* Shadow Tokens */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

    /* Spacing Scale */
    --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;

    /* Typography Scale */
    --font-family-base: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-family-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

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

    /* Border Radius */
    --radius-sm: 0.25rem;
    --radius-md: 0.375rem;
    --radius-lg: 0.5rem;
    --radius-xl: 0.75rem;
    --radius-full: 9999px;

    /* Transitions */
    --transition-fast: 150ms ease-in-out;
    --transition-base: 250ms ease-in-out;
    --transition-slow: 350ms ease-in-out;

    /* Z-index Scale */
    --z-base: 1;
    --z-dropdown: 100;
    --z-sticky: 200;
    --z-modal: 300;
    --z-popover: 400;
    --z-tooltip: 500;

    /* Layout Constraints */
    --max-width-sm: 640px;
    --max-width-md: 768px;
    --max-width-lg: 1024px;
    --max-width-xl: 1280px;
    --max-width-content: 1440px;
}

/* ==================== Dark Theme ==================== */
[data-theme="dark"] {
    --color-primary: #3B82F6;
    --color-primary-hover: #2563EB;
    --color-primary-light: #1E3A8A;
    --color-accent: #10B981;
    --color-accent-hover: #059669;
    --color-background: #0F172A;
    --color-surface: #1E293B;
    --color-surface-secondary: #334155;
    --color-text: #F1F5F9;
    --color-text-secondary: #CBD5E1;
    --color-text-muted: #64748B;
    --color-border: #334155;
    --color-border-strong: #475569;
    --color-error: #EF4444;
    --color-warning: #F59E0B;
    --color-success: #10B981;
    --color-info: #3B82F6;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.4);
}

/* ==================== High Contrast Theme ==================== */
[data-theme="high-contrast"] {
    --color-primary: #0000FF;
    --color-primary-hover: #0000CC;
    --color-primary-light: #E6E6FF;
    --color-accent: #008000;
    --color-accent-hover: #006600;
    --color-background: #FFFFFF;
    --color-surface: #FFFFFF;
    --color-surface-secondary: #F0F0F0;
    --color-text: #000000;
    --color-text-secondary: #000000;
    --color-text-muted: #333333;
    --color-border: #000000;
    --color-border-strong: #000000;
    --color-error: #CC0000;
    --color-warning: #CC6600;
    --color-success: #008000;
    --color-info: #0000FF;

    --shadow-sm: none;
    --shadow-md: none;
    --shadow-lg: 0 0 0 2px #000000;
}

/* ==================== Base Styles ==================== */
html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family-base);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-normal);
    line-height: var(--line-height-normal);
    color: var(--color-text);
    background-color: var(--color-background);
    min-height: 100vh;
}

/* ==================== Typography ==================== */
h1, h2, h3, h4, h5, h6 {
    font-weight: var(--font-weight-bold);
    line-height: var(--line-height-tight);
    color: var(--color-text);
}

h1 {
    font-size: var(--font-size-4xl);
    margin-bottom: var(--space-6);
}

h2 {
    font-size: var(--font-size-3xl);
    margin-bottom: var(--space-5);
}

h3 {
    font-size: var(--font-size-2xl);
    margin-bottom: var(--space-4);
}

h4 {
    font-size: var(--font-size-xl);
    margin-bottom: var(--space-3);
}

h5 {
    font-size: var(--font-size-lg);
    margin-bottom: var(--space-3);
}

h6 {
    font-size: var(--font-size-base);
    margin-bottom: var(--space-2);
}

p {
    margin-bottom: var(--space-4);
    color: var(--color-text-secondary);
}

a {
    color: var(--color-primary);
    text-decoration: underline;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--color-primary-hover);
}

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

code, pre {
    font-family: var(--font-family-mono);
    font-size: var(--font-size-sm);
}

code {
    background-color: var(--color-surface-secondary);
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-sm);
}

pre {
    background-color: var(--color-surface-secondary);
    padding: var(--space-4);
    border-radius: var(--radius-md);
    overflow-x: auto;
    margin-bottom: var(--space-4);
}

/* ==================== Skip Link ==================== */
.skip-link {
    position: absolute;
    top: -100px;
    left: 0;
    background: var(--color-primary);
    color: white;
    padding: var(--space-2) var(--space-4);
    text-decoration: none;
    z-index: var(--z-tooltip);
    border-radius: var(--radius-md);
}

.skip-link:focus {
    top: var(--space-2);
    left: var(--space-2);
}

/* ==================== Focus Visible ==================== */
:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* ==================== 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;
    }
}

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