/* ============================================
   ACADEMIC WEBSITE - STYLES
   A refined, scholarly aesthetic with warmth
   ============================================ */

/* CSS Variables */
:root {
    /* Color palette - warm, scholarly tones (Light Mode) */
    --color-bg: #faf8f5;
    --color-bg-alt: #f4f1eb;
    --color-surface: #ffffff;
    --color-text: #2d2a26;
    --color-text-muted: #6b6560;
    --color-text-light: #9a938b;
    --color-accent: #8b4513;
    --color-accent-hover: #a0522d;
    --color-accent-light: #d4a574;
    --color-border: #e5e0d8;
    --color-border-light: #ece8e1;
    
    /* Typography */
    --font-serif: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
    --font-sans: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    
    /* Spacing - more compact */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2.5rem;
    --space-2xl: 4rem;
    --space-3xl: 6rem;
    
    /* Layout */
    --max-width: 1200px;
    --content-width: 800px;
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
    --transition-slow: 400ms ease;
}

/* Dark Mode - auto detect system preference */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --color-bg: #1a1a1a;
        --color-bg-alt: #242424;
        --color-surface: #2d2d2d;
        --color-text: #e8e4e0;
        --color-text-muted: #a8a4a0;
        --color-text-light: #787470;
        --color-accent: #d4a574;
        --color-accent-hover: #e0b888;
        --color-accent-light: #8b6914;
        --color-border: #3d3d3d;
        --color-border-light: #333333;
    }
}

/* Manual dark mode override */
[data-theme="dark"] {
    --color-bg: #1a1a1a;
    --color-bg-alt: #242424;
    --color-surface: #2d2d2d;
    --color-text: #e8e4e0;
    --color-text-muted: #a8a4a0;
    --color-text-light: #787470;
    --color-accent: #d4a574;
    --color-accent-hover: #e0b888;
    --color-accent-light: #8b6914;
    --color-border: #3d3d3d;
    --color-border-light: #333333;
}

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

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

body {
    font-family: var(--font-sans);
    font-size: 1rem;
    line-height: 1.7;
    color: var(--color-text);
    background-color: var(--color-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Particle canvas background */
#particle-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

/* Grain overlay for texture */
.grain-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.03;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-serif);
    font-weight: 500;
    line-height: 1.2;
    letter-spacing: -0.01em;
}

h1 { font-size: clamp(2.5rem, 5vw, 4rem); }
h2 { font-size: clamp(1.75rem, 3vw, 2.5rem); }
h3 { font-size: clamp(1.25rem, 2vw, 1.5rem); }

p {
    margin-bottom: 1em;
}

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

a {
    color: var(--color-accent);
    text-decoration: none;
    transition: color var(--transition-fast);
}

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

strong {
    font-weight: 600;
}

/* Selection */
::selection {
    background-color: var(--color-accent-light);
    color: var(--color-text);
}

/* ============================================
   NAVIGATION
   ============================================ */

.nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(250, 248, 245, 0.9);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--color-border-light);
    transition: background var(--transition-base);
}

/* Dark mode nav background */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .nav {
        background: rgba(26, 26, 26, 0.9);
    }
}

[data-theme="dark"] .nav {
    background: rgba(26, 26, 26, 0.9);
}

.nav-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: var(--space-md) var(--space-lg);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-links {
    display: flex;
    gap: var(--space-lg);
    margin-left: auto;
    margin-right: var(--space-lg);
}

.nav-logo {
    font-family: var(--font-serif);
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--color-text);
    letter-spacing: -0.02em;
}

.nav-logo:hover {
    color: var(--color-accent);
}

.nav-link {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text-muted);
    letter-spacing: 0.02em;
    position: relative;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 1px;
    background-color: var(--color-accent);
    transition: width var(--transition-base);
}

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

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

/* Theme Toggle Button */
.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: none;
    border: 1px solid var(--color-border);
    border-radius: 50%;
    cursor: pointer;
    color: var(--color-text);
    transition: all var(--transition-base);
}

.theme-toggle:hover {
    background-color: var(--color-bg-alt);
    border-color: var(--color-accent);
}

.theme-toggle .sun-icon {
    display: none;
}

.theme-toggle .moon-icon {
    display: block;
}

/* Dark mode icon swap */
[data-theme="dark"] .theme-toggle .sun-icon,
:root:not([data-theme="light"]) .theme-toggle .sun-icon {
    display: block;
}

[data-theme="dark"] .theme-toggle .moon-icon,
:root:not([data-theme="light"]) .theme-toggle .moon-icon {
    display: none;
}

/* Only apply auto dark mode icon swap when system prefers dark */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .theme-toggle .sun-icon {
        display: block;
    }
    :root:not([data-theme="light"]) .theme-toggle .moon-icon {
        display: none;
    }
}

@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) .theme-toggle .sun-icon {
        display: none;
    }
    :root:not([data-theme="dark"]) .theme-toggle .moon-icon {
        display: block;
    }
}

.nav-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: var(--space-sm);
}

.nav-toggle span {
    width: 24px;
    height: 2px;
    background-color: var(--color-text);
    transition: var(--transition-fast);
}

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

.hero {
    min-height: auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: var(--space-3xl) var(--space-lg) var(--space-2xl);
    position: relative;
}

.hero::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 50%;
    height: 100%;
    background: linear-gradient(135deg, transparent 0%, var(--color-bg-alt) 100%);
    opacity: 0.5;
    z-index: -1;
}

.hero-content {
    max-width: var(--max-width);
    margin: 0 auto;
    width: 100%;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: var(--space-xl);
    align-items: center;
}

.hero-image-wrapper {
    position: relative;
}

.hero-image {
    width: 280px;
    height: 280px;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid var(--color-border);
    box-shadow: 
        0 20px 40px rgba(0, 0, 0, 0.08),
        0 0 0 1px rgba(255, 255, 255, 0.5) inset;
    position: relative;
    cursor: pointer;
}

.hero-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.hero-image .profile-img {
    opacity: 1;
    transition: opacity 0.4s ease-in-out;
}

.hero-image .profile-img-hover {
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0;
    transition: opacity 0.4s ease-in-out;
}

.hero-image:hover .profile-img {
    opacity: 0;
}

.hero-image:hover .profile-img-hover {
    opacity: 1;
}

.hero-image-placeholder {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--color-bg-alt) 0%, var(--color-border) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-light);
}

.hero-image-placeholder svg {
    width: 60%;
    height: 60%;
}

.hero-text {
    max-width: 600px;
}

.hero-greeting {
    font-size: 1rem;
    color: var(--color-text-muted);
    margin-bottom: var(--space-sm);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.hero-name {
    margin-bottom: var(--space-md);
    color: var(--color-text);
}

.hero-title {
    font-family: var(--font-serif);
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--color-accent);
    margin-bottom: var(--space-sm);
}

.hero-affiliation {
    font-size: 1rem;
    color: var(--color-text-muted);
    line-height: 1.6;
    margin-bottom: var(--space-lg);
}

.hero-links {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    align-items: center;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 6px;
    transition: all var(--transition-fast);
    border: 1px solid transparent;
}

.btn-primary {
    background-color: var(--color-accent);
    color: white;
    border-color: var(--color-accent);
}

.btn-primary:hover {
    background-color: var(--color-accent-hover);
    border-color: var(--color-accent-hover);
    color: white;
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: transparent;
    color: var(--color-text);
    border-color: var(--color-border);
}

.btn-secondary:hover {
    background-color: var(--color-bg-alt);
    border-color: var(--color-text-light);
    color: var(--color-text);
}

.btn-icon {
    padding: var(--space-sm);
    background-color: transparent;
    color: var(--color-text-muted);
    border-color: transparent;
}

.btn-icon:hover {
    color: var(--color-accent);
    background-color: var(--color-bg-alt);
}

/* Hero scroll indicator - hidden for compact layout */
.hero-scroll {
    display: none;
}

.scroll-line {
    width: 1px;
    height: 40px;
    background: linear-gradient(to bottom, var(--color-text-light), transparent);
    animation: scroll-pulse 2s ease-in-out infinite;
}

@keyframes scroll-pulse {
    0%, 100% { opacity: 0.3; transform: scaleY(1); }
    50% { opacity: 1; transform: scaleY(1.2); }
}

/* ============================================
   SECTIONS
   ============================================ */

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

.section-alt {
    background-color: var(--color-bg-alt);
}

.section-inner {
    max-width: var(--max-width);
    margin: 0 auto;
}

.section-title {
    margin-bottom: var(--space-lg);
    position: relative;
    display: inline-block;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 0;
    width: 60px;
    height: 2px;
    background-color: var(--color-accent);
}

.section-subtitle {
    margin-top: calc(var(--space-md) * -1);
    margin-bottom: var(--space-xl);
    color: var(--color-text-muted);
    font-size: 0.9375rem;
}

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

.about-content {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: var(--space-xl);
}

.about-text .lead {
    font-family: var(--font-serif);
    font-size: 1.375rem;
    font-weight: 500;
    line-height: 1.5;
    color: var(--color-text);
    margin-bottom: var(--space-lg);
}

.about-text a {
    color: var(--color-accent);
    text-decoration: none;
    position: relative;
    transition: color 0.3s ease;
}

.about-text a::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 1px;
    background-color: var(--color-accent);
    transition: width 0.3s ease;
}

.about-text a:hover {
    color: var(--color-accent-dark, #8b6914);
}

.about-text a:hover::after {
    width: 100%;
}

.about-news h3 {
    font-size: 1rem;
    font-family: var(--font-sans);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    margin-bottom: var(--space-md);
}

.about-news .news-list {
    list-style: none;
}

.about-news .news-list li {
    padding: var(--space-sm) 0;
    border-bottom: 1px solid var(--color-border-light);
    font-size: 0.9375rem;
    color: var(--color-text-muted);
    line-height: 1.6;
}

.about-news .news-list li:last-child {
    border-bottom: none;
}

.about-news .news-date {
    font-weight: 600;
    color: var(--color-accent);
    margin-right: var(--space-sm);
}

/* ============================================
   NEWS SECTION
   ============================================ */

.news-list {
    list-style: none;
}

.news-item {
    display: grid;
    grid-template-columns: 100px 1fr;
    gap: var(--space-lg);
    padding: var(--space-md) 0;
    border-bottom: 1px solid var(--color-border);
}

.news-item:first-child {
    padding-top: 0;
}

.news-date {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-accent);
}

.news-text {
    color: var(--color-text);
}

/* ============================================
   PUBLICATIONS SECTION
   ============================================ */

.publications-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.pub-item {
    display: flex;
    flex-direction: column;
    padding: var(--space-md);
    background-color: var(--color-surface);
    border-radius: 12px;
    border: 1px solid var(--color-border-light);
    transition: all 0.3s ease;
    cursor: pointer;
}

.pub-main {
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: var(--space-lg);
    align-items: center;
}


.pub-item:hover {
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
    transform: translateY(-4px);
    border-color: var(--color-accent-light);
}

.pub-item:hover .pub-title {
    color: var(--color-accent);
}

/* Publication abstract */
.pub-abstract {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.4s ease, opacity 0.3s ease, padding 0.3s ease, margin 0.3s ease;
    font-size: 0.9375rem;
    line-height: 1.7;
    color: var(--color-text-muted);
    padding: 0;
    margin: 0;
}

.pub-item.expanded .pub-abstract {
    max-height: 500px;
    opacity: 1;
    padding-top: var(--space-md);
    margin-top: var(--space-md);
    border-top: 1px solid var(--color-border-light);
}

.pub-thumbnail {
    border-radius: 8px;
    overflow: hidden;
    background-color: var(--color-bg-alt);
    align-self: start;
    width: 250px;
}

.pub-thumbnail img {
    width: 100%;
    height: auto;
    object-fit: contain;
    display: block;
}

.pub-thumbnail-placeholder {
    width: 100%;
    height: 100%;
    min-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-light);
}

.pub-thumbnail-placeholder svg {
    width: 70%;
    height: 70%;
}

.pub-content {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.pub-award {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    font-size: 0.75rem;
    font-weight: 600;
    color: #b8860b;
    background-color: #fdf6e3;
    padding: var(--space-xs) var(--space-sm);
    border-radius: 4px;
    width: fit-content;
}

.pub-title {
    font-size: 1.125rem;
    font-weight: 600;
    font-family: var(--font-sans);
    line-height: 1.3;
}

.pub-authors {
    font-size: 0.9375rem;
    color: var(--color-text-muted);
    line-height: 1.4;
}

.pub-venue {
    font-size: 0.875rem;
    color: var(--color-text-light);
    font-style: italic;
    line-height: 1.4;
}

.pub-links {
    display: flex;
    gap: var(--space-sm);
    margin-top: var(--space-xs);
}

.pub-link {
    font-size: 0.8125rem;
    font-weight: 500;
    padding: var(--space-xs) var(--space-sm);
    background-color: var(--color-bg-alt);
    border-radius: 4px;
    color: var(--color-text-muted);
    transition: all var(--transition-fast);
}

.pub-link:hover {
    background-color: var(--color-accent);
    color: white;
}

/* ============================================
   PROJECTS SECTION
   ============================================ */

.projects-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-md);
}

.project-card {
    background-color: var(--color-surface);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--color-border-light);
    transition: all var(--transition-base);
}

.project-card:hover {
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.08);
    transform: translateY(-4px);
}

.project-image {
    aspect-ratio: 4/3;
    background-color: var(--color-bg-alt);
    overflow: hidden;
}

.project-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-slow);
}

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

.project-image-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-light);
    background: linear-gradient(135deg, var(--color-bg-alt) 0%, var(--color-border-light) 100%);
}

.project-image-placeholder svg {
    width: 50%;
    height: 50%;
}

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

.project-title {
    font-size: 1.125rem;
    margin-bottom: var(--space-sm);
}

.project-desc {
    font-size: 0.9375rem;
    color: var(--color-text-muted);
    margin-bottom: var(--space-md);
}

.project-link {
    font-size: 0.875rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
}

.project-link:hover {
    gap: var(--space-sm);
}

/* ============================================
   TEACHING SECTION
   ============================================ */

.teaching-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.course-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: var(--space-md);
    background-color: var(--color-surface);
    border-radius: 12px;
    border: 1px solid var(--color-border-light);
    transition: all var(--transition-base);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.course-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0;
    transition: opacity 0.4s ease-in-out;
    z-index: 0;
}

.course-item:hover::before {
    opacity: 0.15;
}

.course-item .course-info,
.course-item .course-meta {
    position: relative;
    z-index: 1;
}

.course-item:hover {
    border-color: var(--color-accent-light);
}

.course-item:hover .course-title {
    font-weight: 700;
    color: var(--color-text);
}

.course-item:hover .course-desc {
    color: var(--color-text);
}

.course-item:hover .course-term {
    color: var(--color-text-muted);
    font-weight: 500;
}

/* Individual course item backgrounds */
.course-item[data-hover-image="Asset/upenn.png"]::before {
    background-image: url('Asset/upenn.png');
}

.course-item[data-hover-image="Asset/fife-penn.png"]::before {
    background-image: url('Asset/fife-penn.png');
}

.course-item[data-hover-image="Asset/ilo.png"]::before {
    background-image: url('Asset/ilo.png');
}



.course-title {
    font-size: 1.0625rem;
    font-family: var(--font-sans);
    font-weight: 600;
    margin-bottom: var(--space-xs);
}

.course-desc {
    font-size: 0.9375rem;
    color: var(--color-text-muted);
    max-width: 600px;
}

.course-term {
    font-size: 0.875rem;
    color: var(--color-text-light);
    white-space: nowrap;
}

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

.contact-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-lg);
}

.contact-lead {
    font-family: var(--font-serif);
    font-size: 1.25rem;
    font-weight: 500;
    line-height: 1.5;
    margin-bottom: var(--space-lg);
}

.contact-details {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.contact-item {
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
    color: var(--color-text-muted);
}

.contact-item svg {
    flex-shrink: 0;
    color: var(--color-accent);
}

.contact-item a {
    color: var(--color-text);
}

.contact-note {
    padding: var(--space-lg);
    background-color: var(--color-surface);
    border-radius: 12px;
    border: 1px solid var(--color-border-light);
}

.contact-note h3 {
    font-size: 1rem;
    font-family: var(--font-sans);
    font-weight: 600;
    margin-bottom: var(--space-sm);
}

.contact-note p {
    font-size: 0.9375rem;
    color: var(--color-text-muted);
}

/* ============================================
   FOOTER
   ============================================ */

.footer {
    padding: var(--space-lg) var(--space-lg);
    border-top: 1px solid var(--color-border);
    text-align: center;
}

.footer-inner {
    max-width: var(--max-width);
    margin: 0 auto;
}

.footer p {
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

.footer-note {
    font-size: 0.75rem;
    color: var(--color-text-light);
    margin-top: var(--space-sm);
}

/* ============================================
   BACK TO TOP BUTTON
   ============================================ */

.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 44px;
    height: 44px;
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all var(--transition-base);
    z-index: 999;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.back-to-top:hover {
    background-color: var(--color-accent);
    border-color: var(--color-accent);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

@media (max-width: 768px) {
    .back-to-top {
        bottom: 20px;
        right: 20px;
        width: 40px;
        height: 40px;
    }
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

@media (max-width: 1024px) {
    .hero-content {
        grid-template-columns: 1fr;
        text-align: center;
    }
    
    .hero-image-wrapper {
        justify-self: center;
    }
    
    .hero-image {
        width: 220px;
        height: 220px;
    }
    
    .hero-text {
        max-width: 100%;
    }
    
    .hero-links {
        justify-content: center;
    }
    
    .about-content {
        grid-template-columns: 1fr;
    }
    
    
    .contact-content {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    :root {
        --space-xl: 3rem;
        --space-2xl: 4rem;
        --space-3xl: 6rem;
    }

    
    .nav-links {
        display: flex;
        flex-direction: column;
        gap: 0;
        margin-left: 0;
        margin-right: 0;
        
        /* Animation - collapse to 0 height */
        max-height: 0;
        overflow: hidden;
        opacity: 0;
        transition: max-height var(--transition-slow), 
                    opacity var(--transition-base);
    }
    
    .nav-links .nav-link {
        padding: var(--space-sm) 0;
    }
    
    .nav-links.active {
        max-height: 300px;
        opacity: 1;
    }
    
    .nav-toggle {
        display: flex;
    }
    
    /* Reorder nav-inner for mobile: logo, toggle, theme on one line; links below */
    .nav-inner {
        flex-wrap: wrap;
    }
    
    .nav-inner .nav-logo {
        order: 1;
    }
    
    .nav-inner .nav-links {
        order: 4;
        width: 100%;
        flex-basis: 100%;
    }
    
    .nav-inner .theme-toggle {
        order: 2;
        margin-left: auto;
    }
    
    .nav-inner .nav-toggle {
        order: 3;
        margin-left: var(--space-sm);
    }
    
    .pub-main {
        grid-template-columns: 1fr;
    }
    
    .pub-thumbnail {
        width: 100%;
        max-width: 100%;
        align-self: stretch;
    }
    
    .projects-grid {
        grid-template-columns: 1fr;
    }
    
    /* Compact project cards on mobile */
    .project-card {
        display: grid;
        grid-template-columns: 120px 1fr;
        gap: 0;
        min-height: 120px;
    }
    
    .project-image {
        width: 120px;
        height: 120px;
        min-width: 120px;
        min-height: 120px;
        aspect-ratio: 1/1;
        flex-shrink: 0;
    }
    
    .project-image img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }
    
    .project-content {
        display: flex;
        flex-direction: column;
        justify-content: center;
        padding: var(--space-sm) var(--space-md);
        min-width: 0; /* Prevent content from overflowing grid */
        overflow: hidden;
    }
    
    .project-title {
        font-size: 1.0625rem;
        margin-bottom: var(--space-xs);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .project-desc {
        font-size: 0.9rem;
        display: -webkit-box;
        -webkit-line-clamp: 3;
        -webkit-box-orient: vertical;
        overflow: hidden;
        margin-bottom: 0;
    }
    
    .project-tags {
        display: none;
    }
    
    .course-item {
        flex-direction: column;
        gap: var(--space-sm);
    }
    
    .news-item {
        grid-template-columns: 1fr;
        gap: var(--space-xs);
    }
    
    .news-date {
        font-size: 0.75rem;
    }
}

@media (max-width: 480px) {
    .hero-image {
        width: 180px;
        height: 180px;
    }
    
    .btn {
        padding: var(--space-sm) var(--space-sm);
        font-size: 0.8125rem;
    }
    
    .section {
        padding: var(--space-2xl) var(--space-lg);
    }
}

/* ============================================
   ANIMATIONS
   ============================================ */

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

.hero-content {
    animation: fadeInUp 0.8s ease-out;
}

.section-title {
    animation: fadeInUp 0.6s ease-out;
}

/* Staggered animations for lists */
.pub-item,
.project-card,
.news-item,
.course-item {
    opacity: 0;
    animation: fadeInUp 0.5s ease-out forwards;
}

.pub-item:nth-child(1) { animation-delay: 0.1s; }
.pub-item:nth-child(2) { animation-delay: 0.2s; }
.pub-item:nth-child(3) { animation-delay: 0.3s; }
.pub-item:nth-child(4) { animation-delay: 0.4s; }

.project-card:nth-child(1) { animation-delay: 0.1s; }
.project-card:nth-child(2) { animation-delay: 0.2s; }
.project-card:nth-child(3) { animation-delay: 0.3s; }

.news-item:nth-child(1) { animation-delay: 0.1s; }
.news-item:nth-child(2) { animation-delay: 0.15s; }
.news-item:nth-child(3) { animation-delay: 0.2s; }
.news-item:nth-child(4) { animation-delay: 0.25s; }
.news-item:nth-child(5) { animation-delay: 0.3s; }

.course-item:nth-child(1) { animation-delay: 0.1s; }
.course-item:nth-child(2) { animation-delay: 0.2s; }
.course-item:nth-child(3) { animation-delay: 0.3s; }

/* Print styles */
@media print {
    .nav,
    .hero-scroll,
    .grain-overlay {
        display: none;
    }
    
    .hero {
        min-height: auto;
        padding: var(--space-lg);
    }
    
    .section {
        padding: var(--space-lg);
    }
    
    .pub-item,
    .project-card {
        break-inside: avoid;
    }
}
