/* 定义 CSS 变量 */
:root {
    --bg-gradient: linear-gradient(135deg, #fff0f5 0%, #e6e6fa 100%);
    --text-color: #555;
    --container-bg: rgba(255, 255, 255, 0.8);
    --container-shadow: rgba(255, 192, 203, 0.3);
    --title-color: #db7093;
    --title-shadow: rgba(255, 182, 193, 0.5);
    --subtitle-color: #87ceeb;
    --butterfly-color: #9370db;
    --carousel-bg: #f0f8ff;
    --sakura-color: #ffc0cb;
    --footer-color: #aaa;
    --heart-color: #ff69b4;
    --toggle-bg: #fff;
    --toggle-icon: #f39c12;
    --link-bg: rgba(255, 255, 255, 0.6);
    --link-hover-bg: rgba(255, 255, 255, 0.9);
    --link-text: #db7093;
    --link-border: rgba(219, 112, 147, 0.3);
    --btn-bg: #db7093;
    --btn-text: #fff;
    --btn-hover: #c71585;
}

[data-theme="dark"] {
    --bg-gradient: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    --text-color: #e0e0e0;
    --container-bg: rgba(30, 30, 40, 0.85);
    --container-shadow: rgba(0, 0, 0, 0.5);
    --title-color: #ffb7b2;
    --title-shadow: rgba(255, 182, 193, 0.2);
    --subtitle-color: #a0d8ef;
    --butterfly-color: #b19cd9;
    --carousel-bg: #2a2a3a;
    --sakura-color: #ffb7b2;
    --footer-color: #888;
    --heart-color: #ff69b4;
    --toggle-bg: #333;
    --toggle-icon: #f1c40f;
    --link-bg: rgba(255, 255, 255, 0.1);
    --link-hover-bg: rgba(255, 255, 255, 0.2);
    --link-text: #a0d8ef;
    --link-border: rgba(160, 216, 239, 0.3);
    --btn-bg: #ffb7b2;
    --btn-text: #333;
    --btn-hover: #ff9e99;
}

/* 全局重置与基础样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    transition: background-color 0.5s, color 0.5s, box-shadow 0.5s; /* 添加过渡效果 */
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden; /* 强制隐藏滚动条 */
}

body {
    font-family: "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
    background: var(--bg-gradient);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
}

/* 樱花飘落动画背景 */
.sakura-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.sakura {
    position: absolute;
    background-color: var(--sakura-color);
    border-radius: 100% 0 100% 0;
    opacity: 0.5;
    animation: fall linear infinite;
}

@keyframes fall {
    0% { transform: translate(0, -10%) rotate(0deg); opacity: 0.8; }
    100% { transform: translate(100px, 110vh) rotate(360deg); opacity: 0; }
}

/* 生成不同大小和位置的樱花 */
.sakura:nth-child(1) { left: 10%; width: 15px; height: 15px; animation-duration: 8s; animation-delay: 0s; }
.sakura:nth-child(2) { left: 20%; width: 10px; height: 10px; animation-duration: 12s; animation-delay: 2s; }
.sakura:nth-child(3) { left: 40%; width: 20px; height: 20px; animation-duration: 10s; animation-delay: 1s; }
.sakura:nth-child(4) { left: 60%; width: 12px; height: 12px; animation-duration: 15s; animation-delay: 3s; }
.sakura:nth-child(5) { left: 80%; width: 18px; height: 18px; animation-duration: 9s; animation-delay: 0.5s; }
.sakura:nth-child(6) { left: 90%; width: 14px; height: 14px; animation-duration: 11s; animation-delay: 4s; }


/* 主容器 - 适配全屏 (Index Page) */
.container {
    position: relative;
    z-index: 1;
    width: 90vw;
    height: 90vh;
    max-width: 1200px;
    background: var(--container-bg);
    padding: 2vh 2vw;
    border-radius: 20px;
    box-shadow: 0 10px 30px var(--container-shadow);
    backdrop-filter: blur(5px);
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: space-between; 
}

header {
    flex: 0 0 auto;
    margin-bottom: 2vh;
}

h1 {
    font-size: clamp(1.5rem, 4vw, 3rem);
    color: var(--title-color);
    margin-bottom: 0.5vh;
    text-shadow: 2px 2px 4px var(--title-shadow);
    letter-spacing: 5px;
    font-weight: 300;
}

.subtitle {
    font-size: clamp(0.8rem, 1.5vw, 1.2rem);
    color: var(--subtitle-color);
    font-weight: 300;
}

.butterfly {
    display: inline-block;
    font-size: clamp(1rem, 3vw, 1.5rem);
    color: var(--butterfly-color);
    margin: 0 10px;
    animation: flutter 2s ease-in-out infinite alternate;
}

@keyframes flutter {
    0% { transform: translateY(0) rotate(0deg); }
    100% { transform: translateY(-5px) rotate(10deg); }
}

/* 图片轮播容器 */
.carousel {
    flex: 1 1 auto;
    width: 100%;
    position: relative;
    overflow: hidden;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    background-color: var(--carousel-bg);
    min-height: 0;
}

/* 轮播图片样式 - JS控制 */
.slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 1.5s ease-in-out; /* 淡入淡出时间 */
    z-index: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.slide.active {
    opacity: 1;
    z-index: 2;
}

/* 背景模糊层 */
.slide-bg {
    position: absolute;
    top: -20px; left: -20px; right: -20px; bottom: -20px;
    background-image: var(--bg-image);
    background-size: cover;
    background-position: center;
    filter: blur(20px) brightness(0.9);
    z-index: 1;
}

/* 前景清晰层 */
.slide-inner {
    width: 100%;
    height: 100%;
    background-image: var(--bg-image);
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    z-index: 2;
    filter: drop-shadow(0 10px 20px rgba(0,0,0,0.3));
}

/* 提示信息 */
.loading-msg {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #aaa;
    font-size: 1rem;
    z-index: 0;
}

.footer {
    flex: 0 0 auto;
    margin-top: 2vh;
    font-size: clamp(0.7rem, 1.2vw, 0.9rem);
    color: var(--footer-color);
}

.footer span {
    color: var(--heart-color);
}

.footer-link {
    color: inherit;
    text-decoration: none;
    border-bottom: 1px dashed currentColor;
    transition: all 0.3s ease;
}

.footer-link:hover {
    color: var(--heart-color);
    border-bottom-style: solid;
}

/* 顶部控制栏 */
.top-controls {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 15px;
    z-index: 10;
    align-items: center;
}

/* 模式切换按钮 */
.theme-toggle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--toggle-bg);
    border: none;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    font-size: 1.2rem;
    color: var(--toggle-icon);
}

/* 图标按钮 (GitHub等) */
.icon-btn {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--toggle-bg);
    color: var(--toggle-icon);
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
}

.icon-btn:hover {
    transform: scale(1.1);
}

.icon-btn svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

/* 链接区域样式 */
.links-container {
    flex: 0 0 auto;
    margin-top: 2vh;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 15px;
    min-height: 10px; /* 即使为空也保留一点高度，避免布局跳动 */
}

.link-item {
    text-decoration: none;
    color: var(--link-text);
    background-color: var(--link-bg);
    border: 1px solid var(--link-border);
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    backdrop-filter: blur(2px);
}

.link-item:hover {
    background-color: var(--link-hover-bg);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

/* =========================================
   404 Page Specific Styles
   ========================================= */

/* 404 容器 (覆盖默认 container) */
.container-404 {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 40px;
    background: var(--container-bg);
    border-radius: 20px;
    box-shadow: 0 10px 30px var(--container-shadow);
    backdrop-filter: blur(5px);
    max-width: 600px;
    width: 90%;
    /* Reset flex properties from main container if needed, though class name change handles it */
}

.container-404 h1 {
    font-size: 6rem;
    color: var(--title-color);
    text-shadow: 4px 4px 8px var(--title-shadow);
    margin: 0;
    line-height: 1;
}

.container-404 .subtitle {
    font-size: clamp(0.8rem, 3.5vw, 1.4rem); /* 进一步调小字体，确保能塞进一行 */
    color: var(--subtitle-color);
    margin: 20px 0 40px;
    /* 去掉强制不换行，防止内容被截断 */
}

/* 针对小屏幕的优化 (404) */
@media (max-width: 600px) {
    .container-404 {
        padding: 20px; /* 减小内边距，给文字更多空间 */
        width: 95%;
    }
    .container-404 h1 {
        font-size: 4rem;
    }
}

/* 幽灵动画 */
.ghost-container {
    position: relative;
    width: 120px;
    height: 140px;
    margin: 0 auto 20px;
    animation: float 3s ease-in-out infinite;
}

.ghost {
    width: 120px;
    height: 120px;
    background: #fff;
    border-radius: 60px 60px 0 0;
    position: relative;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
    overflow: hidden;
}

/* 幽灵底部波浪 */
.ghost::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 20px;
    background: radial-gradient(circle at 10px 10px, transparent 10px, #fff 10px);
    background-size: 20px 20px;
    background-position: 0 10px;
    transform: rotate(180deg);
}

.face {
    position: absolute;
    top: 40px;
    left: 50%;
    transform: translateX(-50%);
    width: 70px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.eye {
    width: 12px;
    height: 12px;
    background: #333;
    border-radius: 50%;
}

.mouth {
    width: 10px;
    height: 10px;
    background: #ffb7b2;
    border-radius: 50%;
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
}

/* 幽灵身边的魂火 */
.soul-fire {
    position: absolute;
    width: 20px;
    height: 20px;
    background: #a0d8ef;
    border-radius: 50% 0 50% 50%;
    transform: rotate(-45deg);
    opacity: 0.8;
    box-shadow: 0 0 10px #a0d8ef;
    animation: fireFloat 2s infinite alternate;
}

.soul-fire.left { top: 20px; left: -30px; animation-delay: 0.5s; }
.soul-fire.right { top: 50px; right: -30px; animation-delay: 0s; }

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-20px); }
}

@keyframes fireFloat {
    0% { transform: rotate(-45deg) translateY(0) scale(1); }
    100% { transform: rotate(-45deg) translateY(-10px) scale(1.2); }
}

/* 返回按钮 */
.back-btn {
    display: inline-block;
    padding: 12px 30px;
    background-color: var(--btn-bg);
    color: var(--btn-text);
    text-decoration: none;
    border-radius: 30px;
    font-size: 1.1rem;
    transition: all 0.3s;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.back-btn:hover {
    background-color: var(--btn-hover);
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.2);
}
