/* 
 * Main Stylesheet for Zihan Wan's Portfolio
 * This file contains all the visual styling for the website
 */

/* CSS Custom Properties (Variables) - Think of these as your design system's color palette */
:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --accent-color: #e74c3c;
    --text-color: #333;
    --light-bg: #f5f5f5;
    --white: #ffffff;
    --section-spacing: 100px;
}

/* Universal Reset - This ensures consistent styling across all browsers */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Base Body Styles - Sets up the foundation for your entire page */
body {
    font-family: 'Helvetica Neue', Arial, sans-serif;
    color: var(--text-color);
    line-height: 1.6;
    overflow-x: hidden; /* Prevents horizontal scrollbar from animations */
    position: relative;
}

/* Background Animation - Creates the subtle moving gradient effect */
body:before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(125deg, #2c3e50, #3498db, #2980b9, #1abc9c);
    background-size: 400% 400%;
    z-index: -1; /* Places this behind all other content */
    animation: gradientAnimation 15s ease infinite;
    opacity: 0.05; /* Very subtle effect */
}

/* Keyframe Animation - Defines how the background gradient moves */
@keyframes gradientAnimation {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

/* Floating Particles Container - Houses the animated particles */
.particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

/* Individual Particle Styles - Each particle has unique animation timing */
.particle {
    position: absolute;
    border-radius: 50%;
    background: var(--secondary-color);
    opacity: 0.2;
    pointer-events: none; /* Particles don't interfere with clicking */
}

/* Particle Animation Variations - Creates organic, varied movement */
.particle:nth-child(1) {
    width: 10px;
    height: 10px;
    left: 10%;
    animation: floatParticle 30s linear infinite;
    animation-delay: 0s;
}

.particle:nth-child(2) {
    width: 15px;
    height: 15px;
    left: 30%;
    animation: floatParticle 25s linear infinite;
    animation-delay: 2s;
}

.particle:nth-child(3) {
    width: 8px;
    height: 8px;
    left: 50%;
    animation: floatParticle 35s linear infinite;
    animation-delay: 5s;
}

.particle:nth-child(4) {
    width: 12px;
    height: 12px;
    left: 70%;
    animation: floatParticle 20s linear infinite;
    animation-delay: 1s;
}

.particle:nth-child(5) {
    width: 6px;
    height: 6px;
    left: 85%;
    animation: floatParticle 40s linear infinite;
    animation-delay: 0s;
}

/* Particle Float Animation - Moves particles from bottom to top with rotation */
@keyframes floatParticle {
    0% {
        top: -10%;
        transform: translateX(10px) rotate(0deg);
    }
    100% {
        top: 110%;
        transform: translateX(-10px) rotate(360deg);
    }
}

/* Global Link Styles - Consistent link appearance throughout the site */
a {
    color: var(--secondary-color);
    text-decoration: none;
    transition: color 0.3s; /* Smooth color change on hover */
}

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

/* Section Layout - Consistent spacing for all major page sections */
section {
    padding: 80px 0;
}

/* Container Class - Centers content and provides consistent max-width */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Section Title Styling - Creates consistent headers with decorative underline */
.section-title {
    font-size: 2.5rem;
    margin-bottom: 50px;
    text-align: center;
    color: var(--primary-color);
    position: relative;
}

/* Decorative Underline for Section Titles */
.section-title:after {
    content: '';
    display: block;
    width: 70px;
    height: 4px;
    background: var(--secondary-color);
    margin: 15px auto;
}

/* Header Navigation - Fixed header that stays at top during scroll */
header {
    background: var(--primary-color);
    color: var(--white);
    padding: 20px 0;
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 1000; /* Ensures header stays above other content */
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* Navigation Layout - Flexbox for space-between layout */
nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Logo Styling */
.logo {
    font-size: 1.8rem;
    font-weight: bold;
}

/* Navigation Links Layout */
.nav-links {
    display: flex;
    list-style: none;
}

.nav-links li {
    margin-left: 30px;
}

/* Navigation Link Hover Effects - Animated underline */
.nav-links a {
    color: var(--white);
    position: relative;
    font-weight: 500;
}

.nav-links a:after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: -4px;
    left: 0;
    background-color: var(--secondary-color);
    transition: width 0.3s; /* Animated underline growth */
}

.nav-links a:hover:after {
    width: 100%;
}

.nav-links a:hover {
    color: var(--white);
}

/* Hero Section - Full viewport height with centered content */
.hero {
    height: 100vh;
    display: flex;
    align-items: center;
    background: linear-gradient(135deg, rgba(44, 62, 80, 0.9) 0%, rgba(52, 152, 219, 0.8) 100%);
    color: var(--white);
    text-align: center;
    position: relative;
}

.hero-content {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Hero Text Animations - Staggered entrance effects */
.hero h1 {
    font-size: 3.5rem;
    margin-bottom: 20px;
    animation: fadeInDown 1s ease;
}

.hero p {
    font-size: 1.5rem;
    margin-bottom: 30px;
    opacity: 0.9;
    animation: fadeInUp 1s ease 0.3s forwards;
    opacity: 0; /* Hidden initially, animation reveals it */
}

/* Call-to-Action Button with Advanced Hover Effects */
.btn {
    display: inline-block;
    background: var(--secondary-color);
    color: var(--white);
    padding: 12px 30px;
    border-radius: 30px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
    z-index: 1;
    animation: fadeInUp 1s ease 0.6s forwards;
    opacity: 0;
}

.btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
    color: var(--white);
}

.btn:active {
    transform: translateY(-1px); /* Slight press effect */
}

/* Button Background Animation - Color change on hover */
.btn:after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--accent-color);
    z-index: -1;
    transition: transform 0.3s;
    transform: scaleX(0);
    transform-origin: right;
}

.btn:hover:after {
    transform: scaleX(1);
    transform-origin: left;
}

/* Scroll Down Indicator */
.scroll-down {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    animation: bounce 2s infinite;
    color: var(--white);
    font-size: 2rem;
}

/* About Section Layout */
.about {
    background: var(--white);
}

.about-content {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 50px;
}

.about-text {
    flex: 1;
    min-width: 300px;
}

.about-text h3 {
    font-size: 1.8rem;
    margin-bottom: 20px;
    color: var(--primary-color);
}

.about-text p {
    margin-bottom: 15px;
}

/* Skills Section with Card Grid Layout */
.skills {
    background: var(--light-bg);
}

.skills-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 30px;
}

/* Individual Skill Cards with Hover Effects */
.skill-card {
    background: var(--white);
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
    transition: transform 0.3s, box-shadow 0.3s;
}

.skill-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
}

.skill-icon {
    font-size: 2.5rem;
    margin-bottom: 20px;
    color: var(--secondary-color);
}

.skill-card h3 {
    font-size: 1.5rem;
    margin-bottom: 15px;
    color: var(--primary-color);
}

/* Progress Bar Styling */
.skill-bar {
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
    margin-top: 15px;
}

.skill-progress {
    height: 100%;
    background: var(--secondary-color);
    border-radius: 4px;
    position: relative;
}

/* Research Section */
.research {
    background: var(--white);
}

.research-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 30px;
}

.research-card {
    background: var(--light-bg);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
    transition: transform 0.3s;
}

.research-card:hover {
    transform: translateY(-5px);
}

.research-content {
    padding: 25px;
}

.research-card h3 {
    font-size: 1.4rem;
    margin-bottom: 15px;
    color: var(--primary-color);
}

.research-card p {
    margin-bottom: 20px;
    color: var(--text-color);
}

/* Game Section Styling */
.game {
    background: var(--light-bg);
    padding-bottom: 100px;
}

/* Game Canvas Container */
.game-container {
    width: 100%;
    max-width: 800px;
    height: 320px;
    background: var(--white);
    margin: 0 auto;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    position: relative;
}

#game-canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* Game Control Buttons */
.game-controls {
    display: flex;
    justify-content: center;
    margin-top: 20px;
    gap: 15px;
}

.game-btn {
    padding: 10px 25px;
    background: var(--secondary-color);
    color: var(--white);
    border: none;
    border-radius: 30px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
}

.game-btn:hover {
    background: var(--accent-color);
    transform: translateY(-2px);
}

.game-instructions {
    text-align: center;
    max-width: 600px;
    margin: 20px auto 0;
    font-size: 0.95rem;
    color: #666;
}

/* Footer Styling */
footer {
    background: var(--primary-color);
    color: var(--white);
    text-align: center;
    padding: 30px 0;
}

.social-links {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
    list-style: none;
}

.social-links li {
    margin: 0 10px;
}

.social-links a {
    color: var(--white);
    font-size: 1.5rem;
    transition: all 0.3s;
}

.social-links a:hover {
    color: var(--secondary-color);
    transform: translateY(-3px);
}

.copyright {
    font-size: 0.9rem;
    opacity: 0.7;
}

/* Animation Keyframes - Reusable animations */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0) translateX(-50%);
    }
    40% {
        transform: translateY(-20px) translateX(-50%);
    }
    60% {
        transform: translateY(-10px) translateX(-50%);
    }
}

/* Score Display for Game */
.score-display {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 16px;
    font-weight: bold;
}

/* Responsive Design - Adjusts layout for smaller screens */
@media (max-width: 768px) {
    .section-title {
        font-size: 2rem;
    }
    
    .hero h1 {
        font-size: 2.5rem;
    }
    
    .hero p {
        font-size: 1.2rem;
    }
    
    .research-grid {
        grid-template-columns: 1fr;
    }
    
    .game-container {
        height: 250px;
    }
}