*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.7;
    color: #333;
    background-color: #f5f5f5;
}

a {
    color: #2563eb;
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: #1d4ed8;
    text-decoration: underline;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

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

.fade-in {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.fade-in.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Navigation */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid #e5e5e5;
    z-index: 1000;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

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

.nav-logo {
    font-weight: 700;
    font-size: 1.2rem;
    color: #111;
    letter-spacing: -0.5px;
}

.nav-logo:hover {
    text-decoration: none;
    color: #2563eb;
}

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

.nav-links a {
    color: #555;
    font-size: 0.95rem;
    font-weight: 500;
    position: relative;
}

.nav-links a::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 2px;
    background: #2563eb;
    transition: width 0.2s ease;
}

.nav-links a:hover {
    color: #2563eb;
    text-decoration: none;
}

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

/* Hero Section */
.hero {
    min-height: auto;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 5rem 1.5rem 4rem;
    background: linear-gradient(135deg, #f5f5f5 0%, #e8e8e8 100%);
}

.hero-container {
    display: flex;
    gap: 3rem;
    max-width: 800px;
    width: 100%;
    align-items: flex-start;
}

.profile-image {
    width: 280px;
    height: 280px;
    border-radius: 16px;
    object-fit: cover;
    flex-shrink: 0;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.profile-image:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

.hero-info {
    flex: 1;
    padding-top: 1rem;
}

.hero-info h1 {
    font-size: 2.75rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    color: #111;
    letter-spacing: -1px;
    line-height: 1.2;
}

.tagline {
    font-size: 1.2rem;
    color: #666;
    margin-bottom: 1.25rem;
    font-weight: 500;
}

.social-links {
    display: flex;
    gap: 1rem;
}

.social-links a {
    color: #555;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    padding: 0.5rem;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.social-links a:hover {
    color: #2563eb;
    text-decoration: none;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.social-links svg {
    transition: transform 0.2s ease;
}

.social-links a:hover svg {
    transform: scale(1.1);
}

/* Sections */
.section {
    padding: 5rem 0;
    background: #fff;
}

.section:nth-child(even) {
    background: #fafafa;
}

.section-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 2rem;
    color: #111;
    letter-spacing: -0.5px;
    position: relative;
    display: inline-block;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 0;
    width: 40px;
    height: 3px;
    background: #2563eb;
    border-radius: 2px;
}

/* About Section */
.about-intro {
    font-size: 1.1rem;
    margin-bottom: 2.5rem;
    color: #444;
    line-height: 1.8;
}

/* Timeline - Line with Dots */
.timeline {
    margin-bottom: 2.5rem;
    position: relative;
    padding-left: 30px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 8px;
    bottom: 8px;
    width: 2px;
    background: linear-gradient(to bottom, #2563eb, #93c5fd, #2563eb);
    border-radius: 2px;
}

.timeline-item {
    position: relative;
    margin-bottom: 2rem;
    padding-left: 0;
    background: transparent;
    border: none;
    box-shadow: none;
    transition: transform 0.3s ease;
}

.timeline-item:last-child {
    margin-bottom: 0;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -26px;
    top: 6px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #fff;
    border: 3px solid #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
    transition: all 0.3s ease;
    z-index: 1;
}

.timeline-item:hover::before {
    background: #2563eb;
    box-shadow: 0 0 0 5px rgba(37, 99, 235, 0.25);
    transform: scale(1.2);
}

.timeline-item:hover {
    transform: translateX(6px);
}

.timeline-year {
    font-weight: 700;
    color: #2563eb;
    font-size: 0.85rem;
    margin-bottom: 0.35rem;
    background: transparent;
    padding: 0;
    width: auto;
    display: inline-block;
}

.timeline-content {
    background: #fff;
    padding: 1rem 1.25rem;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    border: 1px solid #eee;
}

.timeline-content:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
    border-color: #ddd;
}

/* Publications */
.about-publications {
    margin-bottom: 2rem;
    padding: 1.25rem 1.5rem;
    background: #f8f9fa;
    border-radius: 10px;
    border-left: 4px solid #2563eb;
}

.about-publications h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #111;
}

.about-publications p {
    font-size: 0.95rem;
    color: #555;
}

.about-publications a {
    font-weight: 500;
}

/* Interests */
.about-interests h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #111;
}

.about-list {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.about-list li {
    background: #f5f5f5;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.9rem;
    color: #555;
    transition: all 0.2s ease;
}

.about-list li:hover {
    background: #2563eb;
    color: #fff;
    transform: translateY(-2px);
}

/* Writing Section */
.writing-intro {
    font-size: 1rem;
    color: #666;
    margin-bottom: 1.5rem;
}

.writing-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.writing-card {
    display: flex;
    gap: 1rem;
    background: #fff;
    border: 1px solid #eee;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.writing-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    border-color: #ddd;
}

.writing-card-image {
    width: 160px;
    height: 107px;
    object-fit: cover;
    flex-shrink: 0;
}

.writing-card-content {
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.writing-card-content h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
    line-height: 1.4;
}

.writing-card-content h3 a {
    color: #111;
}

.writing-card-content h3 a:hover {
    color: #2563eb;
}

.writing-card-excerpt {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 0.5rem;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.writing-card-date {
    font-size: 0.8rem;
    color: #999;
}

.loading {
    color: #888;
    font-size: 0.95rem;
    padding: 1rem 0;
    text-align: center;
}

.writing-links {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

/* Projects Section */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
}

.project-card {
    height: 250px;
}

/* Flip Card */
.flip-card {
    width: 100%;
    height: 100%;
    perspective: 1000px;
}

.flip-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.flip-card:hover .flip-card-inner {
    transform: rotateY(180deg);
}

.flip-card-front, .flip-card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    border-radius: 12px;
    overflow: hidden;
}

.flip-card-front {
    background: #fff;
}

.flip-card-front img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Title overlay on front */
.flip-card-title-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1.5rem 1rem 1rem;
    background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.5) 60%, transparent 100%);
}

.flip-card-title-overlay h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #fff;
    margin: 0;
}

/* Back side */
.flip-card-back {
    background: linear-gradient(135deg, #1e3a5f 0%, #0f172a 100%);
    color: #fff;
    transform: rotateY(180deg);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 1.5rem;
    text-align: center;
}

.flip-card-back h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: #fff;
}

.flip-card-back p {
    font-size: 0.9rem;
    color: rgba(255,255,255,0.85);
    margin-bottom: 1rem;
    line-height: 1.5;
}

.flip-card-back .btn {
    background: #fff;
    color: #1e3a5f;
    padding: 0.6rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 6px;
    text-decoration: none;
    transition: all 0.2s ease;
}

.flip-card-back .btn:hover {
    background: #2563eb;
    color: #fff;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    color: #333;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn:hover {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
    text-decoration: none;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.btn-primary {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
}

.btn-primary:hover {
    background: #1d4ed8;
    border-color: #1d4ed8;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

/* Resume Section */
#resume .container p {
    font-size: 1rem;
    color: #555;
    margin-bottom: 1rem;
}

/* Footer */
footer {
    text-align: center;
    padding: 3rem 1.5rem;
    color: #888;
    font-size: 0.9rem;
    background: #fff;
    border-top: 1px solid #eee;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .nav-container {
        flex-direction: column;
        gap: 0.75rem;
    }

    .nav-links {
        gap: 1rem;
        flex-wrap: wrap;
        justify-content: center;
    }

    .hero-container {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 1.5rem;
    }

    .profile-image {
        width: 200px;
        height: 200px;
    }

    .hero-info h1 {
        font-size: 2rem;
    }

    .tagline {
        font-size: 1rem;
    }

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

    .hero {
        padding: 4rem 1rem 3rem;
    }

    .timeline {
        padding-left: 24px;
    }

    .timeline::before {
        left: 6px;
    }

    .timeline-item::before {
        left: -20px;
        width: 12px;
        height: 12px;
    }

    .timeline-item {
        margin-bottom: 1.5rem;
    }

    .timeline-content {
        padding: 0.875rem 1rem;
    }

    .writing-card {
        flex-direction: column;
    }

    .writing-card-image {
        width: 100%;
        height: 160px;
    }

    .writing-links {
        flex-direction: column;
    }

    .btn {
        text-align: center;
    }

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

    .section {
        padding: 3rem 0;
    }
}
