/* ================================
   Base.css - 全局样式和重置样式
   ================================ */

/* ================================
   CSS 变量 - 设计令牌系统
   ================================ */
:root {
    /* ========== 颜色系统 ========== */
    /* 主色调 - 品牌色 */
    --color-primary: #FF6B35;
    --color-primary-dark: #E8425A;
    --color-primary-light: rgba(255, 107, 53, 0.1);

    /* 功能色 */
    --color-success: #28a745;
    --color-warning: #ffc107;
    --color-error: #dc3545;
    --color-info: #17a2b8;

    /* 中性色 */
    --color-text-primary: #333;
    --color-text-secondary: #666;
    --color-text-tertiary: #999;
    --color-border: #e9e9e9;
    --color-bg-light: #f9f9f9;
    --color-bg-lighter: #f0f0f0;
    --color-white: #ffffff;

    /* 渐变 */
    --gradient-primary: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
    --gradient-success: linear-gradient(135deg, #28a745, #20c997);
    --gradient-warning: linear-gradient(135deg, #ffc107, #fd7e14);
    --gradient-error: linear-gradient(135deg, #dc3545, #c82333);

    /* ========== 间距系统 ========== */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 12px;
    --space-lg: 16px;
    --space-xl: 20px;
    --space-2xl: 24px;
    --space-3xl: 30px;
    --space-4xl: 40px;

    /* ========== 圆角系统 ========== */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-2xl: 20px;
    --radius-full: 50%;

    /* ========== 阴影系统 ========== */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 20px rgba(0, 0, 0, 0.12);
    --shadow-xl: 0 12px 30px rgba(0, 0, 0, 0.15);

    /* ========== 过渡系统 ========== */
    --transition-fast: 0.15s cubic-bezier(0.25, 0.8, 0.25, 1);
    --transition-base: 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
    --transition-slow: 0.35s cubic-bezier(0.25, 0.8, 0.25, 1);

    /* ========== 字体系统 ========== */
    --font-size-xs: 12px;
    --font-size-sm: 14px;
    --font-size-base: 16px;
    --font-size-lg: 18px;
    --font-size-xl: 22px;
    --font-size-2xl: 28px;

    --font-weight-normal: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;

    --line-height-tight: 1.3;
    --line-height-base: 1.6;
    --line-height-relaxed: 1.8;

    /* ========== 布局宽度 ========== */
    --header-width: 1300px;
    --content-width: 1280px;
    --footer-width: 1280px;
    --detail-width: 960px;
    --modal-width: 800px;
    --form-width: 600px;

    /* ========== Z-index 层级 ========== */
    --z-dropdown: 1000;
    --z-sticky: 1020;
    --z-fixed: 1030;
    --z-modal-backdrop: 1040;
    --z-modal: 1050;
    --z-popover: 1060;
    --z-tooltip: 1070;
}

/* 防止页面闪烁的全局预加载机制 */
html {
    visibility: visible;
    opacity: 1;
}

html.page-loaded {
    visibility: visible;
    opacity: 1;
}

/* 防止body初始化时的跳动 */
body {
    visibility: visible;
    opacity: 1;
}

/* ================================
   页面切换平滑过渡效果
   ================================ */

/* 页面容器的默认过渡效果（被 Smart Router 动态控制） */
.page-container,
.site-wrapper {
    /* 不设置默认 transition，由 JS 动态控制避免影响初始加载 */
}

/* 页面切换时的淡入淡出动画类 */
.page-transitioning {
    transition: opacity 0.2s ease-out !important;
}

.page-fade-out {
    opacity: 0 !important;
}

.page-fade-in {
    opacity: 1 !important;
}

/* 防止过渡期间的布局抖动 */
.page-transitioning * {
    pointer-events: none; /* 防止过渡期间的交互 */
}

/* 加载指示器样式（用于页面切换） */
.page-loading-indicator {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #FF6B35, #E8425A);
    z-index: 9999;
    animation: loading-progress 1s ease-in-out infinite;
}

@keyframes loading-progress {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* CSS重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* 全局字体和基础样式 - 恢复背景图 */
html {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "微软雅黑", sans-serif;
    line-height: 1.6;
    background-color: #f5f7fa;
    color: #2c3e50;
    min-height: 100vh;
    /* 恢复背景图片 */
    background-image:
        linear-gradient(135deg, rgba(255, 107, 53, 0.05) 0%, rgba(232, 66, 90, 0.05) 100%),
        image-set(url('/images/background-1920.avif') type('image/avif'), url('/images/background-1920.webp') type('image/webp'), url('/images/background.jpg') type('image/jpeg'));
    background-size: cover;
    background-position: center center;
    background-attachment: fixed;
    background-repeat: no-repeat;
}

/* 仅对资讯等页面应用 flexbox 布局（有 .site-wrapper 的页面） */
.site-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* 确保footer在 site-wrapper 布局中始终在底部 */
.site-wrapper footer {
    margin-top: auto;
}

/* 现代化毛玻璃容器 - 优化版本，减少渲染负担 */
.page-container {
    width: 100%;
    max-width: 1300px;
    margin: 40px auto;
    padding: 30px;
    /* 简化背景，不使用模糊效果 */
    background: rgba(255, 255, 255, 0.95);
    /* 简化阴影 */
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    position: relative;
}

/* 容器悬浮交互效果 - 简化版 */
.page-container:hover {
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.12);
}

/* 链接重置 */
a {
    text-decoration: none;
    color: inherit;
}

/* 图片懒加载和占位符样式 */
img {
    background-color: #e9ecef;
    background-image: radial-gradient(circle at 50% 50%, #dee2e6 2px, transparent 2px);
    background-size: 20px 20px;
    transition: opacity 0.3s ease;
}

img:not([src]) {
    opacity: 0.7;
}

/* 懒加载图片样式 */
img.lazy-loading {
    filter: blur(2px);
    opacity: 0.6;
    transition: filter 0.3s ease, opacity 0.3s ease;
}

img.lazy-loaded {
    filter: blur(0);
    opacity: 1;
}

img.lazy-error {
    opacity: 0.5;
    border: 2px dashed #f44336;
}

/* 移动端图片优化 */
@media (max-width: 768px) {
    img {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
    
    img.lazy-loading {
        background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
        background-size: 200% 100%;
        animation: loading-shimmer 1.5s infinite;
    }
}

@keyframes loading-shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* 横幅图片专用样式 - 更简洁的占位符 */
.banner-img, .carousel-main img, .main-carousel img {
    background: linear-gradient(135deg, #FF6B35 0%, #E8425A 100%);
    background-size: 100% 100%;
    min-height: 200px;
    transition: opacity 0.3s ease;
}

/* 当图片已加载时，不显示背景渐变 */
.banner-img[src]:not([src=""]):not([src*="placeholder"]) {
    background: none;
}

.game-card img, .news-card img {
    min-height: 200px;
    object-fit: cover;
    border-radius: 8px;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.user-avatar, .author-avatar {
    min-height: 40px;
    min-width: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

/* 新闻详情页图片样式 */
.news-detail img {
    margin: 10px 0;
    padding: 10px 0;
    display: block;
    max-width: 100%;
    height: auto;
}
