/* ==========================================
   基础重置
   ========================================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #050505;
    font-family: 'Microsoft YaHei', 'PingFang SC', 'Hiragino Sans GB', sans-serif;
    color: #c8c8c8;
    cursor: crosshair;
}

/* ==========================================
   电脑空间 loading overlay
   ========================================== */
#cs-overlay {
    position: fixed;
    inset: 0;
    z-index: 150;
    background: #050505;
}

#cs-frame {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: none;
    display: block;
    filter: grayscale(1) contrast(1.1);
}

/* ── CRT effect layer ── */
#cs-crt {
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    /* horizontal scan lines */
    background: repeating-linear-gradient(
        to bottom,
        transparent 0px,
        transparent 2px,
        rgba(0, 0, 0, 0.055) 2px,
        rgba(0, 0, 0, 0.055) 4px
    );
    /* vignette */
    box-shadow: inset 0 0 220px rgba(0, 0, 0, 0.72);
    /* subtle flicker */
    animation: crtFlicker 0.12s steps(1) infinite;
}

/* animated grain */
#cs-crt::before {
    content: '';
    position: absolute;
    inset: -80px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.88' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)' opacity='1'/%3E%3C/svg%3E");
    background-size: 220px 220px;
    opacity: 0.10;
    animation: grainShift 0.13s steps(1) infinite;
}

@keyframes crtFlicker {
    0%, 94%, 100% { opacity: 1; }
    95%            { opacity: 0.96; }
    97%            { opacity: 0.98; }
}

/* ── Animated static noise canvas ── */
#cs-static {
    position: absolute;
    inset: 0;
    z-index: 3;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0.38;
    image-rendering: pixelated;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

/* ── UI layer ── */
#cs-ui {
    position: absolute;
    inset: 0;
    z-index: 4;
    pointer-events: none;
}

#cs-title-block {
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    transform: translateY(-58%);
    text-align: center;
    padding: 0 40px;
}

#cs-title {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-size: clamp(44px, 8.5vw, 90px);
    font-weight: 900;
    letter-spacing: 0.35em;
    color: rgba(255, 255, 255, 0.96);
    text-transform: uppercase;
    text-shadow:
        2px 0  0 rgba(255, 0, 60, 0.58),
       -2px 0  0 rgba(0, 200, 255, 0.58);
    opacity: 0;
    animation:
        csTitleIn 1.6s cubic-bezier(0.16, 1, 0.3, 1) 0.4s forwards,
        titleGlitch 8s 2.5s infinite;
}

#cs-subtitle {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-size: clamp(9px, 1.15vw, 12px);
    font-weight: 400;
    letter-spacing: 0.58em;
    color: rgba(120, 120, 120, 0.75);
    text-transform: uppercase;
    margin-top: 22px;
    opacity: 0;
    animation: csTitleIn 1s cubic-bezier(0.16, 1, 0.3, 1) 1.3s forwards;
}

@keyframes csTitleIn {
    from {
        opacity: 0;
        filter: blur(10px);
        letter-spacing: 0.55em;
    }
    to {
        opacity: 1;
        filter: blur(0px);
    }
}

/* ── Progress bar ── */
#cs-pb-wrap {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 110px;
    /* bottom gradient fade */
    background: linear-gradient(to bottom, transparent, rgba(0,0,0,0.5) 40%, rgba(0,0,0,0.88));
}

#cs-pb-track {
    position: absolute;
    top: 52%;
    left: 0;
    right: 0;
    height: 1.5px;
    transform: translateY(-50%);
}

#cs-pb-left,
#cs-pb-right {
    position: absolute;
    top: 0;
    height: 100%;
    width: 0%;
    background: rgba(230, 240, 255, 0.92);
    box-shadow: 0 0 18px rgba(200, 225, 255, 0.85), 0 0 5px rgba(200, 225, 255, 1);
}

#cs-pb-left  { left: 0; }
#cs-pb-right { right: 0; }

/* glowing end-cap dots */
#cs-pb-left::after,
#cs-pb-right::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #e8f4ff;
    box-shadow: 0 0 22px rgba(160, 210, 255, 1), 0 0 8px #e8f4ff;
    transform: translateY(-50%);
}

#cs-pb-left::after  { right: -3.5px; }
#cs-pb-right::after { left: -3.5px; }

/* "CLICK TO ENTER" prompt */
#cs-prompt {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: clamp(10px, 1.1vw, 12px);
    letter-spacing: 0.5em;
    color: rgba(140, 140, 140, 0.85);
    text-transform: uppercase;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
}

#cs-prompt.ready {
    animation: blink 1.2s step-end infinite, promptFloat 3s ease-in-out infinite;
}

/* ── Click catcher ── */
#cs-click-layer {
    position: absolute;
    inset: 0;
    z-index: 10;
    pointer-events: none;
    cursor: pointer;
}

/* ==========================================
   画布容器
   ========================================== */
#canvas-container {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 1;
}

/* ==========================================
   开场进入屏
   ========================================== */
#enter-screen {
    display: none; /* replaced by #cs-overlay */
    position: absolute;
    inset: 0;
    z-index: 100;
    background: rgba(0, 0, 0, 0.92);
    flex-direction: column;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 32px;
    cursor: pointer;
    overflow: hidden;
}

/* 颗粒纹理层（SVG 分形噪点 + 随机位移） */
#enter-screen::before {
    content: '';
    position: absolute;
    inset: -80px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.88' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)' opacity='1'/%3E%3C/svg%3E");
    background-size: 220px 220px;
    opacity: 0.045;
    pointer-events: none;
    animation: grainShift 0.13s steps(1) infinite;
    z-index: 0;
}

/* 内容元素置于颗粒层之上 */
#enter-screen > * { position: relative; z-index: 1; }

@keyframes grainShift {
    0%  { transform: translate(0,    0   ); }
    20% { transform: translate(-6%,  3%  ); }
    40% { transform: translate( 5%,  -4% ); }
    60% { transform: translate(-3%,  6%  ); }
    80% { transform: translate( 4%,  -2% ); }
}

#enter-title {
    font-size: clamp(48px, 10vw, 96px);
    letter-spacing: 0.3em;
    font-weight: bold;
    color: #fff;
    /* 大标题本身也有轻微的故障感 */
    text-shadow:
        2px 0  0 rgba(255, 0, 60, 0.6),
       -2px 0  0 rgba(0, 200, 255, 0.6);
    animation: titleGlitch 6s infinite;
}

#enter-subtitle {
    font-size: clamp(10px, 1.5vw, 14px);
    letter-spacing: 0.5em;
    color: #555;
    text-transform: uppercase;
}

#loading-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

#loading-bar-wrap {
    width: clamp(160px, 25vw, 240px);
    height: 1px;
    background: #1a1a1a;
    position: relative;
}

#loading-bar-fill {
    position: absolute;
    top: 0; left: 0;
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #550000, #c00);
    box-shadow: 0 0 6px rgba(200, 0, 0, 0.5);
    transition: width 0.25s ease-out;
}

#loading-text {
    font-size: 9px;
    letter-spacing: 0.4em;
    color: #333;
    text-transform: uppercase;
    font-variant-numeric: tabular-nums;
}

#enter-prompt {
    font-size: clamp(11px, 1.4vw, 13px);
    letter-spacing: 0.4em;
    color: #888;
    opacity: 0;
    pointer-events: none;
}

#enter-prompt.ready {
    pointer-events: all;
    animation: blink 1.2s step-end infinite, promptFloat 3s ease-in-out infinite;
}

@keyframes promptFloat {
    0%, 100% { transform: translateY(0px);  }
    50%       { transform: translateY(8px);  }
}

#enter-line {
    width: clamp(120px, 20vw, 200px);
    height: 1px;
    background: linear-gradient(90deg, transparent, #444, transparent);
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0; }
}

@keyframes titleGlitch {
    0%, 94%, 100% {
        text-shadow:
             2px 0  0 rgba(255, 0, 60, 0.6),
            -2px 0  0 rgba(0, 200, 255, 0.6);
        clip-path: none;
    }
    95% {
        text-shadow:
            -4px 0  0 rgba(255, 0, 60, 0.9),
             4px 0  0 rgba(0, 200, 255, 0.9);
        transform: translateX(3px);
    }
    96% {
        text-shadow:
             4px 0  0 rgba(255, 0, 60, 0.9),
            -4px 0  0 rgba(0, 200, 255, 0.9);
        transform: translateX(-3px);
    }
    97% {
        text-shadow:
             2px 0  0 rgba(255, 0, 60, 0.6),
            -2px 0  0 rgba(0, 200, 255, 0.6);
        transform: translateX(0);
    }
}

/* ==========================================
   主 UI 层
   ========================================== */
#ui-layer {
    position: absolute;
    inset: 0;
    z-index: 10;
    pointer-events: none;
}

/* ==========================================
   场景标题（左上角）
   ========================================== */
#scene-title {
    position: absolute;
    top: 40px;
    left: 40px;
    font-size: clamp(22px, 3.5vw, 38px);
    letter-spacing: 0.18em;
    font-weight: bold;
    color: rgba(200, 200, 200, 0.65);
    animation: titleFlicker 8s infinite;
}

/* 场景切换时叠加的强烈故障 class，由 JS 临时添加 */
#scene-title.glitching {
    animation: titleCrash 0.4s steps(1) forwards;
}

@keyframes titleFlicker {
    0%, 89%, 91%, 93%, 100% {
        opacity: 1;
        transform: none;
        text-shadow: none;
    }
    90% { opacity: 0.6; transform: translateX(2px); }
    92% { opacity: 0.8; transform: translateX(-1px); text-shadow: 2px 0 #f00; }
}

@keyframes titleCrash {
    0%   { transform: translateX(-6px); opacity: 0.3; color: #f00; }
    25%  { transform: translateX( 8px); opacity: 0.8; color: #0ff; }
    50%  { transform: translateX(-3px); opacity: 0.5; color: #f00; }
    75%  { transform: translateX( 4px); opacity: 0.9; color: #fff; }
    100% { transform: translateX(0);    opacity: 1;   color: #bbb; }
}

/* ==========================================
   深度计（右侧）
   ========================================== */
#depth-gauge {
    position: absolute;
    right: 36px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

#depth-label {
    font-size: 9px;
    letter-spacing: 0.3em;
    color: #444;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: rotate(180deg);
    margin-bottom: 4px;
}

/* 轨道 */
#depth-track {
    width: 2px;
    height: 200px;
    background: #111;
    position: relative;
    overflow: hidden;
}

/* 填充条 */
#depth-fill {
    position: absolute;
    bottom: 0; left: 0;
    width: 100%;
    height: 0%;
    background: linear-gradient(to top, #8b0000, #c00, #ff4444);
    box-shadow: 0 0 8px #f00, 0 0 2px #f00;
    transition: none; /* 由 JS 直接更新，不需要 CSS 过渡 */
}

/* 刻度线 */
#depth-track::before,
#depth-track::after {
    content: '';
    position: absolute;
    left: -3px;
    width: 8px;
    height: 1px;
    background: #333;
}
#depth-track::before { top: 50%; }
#depth-track::after  { top: 25%; }

/* 数值读数 */
#depth-value {
    font-size: 10px;
    letter-spacing: 0.1em;
    color: #c00;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 0 6px #f00;
}

/* ==========================================
   圆环导航（跟随鼠标，垂直滑动触发场景切换）
   ========================================== */
#drag-nav {
    position: fixed;
    left: 0;
    top: 0;
    opacity: 0;
    pointer-events: none;
    z-index: 15;
    -webkit-user-select: none;
    user-select: none;
}

#drag-circle-top {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1.5px solid rgba(200, 200, 200, 0.35);
    background: transparent;
    margin: -20px 0 0 -20px;
    transition: border-color 0.25s, box-shadow 0.25s;
    pointer-events: none;
}

#drag-circle-top.triggered {
    border-color: rgba(200, 0, 0, 0.9);
    box-shadow: 0 0 18px rgba(200, 0, 0, 0.5);
}

#drag-line,
#drag-circle-bottom {
    display: none;
}

/* ==========================================
   场景切换红色闪光遮罩
   ========================================== */
#flash-overlay {
    position: absolute;
    inset: 0;
    z-index: 50;
    background: #8b0000;
    opacity: 0;
    pointer-events: none;
    mix-blend-mode: screen;
}

/* ==========================================
   场景切换中央大标题（溶解效果，z-index 在 flash 之上）
   ========================================== */
#center-title {
    position: absolute;
    inset: 0;
    z-index: 55;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    pointer-events: none;
    opacity: 0;
    text-align: center;
}

#center-title .ct-num {
    font-size: clamp(10px, 1.4vw, 13px);
    letter-spacing: 0.55em;
    color: #555;
    text-transform: uppercase;
}

#center-title .ct-name {
    font-size: clamp(32px, 8vw, 72px);
    letter-spacing: 0.3em;
    font-weight: bold;
    color: #d8d8d8;
    text-transform: uppercase;
    text-shadow:
        0 0 40px rgba(180, 0, 0, 0.35),
        0 0 80px rgba(180, 0, 0, 0.15);
}

/* ==========================================
   坠落通道黑化遮罩（GSAP 时间轴驱动）
   ========================================== */
#fall-overlay {
    position: absolute;
    inset: 0;
    z-index: 45;
    background: #000;
    opacity: 0;
    pointer-events: none;
}

/* ==========================================
   底部场景编号导航
   ========================================== */
#scene-nav-bottom {
    position: absolute;
    bottom: 36px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    pointer-events: all;
    z-index: 15;
}

#scene-nav-current {
    font-size: 18px;
    letter-spacing: 0.1em;
    color: #888;
    cursor: pointer;
    transition: color 0.3s;
    font-variant-numeric: tabular-nums;
}

#scene-nav-current:hover {
    color: #ccc;
}

#scene-nav-expand {
    display: flex;
    gap: 24px;
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
    transition: opacity 0.3s, transform 0.3s;
}

#scene-nav-expand.open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: all;
}

.scene-nav-num {
    font-size: 14px;
    color: #444;
    cursor: pointer;
    letter-spacing: 0.1em;
    transition: color 0.3s;
    font-variant-numeric: tabular-nums;
}

.scene-nav-num:hover {
    color: #ccc;
}

.scene-nav-num.active {
    color: #c00;
    text-shadow: 0 0 8px rgba(200, 0, 0, 0.4);
}

/* ==========================================
   频率可视化入口（右上角圆圈）
   ========================================== */
#visualizer-btn {
    position: absolute;
    top: 36px;
    right: 36px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    pointer-events: all;
    text-decoration: none;
    transition: border-color 0.35s, box-shadow 0.35s;
    z-index: 15;
}

/* 内部小圆点 */
#visualizer-btn::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: rgba(200, 0, 0, 0.45);
    transition: background 0.35s, box-shadow 0.35s;
}

#visualizer-btn:hover {
    border-color: rgba(200, 0, 0, 0.55);
    box-shadow: 0 0 14px rgba(200, 0, 0, 0.22), inset 0 0 6px rgba(200, 0, 0, 0.08);
}

#visualizer-btn:hover::before {
    background: #c00;
    box-shadow: 0 0 10px rgba(200, 0, 0, 0.9);
}


/* ==========================================
   场景04 点击冲击波圆环
   ========================================== */
.shockwave {
    position: fixed;
    width: 120px;
    height: 120px;
    margin: -60px 0 0 -60px;
    border-radius: 50%;
    border: 1.5px solid rgba(200, 0, 0, 0.9);
    box-shadow: 0 0 16px rgba(200, 0, 0, 0.5), inset 0 0 16px rgba(200, 0, 0, 0.2);
    pointer-events: none;
    z-index: 60;
}


/* ==========================================
   声波伤疤治愈屏
   ========================================== */
#healing-screen {
    position: fixed;
    inset: 0;
    z-index: 120;
    background: #050505;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    cursor: crosshair;
}

#healing-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

#healing-hint {
    position: absolute;
    top: 8%;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    letter-spacing: 0.55em;
    color: rgba(180, 160, 140, 0.4);
    text-transform: uppercase;
    pointer-events: none;
    opacity: 0;
    z-index: 2;
}

#healing-complete {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    opacity: 0;
    pointer-events: none;
    z-index: 3;
}

.hc-line1, .hc-line2 {
    font-size: clamp(13px, 2vw, 18px);
    letter-spacing: 0.15em;
    color: rgba(200, 190, 180, 0.7);
    text-align: center;
}

.hc-spacer { height: 40px; }

.hc-title {
    font-size: clamp(18px, 3.5vw, 32px);
    letter-spacing: 0.3em;
    font-weight: bold;
    color: #bbb;
}

.hc-sub {
    font-size: 11px;
    letter-spacing: 0.5em;
    color: #444;
    text-transform: uppercase;
}

.hc-reenter {
    font-size: 11px;
    letter-spacing: 0.4em;
    color: #666;
    cursor: pointer;
    margin-top: 20px;
    animation: blink 1.2s step-end infinite;
    transition: color 0.3s;
}

.hc-reenter:hover { color: #c00; }


/* ==========================================
   竖屏提示（触摸设备竖屏时显示）
   ========================================== */
#portrait-hint {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: #050505;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 28px;
    pointer-events: all;
}

@media (pointer: coarse) and (orientation: portrait) {
    #portrait-hint { display: flex; }
}

/* 手机图标 */
#portrait-icon {
    width: 44px;
    height: 66px;
    border: 2px solid rgba(180, 0, 0, 0.55);
    border-radius: 8px;
    position: relative;
    box-shadow: 0 0 20px rgba(180, 0, 0, 0.18);
    animation: phoneRotate 2.8s ease-in-out infinite;
}

#portrait-icon::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 12px;
    height: 2px;
    border-radius: 1px;
    background: rgba(180, 0, 0, 0.45);
}

#portrait-icon::after {
    content: '';
    position: absolute;
    bottom: 7px;
    left: 50%;
    transform: translateX(-50%);
    width: 11px;
    height: 11px;
    border-radius: 50%;
    border: 1.5px solid rgba(180, 0, 0, 0.45);
}

@keyframes phoneRotate {
    0%, 30%  { transform: rotate(0deg);   opacity: 1; }
    55%, 85% { transform: rotate(-90deg); opacity: 1; }
    92%      { transform: rotate(-90deg); opacity: 0.4; }
    100%     { transform: rotate(-90deg); opacity: 1; }
}

#portrait-text {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-size: 13px;
    letter-spacing: 0.32em;
    color: rgba(160, 160, 160, 0.75);
    text-transform: uppercase;
    text-align: center;
    line-height: 2;
}

#portrait-sub {
    font-size: 11px;
    letter-spacing: 0.18em;
    color: rgba(80, 80, 80, 0.9);
}

/* ==========================================
   移动端横屏通用微调
   ========================================== */
@media (pointer: coarse) {
    /* 触摸设备隐藏鼠标跟随圆环 */
    #drag-nav { display: none !important; }

    /* 触摸设备上禁止长按文字选中 */
    body { -webkit-user-select: none; user-select: none; }

    /* 防止双击缩放干扰交互 */
    #canvas-container { touch-action: none; }

    /* 场景标题和深度计在小屏横屏下稍微缩小边距 */
    #scene-title  { top: 20px; left: 22px; }
    #depth-gauge  { right: 18px; }
    #scene-nav-bottom { bottom: 18px; }
    #visualizer-btn   { top: 18px; right: 18px; }
}
