/* ==========================================
   CSS RESET & CUSTOM PROPERTIES
   ========================================== */

/* Modern CSS Reset */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Custom Properties (CSS Variables) */
:root {
    /* Color System */
    --primary: #0066ff;
    --primary-dark: #0052cc;
    --dark: #0a0e27;
    --light: #f0f4ff;
    --accent: #00d4ff;
    --text: #333333;
    --text-light: #666666;
    --white: #ffffff;
    
    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-accent: linear-gradient(135deg, #0066ff 0%, #00d4ff 100%);
    --gradient-dark: linear-gradient(45deg, #0a0e27, #1a1f3a, #0a0e27);
    
    /* Spacing System (8px base) */
    --space-xs: 0.5rem;
    --space-sm: 1rem;
    --space-md: 1.5rem;
    --space-lg: 2rem;
    --space-xl: 3rem;
    --space-2xl: 5rem;
    
    /* Typography Scale */
    --font-xs: 0.75rem;
    --font-sm: 0.875rem;
    --font-base: 1rem;
    --font-lg: 1.25rem;
    --font-xl: 1.5rem;
    --font-2xl: 2rem;
    --font-3xl: 3rem;
    --font-4xl: 4rem;
    
    /* Animation Timing */
    --transition-fast: 150ms;
    --transition-base: 300ms;
    --transition-slow: 500ms;
    
    /* Shadows */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.15);
    --shadow-glow: 0 10px 30px rgba(0, 212, 255, 0.3);
    
    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 20px;
    --radius-full: 50px;
}

/* ==========================================
   BASE STYLES
   ========================================== */

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 
                'Helvetica Neue', Arial, sans-serif;
    font-size: var(--font-base);
    line-height: 1.6;
    color: var(--text);
    background: #000;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

main, section, nav, article, aside, header, footer {
    display: block;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Skip Link for Accessibility */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary);
    color: var(--white);
    padding: var(--space-sm);
    text-decoration: none;
    z-index: 100;
}

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

/* ==========================================
   HERO SECTION
   ========================================== */

.hero {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gradient-dark);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
    overflow: hidden;
    padding: var(--space-lg);
}

@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

/* Particles */
.particles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    pointer-events: none;
}

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--accent);
    border-radius: 50%;
    opacity: 0.3;
    will-change: transform;
    animation: float 20s infinite linear;
}

@keyframes float {
    from {
        transform: translateY(100vh) rotate(0deg);
        opacity: 0;
    }
    10% { opacity: 0.3; }
    90% { opacity: 0.3; }
    to {
        transform: translateY(-100vh) rotate(720deg);
        opacity: 0;
    }
}

/* Hero Content */
.hero-content {
    position: relative;
    z-index: 2;
    text-align: center;
    padding: var(--space-lg);
    max-width: 900px;
    width: 100%;
}

/* Hero Profile Photo - FIXED */
.hero-profile {
    margin-bottom: var(--space-lg);
    display: flex;
    justify-content: center;
}

.hero-avatar {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    border: 4px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    animation: profileFloat 6s ease-in-out infinite;
    object-fit: cover; /* Prevents distortion */
    object-position: center; /* Centers the image */
}

@keyframes profileFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.hero h1 {
    font-size: clamp(2.5rem, 8vw, 5rem);
    font-weight: 900;
    background: linear-gradient(135deg, #fff 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: var(--space-sm);
    animation: titleGlow 3s ease-in-out infinite alternate;
    text-rendering: optimizeLegibility;
}

@keyframes titleGlow {
    from { filter: brightness(1); }
    to { filter: brightness(1.2); }
}

.hero .tagline {
    font-size: var(--font-xl);
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: var(--space-sm);
    font-weight: 300;
}

.hero .subtitle {
    color: rgba(255, 255, 255, 0.7);
    font-size: var(--font-lg);
    margin-bottom: var(--space-lg);
}

/* CTA Buttons */
.cta-group {
    display: flex;
    gap: var(--space-sm);
    justify-content: center;
    flex-wrap: wrap;
}

.cta-button {
    padding: var(--space-sm) calc(var(--space-lg) * 1.25);
    border: none;
    border-radius: var(--radius-full);
    font-size: var(--font-lg);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base) cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    display: inline-block;
    -webkit-user-select: none;
    user-select: none;
    min-height: 44px;
}

.cta-primary {
    background: var(--gradient-accent);
    color: var(--white);
    box-shadow: var(--shadow-glow);
}

.cta-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 40px rgba(0, 212, 255, 0.4);
}

.cta-secondary {
    background: transparent;
    color: var(--white);
    border: 2px solid rgba(255, 255, 255, 0.3);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

.cta-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent);
}

/* ==========================================
   ABOUT SECTION
   ========================================== */

.about {
    background: var(--white);
    padding: var(--space-2xl) var(--space-lg);
    text-align: center;
}

.about-container {
    max-width: 900px;
    margin: 0 auto;
}

.about h2 {
    font-size: var(--font-3xl);
    margin-bottom: var(--space-lg);
    color: var(--dark);
}

.about-lead {
    font-size: 1.3rem;
    line-height: 1.8;
    color: var(--text);
    margin-bottom: var(--space-lg);
}

/* Strengths Visual */
.strengths-visual {
    margin: var(--space-xl) 0;
}

.strengths-image {
    max-width: 100%;
    height: auto;
    margin: 0 auto;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

/* About Stats */
.about-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--space-lg);
    margin-top: var(--space-xl);
}

.stat-item {
    text-align: center;
}

.stat-number {
    font-size: 2.5rem;
    color: var(--primary);
    font-weight: 900;
    display: block;
}

.stat-label {
    color: var(--text-light);
    font-size: var(--font-sm);
}

.clifton-strengths {
    font-size: var(--font-lg);
    color: var(--text-light);
    margin-top: var(--space-lg);
    font-style: italic;
}

/* ==========================================
   METRICS SECTION - FIXED FOR MOBILE
   ========================================== */

.metrics {
    background: var(--light);
    padding: var(--space-2xl) var(--space-lg);
    overflow-x: hidden; /* Prevent horizontal scroll */
}

.metrics-grid {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--space-xl);
}

.metric-card {
    text-align: center;
    background: var(--white);
    padding: var(--space-lg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    opacity: 0;
    transform: translateY(30px);
    animation: slideUp 0.6s forwards;
    animation-delay: calc(var(--index) * 0.1s);
    transition: all var(--transition-base) ease;
}

/* CSS classes for animation delays */
.metric-index-0 { --index: 0; }
.metric-index-1 { --index: 1; }
.metric-index-2 { --index: 2; }
.metric-index-3 { --index: 3; }

.metric-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-md);
}

@keyframes slideUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.metric-number {
    font-size: 3.5rem;
    font-weight: 900;
    background: var(--gradient-accent);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: block;
    margin-bottom: var(--space-xs);
    font-variant-numeric: tabular-nums;
}

.metric-label {
    font-size: var(--font-lg);
    color: var(--text-light);
    font-weight: 500;
}

/* ==========================================
   PROJECTS SECTION - FIXED IMAGE HEIGHTS
   ========================================== */

.projects {
    background: var(--white);
    padding: var(--space-2xl) var(--space-lg);
}

.projects h2 {
    text-align: center;
    font-size: var(--font-3xl);
    margin-bottom: var(--space-xl);
    color: var(--dark);
}

.project-grid {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: var(--space-lg);
}

/* Featured Projects with Images - FIXED */
.project-card.featured {
    grid-column: span 1;
    background: var(--white);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    transition: all var(--transition-base) cubic-bezier(0.4, 0, 0.2, 1);
}

.project-image {
    position: relative;
    height: 250px; /* Reduced from 600px */
    background: var(--gradient-primary);
    overflow: hidden;
}

.project-image img {
    width: 100%;
    height: 100%;
    object-fit: contain; /* Changed from cover to contain */
    background: #f8f9fa; /* Light background for transparent images */
}

.project-badge {
    position: absolute;
    top: var(--space-sm);
    right: var(--space-sm);
    background: var(--accent);
    color: var(--white);
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-full);
    font-size: var(--font-xs);
    font-weight: 600;
    text-transform: uppercase;
}

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

.project-link {
    display: inline-block;
    margin-top: var(--space-sm);
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    transition: color var(--transition-fast);
}

.project-link:hover {
    color: var(--primary-dark);
}

/* Regular Project Cards */
.project-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    transition: all var(--transition-base) cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
    will-change: transform;
}

.project-card:hover {
    transform: translateY(-10px) scale(1.02);
    box-shadow: 0 20px 40px rgba(0, 102, 255, 0.2);
}

.project-header {
    padding: var(--space-lg);
    background: var(--gradient-primary);
    position: relative;
    overflow: hidden;
}

.project-header::after {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    animation: pulse 3s ease-in-out infinite;
    pointer-events: none;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.project-title {
    font-size: var(--font-xl);
    color: var(--white);
    margin-bottom: var(--space-xs);
    position: relative;
    z-index: 1;
}

.project-category {
    color: rgba(255, 255, 255, 0.9);
    font-size: var(--font-sm);
    text-transform: uppercase;
    letter-spacing: 1px;
    position: relative;
    z-index: 1;
}

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

.project-description {
    color: var(--text-light);
    margin-bottom: var(--space-md);
    line-height: 1.8;
}

.project-tech {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
}

.tech-tag {
    padding: calc(var(--space-xs) * 0.6) var(--space-sm);
    background: var(--light);
    border-radius: var(--radius-lg);
    font-size: var(--font-sm);
    color: var(--primary);
    font-weight: 600;
    transition: all var(--transition-fast);
}

.tech-tag:hover {
    background: var(--primary);
    color: var(--white);
}

/* ==========================================
   SKILLS SECTION - FIXED WIDTH CLASSES
   ========================================== */

.skills {
    background: var(--light);
    padding: var(--space-2xl) var(--space-lg);
}

.skills h2 {
    text-align: center;
    font-size: var(--font-3xl);
    margin-bottom: var(--space-xl);
    color: var(--dark);
}

.skills-container {
    max-width: 1000px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--space-xl);
}

.skill-category {
    background: var(--white);
    padding: var(--space-lg);
    border-radius: var(--radius-lg);
    transition: all var(--transition-base) ease;
    box-shadow: var(--shadow-sm);
}

.skill-category:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 102, 255, 0.1);
}

.skill-category h3 {
    color: var(--primary);
    margin-bottom: var(--space-md);
    font-size: var(--font-lg);
}

.skill-item {
    margin-bottom: calc(var(--space-sm) * 1.2);
}

.skill-name {
    display: flex;
    justify-content: space-between;
    margin-bottom: var(--space-xs);
    font-weight: 600;
    color: var(--text);
}

.skill-bar {
    height: 8px;
    background: #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

.skill-progress {
    height: 100%;
    background: var(--gradient-accent);
    border-radius: 10px;
    width: 0;
    animation: fillBar 2s ease-out forwards;
    animation-delay: calc(var(--index) * 0.1s);
    will-change: width;
}

/* Width and index classes for skills */
.width-75 { --width: 75%; }
.width-80 { --width: 80%; }
.width-85 { --width: 85%; }
.width-90 { --width: 90%; }
.width-92 { --width: 92%; }
.width-95 { --width: 95%; }

.index-0 { --index: 0; }
.index-1 { --index: 1; }
.index-2 { --index: 2; }
.index-3 { --index: 3; }
.index-4 { --index: 4; }
.index-5 { --index: 5; }
.index-6 { --index: 6; }
.index-7 { --index: 7; }
.index-8 { --index: 8; }

@keyframes fillBar {
    to { width: var(--width); }
}

/* ==========================================
   CONTACT SECTION
   ========================================== */

.contact {
    background: var(--dark);
    color: var(--white);
    padding: var(--space-2xl) var(--space-lg);
    text-align: center;
}

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

.contact p {
    font-size: var(--font-lg);
    margin-bottom: var(--space-sm);
    opacity: 0.9;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.contact-subtitle {
    font-size: var(--font-base);
    opacity: 0.8;
    margin-bottom: var(--space-lg);
}

.contact-links {
    display: flex;
    justify-content: center;
    gap: var(--space-lg);
    flex-wrap: wrap;
}

.contact-link {
    padding: var(--space-sm) var(--space-lg);
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-full);
    color: var(--white);
    text-decoration: none;
    transition: all var(--transition-base) ease;
    font-weight: 600;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
}

.contact-link:hover,
.contact-link:focus {
    background: var(--primary);
    border-color: var(--primary);
    transform: translateY(-3px);
}

/* ==========================================
   RESPONSIVE DESIGN - ENHANCED FOR MOBILE
   ========================================== */

@media (max-width: 768px) {
    :root {
        --font-3xl: 2rem; /* Smaller on mobile */
        --font-2xl: 1.5rem;
        --font-xl: 1.25rem;
        --space-2xl: 3rem; /* Less padding on mobile */
    }
    
    /* Hero adjustments */
    .hero-avatar {
        width: 120px;
        height: 120px;
    }
    
    .hero h1 {
        font-size: 2rem; /* Smaller on mobile */
    }
    
    .hero .tagline {
        font-size: 1.1rem;
    }
    
    /* Projects - Single column on mobile */
    .project-grid {
        grid-template-columns: 1fr;
        padding: 0 var(--space-sm); /* Add padding */
    }
    
    .project-card.featured {
        grid-column: span 1;
    }
    
    /* Metrics - 2x2 grid on mobile */
    .metrics {
        padding: var(--space-xl) var(--space-sm); /* Reduce padding */
    }
    
    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-sm); /* Smaller gap */
        padding: 0 var(--space-xs);
    }
    
    .metric-card {
        padding: var(--space-sm); /* Smaller padding */
    }
    
    .metric-number {
        font-size: 2rem; /* Smaller numbers */
    }
    
    .metric-label {
        font-size: 0.875rem; /* Smaller labels */
    }
    
    /* CTA buttons stack on mobile */
    .cta-group {
        flex-direction: column;
        align-items: center;
    }
    
    .cta-button {
        width: 100%;
        max-width: 300px;
    }
    
    /* About stats 2x2 on mobile */
    .about-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* Contact links stack on mobile */
    .contact-links {
        flex-direction: column;
        align-items: center;
    }
    
    .contact-link {
        width: 100%;
        max-width: 300px;
        justify-content: center;
    }
    
    /* Skills section on mobile */
    .skills-container {
        grid-template-columns: 1fr;
        gap: var(--space-lg);
    }
    
    /* Project images on mobile */
    .project-image {
        height: 200px; /* Even smaller on mobile */
    }
    
    /* General section padding on mobile */
    section {
        padding-left: var(--space-sm);
        padding-right: var(--space-sm);
    }
}

/* Extra small devices */
@media (max-width: 480px) {
    .metrics-grid {
        grid-template-columns: 1fr; /* Single column on very small screens */
    }
    
    .about-stats {
        grid-template-columns: 1fr; /* Single column stats */
    }
    
    .hero h1 {
        font-size: 1.75rem;
    }
}

/* Large screens */
@media (min-width: 1200px) {
    .hero-content {
        max-width: 1100px;
    }
    
    .metrics-grid,
    .project-grid {
        max-width: 1400px;
    }
    
    .project-card.featured {
        grid-column: span 1;
    }
}

/* ==========================================
   ACCESSIBILITY
   ========================================== */

*:focus {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

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

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

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

/* ==========================================
   PRINT STYLES
   ========================================== */

@media print {
    * {
        background: transparent !important;
        color: #000 !important;
        box-shadow: none !important;
        text-shadow: none !important;
    }
    
    a,
    a:visited {
        text-decoration: underline;
    }
    
    a[href]:after {
        content: " (" attr(href) ")";
    }
    
    .hero,
    .metrics,
    .projects,
    .skills {
        page-break-after: always;
    }
    
    .particles,
    .project-header::after {
        display: none;
    }
}

/* ==========================================
   PERFORMANCE OPTIMIZATIONS
   ========================================== */

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