/**
 * TXCWeb - 视觉特效样式
 *
 * 设计原则：特效服务于功能
 * - 每个视觉效果都有明确的用户引导或产品价值传递作用
 * - 性能优先，确保 60fps
 * - 尊重 prefers-reduced-motion 偏好
 * - 支持低性能设备降级
 *
 * Copyright (c) 2024-2026 田小橙 (TXC)
 */

/* ========== 特效容器层 ========== */
#effects-canvas-bg,
#effects-three-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
}

#effects-three-layer {
    z-index: 0;
}

/* 当特效启用时，主内容层提升到特效之上 */
.effects-enabled .bc_content {
    position: relative;
    z-index: 2;
}

/* ========== 性能模式标记 ========== */
/* 低性能模式：禁用重度特效，保留基础动效 */
body.effects-low-power #effects-three-layer {
    display: none;
}

body.effects-low-power #effects-canvas-bg {
    opacity: 0.4;
}

/* ========== 3D 头像装饰层 ========== */
/* 功能：突出用户身份核心信息，建立视觉层级 */
.avatar-3d-wrapper {
    position: relative;
    transform-style: preserve-3d;
    will-change: transform;
}

.avatar-3d-wrapper .img-avatar {
    position: relative;
    z-index: 2;
    transform: translateZ(20px);
}

.avatar-3d-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 90px;
    height: 90px;
    margin: -45px 0 0 -45px;
    border-radius: 50%;
    border: 2px solid rgba(102, 126, 234, 0.4);
    box-shadow: 0 0 30px rgba(102, 126, 234, 0.3),
                inset 0 0 20px rgba(118, 75, 162, 0.2);
    pointer-events: none;
    z-index: 1;
    will-change: transform, opacity;
}

.avatar-3d-ring::before {
    content: '';
    position: absolute;
    top: -3px;
    left: 50%;
    width: 6px;
    height: 6px;
    margin-left: -3px;
    border-radius: 50%;
    background: #667eea;
    box-shadow: 0 0 12px #667eea;
}

/* ========== 卡片光晕引导效果 ========== */
/* 功能：引导用户注意力到核心交互区域 */
.site-card::after,
.friend-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: inherit;
    background: radial-gradient(
        circle at var(--mx, 50%) var(--my, 50%),
        rgba(102, 126, 234, 0.15) 0%,
        transparent 40%
    );
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 1;
}

.site-card:hover::after,
.friend-card:hover::after {
    opacity: 1;
}

/* ========== 状态指示器增强 ========== */
/* 功能：通过脉冲强度传递站点健康状态 */
.site-card-status {
    position: relative;
}

.site-card-status::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    border: 2px solid currentColor;
    opacity: 0;
    animation: status-ripple 2s ease-out infinite;
}

@keyframes status-ripple {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.8;
    }
    100% {
        transform: translate(-50%, -50%) scale(3);
        opacity: 0;
    }
}

/* ========== 滚动进度指示器 ========== */
/* 功能：传递页面阅读进度，增强长内容浏览体验 */
#scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    z-index: 99998;
    pointer-events: none;
    box-shadow: 0 0 10px rgba(102, 126, 234, 0.6);
    will-change: width;
}

/* ========== 核心信息高亮脉冲 ========== */
/* 功能：首次进入时引导用户关注身份信息 */
@keyframes attention-pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(102, 126, 234, 0.4);
    }
    50% {
        box-shadow: 0 0 0 12px rgba(102, 126, 234, 0);
    }
}

.attention-highlight {
    animation: attention-pulse 2s ease-out 2;
}

/* ========== Toast 增强动画 ========== */
/* 功能：通过弹性反馈强化操作确认感 */
.toast-notification.gsap-enter {
    will-change: transform, opacity;
}

/* ========== 数字滚动器样式 ========== */
/* 功能：运行时间数字滚动，传递网站活跃度 */
.runtime-digit {
    display: inline-block;
    min-width: 1.2em;
    text-align: center;
    font-variant-numeric: tabular-nums;
    will-change: transform;
}

/* ========== 视觉锚点 - 站点卡片 ========== */
/* 功能：3D 倾斜效果暗示卡片可点击交互 */
.site-card,
.friend-card {
    transform-style: preserve-3d;
    will-change: transform;
}

.site-card-title,
.site-card-desc,
.friend-card-info {
    transform: translateZ(20px);
}

/* ========== 引导箭头动效 ========== */
/* 功能：引导用户向下浏览更多内容 */
.scroll-hint {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.6);
    font-size: 12px;
    letter-spacing: 2px;
    z-index: 10;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.scroll-hint.visible {
    opacity: 1;
}

.scroll-hint .arrow {
    display: block;
    width: 20px;
    height: 20px;
    margin: 4px auto 0;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    animation: scroll-bounce 1.5s ease-in-out infinite;
}

@keyframes scroll-bounce {
    0%, 100% { transform: rotate(45deg) translate(0, 0); }
    50% { transform: rotate(45deg) translate(4px, 4px); }
}

/* ========== 低性能模式降级 ========== */
body.effects-low-power .avatar-3d-ring,
body.effects-low-power .scroll-hint,
body.effects-low-power #scroll-progress {
    display: none;
}

body.effects-low-power .site-card,
body.effects-low-power .friend-card {
    will-change: auto;
}

/* ========== 尊重减少动画偏好 ========== */
@media (prefers-reduced-motion: reduce) {
    #effects-canvas-bg,
    #effects-three-layer {
        display: none !important;
    }

    .avatar-3d-ring,
    .scroll-hint,
    #scroll-progress {
        display: none !important;
    }

    .site-card,
    .friend-card {
        will-change: auto;
        transform: none !important;
    }

    .attention-highlight {
        animation: none;
    }

    .site-card-status::before {
        animation: none;
        display: none;
    }
}

/* ========== 响应式优化 ========== */
@media (max-width: 768px) {
    .avatar-3d-ring {
        width: 75px;
        height: 75px;
        margin: -37.5px 0 0 -37.5px;
    }

    .scroll-hint {
        display: none;
    }
}
