/* ========================================
   CSS 变量定义
   ======================================== */
:root {
    /* 背景色 */
    --bg-red-dark: #5C0A0A;
    --bg-red-medium: #7A1515;
    --bg-scan-area: rgba(50, 10, 10, 0.7);
    
    /* 文字色 */
    --text-gold: #FFD700;
    --text-gold-light: #E8C252;
    --text-white: #FFFFFF;
    
    /* 边框色 */
    --border-gold: #B8860B;
    --border-gold-light: rgba(255, 200, 100, 0.3);
    --border-cyan: #40E0D0;
    
    /* 按钮色 */
    --btn-blue-start: #2563EB;
    --btn-blue-end: #1D4ED8;
    
    /* 步骤数字 */
    --step-num-bg: #0EA5E9;
}

/* ========================================
   基础样式重置
   ======================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow-x: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 
                 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: var(--bg-red-dark);
    color: var(--text-white);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* ========================================
   页面容器
   ======================================== */
.page-container {
    min-height: 100vh;
    background: linear-gradient(180deg, var(--bg-red-medium) 0%, var(--bg-red-dark) 100%);
    padding: 20px;
    padding-bottom: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    overflow: hidden;
}

/* ========================================
   标题区域
   ======================================== */
.header {
    text-align: center;
    margin-top: 25px;
    margin-bottom: 15px;
}

.main-title {
    color: var(--text-gold);
    font-size: 28px;
    font-weight: bold;
    letter-spacing: 2px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.sub-title {
    color: var(--text-gold-light);
    font-size: 14px;
    margin-top: 10px;
    opacity: 0.9;
}

/* ========================================
   主内容容器 - 金色边框
   ======================================== */
.main-content-wrapper {
    width: 90%;
    max-width: 380px;
    margin-top: 15px;
    padding: 20px;
    border: 2px solid var(--border-gold);
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* 中奖状态 - 移除边框 */
.main-content-wrapper.reward-mode {
    border: none;
    padding: 0;
}

/* ========================================
   扫描区域
   ======================================== */
.scan-area-wrapper {
    width: 100%;
    padding: 0;
    background: transparent;
    border-radius: 16px;
}

.scan-area {
    background: rgba(50, 18, 12, 0.9);
    border-radius: 16px;
    padding: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 280px;  /* 增加高度 */
}

/* 初始状态占位符 */
.scan-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.scan-placeholder.hidden {
    display: none;
}

/* 扫描框 - 虚线样式（初始状态） */
.scan-frame-dashed {
    width: 160px;
    height: 160px;
    border: 2px dashed var(--border-gold);
    border-radius: 18px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: transparent;
}

/* 扫描区域相机图标 - CSS 绘制（金黄色） */
.scan-camera-icon {
    display: inline-block;
    width: 48px;
    height: 36px;
    position: relative;
    border: 3px solid var(--text-gold);
    border-radius: 6px;
}

/* 相机镜头 */
.scan-camera-icon::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 16px;
    border: 3px solid var(--text-gold);
    border-radius: 50%;
}

/* 相机顶部凸起 */
.scan-camera-icon::after {
    content: '';
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 16px;
    height: 5px;
    background: var(--text-gold);
    border-radius: 2px 2px 0 0;
}

/* 扫描提示文字 */
.scan-hint {
    color: var(--text-gold-light);
    font-size: 14px;
    margin-top: 25px;
    text-align: center;
}

/* ========================================
   扫描状态视图
   ======================================== */
.scanner-view {
    width: 100%;
    height: 100%;  /* 填满 scan-area */
    display: flex;
    flex-direction: column;
    align-items: center;
}

.scanner-view.hidden {
    display: none;
}

/* 相机容器 */
.camera-container {
    position: relative;
    width: 100%;
    height: 100%;  /* 填满父容器 */
    background: #000;
    border-radius: 12px;
    overflow: hidden;
}

/* MindAR 容器 */
.ar-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* MindAR 视频和 canvas 样式覆盖 */
.ar-container video,
.ar-container canvas {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
}

/* 修复 MindAR video z-index 问题（MindAR 默认设置 z-index: -2 导致视频被遮挡） */
.ar-container video {
    z-index: 1 !important;
}

/* 扫描框 - 实线样式（扫描中） */
.scan-frame-solid {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 160px;
    height: 120px;
    border: 3px solid var(--border-cyan);
    border-radius: 12px;
    box-shadow: 0 0 20px rgba(64, 224, 208, 0.3);
    pointer-events: none;
    z-index: 10;
}

/* ========================================
   步骤说明
   ======================================== */
.steps-container {
    width: 100%;
    margin-top: 25px;
}

.step-item {
    display: flex;
    align-items: flex-start;
    margin-bottom: 18px;
}

.step-num {
    width: 28px;
    height: 28px;
    min-width: 28px;
    background: var(--step-num-bg);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-size: 14px;
    font-weight: bold;
    margin-right: 12px;
}

.step-text {
    color: var(--text-gold-light);
    font-size: 14px;
    line-height: 28px;
}

/* ========================================
   操作按钮
   ======================================== */
.action-btn {
    width: 100%;
    margin-top: 20px;
    padding: 14px 0;
    background: linear-gradient(90deg, #4A9EFF, #2563EB);
    border: none;
    border-radius: 25px;
    color: white;
    font-size: 17px;
    font-weight: 500;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: opacity 0.3s ease, transform 0.2s ease;
    box-shadow: 0 4px 15px rgba(37, 99, 235, 0.4);
}

.action-btn:active {
    transform: scale(0.98);
    opacity: 0.9;
}

/* 按钮相机图标 - CSS 绘制 */
.btn-icon {
    display: inline-block;
    width: 24px;
    height: 18px;
    position: relative;
    border: 2px solid #fff;
    border-radius: 3px;
}

/* 相机镜头 */
.btn-icon::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    border: 2px solid #fff;
    border-radius: 50%;
}

/* 相机顶部凸起 */
.btn-icon::after {
    content: '';
    position: absolute;
    top: -5px;
    left: 50%;
    transform: translateX(-50%);
    width: 8px;
    height: 3px;
    background: #fff;
    border-radius: 1px 1px 0 0;
}

.btn-text {
    font-size: 18px;
}

/* 按钮扫描中状态 */
.action-btn:disabled {
    background: linear-gradient(90deg, #6B7280, #4B5563);
    box-shadow: 0 4px 15px rgba(107, 114, 128, 0.4);
    cursor: default;
}

.action-btn:disabled:active {
    transform: none;
}

/* 按钮图标旋转动画 - 使用 CSS 加载动画替代 emoji */
.btn-icon.rotating {
    display: inline-block;
    font-size: 0;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* 旋转时隐藏相机图标的伪元素 */
.btn-icon.rotating::before,
.btn-icon.rotating::after {
    display: none;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ========================================
   隐藏工具类
   ======================================== */
.hidden {
    display: none !important;
}

/* ========================================
   模态框（保留原有样式）
   ======================================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background: linear-gradient(135deg, #1e1e2e 0%, #2a2a4a 100%);
    padding: 30px;
    border-radius: 20px;
    text-align: center;
    max-width: 320px;
    width: 90%;
    transform: scale(1);
    transition: transform 0.3s ease;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.modal.hidden .modal-content {
    transform: scale(0.9);
}

.modal-content h2 {
    font-size: 24px;
    margin-bottom: 10px;
    background: linear-gradient(90deg, #00d4ff, #00ff88);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.modal-content p {
    font-size: 16px;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 25px;
}

/* 诗句文本样式 */
.modal-content .poem-text {
    font-size: 15px;
    line-height: 1.9;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 30px;
    text-align: center;
    letter-spacing: 0.5px;
    font-weight: 400;
}

/* 中奖弹窗特效 */
.lucky-content {
    overflow: hidden;
}

.lucky-animation {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.lucky-content h2 {
    animation: bounce 0.5s ease;
}

@keyframes bounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* 错误弹窗 */
.error-content h2 {
    color: #ff6b6b;
    background: none;
    -webkit-text-fill-color: #ff6b6b;
}

/* ========================================
   按钮样式（弹窗内）
   ======================================== */
.btn {
    padding: 12px 30px;
    border: none;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    outline: none;
}

.btn-primary {
    background: linear-gradient(90deg, #00d4ff, #00ff88);
    color: #000;
}

.btn-primary:active {
    transform: scale(0.95);
    opacity: 0.9;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-secondary:active {
    background: rgba(255, 255, 255, 0.2);
}

.btn-large {
    padding: 15px 40px;
    font-size: 18px;
}

/* ========================================
   Toast提示
   ======================================== */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 12px 24px;
    border-radius: 25px;
    font-size: 14px;
    z-index: 200;
    transition: opacity 0.3s ease;
}

.toast.hidden {
    opacity: 0;
    pointer-events: none;
}

/* ========================================
   响应式适配
   ======================================== */
@media screen and (max-height: 600px) {
    .header {
        margin-top: 20px;
        margin-bottom: 10px;
    }
    
    .main-title {
        font-size: 24px;
    }
    
    .scan-area {
        padding: 15px;
        height: 200px;  /* 小屏幕稍微减小高度 */
    }
    
    .scan-frame-dashed {
        width: 150px;
        height: 110px;
    }
    
    .camera-icon {
        font-size: 36px;
    }
    
    .steps-container {
        margin-top: 15px;
    }
    
    .step-item {
        margin-bottom: 10px;
    }
    
    .action-btn {
        margin-top: 15px;
        padding: 14px 0;
    }
}

/* 安全区域适配 (刘海屏) */
@supports (padding-top: env(safe-area-inset-top)) {
    .page-container {
        padding-top: calc(20px + env(safe-area-inset-top));
        padding-bottom: calc(40px + env(safe-area-inset-bottom));
    }
}

/* ========================================
   中奖奖励页面样式
   ======================================== */

/* 奖励头部 - 放在 scan-area 内部 */
.reward-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    text-align: center;
    padding: 20px;
}

.reward-header.hidden {
    display: none;
}

/* ========================================
   中奖状态 - 玻璃质感卡片
   ======================================== */
.scan-area-wrapper.reward-mode {
    background: linear-gradient(145deg, rgba(255,255,255,0.1), rgba(255,255,255,0.05));
    border: 1px solid rgba(255, 215, 0, 0.3);
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    padding: 3px;
}

.scan-area-wrapper.reward-mode .scan-area {
    background: transparent;
    height: auto;
    padding: 28px 20px;
}

/* ✨ 闪耀图标 */
.reward-header .sparkle-icon {
    font-size: 48px;
    margin-bottom: 15px;
    display: inline-block;
    animation: sparkleBounce 1.8s ease-in-out infinite;
}

/* 优雅的上下跳动动画 */
@keyframes sparkleBounce {
    0%, 100% {
        transform: translateY(0);
        filter: drop-shadow(0 4px 8px rgba(255, 215, 0, 0.4));
    }
    50% {
        transform: translateY(-8px);
        filter: drop-shadow(0 12px 16px rgba(255, 215, 0, 0.2));
    }
}

/* 恭喜发财文字 */
.reward-header .reward-congrats {
    color: var(--text-gold);
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 8px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* 副标题 */
.reward-header .reward-subtitle {
    color: var(--text-gold-light);
    font-size: 14px;
    opacity: 0.9;
}

/* ========================================
   奖励卡片列表
   ======================================== */
.reward-cards {
    width: 100%;
    margin-top: 15px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.reward-cards.hidden {
    display: none;
}

/* 单个奖励卡片 - 左边框风格 */
.reward-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    background: rgba(0, 0, 0, 0.15);
    border: none;
    border-left: 4px solid var(--text-gold);
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* 奖励信息区域 */
.reward-info {
    flex: 1;
    min-width: 0;
    margin-right: 15px;
}

/* 奖励名称 */
.reward-name {
    color: #FFF1A8;
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 4px;
}

/* 奖励描述 */
.reward-desc {
    color: rgba(255, 255, 255, 0.7);
    font-size: 13px;
}

/* 奖励操作按钮 - 金色渐变 */
.reward-action-btn {
    padding: 8px 18px;
    background: linear-gradient(90deg, #FFD700, #FFA500);
    border: none;
    border-radius: 20px;
    color: #640000;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.reward-action-btn:active {
    transform: scale(0.95);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

/* ========================================
   中奖后的操作按钮组
   ======================================== */
.reward-buttons {
    width: 100%;
    margin-top: 15px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* 重置按钮在 reward-buttons 中的 margin */
.reward-buttons .action-btn {
    margin-top: 0;
}

.reward-buttons.hidden {
    display: none;
}

/* 底部按钮 - 基础样式 */
.reward-btn-outline {
    font-weight: bold;
    letter-spacing: 1px;
    transition: all 0.3s ease;
}

.reward-btn-outline:active {
    transform: scale(0.98);
}

/* 再次寻觅福气 - 蓝色渐变实心（Primary） */
#rescan-btn {
    background: linear-gradient(90deg, #4A9EFF, #2563EB) !important;
    border: none !important;
    color: white !important;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4) !important;
}

#rescan-btn:active {
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3) !important;
}

/* 传递财运好礼 - 金色渐变实心（Secondary） */
#share-btn {
    background: linear-gradient(90deg, #FFD700, #F59E0B) !important;
    border: none !important;
    color: #640000 !important;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3) !important;
}

#share-btn:active {
    box-shadow: 0 2px 6px rgba(245, 158, 11, 0.2) !important;
}

/* 返回首页 - 透明描边（Tertiary） */
#home-btn {
    background: transparent !important;
    border: 1.5px solid var(--text-gold) !important;
    color: var(--text-gold) !important;
    box-shadow: none !important;
}

#home-btn:active {
    background: rgba(255, 215, 0, 0.1) !important;
}

/* ========================================
   响应式适配
   ======================================== */
@media screen and (max-height: 700px) {
    .header {
        margin-top: 15px;
        margin-bottom: 10px;
    }
    
    .main-content-wrapper {
        padding: 15px;
    }
    
    .scan-area {
        height: 240px;
        padding: 25px;
    }
    
    .scan-frame-dashed {
        width: 140px;
        height: 140px;
    }
    
    .steps-container {
        margin-top: 20px;
    }
    
    .step-item {
        margin-bottom: 14px;
    }
    
    .action-btn {
        margin-top: 15px;
        padding: 12px 0;
    }
}

@media screen and (max-height: 600px) {
    .reward-header {
        padding: 15px;
    }
    
    .reward-header .sparkle-icon {
        font-size: 40px;
    }
    
    .reward-header .reward-congrats {
        font-size: 20px;
    }
    
    .scan-area-wrapper.reward-mode .scan-area {
        padding: 20px 15px;
    }
    
    .reward-cards {
        margin-top: 10px;
        gap: 10px;
    }
    
    .reward-card {
        padding: 14px 16px;
    }
    
    .reward-name {
        font-size: 16px;
    }
    
    .reward-desc {
        font-size: 12px;
    }
    
    .reward-buttons {
        margin-top: 12px;
        gap: 8px;
    }
}

/* ========================================
   壁纸预览弹窗（用于微信长按保存）
   ======================================== */
.wallpaper-preview-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 200;
    padding: 20px;
}

.wallpaper-preview-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 100%;
    max-height: 100%;
}

.wallpaper-preview-img {
    max-width: 100%;
    max-height: 70vh;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    object-fit: contain;
}

.wallpaper-preview-hint {
    color: var(--text-gold-light);
    font-size: 14px;
    margin-top: 20px;
    text-align: center;
}

.wallpaper-preview-close {
    margin-top: 20px;
    padding: 12px 40px;
}
