/* ════════════════════════════════════════════════════════════
   基础样式 — Reset + 排版 + 背景
   ════════════════════════════════════════════════════════════ */

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    background: var(--bg-darkest);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
    position: relative;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* 全局背景层（增强径向渐变光晕） */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse at 20% 0%, rgba(196, 77, 255, 0.12) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 100%, rgba(255, 107, 157, 0.10) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 30%, rgba(77, 255, 255, 0.05) 0%, transparent 60%),
        radial-gradient(ellipse at 70% 20%, rgba(212, 175, 55, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 30% 80%, rgba(196, 77, 255, 0.05) 0%, transparent 50%),
        var(--gradient-acg-bg);
    z-index: -2;
}

/* SVG 噪点纹理 */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.03 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    opacity: 0.4;
    z-index: -1;
    pointer-events: none;
}

/* ── 星空背景 ── */
.starfield {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    overflow: hidden;
}

.star {
    position: absolute;
    background: white;
    border-radius: 50%;
    animation: twinkle var(--twinkle-duration, 3s) ease-in-out infinite;
}

@keyframes twinkle {
    0%, 100% { opacity: 0.2; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.2); }
}

/* ── 流星效果（纯 CSS，偶尔划过） ── */
/* 流星：从右上飞向左下，亮头在前，透明尾迹在后 */
.starfield::before,
.starfield::after {
    content: '';
    position: absolute;
    top: -20px;
    width: 140px;
    height: 1.5px;
    background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.2) 30%, rgba(255, 255, 255, 0.9) 80%, #ffffff 100%);
    border-radius: var(--radius-full);
    /* 旋转 135deg：线条从枢轴点（右端=亮头）向右上延伸，亮头位于左下方向 */
    transform: translate(0, 0) rotate(135deg);
    transform-origin: right center;
    opacity: 0;
    filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.6));
    pointer-events: none;
}

.starfield::before {
    left: 80%;
    animation: meteor 11s linear infinite;
    animation-delay: 3s;
}

.starfield::after {
    left: 50%;
    width: 100px;
    animation: meteor 14s linear infinite;
    animation-delay: 8s;
}

@keyframes meteor {
    0% {
        opacity: 0;
        transform: translate(0, 0) rotate(135deg);
    }
    2% {
        opacity: 1;
    }
    15% {
        opacity: 1;
    }
    20% {
        opacity: 0;
        transform: translate(-500px, 500px) rotate(135deg);
    }
    100% {
        opacity: 0;
        transform: translate(-500px, 500px) rotate(135deg);
    }
}

/* ── 动态流星（JS 生成，覆盖全屏对角线） ── */
/* 2026-06-25 新增：常规背景流星从 2 条伪元素升级为 8 条 JS 动态流星 */
.meteor-dynamic {
    position: absolute;
    width: var(--meteor-length, 150px);
    height: 1.5px;
    background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.2) 30%, rgba(255, 255, 255, 0.9) 80%, #ffffff 100%);
    border-radius: var(--radius-full);
    transform: translate(0, 0) rotate(135deg);
    transform-origin: right center;
    opacity: 0;
    filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.6));
    pointer-events: none;
}

@keyframes meteorSweep {
    0% {
        opacity: 0;
        transform: translate(0, 0) rotate(135deg);
    }
    3% {
        opacity: 1;
    }
    10% {
        opacity: 1;
    }
    25% {
        opacity: 0.8;
    }
    40% {
        opacity: 0;
        transform: translate(var(--meteor-dx, -80vw), var(--meteor-dy, 100vh)) rotate(135deg);
    }
    100% {
        opacity: 0;
        transform: translate(var(--meteor-dx, -80vw), var(--meteor-dy, 100vh)) rotate(135deg);
    }
}

/* ── 粒子背景 ── */
.particles {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    overflow: hidden;
}

.particle {
    position: absolute;
    border-radius: 50%;
    animation: float var(--float-duration, 20s) linear infinite;
    box-shadow:
        0 0 6px rgba(255, 255, 255, 0.6),
        0 0 12px rgba(196, 77, 255, 0.4),
        0 0 20px rgba(255, 107, 157, 0.2);
    filter: blur(0.5px);
    will-change: transform, opacity;
}

@keyframes float {
    0% { transform: translateY(100vh) translateX(0) rotate(0deg); opacity: 0; }
    10% { opacity: var(--particle-opacity, 0.6); }
    90% { opacity: var(--particle-opacity, 0.6); }
    100% { transform: translateY(-100px) translateX(var(--float-x, 50px)) rotate(360deg); opacity: 0; }
}

/* ── 排版 ── */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-title);
    font-weight: 700;
    line-height: 1.3;
}

a {
    color: var(--gold);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--gold-light);
}

/* ── 滚动条 ── */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-darker);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-light);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gold-dark);
}

/* ── 工具类 ── */
/* 滚动入场动效（2026-06-25 优化）：IntersectionObserver 实现，每次进入视口都触发
   优化点：移除 content-visibility: auto（与 IntersectionObserver 配合时会在元素
   进入视口瞬间触发首次渲染，造成卡顿）；缩短 transition 时长；添加 backface-visibility
   提升合成层性能 */
.reveal {
    opacity: 0;
    transform: translateY(24px) scale(0.98);
    transition: opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1), transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: opacity, transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.reveal.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* 延迟类（保留，用于 staggered 入场） */
.delay-1 { transition-delay: 0.1s; }
.delay-2 { transition-delay: 0.2s; }
.delay-3 { transition-delay: 0.3s; }
.delay-4 { transition-delay: 0.4s; }

/* 保留 revealUp 动画用于其他场景 */
@keyframes revealUp {
    to { opacity: 1; transform: translateY(0); }
}

.hidden {
    display: none !important;
}

/* ════════════════════════════════════════════════════════════
   高分辨率显示器适配（任务3）
   ════════════════════════════════════════════════════════════ */

/* ── 流式字号应用到全局排版 ── */
h1 { font-size: var(--fs-title); }
h2 { font-size: var(--fs-subtitle); }
h3 { font-size: var(--fs-body); }

body {
    font-size: var(--fs-body);
}

/* ── 2K 分辨率（2560px+）：放大间距与卡片尺寸 ── */
@media (min-width: 2560px) {
    :root {
        --space-sm: 10px;
        --space-md: 20px;
        --space-lg: 30px;
        --space-xl: 40px;
        --space-2xl: 60px;
        --space-3xl: 80px;
        --text-base: 1.05rem;
        --text-lg: 1.2rem;
        --text-xl: 1.35rem;
        --text-2xl: 1.7rem;
        --text-3xl: 2.3rem;
        --text-4xl: 3rem;
    }

    .main-content {
        max-width: 1800px;
    }
}

/* ── 4K 分辨率（3840px+）：进一步放大，避免内容过小 ── */
@media (min-width: 3840px) {
    :root {
        --space-sm: 14px;
        --space-md: 28px;
        --space-lg: 42px;
        --space-xl: 56px;
        --space-2xl: 80px;
        --space-3xl: 112px;
        --text-base: 1.25rem;
        --text-lg: 1.45rem;
        --text-xl: 1.65rem;
        --text-2xl: 2.1rem;
        --text-3xl: 2.8rem;
        --text-4xl: 3.6rem;
    }

    .main-content {
        max-width: 2400px;
    }
}

/* ── 高 DPI 适配（Retina 等） ── */
@media (min-resolution: 2dppx) {
    .card-frame {
        border-width: 2px;
    }

    .star {
        box-shadow: 0 0 2px rgba(255, 255, 255, 0.5);
    }
}

@media (min-resolution: 3dppx) {
    body {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}
