/**
 * Base Styles - Modern Portfolio Design System
 * Foundation styles, resets, and design system variables
 * Performance: Critical styles are inlined; this loads deferred
 */

/* ============================================
   CSS Custom Properties (Design Tokens)
   ============================================ */
:root {
    /* Colors - Dark Mode (default) - Deep Navy Theme */
    --bg: #0a0f1e;
    --bg-gradient: linear-gradient(135deg, #0a0f1e 0%, #0f1729 50%, #162033 100%);
    --elev: #0f172a;
    --elev-hover: #1a2332;
    --text: #e6eaf2;
    --text-primary: #ffffff;
    --muted: #9aa4b2;
    --muted-light: #cbd5e0;
    --accent: #10b981;
    --accent-hover: #059669;
    --accent-2: #3b82f6;
    --accent-2-hover: #2563eb;
    --warn: #f59e0b;
    --danger: #ef4444;
    --success: #10b981;
    --border: #1e293b;
    --border-light: #334155;
    
    /* Typography */
    --font-base: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, "Noto Sans", Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
    --font-mono: "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", Consolas, "Courier New", monospace;
    
    /* Font Sizes - Fluid Typography */
    --text-xs: clamp(12px, 1.5vw, 14px);
    --text-sm: clamp(14px, 2vw, 16px);
    --text-base: clamp(16px, 2.2vw, 18px);
    --text-lg: clamp(18px, 2.5vw, 20px);
    --text-xl: clamp(20px, 3vw, 24px);
    --text-2xl: clamp(24px, 4vw, 28px);
    --text-3xl: clamp(28px, 5vw, 36px);
    --text-4xl: clamp(36px, 6vw, 48px);
    --text-5xl: clamp(48px, 8vw, 64px);
    
    /* Spacing - 8-point system */
    --space-1: 8px;
    --space-2: 16px;
    --space-3: 24px;
    --space-4: 32px;
    --space-5: 40px;
    --space-6: 48px;
    --space-8: 64px;
    --space-10: 80px;
    --space-12: 96px;
    
    /* Layout */
    --max-width: 1200px;
    --container-padding: clamp(16px, 5vw, 32px);
    
    /* Borders */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    
    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Z-index */
    --z-base: 1;
    --z-dropdown: 100;
    --z-sticky: 200;
    --z-modal: 1000;
}

/* Light Mode Override */
@media (prefers-color-scheme: light) {
    :root {
        --bg: #ffffff;
        --elev: #f6f8fb;
        --text: #0b1220;
        --muted: #4b5563;
        --accent: #059669;
        --accent-2: #3b82f6;
        --border: #dde5ee;
        
        --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
        --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
        --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.15), 0 4px 6px -4px rgb(0 0 0 / 0.1);
        --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.15), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    }
}

/* Reduced Motion Support (Accessibility) */
@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;
    }
}

/* ============================================
   Reset & Base Styles
   ============================================ */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-base);
    font-size: var(--text-base);
    line-height: 1.6;
    color: #000000;
    background-color: var(--bg);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ============================================
   Typography
   ============================================ */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.25;
    margin-bottom: var(--space-2);
    color: #000000;
}

h1 { font-size: var(--text-4xl); }
h2 { font-size: var(--text-3xl); }
h3 { font-size: var(--text-2xl); }
h4 { font-size: var(--text-xl); }
h5 { font-size: var(--text-lg); }
h6 { font-size: var(--text-base); }

p {
    margin-bottom: var(--space-2);
    line-height: 1.7;
}

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

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

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

strong, b {
    font-weight: 600;
}

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

code {
    background: var(--elev);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--accent);
}

pre {
    background: var(--elev);
    padding: var(--space-2);
    border-radius: var(--radius-md);
    overflow-x: auto;
    border: 1px solid var(--border);
}

pre code {
    background: none;
    padding: 0;
    color: #000000;
}

ul, ol {
    margin-bottom: var(--space-2);
    padding-left: var(--space-3);
}

li {
    margin-bottom: var(--space-1);
    line-height: 1.6;
}

blockquote {
    border-left: 4px solid var(--accent);
    padding-left: var(--space-2);
    margin: var(--space-3) 0;
    font-style: italic;
    color: var(--muted);
}

/* ============================================
   Layout Utilities
   ============================================ */
.container {
    width: 100%;
    max-width: var(--max-width);
    margin-left: auto;
    margin-right: auto;
    padding-left: var(--container-padding);
    padding-right: var(--container-padding);
}

.container-fluid {
    width: 100%;
    padding-left: var(--container-padding);
    padding-right: var(--container-padding);
}

/* Grid System (12-column fluid) */
.grid {
    display: grid;
    gap: var(--space-3);
}

.grid-cols-1 { grid-template-columns: repeat(1, 1fr); }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid-cols-12 { grid-template-columns: repeat(12, 1fr); }

/* Flexbox Utilities */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-start { justify-content: flex-start; }
.justify-end { justify-content: flex-end; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }

/* Spacing Utilities */
.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.pt-4 { padding-top: var(--space-4); }
.pb-4 { padding-bottom: var(--space-4); }
.pt-8 { padding-top: var(--space-8); }
.pb-8 { padding-bottom: var(--space-8); }

/* Text Utilities */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.text-muted { color: #666666 !important; }
.text-accent { color: var(--accent); }
.font-mono { font-family: var(--font-mono); }

/* Display Utilities */
.block { display: block; }
.inline-block { display: inline-block; }
.hidden { display: none; }
.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;
}

/* ============================================
   Skip Link (Accessibility)
   ============================================ */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--accent);
    color: var(--bg);
    padding: var(--space-1) var(--space-2);
    text-decoration: none;
    font-weight: 600;
    z-index: 10000;
    border-radius: 0 0 var(--radius-sm) 0;
}

.skip-link:focus {
    top: 0;
}

/* ============================================
   Images & Media
   ============================================ */
img,
video,
svg {
    max-width: 100%;
    height: auto;
    display: block;
}

img {
    border-style: none;
}

/* ============================================
   Focus States (Accessibility)
   ============================================ */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ============================================
   Selection
   ============================================ */
::selection {
    background-color: var(--accent);
    color: var(--bg);
}

::-moz-selection {
    background-color: var(--accent);
    color: var(--bg);
}

/* ============================================
   Scrollbar (Webkit)
   ============================================ */
::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

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

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

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

/* ============================================
   Responsive Breakpoints
   ============================================ */

/* Mobile: 0-479px (default styles above) */

/* Small Mobile: 480-767px */
@media (min-width: 480px) {
    :root {
        --container-padding: clamp(20px, 5vw, 40px);
    }
    
    .grid-sm-2 { grid-template-columns: repeat(2, 1fr); }
}

/* Tablet: 768-1023px */
@media (min-width: 768px) {
    :root {
        --container-padding: 32px;
    }
    
    .grid-md-2 { grid-template-columns: repeat(2, 1fr); }
    .grid-md-3 { grid-template-columns: repeat(3, 1fr); }
    .flex-md-row { flex-direction: row; }
}

/* Desktop: 1024-1439px */
@media (min-width: 1024px) {
    :root {
        --container-padding: 40px;
    }
    
    .grid-lg-3 { grid-template-columns: repeat(3, 1fr); }
    .grid-lg-4 { grid-template-columns: repeat(4, 1fr); }
}

/* Large Desktop: 1440px+ */
@media (min-width: 1440px) {
    :root {
        --container-padding: 48px;
    }
    
    .grid-xl-4 { grid-template-columns: repeat(4, 1fr); }
}
