/**
 * 版本: 2508325 - 页面加载优化CSS
 * 防止页面闪烁，提供平滑的加载体验
 * 注意：不覆盖任何现有样式，只提供基础保障
 */

/* loading-optimization.css中移除body样式，避免与主样式文件冲突 */

/* 页面内容容器 */
.page-content {
    opacity: 1 !important; /* 修复：确保内容始终可见 */
    transition: opacity 0.4s ease-in-out;
    min-height: 100vh;
}

.page-content.loaded {
    opacity: 1;
}

/* 初始页面加载指示器样式 */
#loadingIndicator {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(var(--bg-color-rgb, 0, 0, 0), 0.1) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 9999;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #333;
    /* 自动淡出：即使JS异常也会在短时间内消失 */
    opacity: 1;
    animation: loadingFadeOut 0.6s ease 0.8s forwards;
}

/* 页面翻页时的加载指示器样式 */
#pageLoadingIndicator {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(var(--bg-color-rgb, 0, 0, 0), 0.05) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 9999;
    /* 移除flex布局，只保留模糊背景 */
    pointer-events: none;
    display: block;
    opacity: 1;
    animation: loadingFadeOut 0.6s ease 0.8s forwards;
}

/* 通用加载指示器样式 */
.loading-indicator {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(var(--bg-color-rgb, 0, 0, 0), 0.05) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 9999;
    /* 移除flex布局，只保留模糊背景 */
    pointer-events: none;
    display: block;
    opacity: 1;
    animation: loadingFadeOut 0.6s ease 0.8s forwards;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255, 215, 0, 0.3);
    border-top: 4px solid #FFD700;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
    box-shadow: 0 0 25px rgba(255, 215, 0, 0.8), 0 0 40px rgba(255, 215, 0, 0.4);
}

.loading-text {
    font-size: 18px;
    font-weight: 600;
    text-align: center;
    color: #2c3e50;
    text-shadow: 0 0 15px rgba(255, 215, 0, 0.8), 0 0 25px rgba(255, 215, 0, 0.6);
    animation: glowPulse 2s ease-in-out infinite;
}

.loading-subtitle {
    font-size: 14px;
    color: #7f8c8d;
    margin-top: 10px;
    text-align: center;
    text-shadow: 0 0 12px rgba(255, 215, 0, 0.7), 0 0 20px rgba(255, 215, 0, 0.4);
    animation: subtleGlow 3s ease-in-out infinite;
}

/* 动画定义 */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes glowPulse {
    0%, 100% { 
        text-shadow: 0 0 15px rgba(255, 215, 0, 0.8), 0 0 25px rgba(255, 215, 0, 0.6);
        transform: scale(1);
    }
    50% { 
        text-shadow: 0 0 25px rgba(255, 215, 0, 1), 0 0 35px rgba(255, 215, 0, 0.8), 0 0 45px rgba(255, 215, 0, 0.4);
        transform: scale(1.05);
    }
}

@keyframes subtleGlow {
    0%, 100% { 
        text-shadow: 0 0 12px rgba(255, 215, 0, 0.7), 0 0 20px rgba(255, 215, 0, 0.4);
        opacity: 0.8;
    }
    50% { 
        text-shadow: 0 0 20px rgba(255, 215, 0, 0.9), 0 0 30px rgba(255, 215, 0, 0.6), 0 0 40px rgba(255, 215, 0, 0.3);
        opacity: 1;
    }
}

/* 遮罩自动淡出隐藏（兜底） */
@keyframes loadingFadeOut {
    to {
        opacity: 0;
        visibility: hidden;
    }
}

/* 防止内容闪烁的额外样式 */
* {
    box-sizing: border-box;
}
/* 确保图片不会超出容器 */
img {
    max-width: 100%;
    height: auto;
}

/* 基础链接样式（不覆盖现有样式） */
a {
    color: inherit;
    text-decoration: inherit;
}

/* 基础表单样式（不覆盖现有样式） */
input, textarea, select {
    font-family: inherit;
    font-size: inherit;
}

/* 导航栏圆角样式 - 确保加载页面也有圆角效果 */
.navbar a.active {
    border-radius: 8px ;
}

/* 深色模式下的导航栏圆角 */
@media (prefers-color-scheme: dark) {
    .navbar a.active {
        border-radius: 8px ;
    }
}

/* 防止页面跳转时的白色闪烁 - 但不影响卡片样式 */
html, body {
    background-color: inherit !important;
}

/* 确保页面容器有最小背景色，防止白色闪烁 - 但不影响卡片样式 */
.page-content:not(.card), .container:not(.card) {
    background: inherit;
    min-height: 100vh;
}

/* 页面跳转时临时禁用动画（通过JS动态添加的类） - 仅限导航栏 */
.loading-navigation .navbar {
    transition: none !important;
}

/* 完全不干扰主题的卡片样式 - 移除所有强制样式 */

/* 确保手机版卡片样式不被干扰 - 为AJAX帖子链接恢复毛玻璃效果 */
@media (max-width: 768px) {
    /* 恢复星空主题等手机版主题的毛玻璃效果 */
    div[data-href].post-link {
        background: rgba(255, 255, 255, 0.12) !important;
        background-color: rgba(255, 255, 255, 0.12) !important;
        background-image: none !important;
        backdrop-filter: blur(2px) !important;
        -webkit-backdrop-filter: blur(2px) !important;
        border: 1px solid rgba(255, 255, 255, 0.18) !important;
        border-radius: 12px !important;
        box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15) !important;
    }
    
    /* 针对不同主题可能需要的调整 */
    .card.post-link[data-href] {
        background: rgba(255, 255, 255, 0.12) !important;
        backdrop-filter: blur(2px) !important;
        -webkit-backdrop-filter: blur(2px) !important;
    }
}
