/* ════════════════════════════════════════════════════════════════
   夜间模式对角线扫光特效 CSS（配合 fun_optimized.js 使用）
   效果：点击切换时，黑色从右上角向左下角对角线展开/收起
   ════════════════════════════════════════════════════════════════ */

/* ─── 对角线扫光遮罩层 ─── */
#diagonal-wipe-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 99999;
    pointer-events: none;
    will-change: clip-path;
    background: #121212;
}

/* 扫光过程中的内容保护：防止闪烁 */
html.theme-transitioning,
html.theme-transitioning * {
    transition: none !important;
    animation: none !important;
}

/* ─── 模式切换按钮增强 ─── */
.mode-toggle {
    position: relative;
    overflow: hidden;
    border-radius: var(--border-radius);
    transition: all var(--transition-base);
}

.mode-toggle::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: radial-gradient(circle, rgba(74, 111, 165, 0.2) 0%, transparent 70%);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.6s ease, height 0.6s ease;
    pointer-events: none;
}

.mode-toggle:active::before {
    width: 100px;
    height: 100px;
}

.mode-toggle svg {
    transition: transform var(--transition-bounce);
}

.mode-toggle:hover svg {
    transform: rotate(15deg) scale(1.1);
}

/* 切换时的图标旋转动画 */
@keyframes iconSpin {
    from { transform: rotate(0deg) scale(1); }
    50% { transform: rotate(180deg) scale(0.8); }
    to { transform: rotate(360deg) scale(1); }
}

.mode-toggle.switching svg {
    animation: iconSpin 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ─── 夜间模式全局过渡增强 ─── */
html.dark,
html.dark body,
html.dark #container,
html.dark .post-item,
html.dark .post-content,
html.dark .breadcrumb-nav,
html.dark #article-info,
html.dark .comment_excerpt,
html.dark .links-card,
html.dark .mixtapeEmbed {
    transition: background-color 0.5s cubic-bezier(0.4, 0, 0.2, 1),
                color 0.5s cubic-bezier(0.4, 0, 0.2, 1),
                border-color 0.5s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

/* 夜间模式下的图片反色保护 */
html.dark .site-logo {
    filter: brightness(0) invert(1);
    transition: filter 0.5s ease;
}

/* 夜间模式代码块微光 */
html.dark .post-content pre::after {
    box-shadow: 0 0 8px rgba(122, 168, 98, 0.3), 20px 0 8px rgba(229, 185, 120, 0.3), 40px 0 8px rgba(212, 134, 111, 0.3);
}

/* 夜间模式链接下划线发光 */
html.dark .post-content a {
    text-decoration-color: var(--border-primary);
    transition: text-decoration-color 0.3s ease, color 0.3s ease;
}

html.dark .post-content a:hover {
    text-decoration-color: var(--text-theme);
    text-shadow: 0 0 20px rgba(90, 140, 185, 0.15);
}

/* 夜间模式引用块左侧发光 */
html.dark .post-content blockquote {
    border-left-color: var(--text-theme);
    box-shadow: -3px 0 10px rgba(90, 140, 185, 0.1);
}

/* 夜间模式表格行悬停 */
html.dark .post-content tr:hover {
    background-color: rgba(255, 255, 255, 0.03);
}

/* 夜间模式友链卡片扫光增强 */
html.dark .links-card::before {
    background: linear-gradient(45deg, transparent 30%, rgba(90, 140, 185, 0.08) 50%, transparent 70%);
}

/* 夜间模式评论项悬停 */
html.dark .comment_list_box:hover {
    background: rgba(255, 255, 255, 0.02);
}

/* 夜间模式分页按钮 */
html.dark .page-navigator a:hover {
    box-shadow: 0 0 0 1px var(--text-theme);
}

/* 夜间模式表情面板 */
html.dark .box {
    background: var(--bg-light);
    border-color: var(--border-primary);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

/* 夜间模式滚动条 */
html.dark ::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

html.dark ::-webkit-scrollbar-thumb {
    background: var(--border-primary);
}

html.dark ::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ─── 星星背景特效（夜间模式可选）─── */
@keyframes twinkle {
    0%, 100% { opacity: 0.3; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.2); }
}

html.dark body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
    background-image:
        radial-gradient(2px 2px at 20px 30px, rgba(255,255,255,0.15), transparent),
        radial-gradient(2px 2px at 40px 70px, rgba(255,255,255,0.1), transparent),
        radial-gradient(1px 1px at 90px 40px, rgba(255,255,255,0.12), transparent),
        radial-gradient(2px 2px at 130px 80px, rgba(255,255,255,0.08), transparent),
        radial-gradient(1px 1px at 160px 120px, rgba(255,255,255,0.1), transparent),
        radial-gradient(2px 2px at 200px 50px, rgba(255,255,255,0.06), transparent),
        radial-gradient(1px 1px at 250px 90px, rgba(255,255,255,0.09), transparent),
        radial-gradient(2px 2px at 300px 150px, rgba(255,255,255,0.07), transparent),
        radial-gradient(1px 1px at 350px 30px, rgba(255,255,255,0.11), transparent),
        radial-gradient(2px 2px at 400px 100px, rgba(255,255,255,0.05), transparent),
        radial-gradient(1px 1px at 450px 60px, rgba(255,255,255,0.08), transparent),
        radial-gradient(2px 2px at 500px 130px, rgba(255,255,255,0.06), transparent),
        radial-gradient(1px 1px at 550px 20px, rgba(255,255,255,0.1), transparent),
        radial-gradient(2px 2px at 600px 80px, rgba(255,255,255,0.07), transparent),
        radial-gradient(1px 1px at 650px 140px, rgba(255,255,255,0.09), transparent),
        radial-gradient(2px 2px at 700px 40px, rgba(255,255,255,0.05), transparent),
        radial-gradient(1px 1px at 750px 110px, rgba(255,255,255,0.08), transparent),
        radial-gradient(2px 2px at 800px 70px, rgba(255,255,255,0.06), transparent),
        radial-gradient(1px 1px at 850px 150px, rgba(255,255,255,0.1), transparent),
        radial-gradient(2px 2px at 900px 50px, rgba(255,255,255,0.07), transparent);
    background-repeat: repeat;
    background-size: 1000px 200px;
    animation: twinkle 4s ease-in-out infinite;
    opacity: 0.6;
}

/* ─── 扫光完成后的淡入效果 ─── */
@keyframes contentReveal {
    from {
        opacity: 0.95;
        filter: brightness(0.9);
    }
    to {
        opacity: 1;
        filter: brightness(1);
    }
}

html.dark body {
    animation: contentReveal 0.3s ease-out 0.6s both;
}

/* ─── 响应式：移动端简化特效 ─── */
@media (max-width: 768px) {
    #diagonal-wipe-overlay {
        transition-duration: 0.5s !important;
    }

    html.dark body::after {
        display: none;
    }
}

/* 减少动画偏好 */
@media (prefers-reduced-motion: reduce) {
    #diagonal-wipe-overlay {
        transition: none !important;
        opacity: 0;
    }

    .mode-toggle.switching svg {
        animation: none;
    }

    html.dark body::after {
        animation: none;
    }
}
