:root {
    /* 60-30-10 Color System - Optimized */
    
    /* Neutral colors (60%) - Primary color distribution */
    --neutral-100: #FAFAFB; /* Off-white - backgrounds */
    --neutral-200: #F1F5F9; /* Soft gray - secondary backgrounds */
    --neutral-300: #E5E7EB; /* Light gray - borders, dividers */
    --neutral-400: #9CA3AF; /* Medium gray - disabled states */
    --neutral-600: #4a4a4a; /* Dark gray - secondary text */
    --neutral-800: #1a1a1a; /* Near black - primary text */
    
    /* Primary/brand colors (30%) - Secondary color distribution */
    --primary-600: #1E3A8A; /* Deep navy - main brand color */
    --primary-400: #3B82F6; /* Steel blue - secondary brand color */
    
    /* Accent color (10%) - Minimal color distribution */
    --accent-500: #D7BA89; /* Warm gold - CTAs, highlights */
    
    /* Semantic color mappings for light mode */
    --text-primary: var(--neutral-800);
    --text-secondary: var(--neutral-600);
    --text-tertiary: var(--neutral-400);
    --bg-primary: var(--neutral-100);
    --bg-secondary: var(--neutral-200);
    --border-color: var(--neutral-300);
    
    /* Dark mode colors */
    --dark-bg-primary: #121212;
    --dark-bg-secondary: #1e1e1e;
    --dark-text-primary: #e0e0e0;
    --dark-text-secondary: #a0a0a0;
    --dark-text-tertiary: #6a6a6a;
    --dark-border: #2a2a2a;
    
    /* Legacy compatibility - will be phased out */
    --deep-navy: var(--primary-600);
    --steel-blue: var(--primary-400);
    --warm-gold: var(--accent-500);
    --muted-blue-gray: #6B7280;
    --off-white: var(--neutral-100);
    --soft-gray: var(--neutral-200);
    
    /* Spacing scale with rem for better accessibility */
    --space-xs: 0.5rem;
    --space-sm: 1rem;
    --space-md: 1.5rem;
    --space-lg: 2rem;
    --space-xl: 3rem;
    --space-2xl: 4rem;
    --space-3xl: 6rem;
    
    /* Typography scale - optimized for modern readability */
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 1.875rem;
    --text-4xl: 2.25rem;
    --text-5xl: 3rem;
    --text-6xl: 3.75rem;
    
    /* Improved line heights for better readability */
    --line-height-tight: 1.25;
    --line-height-normal: 1.5;
    --line-height-relaxed: 1.625;
    --line-height-loose: 2;
    
    /* Content width constraints for optimal reading */
    --content-width-narrow: 600px;
    --content-width-medium: 800px;
    --content-width-wide: 1000px;
}

/* CSS Reset & Base Styles - consolidated for fewer rules */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: 'Inter', system-ui, sans-serif;
    line-height: 1.6;
    font-weight: 400;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color 0.3s ease, color 0.3s ease;
    color: var(--text-primary);
    background-color: var(--bg-primary);
}

/* Theme Classes - Optimized */
body.light-mode {
    --text-primary: var(--neutral-800);
    --text-secondary: var(--neutral-600);
    --text-tertiary: var(--neutral-400);
    --bg-primary: var(--neutral-100);
    --bg-secondary: var(--neutral-200);
    --border-color: var(--neutral-300);
    --bg-white: #FFFFFF;
}

body.dark-mode {
    --text-primary: var(--dark-text-primary);
    --text-secondary: var(--dark-text-secondary);
    --text-tertiary: var(--dark-text-tertiary);
    --bg-primary: var(--dark-bg-primary);
    --bg-secondary: var(--dark-bg-secondary);
    --border-color: var(--dark-border);
    --bg-white: var(--dark-bg-secondary);
}

/* Typography System */
.serif {
    font-family: 'Crimson Pro', Georgia, serif;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: var(--line-height-tight);
    letter-spacing: -0.02em;
    margin-bottom: var(--space-md);
}

/* Typography Classes - Enhanced with better line heights and spacing */
.text-6xl { 
    font-size: var(--text-6xl); 
    line-height: var(--line-height-tight);
    font-weight: 700;
    letter-spacing: -0.025em;
}
.text-5xl { 
    font-size: var(--text-5xl); 
    line-height: var(--line-height-tight);
    font-weight: 600;
    letter-spacing: -0.025em;
}
.text-4xl { 
    font-size: var(--text-4xl); 
    line-height: var(--line-height-tight);
    font-weight: 600;
    letter-spacing: -0.025em;
}
.text-3xl { 
    font-size: var(--text-3xl); 
    line-height: var(--line-height-normal);
    font-weight: 600;
}
.text-2xl { 
    font-size: var(--text-2xl); 
    line-height: var(--line-height-normal);
    font-weight: 600;
}
.text-xl { 
    font-size: var(--text-xl); 
    line-height: var(--line-height-normal);
    font-weight: 500;
}
.text-lg { 
    font-size: var(--text-lg); 
    line-height: var(--line-height-relaxed);
    font-weight: 400;
}
.text-base { 
    font-size: var(--text-base); 
    line-height: var(--line-height-relaxed);
    font-weight: 400;
}
.text-sm { 
    font-size: var(--text-sm); 
    line-height: var(--line-height-normal);
    font-weight: 400;
}

/* Color Utilities - Aligned with 60-30-10 system */
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.text-brand { color: var(--primary-600); }
.text-brand-light { color: var(--primary-400); }
.text-accent { color: var(--accent-500); }
.text-white { color: white; }

/* Text Alignment */
.text-left { text-align: left; }
.text-center { text-align: center; }
.text-right { text-align: right; }

/* Background Colors */
.bg-brand { background-color: var(--primary-600); } /* Primary brand (navy) */
.bg-brand-light { background-color: var(--primary-400); } /* Secondary brand (blue) */
.bg-accent { background-color: var(--accent-500); } /* Accent (gold) */
.bg-soft { background-color: var(--bg-secondary); } /* Soft backgrounds */
.bg-white { background-color: var(--bg-white); }

/* Legacy color classes for compatibility */
.bg-secondary { background-color: var(--primary-400); }
.bg-accent-secondary { background-color: var(--accent-500); }
.text-accent-secondary { color: var(--accent-500); }

/* Layout Utilities */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--space-sm);
}

.section {
    padding: var(--space-3xl) 0;
}

.section-sm {
    padding: var(--space-2xl) 0;
}

/* Grid System */
.grid {
    display: grid;
}

.grid-2 {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-2xl);
}

.about-grid {
    align-items: start; /* Changed from center to start for better text flow */
    gap: var(--space-3xl); /* Maintain large gap between columns */
    /* Ensure spacing from the section heading above even if margins collapse */
    margin-top: var(--space-2xl);
}

/* About Section Text Content - Specific spacing for text-heavy content */
.about-grid > div:first-child {
    padding-right: var(--space-lg); /* Add breathing room on the right */
    line-height: 1.7; /* Slightly increase line height for better readability */
}

.about-grid > div:first-child p {
    margin-bottom: var(--space-xl); /* Increase spacing between paragraphs */
    max-width: 90%; /* Slightly constrain line length for better readability */
}

.about-grid > div:first-child p:last-child {
    margin-bottom: var(--space-2xl); /* Add extra space after the last paragraph for visual transition */
}

/* About Section Stats Card - Position and spacing adjustments */
.about-grid .card {
    margin-top: var(--space-lg); /* Add top margin to create visual separation */
}

.grid-3 {
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-2xl);
}

.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.items-center {
    align-items: center;
}

.justify-center {
    justify-content: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }
.gap-xl { gap: var(--space-xl); }

/* Spacing Utilities */
.mt-xs { margin-top: var(--space-xs); }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mt-xl { margin-top: var(--space-xl); }
.mt-2xl { margin-top: var(--space-2xl); }

.mb-xs { margin-bottom: var(--space-xs); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.mb-xl { margin-bottom: var(--space-xl); }
.mb-2xl { margin-bottom: var(--space-2xl); }

.py-sm { padding: var(--space-sm) 0; }
.py-md { padding: var(--space-md) 0; }
.py-lg { padding: var(--space-lg) 0; }
.py-xl { padding: var(--space-xl) 0; }

.px-sm { padding: 0 var(--space-sm); }
.px-md { padding: 0 var(--space-md); }
.px-lg { padding: 0 var(--space-lg); }
.px-xl { padding: 0 var(--space-xl); }

/* Component Styles */
.btn {
    display: inline-flex;
    align-items: center;
    padding: var(--space-sm) var(--space-lg);
    border-radius: 6px;
    text-decoration: none;
    font-weight: 500;
    transition: all 200ms ease;
    cursor: pointer;
    border: none;
    font-size: var(--text-base);
    min-height: 44px; /* Touch-friendly */
}

.btn-primary {
    background-color: var(--deep-navy);
    color: white;
}

.btn-primary:hover {
    background-color: var(--steel-blue);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(30, 58, 138, 0.25);
}

.btn-secondary {
    background-color: var(--warm-gold);
    color: white;
    border: none;
}

.btn-secondary:hover {
    background-color: var(--muted-blue-gray);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(139, 158, 183, 0.25);
}

.btn-outline {
    background-color: transparent;
    color: var(--text-primary);
    border: 2px solid var(--muted-blue-gray);
}

.btn-outline:hover {
    background-color: var(--muted-blue-gray);
    color: white;
    border-color: var(--muted-blue-gray);
}

/* Navigation */
.nav {
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 100;
    padding: var(--space-sm) 0;
    transition: background-color 0.3s ease, border-color 0.3s ease;
    /* Default styles will be controlled by light-mode/dark-mode classes */
}

.nav-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-logo {
    font-weight: 700;
    font-size: var(--text-xl);
    color: var(--text-primary);
    text-decoration: none;
}

.nav-links {
    display: flex;
    list-style: none;
    gap: var(--space-lg);
}

.nav-link {
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 500;
    transition: color 200ms ease;
    padding: var(--space-xs) var(--space-sm);
}

.nav-link:hover {
    color: var(--warm-gold);
}

.nav-link.active {
    color: var(--deep-navy);
    font-weight: 600;
    position: relative;
}

.nav-link.active::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: var(--warm-gold);
}

/* Hero Section - Enhanced for better visual hierarchy */
.hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    padding-top: 80px; /* Account for fixed nav */
    position: relative;
    overflow: hidden;
    text-align: center;
}

.hero-parallax-bg {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: -1;
    background: linear-gradient(135deg, rgba(30, 58, 138, 0.05), rgba(59, 130, 246, 0.08));
}

.hero-content {
    max-width: var(--content-width-medium);
    position: relative;
    z-index: 2;
    margin: 0 auto;
    padding: 0 var(--space-md);
}

.hero-content h1 {
    margin-bottom: var(--space-xl);
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
}

.hero-content p {
    margin-bottom: var(--space-2xl);
    max-width: var(--content-width-narrow);
    margin-left: auto;
    margin-right: auto;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    background: rgba(139, 158, 183, 0.15);
    color: var(--muted-blue-gray);
    padding: var(--space-xs) var(--space-sm);
    border-radius: 20px;
    font-size: var(--text-sm);
    font-weight: 500;
    margin-bottom: var(--space-xl);
    border: 1px solid rgba(139, 158, 183, 0.2);
}

/* Hero specific content styling */
.hero-description {
    max-width: var(--content-width-narrow);
    margin-left: auto;
    margin-right: auto;
}

.hero-actions {
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-md);
}

/* Cards - Enhanced spacing and typography */
.card {
    background: var(--bg-white);
    border-radius: 12px;
    padding: var(--space-xl);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 300ms ease;
    border: 1px solid var(--border-color);
}

.card h3 {
    margin-bottom: var(--space-md);
    line-height: var(--line-height-normal);
}

.card p {
    line-height: var(--line-height-relaxed);
    margin-bottom: var(--space-md);
}

.card p:last-child {
    margin-bottom: 0;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

/* Skills Section */
.skill-category {
    background: var(--bg-white);
    border-radius: 8px;
    padding: var(--space-xl);
    border-left: 4px solid var(--deep-navy);
    margin-bottom: var(--space-lg);
    position: relative;
    border: 1px solid var(--border-color);
}

.skill-category:nth-child(1) {
    border-left: 4px solid var(--deep-navy);
}

.skill-category:nth-child(1) h3 {
    color: var(--deep-navy);
}

.skill-category:nth-child(2) {
    border-left: 4px solid var(--warm-gold);
}

.skill-category:nth-child(2) h3 {
    color: var(--warm-gold);
}

.skill-category:nth-child(3) {
    border-left: 4px solid #6B7280 !important;
}

.skill-category:nth-child(3) h3 {
    color: #6B7280 !important;
}

.skill-list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
    margin-top: var(--space-md); /* Increased from space-sm to space-md for better visual separation */
}

.skill-tag {
    background: var(--soft-gray);
    color: var(--light-text-primary); /* Use light text color for better contrast */
    padding: var(--space-xs) var(--space-sm);
    border-radius: 16px;
    font-size: var(--text-sm);
    font-weight: 500;
}

/* Project Cards */
.project-card {
    background: var(--bg-white);
    border-radius: 12px;
    overflow: hidden;
    transition: all 300ms ease;
    border: 1px solid var(--border-color);
    margin-bottom: var(--space-lg);
}

.project-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 15px 35px rgba(30, 58, 138, 0.1);
    border-color: var(--deep-navy);
}

.project-header {
    height: 200px;
    background: linear-gradient(135deg, var(--deep-navy), var(--steel-blue));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: var(--text-4xl);
    font-weight: 300;
}

.project-content {
    padding: var(--space-lg);
}

.project-meta {
    display: flex;
    gap: var(--space-xs);
    margin-bottom: var(--space-md); /* Increased from space-sm to space-md for better visual separation */
}

.project-tag {
    background: rgba(30, 58, 138, 0.1);
    color: var(--deep-navy);
    padding: var(--space-xs) var(--space-sm);
    border-radius: 12px;
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.project-card:nth-child(2) .project-tag:first-child {
    background: rgba(215, 186, 137, 0.15);
    color: var(--warm-gold);
}

.project-card:nth-child(2) .project-header {
    background: linear-gradient(135deg, var(--warm-gold), var(--steel-blue));
}

.project-card:nth-child(3) .project-tag:first-child {
    background: rgba(139, 158, 183, 0.15);
    color: var(--muted-blue-gray);
}

.project-card:nth-child(3) .project-header {
    background: linear-gradient(135deg, var(--muted-blue-gray), var(--deep-navy));
}

/* Mobile Menu */
.mobile-menu {
    display: none;
    color: var(--text-primary);
    transition: color 0.3s ease, opacity 0.3s ease;
}

.mobile-menu:hover {
    opacity: 0.7;
}

.mobile-menu-container {
    position: fixed;
    top: 0;
    right: -300px;
    width: 300px;
    height: 100vh;
    background: var(--deep-navy);
    padding: var(--space-xl);
    z-index: 200;
    transition: right 0.3s ease;
    box-shadow: -5px 0 15px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.mobile-menu-container.active {
    right: 0;
}

.mobile-menu-container .nav-links {
    display: flex;
    flex-direction: column;
    gap: var(--space-xl);
    list-style: none;
}

.mobile-menu-container .nav-link {
    color: white;
    font-size: var(--text-xl);
    text-align: center;
}

.mobile-menu-container .nav-link:hover {
    color: var(--warm-gold);
}

/* Responsive Design - Enhanced for better mobile typography */
@media (max-width: 768px) {
    .container {
        padding: 0 var(--space-md);
    }
    
    .section {
        padding: var(--space-2xl) 0;
    }
    
    .section-heading-container {
        margin-bottom: var(--space-xl);
        padding: 0 var(--space-sm);
    }
    
    .section-heading-container h2 {
        margin-bottom: var(--space-md);
    }
    
    .grid-2, .grid-3 {
        grid-template-columns: 1fr;
        gap: var(--space-xl);
    }
    
    .about-grid {
        gap: var(--space-2xl);
    }
    
    /* Reset about section specific styles on mobile */
    .about-grid > div:first-child {
        padding-right: 0;
    }
    
    .about-grid > div:first-child p:last-child {
        margin-bottom: var(--space-lg); /* Reduce spacing on mobile */
    }
    
    .about-grid .card {
        margin-top: 0; /* Remove top margin on mobile for better flow */
        padding: var(--space-lg); /* Reduce padding on mobile */
    }
    
    .nav-links {
        display: none;
    }
    
    .mobile-menu {
        display: block;
        background: none;
        border: none;
        cursor: pointer;
        padding: var(--space-xs);
        color: var(--text-primary);
        transition: color 0.3s ease, opacity 0.3s ease;
    }
    
    .mobile-menu:hover {
        opacity: 0.7;
    }
    
    .hero {
        min-height: 90vh;
        text-align: center;
        padding-top: 60px;
    }
    
    .hero-content {
        max-width: 100%;
        padding: 0 var(--space-sm);
    }
    
    .hero-content h1 {
        margin-bottom: var(--space-lg);
    }
    
    .hero-content p {
        margin-bottom: var(--space-xl);
    }
    
    .text-6xl {
        font-size: var(--text-4xl);
        line-height: var(--line-height-tight);
    }
    
    .text-5xl {
        font-size: var(--text-3xl);
        line-height: var(--line-height-tight);
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 var(--space-sm);
    }
    
    .section {
        padding: var(--space-xl) 0;
    }
    
    .section-heading-container {
        margin-bottom: var(--space-lg);
        padding: 0;
    }
    
    .text-4xl {
        font-size: var(--text-2xl);
        line-height: var(--line-height-tight);
    }
    
    .text-3xl {
        font-size: var(--text-xl);
        line-height: var(--line-height-normal);
    }
    
    .text-2xl {
        font-size: var(--text-lg);
        line-height: var(--line-height-normal);
    }
    
    .hero-content h1 {
        margin-bottom: var(--space-md);
    }
    
    .hero-content p {
        margin-bottom: var(--space-lg);
        font-size: var(--text-base);
    }
    
    .about-grid .card {
        padding: var(--space-md); /* Further reduce padding on very small screens */
    }
    
    .card {
        padding: var(--space-lg);
    }
    
    .btn {
        width: 100%;
        justify-content: center;
        padding: var(--space-md) var(--space-lg);
    }
}

/* Form Validation Styles */
.field-error {
    color: #EF4444;
    font-size: var(--text-sm);
    margin-top: 4px;
    font-weight: 500;
}

input.error, 
textarea.error {
    border-color: #EF4444;
    background-color: rgba(239, 68, 68, 0.05);
}

/* Performance Optimizations */
.lazy-load {
    opacity: 0;
    transform: translateY(20px);
    transition: all 600ms ease;
}

.lazy-load.loaded {
    opacity: 1;
    transform: translateY(0);
}

/* Focus and Accessibility */
.btn:focus,
.nav-link:focus {
    outline: 2px solid var(--muted-blue-gray);
    outline-offset: 2px;
}

.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--deep-navy);
    color: white;
    padding: 8px;
    z-index: 1000;
    transition: top 0.3s;
}

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

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

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

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

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

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