/**
 * 黑色涟漪 - 公用主题样式
 * 亮色/暗色两套主题，通过 data-theme 切换
 */
/* ===== CSS 变量定义两套主题 ===== */
:root {
    /* 亮色主题（默认） */
    --bg-primary: #f4f2ed;
    --bg-secondary: rgba(250, 248, 245, 0.7);
    --text-primary: #2b2b2b;
    --text-secondary: #4a4e57;
    --text-tertiary: #5d6c73;
    --accent-primary: #608a9c;
    --accent-secondary: #6e9eb3;
    --border-color: #c3cfd6;
    --shadow-color: rgba(70, 130, 200, 0.05);
    --shadow-hover: rgba(30, 144, 255, 0.12);
    --glow-color: rgba(30, 144, 255, 0.15);
    --seal-color: #b0655a;
    --grid-color: rgba(100, 150, 200, 0.04);
    --scan-gradient: linear-gradient(90deg, transparent, rgba(0,160,255,0.3), rgba(30,144,255,0.5), rgba(0,160,255,0.3), transparent);
    --code-watermark: #6f8c9f;
    --icon-color: #608a9c;
}

[data-theme="dark"] {
    /* 暗色主题 */
    --bg-primary: #050507;
    --bg-secondary: rgba(15, 15, 20, 0.45);
    --text-primary: #e0e0e0;
    --text-secondary: #aaa;
    --text-tertiary: #bbb;
    --accent-primary: #cc3333;
    --accent-secondary: rgba(204, 0, 0, 0.4);
    --border-color: rgba(100, 100, 120, 0.15);
    --shadow-color: rgba(0, 0, 0, 0.3);
    --shadow-hover: rgba(204, 0, 0, 0.15);
    --glow-color: rgba(255, 255, 255, 0.1);
    --seal-color: #cc3333;
    --grid-color: rgba(255, 255, 255, 0.02);
    --scan-gradient: linear-gradient(90deg, transparent, rgba(204, 0, 0, 0.3), rgba(255, 100, 100, 0.4), rgba(204, 0, 0, 0.3), transparent);
    --code-watermark: rgba(255, 255, 255, 0.1);
    --icon-color: #cc3333;
}

/* ===== 全局基础样式（使用主题变量） ===== */
body.site-theme {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    transition: background-color 2s cubic-bezier(0.25, 0.1, 0.25, 1),
                color 1.2s cubic-bezier(0.25, 0.1, 0.25, 1);
}

/* 背景纹理层 */
body.site-theme::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
    will-change: opacity, background-image;
    transition: opacity 2s cubic-bezier(0.25, 0.1, 0.25, 1),
                background-image 2s cubic-bezier(0.25, 0.1, 0.25, 1);
}

/* 亮色主题背景：科技网格 */
body.site-theme::before {
    background-image:
        repeating-linear-gradient(0deg, var(--grid-color) 0px, transparent 1px, transparent 8px),
        repeating-linear-gradient(90deg, var(--grid-color) 0px, transparent 1px, transparent 8px);
    background-size: 24px 24px;
    opacity: 1;
}

/* 暗色主题背景：噪点 */
[data-theme="dark"] body.site-theme::before {
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.02'/%3E%3C/svg%3E");
    background-size: 100% 100%;
}

/* ===== 主题切换遮罩层 ===== */
body.site-theme::after {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, transparent 0%, rgba(0,0,0,0.03) 100%);
    pointer-events: none;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.6s ease-in-out;
}

body.site-theme.theme-transitioning::after {
    opacity: 1;
}

/* ===== 水墨铺开效果层（首页等可选使用） ===== */
.ink-splash {
    position: fixed;
    width: 100vmax;
    height: 100vmax;
    border-radius: 50%;
    pointer-events: none;
    z-index: 10000;
    opacity: 0;
    transform: translate(-50%, -50%) scale(0);
    mix-blend-mode: normal;
    background:
        radial-gradient(circle at 45% 45%, var(--ink-center) 0%, transparent 15%),
        radial-gradient(circle at 55% 50%, var(--ink-center) 0%, transparent 18%),
        radial-gradient(circle at 50% 55%, var(--ink-mid) 0%, transparent 25%),
        radial-gradient(circle at 50% 50%, var(--ink-mid) 0%, var(--ink-edge) 40%, transparent 70%);
    filter: blur(2px);
    transition: none;
    will-change: transform, opacity;
}

.ink-splash {
    --ink-center: rgba(15, 15, 20, 0.98);
    --ink-mid: rgba(15, 15, 20, 0.65);
    --ink-edge: rgba(15, 15, 20, 0.25);
}

[data-theme="dark"] .ink-splash {
    --ink-center: rgba(244, 242, 237, 0.98);
    --ink-mid: rgba(244, 242, 237, 0.65);
    --ink-edge: rgba(244, 242, 237, 0.25);
}

@keyframes inkSpread {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0); filter: blur(0px); }
    3% { opacity: 1; filter: blur(1px); }
    15% { transform: translate(-50%, -50%) scale(0.3); filter: blur(2px); }
    40% { transform: translate(-50%, -50%) scale(1.2); filter: blur(3px); }
    70% { transform: translate(-50%, -50%) scale(2); filter: blur(2.5px); }
    100% { opacity: 1; transform: translate(-50%, -50%) scale(2.8); filter: blur(2px); }
}

@keyframes inkFadeOut {
    0% { opacity: 1; transform: translate(-50%, -50%) scale(2.8); filter: blur(2px); }
    50% { opacity: 0.6; filter: blur(3px); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(3); filter: blur(4px); }
}

.ink-splash.spreading {
    animation: inkSpread 1.4s cubic-bezier(0.15, 0.5, 0.3, 0.95) forwards;
}

.ink-splash.fading {
    animation: inkFadeOut 1s cubic-bezier(0.4, 0, 0.6, 1) forwards;
}

/* ===== 主题切换按钮 ===== */
.theme-toggle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-secondary);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: var(--accent-primary);
    box-shadow: 0 4px 12px var(--shadow-color);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
                box-shadow 0.4s ease,
                background 1.2s cubic-bezier(0.25, 0.1, 0.25, 1),
                border-color 1.2s cubic-bezier(0.25, 0.1, 0.25, 1),
                color 1.2s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.theme-toggle:hover {
    transform: scale(1.1) rotate(15deg);
    box-shadow: 0 6px 20px var(--shadow-hover);
}

.theme-toggle.ink-trigger {
    animation: buttonPulse 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes buttonPulse {
    0% { transform: scale(1); }
    30% { transform: scale(0.85); }
    60% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

.theme-toggle::before {
    content: '☀';
    transition: opacity 0.5s ease, transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

[data-theme="dark"] .theme-toggle::before {
    content: '☾';
    transform: rotate(20deg);
}
