/* ar-view.css - 扫描容器与 AR 增强视觉层 */

/* 扫描容器 */
#scanner-container {
    position: fixed;
    top: 109px;
    left: 0;
    width: 100%;
    height: 60vw;
    z-index: 10;
    pointer-events: none;
    display: flex;
    justify-content: center;
    align-items: center;
}

#scanner-container {
    display: flex !important;
}

.indoor-scan-line {
    position: absolute;
    width: 90vw;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--gold), transparent);
    opacity: 0.8;    
    display: none;
    animation: scanMove 3s infinite ease-in-out;
	will-change: transform;
}

.outdoor-wave {
    position: absolute;
    width: 10vw;
    height: 10vw;
    border: 2px solid var(--gold);
    border-radius: 50%;
    display: none;
    animation: waveRipple 3s infinite ease-out;
}

.scene-focus-box {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    
    /* 响应式核心：使用 vmin 确保在横屏和竖屏下都不溢出 */
    width: 80vmin; 
    aspect-ratio: 1 / 1; /* 保持 1:1 比例 */
    
    /* 限制最大和最小尺寸 */
    max-width: 300px;
    max-height: 300px;
    min-width: 150px;

    border: 2px solid var(--gold);
    display: none;
    
    /* 性能优化：为 transform 添加 will-change */
    will-change: transform, opacity;
    animation: focusPulse 2.5s infinite ease-in-out;
}

/* 推荐：CSS 动画（不卡顿） */
.scan-line {
  animation: move 2s infinite;
  transform: translateZ(0); /* 开启 GPU 加速 */
}


/* 添加到你的 style.css 或 <style> 标签中 */

/* 定义一个 GPU 加速的旋转动画 */
@keyframes gpu-spin {
    0% { transform: rotate(0deg) translateZ(0); }
    100% { transform: rotate(360deg) translateZ(0); }
}

/* 定义一个呼吸/脉冲动画 */
@keyframes gpu-pulse {
    0% { transform: scale(1) translateZ(0); opacity: 0.8; }
    50% { transform: scale(1.1) translateZ(0); opacity: 0.4; }
    100% { transform: scale(1) translateZ(0); opacity: 0.8; }
}

/* 找到你的扫描圈或扫描线的 class，加上这个 animation 属性 */
/* 例如你的扫描圈 class 叫 .scan-circle */
.scan-circle {
    /* 3秒转一圈，无限循环，线性 */
    animation: gpu-spin 3s linear infinite;
    /* 强制开启硬件加速 */
    will-change: transform;
}

/* 例如你的扫描框 class 叫 .scan-box */
.scan-box {
    animation: gpu-pulse 2s ease-in-out infinite;
    will-change: transform, opacity;
}

/* 针对大屏幕的微调 */
@media (min-width: 1024px) {
    .scene-focus-box {
        max-width: 400px;
        border-width: 3px; /* 大屏下边框可以加粗 */
    }
}

/* 针对折叠屏或极小屏幕 */
@media (max-width: 320px) {
    .scene-focus-box {
        width: 90vw;
    }
}

/* AR扫描按钮 */
#ar-scan-btn {
    position: relative;
    top: 0;
    left: 0;
    transform: none;
    background: rgba(255, 215, 0, 0.9);
    color: #000;
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    font-weight: bold;
    font-size: 13px;
    z-index: 1000;
    display: none;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

#ar-scan-btn:hover {
    background: rgba(255, 215, 0, 1);
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
}

/* 动画关键帧 */
@keyframes scanMove {
    0%, 100% { top: 20%; opacity: 0; }
    50% { opacity: 1; top: 60%; }
}

@keyframes waveRipple {
    0% { width: 0; height: 0; opacity: 1; }
    100% { width: 120vw; height: 120vw; opacity: 0; }
}

@keyframes focusPulse {
    0% { transform: translate(-50%, -50%) rotate(0deg) scale(1.2); opacity: 0; }
    50% { transform: translate(-50%, -50%) rotate(180deg) scale(0.6); opacity: 1; }
    100% { transform: translate(-50%, -50%) rotate(360deg) scale(0.3); opacity: 0; }
}

#object-text {
    position: fixed !important; /* 从 absolute 改为 fixed，无视父容器限制 */
    top: 30% !important;        /* 垂直位置 */
    /* left: 0 !important;         锁定最左 */
    /* width: 100vw !important;    占满屏幕物理宽度 */
    text-align: center !important; /* 内部文字水平居中 */
    
    color: #00ff80;
    font-weight: lighter;
    font-size: 24px;            /* 稍微调大一点 */
    text-shadow: 0 0 10px rgba(0,0,0,0.8);
    z-index: 1000;
    padding: 0;
    display: block;
    pointer-events: none;       /* 防止遮挡点击操作 */
}

/* 低功耗模式：减少动画与特效 */
.low-power .indoor-scan-line,
.low-power .outdoor-wave,
.low-power .scene-focus-box {
    animation: none !important;
    opacity: 0.5;
}

.low-power #scanner-container {
    display: none;
}

.low-power #ar-load-mask {
    backdrop-filter: none;
}

.low-power .ar-load-card i {
    animation: none;
}

/* AR 场景淡入淡出 */
#ar-scene-container {
    opacity: 0;
    transition: opacity 0.35s ease;
}

.ar-scene-active #ar-scene-container {
    opacity: 1;
}

/* AR 场景加载遮罩 */
#ar-load-mask {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.85);
    z-index: 9000;
    backdrop-filter: blur(8px);
}

#ar-load-mask.show {
    display: flex;
}

.ar-load-card {
    display: grid;
    gap: 8px;
    padding: 18px 22px;
    border: 1px solid rgba(255, 215, 0, 0.35);
    border-radius: 14px;
    background: rgba(10, 10, 10, 0.85);
    color: var(--gold);
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

.ar-load-card i {
    font-size: 22px;
    animation: spin 2.4s linear infinite;
}

.ar-load-title {
    font-size: 16px;
    font-weight: 600;
}

.ar-load-sub {
    font-size: 12px;
    color: rgba(255, 215, 0, 0.7);
}

@keyframes textShine {
    from { opacity: 0.6; transform: scale(0.95); text-shadow: 0 0 5px var(--gold); }
    to { opacity: 1; transform: scale(1.05); text-shadow: 0 0 25px var(--gold), 0 0 40px #fff; }
}

/* ============ A-Frame/Three.js 场景强制修复 ============ */

#aframe-scene,
#ar-scene-container {
    position: fixed ;
    top: 0 ;
    left: 0 ;
    width: 100vw ;
    height: 100vh ;
    z-index: 1 ;
    pointer-events: auto ;
}

.a-canvas {
    position: fixed ;
    top: 0 ;
    left: 0 ;
    width: 100% ;
    height: 100% ;
    z-index: 1 ;
    transform: none ;
}

body.ar-scene-active .a-canvas {
    z-index: 2 !important;
}

.a-camera .a-camera-view {
    transform: scaleX(-1) !important;
}

.a-enter-vr,
.a-orientation-modal {
    display: none !important;
}

/* ============ 摆件控制系统 (新下拉模式) ============ */

/* 1. 主触发按钮 (黄色圆球) */
#ornament-buttons {
    position: fixed;
    top: 40px; /* 与报告按钮对齐的高度 */
    right: 35px;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ffff00, #ffcc00); /* 黄色渐变 */
    border: 1.5px solid #ffff00;
    color: #000;
    font-weight: bold;
    font-size: 20px;
    z-index: 5000; /* 确保在最上层 */
    display: none; /* 初始隐藏，confirmMingGua 后显示 */
    cursor: pointer;
    box-shadow: 0 0 15px rgba(255, 255, 0, 0.5); /* 黄色光晕 */
    align-items: center;
    justify-content: center;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#ornament-buttons:active {
    transform: scale(0.9);
}

/* 2. 下拉菜单容器 */
.ornament-buttons {
    position: fixed;
    top: 95px; /* 紧贴主按钮下方 */
    right: 33px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: rgba(0, 0, 0, 0.6);
    padding: 10px;
    border-radius: 30px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 215, 0, 0.3);
    z-index: 4999;
    
    /* 下拉动画初始状态 */
    opacity: 0;
    visibility: hidden;
    transform: translateY(-20px) scale(0.8);
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    transform-origin: top center;
    pointer-events: none;
}

/* 下拉菜单展开状态 */
.ornament-buttons.expanded {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* 3. 菜单内图标按钮样式 */
.ornament-icon-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(26, 26, 26, 0.9);
    color: gold;
    border: 1.5px solid gold;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

.ornament-icon-btn:hover {
    background: rgba(255, 215, 0, 0.2);
    transform: scale(1.1);
}

/* 4. 移除/关闭按钮 (红色) */
.remove-btn {
    color: #ff6b6b;
    border-color: #ff6b6b;
    margin-top: 5px;
    background: rgba(255, 107, 107, 0.1);
}

.remove-btn:hover {
    background: rgba(255, 107, 107, 0.3);
}

/* 5. 脉冲动画：黄色按钮呼吸效果 */
@keyframes pulsebjBtn {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 255, 0, 0.7);
    }
    70% {
        box-shadow: 0 0 0 15px rgba(255, 255, 0, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(255, 255, 0, 0);
    }
}

#ornament-buttons {
    animation: pulsebjBtn 2s infinite;
}

/* 适配移动端极小屏幕 */
@media (max-height: 600px) {
    #ornament-buttons {
        top: 20px;
    }
    .ornament-buttons {
        top: 75px;
        gap: 8px;
    }
    .ornament-icon-btn {
        width: 38px;
        height: 38px;
        font-size: 16px;
    }
}

/* ============ 摆件控制系统 (重命名 ID 避免冲突) ============ */

/* 1. 主触发按钮 - 顶部控制栏样式 */
#master-bj-trigger {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.15), rgba(255, 215, 0, 0.1));
    border: 1px solid rgba(255, 215, 0, 0.3);
    color: var(--gold);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2), 0 0 10px rgba(255, 215, 0, 0.1);
    font-size: 20px;
    position: relative;
    overflow: hidden;
    z-index: 1001;
}

#master-bj-trigger::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 215, 0, 0.2), transparent);
    transition: left 0.6s ease;
}

#master-bj-trigger:hover {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.25), rgba(255, 215, 0, 0.15));
    border-color: rgba(255, 215, 0, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3), 0 0 15px rgba(255, 215, 0, 0.3);
}

#master-bj-trigger:hover::before {
    left: 100%;
}

#master-bj-trigger i {
    font-size: 16px;
    transition: transform 0.3s ease;
}

#master-bj-trigger:hover i {
    transform: scale(1.1) rotate(10deg);
}

#master-bj-trigger:active {
    transform: translateY(-1px) scale(0.95);
}

/* 2. 下拉列表容器 - 使用全新 Class */
.bj-list-container {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 15px;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, rgba(15, 15, 15, 0.9), rgba(30, 30, 40, 0.8));
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 215, 0, 0.3);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4), 0 0 15px rgba(255, 215, 0, 0.15);
    z-index: 5999;
    min-width: 180px;
    
    /* 下拉动画初始状态 */
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px) scale(0.95);
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    transform-origin: top right;
    pointer-events: none;
}

/* 展开状态 */
.bj-list-container.bj-expanded {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.5), 0 0 25px rgba(255, 215, 0, 0.2);
}

/* 内部按钮样式优化 */
.ornament-icon-btn {
    padding: 12px;
    border-radius: var(--radius-md);
    background: rgba(255, 215, 0, 0.1);
    border: 1px solid rgba(255, 215, 0, 0.3);
    color: var(--gold);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    font-size: 16px;
}

.ornament-icon-btn:hover {
    background: rgba(255, 215, 0, 0.2);
    border-color: rgba(255, 215, 0, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.4);
}

.ornament-icon-btn.remove-btn {
    background: rgba(255, 68, 68, 0.1);
    border-color: rgba(255, 68, 68, 0.3);
    color: #ff4444;
}

.ornament-icon-btn.remove-btn:hover {
    background: rgba(255, 68, 68, 0.2);
    border-color: rgba(255, 68, 68, 0.5);
    box-shadow: 0 0 15px rgba(255, 68, 68, 0.4);
}

#ar-scan-btn {
    display: none !important;
}