/* =========================================
CORE VARIABLES & THEME ENGINE
========================================= */
:root {
    /* --- 默认 Light Mode (ACG Pastel) --- */
    --bg-base: #fdfbff;
    --bg-gradient-1: hsla(28, 100%, 74%, 0.8);
    --bg-gradient-2: hsla(189, 100%, 56%, 0.8);
    --bg-gradient-3: hsla(355, 100%, 93%, 0.8);
    
    --glass-surface: rgba(255, 255, 255, 0.65); /* 更通透 */
    --glass-border: rgba(255, 255, 255, 0.8);
    --glass-shadow: rgba(142, 142, 240, 0.15);
    --glass-blur: 24px;
    
    --text-primary: #1a1c1e;
    --text-secondary: #42474e;
    --text-tertiary: #72777f;
    
    --accent-primary: #6750a4;
    --tag-bg: rgba(103, 80, 164, 0.08);
    --tag-text: #6750a4;

    --ease-elastic: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-smooth: cubic-bezier(0.4, 0.0, 0.2, 1);
}

/* --- Dark Mode Override (Deep Liquid) --- */
[data-theme="dark"] {
    --bg-base: #0f0f13;
    --bg-gradient-1: hsla(253, 40%, 20%, 0.6);
    --bg-gradient-2: hsla(225, 40%, 25%, 0.6);
    --bg-gradient-3: hsla(339, 40%, 25%, 0.6);

    --glass-surface: rgba(30, 30, 35, 0.6);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: rgba(0, 0, 0, 0.5);

    --text-primary: #e3e2e6;
    --text-secondary: #c4c6d0;
    --text-tertiary: #8e9099;
    
    --accent-primary: #d0bcff;
    --tag-bg: rgba(208, 188, 255, 0.1);
    --tag-text: #e8def8;
}

/* =========================================
ATMOSPHERIC BACKGROUND (New)
========================================= */
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    min-height: 100vh;
    color: var(--text-primary);
    background-color: var(--bg-base);
    transition: background-color 0.5s var(--ease-smooth), color 0.3s;
    overflow-x: hidden;
    position: relative;
}

/* 使用伪元素创建流动的光斑，性能优于直接操作 body background */
body::before, body::after {
    content: '';
    position: fixed;
    inset: -50%;
    width: 200%;
    height: 200%;
    background: 
        radial-gradient(circle at 50% 50%, var(--bg-gradient-1), transparent 50%),
        radial-gradient(circle at 0% 0%, var(--bg-gradient-2), transparent 40%),
        radial-gradient(circle at 100% 100%, var(--bg-gradient-3), transparent 40%);
    filter: blur(80px); /* 极度模糊产生液体感 */
    opacity: 0.6;
    z-index: -1;
    animation: liquid-flow 20s ease-in-out infinite alternate;
    pointer-events: none;
    transition: background 1s ease; /* 颜色切换过渡 */
}

body::after {
    background-size: 150% 150%;
    animation-direction: reverse;
    animation-duration: 25s;
    mix-blend-mode: overlay; /* 叠加模式增加色彩深度 */
}

@keyframes liquid-flow {
    0% { transform: translate(0, 0) rotate(0deg); }
    100% { transform: translate(-5%, -5%) rotate(5deg); }
}

/* =========================================
THEME TOGGLE BUTTON
========================================= */
.theme-toggle {
    background: transparent;
    border: none;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    font-size: 1.2rem;
    transition: all 0.3s var(--ease-elastic);
    position: relative;
    overflow: hidden;
}

.theme-toggle:hover {
    background: var(--tag-bg);
    transform: rotate(15deg);
}

.theme-toggle:active {
    transform: scale(0.9);
}

/* 简单的图标切换动画 */
.theme-icon {
    position: absolute;
    transition: all 0.5s var(--ease-elastic);
}

/* 默认显示月亮 (假设当前是浅色，点击变深色) - 逻辑由JS控制类名 */
[data-theme="light"] .fa-sun { transform: translateY(30px) rotate(90deg); opacity: 0; }
[data-theme="light"] .fa-moon { transform: translateY(0) rotate(0); opacity: 1; }

[data-theme="dark"] .fa-sun { transform: translateY(0) rotate(0); opacity: 1; }
[data-theme="dark"] .fa-moon { transform: translateY(-30px) rotate(-90deg); opacity: 0; }

/* =========================================
    HEADER: FLOAT GLASS
    ========================================= */
.glass-header {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 1200px;
    height: 64px;
    border-radius: 32px; /* Superellipse Pill Shape */
    background: var(--glass-surface);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    box-shadow: 0 8px 32px 0 var(--glass-shadow);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    transition: all 0.3s var(--ease-smooth);
}

.brand-group {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text-primary);
}

.brand-logo {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* 优化后的文字动画 */
.brand-text-wrapper {
    position: relative;
    height: 24px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.brand-text {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 24px;
    white-space: nowrap;
    animation: text-slide 6s cubic-bezier(0.83, 0, 0.17, 1) infinite;
}

@keyframes text-slide {
    0%, 45% { transform: translateY(0); opacity: 1; filter: blur(0); }
    50%, 95% { transform: translateY(-24px); opacity: 1; filter: blur(0); }
    100% { transform: translateY(0); opacity: 1; filter: blur(0); }
}

/* =========================================
    MAIN GRID: LIQUID LAYOUT
    ========================================= */
main {
    padding: 120px 20px 60px; /* Top padding for fixed header */
    max-width: 1200px;
    margin: 0 auto;
}

.liquid-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
    /* 列表载入时的交错动画 */
}

/* 项目容器 - "No-Card" Rule: 看起来像漂浮的水滴/玻璃片 */
.project-item {
    position: relative;
    background: var(--glass-surface);
    border: 1px solid transparent; /* 预留边框位置 */
    border-radius: 24px; /* Apple Style Rounded Corners */
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    text-decoration: none;
    color: inherit;
    transition: all 0.4s var(--ease-elastic);
    opacity: 0; /* JS控制淡入 */
    transform: translateY(20px);
    animation: fade-in-up 0.6s var(--ease-smooth) forwards;
}

/* 玻璃边缘光感 */
.project-item::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 24px;
    padding: 1px;
    background: linear-gradient(135deg, rgba(255,255,255,0.4), rgba(255,255,255,0.05));
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
}

/* Hover State: Lift & Glow (Refraction) */
.project-item:hover {
    transform: translateY(-6px) scale(1.01);
    background: rgba(255, 255, 255, 0.65); /* 增加不透明度 */
    box-shadow: 
        0 12px 40px -8px var(--glass-shadow),
        inset 0 0 0 1px rgba(255,255,255,0.5); /* Inner Glow */
    backdrop-filter: blur(30px); /* 加重模糊模拟对焦 */
}

.item-header {
    display: flex;
    align-items: center;
    gap: 16px;
}

.item-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: #fff;
    object-fit: cover;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    transition: transform 0.3s var(--ease-elastic);
}

.project-item:hover .item-icon {
    transform: scale(1.1) rotate(-3deg);
}

.item-title {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
}

.item-desc {
    margin: 0;
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.6;
    flex-grow: 1; /* 推到底部 */
}

.item-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
}

.item-url {
    font-size: 0.85rem;
    color: var(--text-tertiary);
    font-family: monospace;
    opacity: 0.8;
}

.tags-container {
    display: flex;
    gap: 8px;
}

.tag {
    font-size: 0.75rem;
    padding: 4px 10px;
    border-radius: 12px;
    background: var(--tag-bg);
    color: var(--tag-text);
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* 外部箭头指示器 */
.arrow-indicator {
    opacity: 0;
    transform: translateX(-10px);
    transition: all 0.3s var(--ease-smooth);
    color: var(--accent-primary);
}

.project-item:hover .arrow-indicator {
    opacity: 1;
    transform: translateX(0);
}

/* =========================================
    LOADING STATES & ANIMATIONS
    ========================================= */
@keyframes fade-in-up {
    to { opacity: 1; transform: translateY(0); }
}

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(90deg, rgba(255,255,255,0.1) 25%, rgba(255,255,255,0.3) 50%, rgba(255,255,255,0.1) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 8px;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* 移动端优化 */
@media (max-width: 768px) {
    .glass-header { width: 95%; padding: 0 16px; }
    .liquid-grid { grid-template-columns: 1fr; }
    .project-item:active { transform: scale(0.98); } /* 触摸反馈 */
}