/* ========================================
   塔罗牌抽取功能 - 样式表
   ======================================== */

/* ---- 抽取容器 ---- */
.draw-container {
    max-width: 1000px;
    margin: 0 auto;
    animation: fadeIn 0.4s ease;
}

/* ---- 牌阵选择 ---- */
.spread-selection {
    text-align: center;
}

.spread-selection h2 {
    font-size: 2rem;
    color: #1a1a2e;
    margin-bottom: 10px;
}

.spread-selection .section-desc {
    color: #666;
    margin-bottom: 30px;
    font-size: 1rem;
}

.spread-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.spread-card {
    background: linear-gradient(135deg, #f8f9ff 0%, #f0f0ff 100%);
    border: 2px solid #e0e0f0;
    border-radius: 16px;
    padding: 30px 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.spread-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #667eea, #764ba2);
    opacity: 0;
    transition: opacity 0.3s;
}

.spread-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 40px rgba(102, 126, 234, 0.2);
    border-color: #667eea;
}

.spread-card:hover::before {
    opacity: 1;
}

.spread-card .spread-icon {
    font-size: 3rem;
    margin-bottom: 12px;
    display: block;
}

.spread-card h3 {
    font-size: 1.3rem;
    color: #1a1a2e;
    margin-bottom: 8px;
}

.spread-card p {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 12px;
    line-height: 1.5;
}

.spread-card .card-count {
    display: inline-block;
    padding: 4px 14px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    border-radius: 20px;
    font-size: 0.85rem;
}

/* ---- 偏好设置 ---- */
.draw-prefs {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.draw-prefs label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    color: #555;
    cursor: pointer;
}

.draw-prefs input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #667eea;
    cursor: pointer;
}

/* ---- 洗牌动画 ---- */
.shuffle-stage {
    text-align: center;
    padding: 40px 20px;
}

.shuffle-stage h3 {
    font-size: 1.5rem;
    color: #1a1a2e;
    margin-bottom: 10px;
}

.shuffle-stage .shuffle-hint {
    color: #888;
    font-size: 0.95rem;
    margin-bottom: 40px;
}

.shuffle-cards {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    min-height: 200px;
    perspective: 800px;
}

.shuffle-card {
    width: 80px;
    height: 120px;
    border-radius: 8px;
    background: linear-gradient(160deg, #1a1040, #2d1b69, #1a1040);
    border: 2px solid #d4af37;
    position: relative;
    animation: shuffleMove 0.3s ease-in-out infinite alternate;
    box-shadow: 0 4px 15px rgba(106, 13, 173, 0.3);
}

.shuffle-card::after {
    content: '✦';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: rgba(212, 175, 55, 0.7);
    font-size: 1.2rem;
}

.shuffle-card:nth-child(1) { animation-delay: 0s; }
.shuffle-card:nth-child(2) { animation-delay: 0.05s; }
.shuffle-card:nth-child(3) { animation-delay: 0.1s; }
.shuffle-card:nth-child(4) { animation-delay: 0.15s; }
.shuffle-card:nth-child(5) { animation-delay: 0.2s; }
.shuffle-card:nth-child(6) { animation-delay: 0.25s; }
.shuffle-card:nth-child(7) { animation-delay: 0.3s; }
.shuffle-card:nth-child(8) { animation-delay: 0.35s; }

@keyframes shuffleMove {
    0% { transform: translateY(0) rotate(-3deg) scale(1); }
    100% { transform: translateY(-15px) rotate(3deg) scale(1.05); }
}

/* ---- 卡牌背面 (CSS绘制) ---- */
.card-back {
    aspect-ratio: 2/3;
    border-radius: 12px;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    background:
        linear-gradient(135deg, #d4af37, #c9a030, #d4af37),
        linear-gradient(160deg, #1a1040 0%, #2d1b69 30%, #1a1040 50%, #2d1b69 70%, #1a1040 100%);
    background-origin: border-box;
    background-clip: padding-box, content-box;
    border: 3px solid transparent;
    box-shadow: 0 6px 25px rgba(106, 13, 173, 0.35);
    transition: all 0.3s ease;
}

.card-back:hover {
    box-shadow: 0 8px 35px rgba(212, 175, 55, 0.5);
    transform: translateY(-4px);
}

/* 内边框装饰 */
.card-back::before {
    content: '';
    position: absolute;
    inset: 8px;
    border: 1.5px solid rgba(212, 175, 55, 0.45);
    border-radius: 7px;
    z-index: 1;
}

/* 中央八角星 */
.card-back::after {
    content: '✦';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2rem;
    color: rgba(212, 175, 55, 0.8);
    text-shadow: 0 0 20px rgba(212, 175, 55, 0.6);
    z-index: 2;
    animation: starPulse 2s ease-in-out infinite;
}

/* 角落的小星装饰 */
.card-back-corner {
    position: absolute;
    font-size: 0.7rem;
    color: rgba(212, 175, 55, 0.5);
    z-index: 2;
}
.card-back-corner.tl { top: 14px; left: 14px; }
.card-back-corner.tr { top: 14px; right: 14px; }
.card-back-corner.bl { bottom: 14px; left: 14px; }
.card-back-corner.br { bottom: 14px; right: 14px; }

@keyframes starPulse {
    0%, 100% { opacity: 0.5; transform: translate(-50%, -50%) scale(1); }
    50% { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
}

/* ---- 3D 翻转容器 ---- */
.card-flip-container {
    perspective: 1000px;
    cursor: pointer;
}

.card-flip-inner {
    position: relative;
    width: 100%;
    aspect-ratio: 2/3;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
}

.card-flip-inner.flipped {
    transform: rotateY(180deg);
}

.card-flip-front,
.card-flip-back-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 12px;
    overflow: hidden;
}

/* 正面 = 卡牌背面图案 */
.card-flip-front {
    z-index: 2;
}

/* 背面 = 实际牌面图片 (翻转后可见) */
.card-flip-back-face {
    transform: rotateY(180deg);
    z-index: 1;
}

.card-flip-back-face img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 12px;
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.25);
}

.card-flip-back-face img.reversed-image {
    transform: rotate(180deg);
}

/* ---- 翻牌后阶段 ---- */
.face-down-stage,
.reading-stage {
    text-align: center;
}

.face-down-stage h3,
.reading-stage h3 {
    font-size: 1.5rem;
    color: #1a1a2e;
    margin-bottom: 8px;
}

.face-down-hint,
.reading-hint {
    color: #888;
    font-size: 0.95rem;
    margin-bottom: 30px;
}

/* ---- 牌阵布局 ---- */
.drawn-cards-area {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 24px;
    flex-wrap: wrap;
    margin-bottom: 30px;
}

/* 单牌：大尺寸居中 */
.drawn-cards-area.layout-single .card-flip-container {
    width: 200px;
}

/* 三牌：水平排列 */
.drawn-cards-area.layout-horizontal .card-flip-container {
    width: 160px;
}

/* 五牌：十字排列 */
.drawn-cards-area.layout-cross {
    display: grid;
    grid-template-columns: 150px 150px 150px;
    grid-template-rows: auto auto auto;
    gap: 16px;
    justify-content: center;
    justify-items: center;
}

.drawn-cards-area.layout-cross .card-flip-container {
    width: 140px;
}

.drawn-cards-area.layout-cross .card-flip-container:nth-child(1) { grid-column: 1; grid-row: 2; }
.drawn-cards-area.layout-cross .card-flip-container:nth-child(2) { grid-column: 2; grid-row: 1; }
.drawn-cards-area.layout-cross .card-flip-container:nth-child(3) { grid-column: 3; grid-row: 2; }
.drawn-cards-area.layout-cross .card-flip-container:nth-child(4) { grid-column: 2; grid-row: 2; }
.drawn-cards-area.layout-cross .card-flip-container:nth-child(5) { grid-column: 2; grid-row: 3; }

/* ---- 位置标签 ---- */
.card-position-label {
    display: inline-block;
    padding: 4px 14px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    margin-top: 10px;
    margin-bottom: 4px;
}

/* ---- 卡牌名称 (翻牌后) ---- */
.card-name-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: #1a1a2e;
    margin-top: 4px;
}

/* ---- 逆位标识 ---- */
.reversal-badge {
    display: inline-block;
    padding: 4px 12px;
    background: #e74c3c;
    color: #fff;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    margin-top: 4px;
    animation: fadeIn 0.3s ease;
}

.reversal-badge.upright-badge {
    background: #27ae60;
}

/* ---- 解读面板 ---- */
.reading-panels {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 20px;
    text-align: left;
}

.reading-panel {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 20px;
    border-left: 4px solid #667eea;
    transition: border-color 0.3s;
}

.reading-panel.reversed-panel {
    border-left-color: #e74c3c;
    background: #fef5f5;
}

.reading-panel h4 {
    font-size: 1rem;
    color: #1a1a2e;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.reading-panel .panel-card-name {
    font-size: 0.85rem;
    color: #888;
    font-weight: normal;
}

.reading-panel .panel-meaning {
    font-size: 0.9rem;
    color: #555;
    line-height: 1.7;
    margin-top: 8px;
}

/* ---- 操作按钮 ---- */
.draw-actions {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
    margin-top: 30px;
}

.btn-draw {
    padding: 12px 28px;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.3s ease;
    font-family: inherit;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(102, 126, 234, 0.5);
}

.btn-secondary {
    background: #fff;
    color: #555;
    border: 2px solid #ddd;
}

.btn-secondary:hover {
    border-color: #667eea;
    color: #667eea;
    transform: translateY(-2px);
}

.btn-gold {
    background: linear-gradient(135deg, #d4af37, #c9a030);
    color: #fff;
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.4);
}

.btn-gold:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(212, 175, 55, 0.5);
}

/* ---- 背景粒子 ---- */
.particles-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
    overflow: hidden;
}

.particle {
    position: absolute;
    width: 3px;
    height: 3px;
    background: rgba(212, 175, 55, 0.6);
    border-radius: 50%;
    animation: particleFloat linear infinite;
}

@keyframes particleFloat {
    0% {
        transform: translateY(0) translateX(0);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translateY(-100vh) translateX(30px);
        opacity: 0;
    }
}

/* ---- 响应式 ---- */
@media (max-width: 768px) {
    .spread-grid {
        grid-template-columns: 1fr;
    }

    .drawn-cards-area.layout-horizontal {
        flex-direction: column;
        align-items: center;
    }

    .drawn-cards-area.layout-horizontal .card-flip-container {
        width: 140px;
    }

    .drawn-cards-area.layout-cross {
        grid-template-columns: 110px 110px 110px;
        gap: 10px;
    }

    .drawn-cards-area.layout-cross .card-flip-container {
        width: 100px;
    }

    .drawn-cards-area.layout-single .card-flip-container {
        width: 160px;
    }

    .reading-panels {
        grid-template-columns: 1fr;
    }

    .draw-actions {
        flex-direction: column;
        align-items: center;
    }

    .shuffle-card {
        width: 55px;
        height: 82px;
    }
}
