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

/* Variables */
:root {
    --primary-color: #2c3e50;
    --accent-color: #3498db;
    --text-color: #333;
    --light-bg: #f5f6fa;
    --white: #ffffff;
    --gradient-1: #00c6ff;
    --gradient-2: #0072ff;
}

html, body {
    min-height: 100vh;
    overflow-x: hidden; /* Prevent horizontal scrolling */
    /* Handle mobile viewport issues */
    min-height: 100dvh;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100vw; /* Prevent content from exceeding viewport width */
    /* Mobile scroll fix */
    -webkit-overflow-scrolling: touch;
}

main {
    flex: 1 0 auto;
    padding-top: 60px; /* Space for fixed nav */
    min-height: calc(100vh - 60px); /* Account for footer height */
    width: 100%;
    max-width: 100vw; /* Prevent overflow */
    overflow-x: hidden; /* Prevent horizontal scrolling */
}

/* Navigation */
nav {
    position: fixed;
    width: 100%;
    background-color: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
}

.nav-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
}

.logo a {
    color: var(--primary-color);
    text-decoration: none;
    font-size: 1.5rem;
    font-weight: bold;
}

.nav-links {
    display: flex;
    list-style: none;
}

.nav-links li a {
    color: var(--primary-color);
    text-decoration: none;
    padding: 0.5rem 1rem;
    transition: color 0.3s ease;
}

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

.highlight {
    color: var(--gradient-1);
    font-weight: 700;
}

.menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    width: 30px;
    height: 21px;
    cursor: pointer;
}

.menu-toggle span {
    display: block;
    width: 100%;
    height: 3px;
    background-color: var(--primary-color);
    transition: all 0.3s ease;
}

/* Hero Section */
.hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--gradient-1), var(--gradient-2));
    color: var(--white);
    text-align: center;
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    width: 150%;
    height: 150%;
    background: url('data:image/svg+xml,<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg"><path fill="rgba(255, 255, 255, 0.05)" d="M45.3,-51.5C58.9,-37.3,70.3,-21.3,72.7,-3.5C75.1,14.4,68.5,34.1,54.9,45.6C41.3,57.1,20.6,60.4,1.5,58.7C-17.7,57,-35.4,50.2,-48.9,37.8C-62.4,25.4,-71.7,7.3,-70.1,-9.8C-68.5,-27,-56.1,-43.2,-41,-54.1C-25.8,-65,-12.9,-70.6,1.7,-72.6C16.3,-74.6,31.7,-65.8,45.3,-51.5Z" transform="translate(100 100)" /></svg>') center/cover;
    animation: rotate 20s linear infinite;
    opacity: 0.1;
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.hero-content {
    padding: 2rem;
}

.hero h1 {
    font-size: 3rem;
    margin-bottom: 1rem;
    animation: fadeInDown 1s ease;
}

.typewriter {
    animation: fadeInUp 1s ease 0.5s both;
}

.cta-button {
    display: inline-block;
    padding: 1rem 2rem;
    background-color: var(--white);
    color: var(--primary-color);
    text-decoration: none;
    border-radius: 5px;
    margin-top: 2rem;
    transition: transform 0.3s ease;
    animation: fadeInUp 1s ease 1s both;
}

.cta-button:hover {
    transform: translateY(-3px);
}

/* Section Containers */
.hero,
.about,
.projects,
.contact {
    padding: 5rem 2rem;
}

.about-content,
.project-grid {
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

/* Container and Section Layouts */
.projects {
    padding: 5rem 2rem;
    background-color: var(--light-bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.project-grid {
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    padding: 0;
    align-items: start;
    justify-content: center;
}

/* Two cards layout optimization */
.project-grid.two-cards-layout {
    grid-template-columns: repeat(2, minmax(300px, 400px));
    max-width: 900px;
    gap: 3rem;
}

/* Special layout for when there are exactly 2 regular cards */
.project-grid:has(.project-card:not(.featured):nth-child(3)):not(:has(.project-card:not(.featured):nth-child(4))) {
    grid-template-columns: repeat(2, minmax(300px, 400px));
    max-width: 900px;
}

main {
    flex: 1;
    padding-top: 60px; /* Space for fixed nav */
}

/* Sections */
section {
    padding: 5rem 2rem;
}

section h2 {
    font-size: 2.5rem;
    margin-bottom: 3rem;
    text-align: center;
    color: var(--primary-color);
    position: relative;
}

section h2::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 50px;
    height: 3px;
    background: linear-gradient(135deg, var(--gradient-1), var(--gradient-2));
    border-radius: 2px;
}

/* About Section */
.about {
    background-color: var(--light-bg);
}

.about-content {
    max-width: 800px;
    margin: 0 auto;
}

.skill-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 1rem;
}

.skill-tags span {
    background-color: var(--accent-color);
    color: var(--white);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.9rem;
}

/* Projects Section */
.project-card {
    position: relative;
    background: var(--white);
    transition: all 0.3s ease;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
    height: fit-content;
}

.project-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

.project-card img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 10px;
    transition: transform 0.3s ease;
}

.project-card:hover img {
    transform: scale(1.05);
}

.project-placeholder {
    width: 100%;
    height: 200px;
    background: linear-gradient(135deg, #f0f0f0 0%, #e0e0e0 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #888;
    font-size: 1.1rem;
    font-weight: 500;
}

.project-card.featured .project-placeholder {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    color: white;
    font-weight: 600;
    letter-spacing: 2px;
    font-size: 1.3rem;
}

.project-links {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    justify-content: center;
}

.project-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1.5rem;
    background: linear-gradient(135deg, var(--gradient-1), var(--gradient-2));
    color: var(--white);
    text-decoration: none;
    border-radius: 25px;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.project-link.github {
    background: var(--primary-color);
}

.project-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.project-card h3 {
    font-size: 1.5rem;
    margin: 1rem;
    color: var(--primary-color);
}

.project-card p {
    padding: 0 1rem;
    color: var(--text-color);
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 1rem;
}

.project-card.featured {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: row;
    gap: 2rem;
    padding: 2rem;
    position: relative;
    overflow: visible;
    background: var(--white);
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    margin: 0 auto 2rem auto;
    max-width: 1100px;
    width: 100%;
}

.project-card.featured .project-image {
    flex: 1;
    min-width: 45%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: var(--light-bg);
    border-radius: 10px;
}

.project-card.featured .project-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 2rem;
}

.project-card.featured img {
    height: 100%;
    border-radius: 10px;
    max-width: 100%;
    max-height: 300px;
    width: auto;
    height: auto;
    object-fit: contain;
}

.project-badge {
    position: absolute;
    top: -12px;
    left: 2rem;
    background: linear-gradient(135deg, var(--gradient-1), var(--gradient-2));
    color: var(--white);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.tech-stack {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 1rem;
    justify-content: center;
}

.tech-stack span {
    background: var(--light-bg);
    color: var(--primary-color);
    padding: 0.3rem 0.8rem;
    border-radius: 15px;
    font-size: 0.85rem;
    transition: all 0.3s ease;
}

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

/* Contact Section Styles */
.contact {
    padding: 5rem 2rem;
    background-color: var(--light-bg);
}

.contact-content {
    max-width: 1200px;
    margin: 0 auto;
    text-align: center;
    opacity: 1;
    transform: none;
}

/* Remove previous animation styles for social links */
.contact.reveal .social-links a,
.contact.reveal .social-links,
.contact.reveal .contact-text {
    opacity: 1;
    transform: none;
    transition: none;
}

/* Contact Section and Social Links */
.social-links {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 3.5rem;
    margin-top: 3rem;
}

.social-links a {
    color: var(--gradient-1);
    font-size: 3rem;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: var(--white);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

.social-links a::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--gradient-1), var(--gradient-2));
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 1;
}

.social-links a i {
    position: relative;
    z-index: 2;
    transition: all 0.3s ease;
}

.social-links a:hover {
    transform: translateY(-8px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.2);
}

.social-links a:hover::before {
    opacity: 1;
}

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

/* Specific colors for each social link */
.social-links a.github {
    color: #333;
}

.social-links a.linkedin {
    color: #0077b5;
}

.social-links a.email {
    color: #ea4335;
}

/* Footer Styles */
footer {
    background: linear-gradient(135deg, var(--gradient-1), var(--gradient-2));
    color: var(--white);
    text-align: center;
    padding: 1.5rem;
    position: relative;
    width: 100%;
    margin-top: auto;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
}

/* Desktop optimizations */
@media (min-width: 769px) {
    .project-grid {
        padding: 0 2rem;
    }
    
    /* Two cards layout - center them nicely */
    .project-grid.two-cards-layout {
        grid-template-columns: repeat(2, minmax(320px, 400px));
        max-width: 900px;
        gap: 3rem;
        justify-content: center;
    }
    
    /* If there are 3 or more cards, use full width */
    .project-grid:has(.project-card:not(.featured):nth-child(4)) {
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
        max-width: 1200px;
    }
    
    .project-card.featured {
        margin: 0 0 3rem 0;
        max-width: 1100px;
    }
    
    .projects {
        padding: 5rem 2rem;
    }
}

/* Media Queries */
@media (max-width: 768px) {
    /* Navigation fixes */
    .nav-content {
        flex-direction: row;
        justify-content: space-between;
        padding: 1rem;
    }

    .logo {
        flex: 1;
    }

    .nav-links {
        margin-top: 0;
        position: fixed;
        top: 70px;
        left: 0;
        width: 100%;
        background: rgba(255, 255, 255, 0.98);
        padding: 20px;
        flex-direction: column;
        align-items: center;
        gap: 20px;
        transform: translateY(-150%);
        transition: transform 0.3s ease;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    }

    .nav-links.active {
        transform: translateY(0);
    }

    .menu-toggle {
        display: flex;
        position: relative;
        z-index: 1001;
    }

    .menu-toggle.active span:first-child {
        transform: rotate(45deg) translate(6px, 6px);
    }

    .menu-toggle.active span:nth-child(2) {
        opacity: 0;
    }

    .menu-toggle.active span:last-child {
        transform: rotate(-45deg) translate(6px, -6px);
    }

    /* Hero section fixes */
    .hero {
        padding: 2rem 1rem;
        min-height: 100vh;
        min-height: 100dvh; /* Dynamic viewport height for mobile */
        text-align: center;
        height: auto;
    }

    .hero-content {
        padding: 1rem;
        width: 100%;
        max-width: 100%;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        min-height: calc(100vh - 4rem);
        min-height: calc(100dvh - 4rem);
    }

    .hero h1 {
        font-size: 2rem;
        margin-bottom: 1rem;
        line-height: 1.2;
    }

    .typewriter p {
        font-size: 1.2rem;
        margin-bottom: 1.5rem;
    }

    .cta-button {
        padding: 0.8rem 1.5rem;
        font-size: 0.9rem;
    }

    /* Main element mobile fix */
    main {
        padding-top: 60px;
        min-height: auto;
    }

    /* Section padding adjustments */
    section {
        padding: 3rem 1rem;
    }

    section h2 {
        font-size: 2rem;
        margin-bottom: 2rem;
    }

    /* Projects section mobile fix */
    .projects {
        padding: 3rem 1rem;
        align-items: stretch;
    }

    /* About section fixes */
    .about-content {
        padding: 0 1rem;
        text-align: center;
    }

    .skills h3 {
        margin-top: 2rem;
        margin-bottom: 1rem;
    }

    .skill-tags {
        justify-content: center;
        gap: 0.8rem;
    }

    .skill-tags span {
        padding: 0.4rem 0.8rem;
        font-size: 0.85rem;
    }

    /* Project section fixes */
    .project-grid {
        grid-template-columns: 1fr !important;
        gap: 1.5rem;
        padding: 0;
        max-width: 100% !important;
        justify-content: stretch;
    }

    /* Reset desktop optimizations for mobile */
    .project-grid.two-cards-layout {
        grid-template-columns: 1fr !important;
        max-width: 100% !important;
        gap: 1.5rem;
    }

    .project-card {
        margin: 0;
        border-radius: 10px;
        overflow: hidden;
        width: 100%;
    }

    .project-card.featured {
        grid-column: 1;
        flex-direction: column;
        margin: 0 0 2rem 0;
        padding: 1.5rem;
        max-width: 100%;
    }

    .project-card.featured .project-image {
        min-width: 100%;
        padding: 1rem;
        order: 1;
    }

    .project-card.featured .project-content {
        padding: 1rem 0;
        order: 2;
        text-align: center;
    }

    .project-card.featured img {
        width: 100%;
        height: auto;
        max-height: 200px;
        object-fit: contain;
    }

    .project-badge {
        position: absolute;
        top: -8px;
        left: 1rem;
        font-size: 0.8rem;
        padding: 0.3rem 0.8rem;
    }

    /* Project links mobile optimization */
    .project-links {
        flex-direction: column;
        gap: 0.8rem;
        padding: 1rem;
    }

    .project-link {
        padding: 0.6rem 1.2rem;
        font-size: 0.9rem;
        text-align: center;
    }

    .tech-stack {
        gap: 0.4rem;
        margin: 1rem 0;
    }

    .tech-stack span {
        padding: 0.25rem 0.6rem;
        font-size: 0.8rem;
    }

    /* Contact section fixes */
    .contact {
        padding: 3rem 1rem;
    }

    .contact-content {
        text-align: center;
        padding: 0 1rem;
    }

    .contact-text {
        font-size: 1rem;
        margin-bottom: 2rem;
    }

    .social-links {
        flex-direction: row;
        justify-content: center;
        gap: 2rem;
        margin-top: 2rem;
    }

    .social-links a {
        width: 70px;
        height: 70px;
        font-size: 2rem;
    }

    /* Footer fixes */
    footer {
        padding: 1rem;
        font-size: 0.9rem;
    }
}

/* Additional mobile optimizations for very small screens */
@media (max-width: 480px) {
    /* Mobile viewport fixes */
    .hero {
        padding: 1rem;
        min-height: 100vh;
        min-height: 100dvh;
        height: auto;
    }

    .hero-content {
        min-height: calc(100vh - 2rem);
        min-height: calc(100dvh - 2rem);
        padding: 0.5rem;
    }

    .hero h1 {
        font-size: 1.7rem;
        line-height: 1.3;
    }

    .typewriter p {
        font-size: 1rem;
    }

    .cta-button {
        padding: 0.7rem 1.2rem;
        font-size: 0.85rem;
    }

    section h2 {
        font-size: 1.8rem;
    }

    .skill-tags {
        gap: 0.5rem;
    }

    .skill-tags span {
        padding: 0.3rem 0.6rem;
        font-size: 0.8rem;
    }

    .social-links {
        gap: 1.5rem;
    }

    .social-links a {
        width: 60px;
        height: 60px;
        font-size: 1.5rem;
    }

    .project-card.featured {
        padding: 1rem;
        margin: 0 0 1.5rem 0;
    }

    .project-card.featured .project-content h3 {
        font-size: 1.3rem;
    }

    .project-card.featured .project-content p {
        font-size: 0.9rem;
    }

    /* Ensure single column on very small screens */
    .project-grid {
        grid-template-columns: 1fr !important;
        max-width: 100% !important;
        gap: 1rem;
        padding: 0;
    }

    .project-grid.two-cards-layout {
        grid-template-columns: 1fr !important;
        max-width: 100% !important;
        gap: 1rem;
    }
}

/* Enhanced Animations */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.hero h1 {
    animation: fadeInDown 1s ease;
}

.typewriter {
    animation: fadeInUp 1s ease 0.5s both;
}

.cta-button {
    animation: fadeInUp 1s ease 1s both;
}

/* Scroll Animations */
.reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.8s ease;
}

.reveal.active {
    opacity: 1;
    transform: translateY(0);
}

/* Scroll Reveal Animations */
.reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.reveal.show {
    opacity: 1;
    transform: translateY(0);
}

/* Project Card Animation Delay */
.project-card:nth-child(1) {
    transition-delay: 0.1s;
}

.project-card:nth-child(2) {
    transition-delay: 0.2s;
}

.project-card:nth-child(3) {
    transition-delay: 0.3s;
}

/* Skill Tags Animation Delay */
.skill-tags span {
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    transition-delay: var(--delay, 0s);
}

.skill-tags.show span {
    opacity: 1;
    transform: translateY(0);
}

/* Contact Section Animation */
.contact.reveal .social-links a {
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.contact.reveal.show .social-links a {
    opacity: 1;
    transform: translateY(0);
}

.contact.reveal .social-links a:nth-child(1) { transition-delay: 0.1s; }
.contact.reveal .social-links a:nth-child(2) { transition-delay: 0.2s; }
.contact.reveal .social-links a:nth-child(3) { transition-delay: 0.3s; }

.contact.reveal .contact-text {
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.contact.reveal.show .contact-text {
    opacity: 1;
    transform: translateY(0);
    transition-delay: 0.1s;
}
