/* Global Styles */
:root {
    /* Light Theme (Default) */
    --bg-body: #eef2f5;
    --bg-container: #ffffff;
    --text-main: #333333;
    --text-secondary: #666666;
    --text-light: #ffffff;
    --primary-color: #2a5298;
    --primary-dark: #1e3c72;
    --header-gradient: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    --glass-bg: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.4);
    --card-shadow: rgba(0,0,0,0.08);
    --nav-bg: #ffffff;
    --nav-border: #eeeeee;
    --link-hover-bg: rgba(42, 82, 152, 0.08);
    --grid-line: rgba(30, 60, 114, 0.04);
    --info-bg-gradient: linear-gradient(120deg, #f0f7ff 0%, #e1eeff 50%, #f0f7ff 100%);
    --info-border: rgba(161, 196, 253, 0.2);
    --footer-border: rgba(255, 255, 255, 0.4);
}

[data-theme="dark"] {
    /* Dark Theme */
    --bg-body: #121212;
    --bg-container: #1e1e1e;
    --text-main: #e0e0e0;
    --text-secondary: #aaaaaa;
    --text-light: #e0e0e0;
    --primary-color: #64b5f6;
    --primary-dark: #1565c0;
    --header-gradient: linear-gradient(135deg, #0d1b2a 0%, #1b263b 100%);
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --card-shadow: rgba(0,0,0,0.3);
    --nav-bg: #1e1e1e;
    --nav-border: #333333;
    --link-hover-bg: rgba(100, 181, 246, 0.1);
    --grid-line: rgba(255, 255, 255, 0.05);
    --info-bg-gradient: linear-gradient(120deg, #2d2d2d 0%, #333333 50%, #2d2d2d 100%);
    --info-border: rgba(255, 255, 255, 0.1);
    --footer-border: rgba(255, 255, 255, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Microsoft YaHei", sans-serif;
    background-color: var(--bg-body);
    background-image: 
        radial-gradient(circle at 50% 30%, rgba(255,255,255,0.05) 0%, transparent 100%),
        linear-gradient(var(--grid-line) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
    background-size: 100% 100%, 30px 30px, 30px 30px;
    background-attachment: fixed;
    color: var(--text-main);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Theme Toggle Button */
.theme-toggle {
    background: transparent;
    border: none;
    color: var(--text-main);
    cursor: pointer;
    padding: 10px;
    font-size: 1.2em;
    transition: transform 0.3s ease, color 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 102;
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
}

.theme-toggle:hover {
    transform: translateY(-50%) rotate(15deg) scale(1.1);
    color: var(--primary-color);
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(30px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes slideOutLeft {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(-30px); }
}

/* Container */
.container {
    max-width: 1000px;
    width: 95%;
    margin: 40px auto;
    background: var(--bg-container);
    border-radius: 16px;
    box-shadow: 0 20px 40px var(--card-shadow);
    overflow: hidden;
    animation: fadeIn 0.8s ease-out;
    min-height: 80vh;
    display: flex;
    flex-direction: column;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

/* Header */
header {
    background: var(--header-gradient);
    color: var(--text-light);
    padding: 80px 30px;
    text-align: center;
    position: relative;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    height: auto;
    opacity: 1;
    overflow: hidden;
    box-shadow: 0 4px 15px var(--card-shadow);
}

/* Wave Animation Effect */
header::before, header::after {
    content: "";
    position: absolute;
    left: 50%;
    min-width: 250%;
    min-height: 250%;
    background-color: rgba(255, 255, 255, 0.05);
    animation-name: rotate;
    animation-iteration-count: infinite;
    animation-timing-function: linear;
    border-radius: 40%;
    transform: translateX(-50%) translateY(-50%);
    z-index: 0;
}

header::before {
    bottom: -220%;
    animation-duration: 12s;
}

header::after {
    bottom: -215%;
    animation-duration: 15s;
    background-color: rgba(255, 255, 255, 0.08);
}

@keyframes rotate {
    0% { transform: translateX(-50%) rotate(0deg); }
    100% { transform: translateX(-50%) rotate(360deg); }
}

@keyframes float {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
    100% { transform: translateY(0px); }
}

header h1, header p, .campus-badge {
    position: relative;
    z-index: 2;
}

#global-particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
    font-weight: 700;
    letter-spacing: 1px;
    animation: fadeIn 1s ease-out 0.3s backwards;
}

header p {
    font-size: 1.1em;
    opacity: 0.95;
    text-shadow: 0 1px 2px rgba(0,0,0,0.1);
    font-weight: 300;
    animation: fadeIn 1s ease-out 0.6s backwards;
}

header.collapsed {
    padding: 0;
    height: 0;
    opacity: 0;
    margin: 0;
}

.campus-badge {
    width: 110px;
    height: 110px;
    background: var(--bg-container);
    border-radius: 50%;
    margin: 0 auto 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    color: var(--primary-dark);
    box-shadow: 0 10px 25px var(--card-shadow);
    border: 4px solid var(--glass-border);
    transition: transform 0.3s ease;
    backdrop-filter: blur(5px);
    animation: float 6s ease-in-out infinite;
}

.campus-badge:hover {
    animation-play-state: paused;
    transform: scale(1.1) rotate(5deg);
}

.campus-badge:hover {
    transform: rotate(10deg) scale(1.05);
}

/* Navigation */
.nav-container {
    background: var(--nav-bg);
    border-bottom: 1px solid var(--nav-border);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 10px var(--card-shadow);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.menu-toggle {
    display: none; /* Hidden on desktop */
}

nav {
    position: relative;
    height: 60px; /* Fixed height for navbar */
    display: flex;
    align-items: center;
    justify-content: center; /* Center the UL */
}

nav ul {
    list-style: none;
    display: flex;
    justify-content: center;
    padding: 0;
    margin: 0;
}

nav ul li {
    margin: 0 5px;
}

nav ul li a {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 20px 25px;
    display: block;
    transition: all 0.3s ease;
    font-weight: 600;
    position: relative;
}

nav ul li a:hover, nav ul li a.active {
    color: var(--primary-color);
    background: transparent;
}

nav ul li a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 3px;
    background: var(--primary-color);
    transition: all 0.3s;
    transform: translateX(-50%);
}

nav ul li a:hover::after, nav ul li a.active::after {
    width: 80%;
}

/* Main Content */
.main-content {
    padding: 50px;
    flex: 1; /* Push footer down */
    opacity: 1;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.main-content.fade-out {
    opacity: 0;
    transform: translateY(10px);
}

.main-content.fade-in {
    animation: slideInRight 0.5s ease forwards;
}

/* Grid Layout for Home */
.home-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 40px;
    align-items: start;
}

/* Cards */
@keyframes cardShimmer {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.container {
    background: var(--bg-container);
    background-size: 200% 200%;
    animation: cardShimmer 4s ease-in-out infinite;
}

.welcome-card, .quick-links, .content-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    box-shadow: 0 8px 32px var(--card-shadow);
    backdrop-filter: blur(4px);
    position: relative;
    overflow: hidden;
}

/* Welcome Card Styling */
.welcome-card {
    padding: 40px;
    border-radius: 16px;
}

.welcome-header h2 {
    color: var(--primary-dark);
    margin-bottom: 10px;
    font-size: 1.8em;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1em;
    margin-bottom: 30px;
}

.feature-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.feature-item {
    display: flex;
    align-items: center;
    padding: 15px;
    background: var(--glass-bg);
    border-radius: 12px;
    transition: transform 0.3s ease;
    border: 1px solid var(--glass-border);
    text-decoration: none; /* For anchor tags */
    color: inherit; /* Inherit text color */
    cursor: pointer;
}

.feature-item:hover {
    transform: translateY(-3px);
    background: var(--bg-container);
    box-shadow: 0 5px 15px var(--card-shadow);
}

.feature-item .icon {
    font-size: 2em;
    margin-right: 15px;
}

.feature-item .text strong {
    display: block;
    color: var(--primary-color);
    font-size: 1.1em;
    margin-bottom: 4px;
}

.feature-item .text p {
    font-size: 0.9em;
    color: var(--text-secondary);
    margin: 0;
}

.quote {
    font-style: italic;
    color: var(--text-secondary);
    border-left: 4px solid var(--primary-color);
    padding-left: 15px;
    margin-top: 20px;
    background: var(--link-hover-bg);
    padding: 15px;
    border-radius: 0 8px 8px 0;
}

/* Quick Links Styling */
.quick-links {
    padding: 30px;
    border-radius: 16px;
}

.quick-links h3 {
    color: var(--primary-dark);
    margin-bottom: 20px;
    font-size: 1.4em;
    border-bottom: 2px solid var(--info-border);
    padding-bottom: 10px;
}

.links-grid {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.link-card {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    text-decoration: none;
    color: var(--text-main);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.link-card:hover {
    transform: translateX(5px);
    background: var(--bg-container);
    box-shadow: 0 5px 15px var(--card-shadow);
    border-color: var(--primary-color);
}

.link-icon {
    font-size: 1.5em;
    margin-right: 15px;
}

.link-text {
    font-weight: 600;
    flex-grow: 1;
    font-size: 1.05em;
}

.arrow {
    color: var(--primary-color);
    opacity: 0;
    transform: translateX(-10px);
    transition: all 0.3s ease;
    font-weight: bold;
}

.link-card:hover .arrow {
    opacity: 1;
    transform: translateX(0);
}

/* Code Highlighting Overrides */
pre[class*="language-"] {
    border-radius: 8px;
    margin: 15px 0;
    box-shadow: 0 4px 15px var(--card-shadow);
    border: 1px solid var(--glass-border);
}

code[class*="language-"], pre[class*="language-"] {
    font-family: 'Fira Code', 'Consolas', 'Monaco', 'Andale Mono', 'Ubuntu Mono', monospace;
    font-size: 14px;
    text-shadow: none !important;
}

/* KaTeX Overrides for Dark Mode */
.katex {
    color: var(--text-main) !important;
}

.katex-display {
    background: transparent !important;
    box-shadow: none !important;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 10px 0;
}

/* Footer */
footer {
    background: var(--glass-bg);
    backdrop-filter: blur(4px);
    color: var(--text-secondary);
    text-align: center;
    padding: 25px 20px;
    border-top: 1px solid var(--footer-border);
    font-size: 0.9em;
    position: relative;
    width: 100%;
    box-sizing: border-box;
}

@keyframes floatText {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-3px); }
    100% { transform: translateY(0px); }
}

footer p {
    margin: 5px 0;
    transition: all 0.3s ease;
    animation: floatText 4s ease-in-out infinite;
}

footer p:nth-child(2) {
    animation-delay: 1s; /* Stagger animation */
    font-weight: 500;
}

footer p:hover {
    color: var(--primary-color);
    transform: scale(1.05);
    text-shadow: 0 0 8px rgba(42, 82, 152, 0.2);
    cursor: default;
}

footer a {
    color: inherit;
    text-decoration: none;
    cursor: pointer;
}

footer a:hover {
    text-decoration: underline;
}

/* Subpage Specifics */
.page-title {
    font-size: 2.2em;
    color: var(--text-main);
    margin-bottom: 40px;
    border-left: 6px solid var(--primary-color);
    padding-left: 25px;
    animation: slideInRight 0.5s ease;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.content-card {
    padding: 35px;
    border-radius: 16px;
    box-shadow: 0 10px 30px var(--card-shadow);
    margin-bottom: 40px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
}

.content-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 35px var(--card-shadow);
}

.content-card h3 {
    color: var(--primary-dark);
    margin-bottom: 20px;
    font-size: 1.5em;
    border-bottom: 2px solid var(--info-border);
    padding-bottom: 10px;
}

.content-card p {
    margin-bottom: 15px;
    color: var(--text-secondary);
    font-size: 1.05em;
    line-height: 1.8;
}

/* Code Snippet / Math Formula Box */
.code-snippet {
    background: var(--info-bg-gradient);
    color: var(--text-main);
    border: 1px solid var(--info-border);
    padding: 20px;
    border-radius: 12px;
    margin-top: 20px;
    box-shadow: 0 4px 15px var(--card-shadow);
}

.code-snippet strong {
    color: var(--primary-color);
    display: block;
    margin-bottom: 10px;
    font-size: 1.1em;
}

/* Info Grid System (Generalized) */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
    margin: 25px 0;
}

.info-item {
    background: var(--info-bg-gradient);
    background-size: 200% 200%;
    padding: 25px;
    border-radius: 12px;
    border: 1px solid var(--info-border);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    font-size: 1.1em;
    line-height: 1.6;
    text-decoration: none; /* Ensure links don't have underline */
    color: inherit; /* Inherit text color */
}

a.info-item {
    cursor: pointer;
}

.info-item strong {
    color: var(--primary-color);
    margin-right: 15px;
    font-weight: 600;
    min-width: 90px;
    position: relative;
    z-index: 2;
}

.info-item span, .info-item p {
    position: relative;
    z-index: 2;
    color: var(--text-main);
}

.info-item::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.8), transparent);
    transform: skewX(-20deg);
    pointer-events: none;
}

.info-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px var(--card-shadow);
    border-color: var(--primary-color);
}

.info-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 5px;
    background: linear-gradient(to bottom, var(--primary-color), transparent);
    opacity: 0.8;
    z-index: 1;
}

/* Timeline Styles */
.activity-timeline {
    background: var(--glass-bg);
    padding: 25px;
    border-radius: 12px;
    margin: 20px 0;
    border: 1px solid var(--glass-border);
}

.timeline-item {
    margin: 15px 0;
    padding-left: 25px;
    position: relative;
    color: var(--text-secondary);
    font-size: 1.05em;
}

.timeline-item:before {
    content: "•";
    color: var(--primary-color);
    font-size: 24px;
    position: absolute;
    left: 0;
    top: -8px;
}

/* Skills Tags */
.skills {
    display: flex;
    gap: 12px;
    margin: 20px 0;
    flex-wrap: wrap;
}

.skill-tag {
    background: var(--header-gradient);
    color: var(--text-light);
    padding: 8px 16px;
    border-radius: 25px;
    font-size: 0.9em;
    box-shadow: 0 4px 10px var(--card-shadow);
    transition: transform 0.2s ease;
}

.skill-tag:hover {
    transform: translateY(-2px);
}

/* Responsive Images */
.content-card img {
    width: 100%;
    height: 300px;
    object-fit: cover;
    border-radius: 12px;
    margin: 20px 0;
    box-shadow: 0 8px 20px var(--card-shadow);
    transition: transform 0.3s ease;
}

.content-card img:hover {
    transform: scale(1.02);
}

/* Animations */
@keyframes gradientFlow {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes shine {
    0% { left: -100%; opacity: 0; }
    20% { left: 100%; opacity: 0.5; }
    100% { left: 100%; opacity: 0; }
}
    transition: transform 0.3s ease;
}
.content-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px var(--card-shadow);
}

/* Mobile Optimization */
@media (max-width: 768px) {
    /* Container & Layout */
    .container {
        width: 100%;
        margin: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .main-content {
        padding: 20px;
    }

    /* Header */
    header {
        padding: 40px 20px;
    }

    header h1 {
        font-size: 1.8em;
    }

    .campus-badge {
        width: 80px;
        height: 80px;
        font-size: 30px;
    }

    .campus-badge img {
        width: 80px;
        height: 80px;
    }

    /* Navigation */
    .nav-container {
        position: sticky;
        top: 0;
        padding: 0;
        background: var(--glass-bg); /* Glass effect base */
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        box-shadow: 0 4px 20px var(--card-shadow);
    }

    nav {
        position: relative;
        height: 60px; /* Fixed height for navbar */
        display: flex;
        align-items: center;
    }
    
    /* Add a logo/brand to the navbar for mobile */
    nav::before {
        content: '校园探索者';
        position: absolute;
        left: 20px;
        font-weight: 700;
        color: var(--primary-color);
        font-size: 1.1em;
        opacity: 0.9;
    }

    .menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        background: transparent;
        border: none;
        font-size: 1.4em;
        color: var(--primary-color);
        cursor: pointer;
        width: 60px;
        height: 60px;
        position: absolute;
        right: 0;
        top: 0;
        z-index: 101;
        transition: all 0.3s ease;
    }
    
    .menu-toggle:active {
        transform: scale(0.9);
        background: var(--glass-border);
    }

    /* Mobile Theme Toggle Position */
    .theme-toggle {
        position: absolute;
        right: 60px; /* Left of hamburger */
        top: 0;
        width: 60px;
        height: 60px;
        font-size: 1.4em;
        margin: 0;
        transform: none; /* Reset desktop transform */
    }

    .theme-toggle:hover {
        transform: none;
        background: transparent;
    }

    nav ul {
        display: none; /* Hidden by default */
        flex-direction: column;
        width: 100%;
        background: var(--bg-container);
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        border-bottom: 1px solid var(--glass-border);
        padding: 10px 15px 20px;
        box-shadow: 0 15px 30px var(--card-shadow);
        position: absolute;
        top: 60px; /* Below navbar */
        left: 0;
    }

    nav ul.active {
        display: flex;
        animation: menuSlide 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    }

    @keyframes menuSlide {
        from { opacity: 0; transform: translateY(-10px) scale(0.98); }
        to { opacity: 1; transform: translateY(0) scale(1); }
    }

    nav ul li {
        margin: 4px 0;
        width: 100%;
        border: none;
        opacity: 0;
        animation: itemFade 0.4s ease forwards;
    }
    
    /* Stagger animation */
    nav ul li:nth-child(1) { animation-delay: 0.05s; }
    nav ul li:nth-child(2) { animation-delay: 0.1s; }
    nav ul li:nth-child(3) { animation-delay: 0.15s; }
    nav ul li:nth-child(4) { animation-delay: 0.2s; }
    nav ul li:nth-child(5) { animation-delay: 0.25s; }

    @keyframes itemFade {
        from { opacity: 0; transform: translateX(-10px); }
        to { opacity: 1; transform: translateX(0); }
    }

    nav ul li a {
        padding: 12px 20px;
        display: flex;
        align-items: center;
        width: 100%;
        border-radius: 10px;
        color: var(--text-secondary);
        font-weight: 500;
        transition: all 0.2s;
        font-size: 1em;
    }

    nav ul li a:hover, nav ul li a.active {
        background: var(--glass-bg);
        color: var(--primary-color);
        padding-left: 25px;
    }
    
    /* Active indicator dot */
    nav ul li a::before {
        content: '';
        display: inline-block;
        width: 6px;
        height: 6px;
        background: var(--primary-color);
        border-radius: 50%;
        margin-right: 12px;
        opacity: 0;
        transition: opacity 0.2s;
    }
    
    nav ul li a.active::before {
        opacity: 1;
    }

    nav ul li a::after {
        display: none; /* Remove desktop underline */
    }

    /* Grids */
    .home-grid, .info-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .feature-list {
        grid-template-columns: 1fr;
    }

    /* Cards */
    .welcome-card, .quick-links, .content-card {
        padding: 20px;
    }

    .info-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .info-item strong {
        margin-bottom: 5px;
    }

    /* Typography */
    .page-title {
        font-size: 1.5em;
        margin-bottom: 20px;
    }

    h2 {
        font-size: 1.4em;
    }

    h3 {
        font-size: 1.2em;
    }
    
    /* Footer */
    footer {
        padding: 20px 15px;
        font-size: 0.85em;
    }
}
