/**
 * 牌阵预览样式
 * 用于AI解读框中显示的牌阵布局预览
 */

/* 🎨 牌阵预览容器 */
.spread-preview {
    width: 100%;
    margin: 0 0 30px 0;
    padding: 15px 5px; /* 减少左右padding到最小 */
    background: linear-gradient(135deg, rgba(0, 123, 175, 0.05) 0%, rgba(0, 123, 175, 0.02) 100%);
    border-radius: 12px;
    border: 1px solid rgba(0, 123, 175, 0.1);
    box-sizing: border-box;
}

/* 🎨 预览头部 */
.spread-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid rgba(0, 123, 175, 0.15);
    cursor: pointer;
    user-select: none;
}

/* 🎨 预览标题 */
.spread-preview-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.1em;
    font-weight: 600;
    color: #ffffff;
}

.spread-preview-title i {
    font-size: 1em;
}

/* 🎨 折叠/展开按钮 */
.spread-preview-toggle {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    padding: 6px 12px;
    cursor: pointer;
    color: #ffffff;
    font-size: 0.85em;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.spread-preview-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.5);
}

.spread-preview-toggle i {
    transition: transform 0.3s ease;
    font-size: 0.9em;
}

.spread-preview-toggle .toggle-text {
    white-space: nowrap;
}

/* 🎨 卡牌容器 */
.spread-preview-cards {
    display: grid;
    gap: 15px;
    position: relative;
}

/* 🎨 二选一牌阵布局 */
.choice-preview .spread-preview-cards {
    display: grid;
    grid-template-columns: 1fr 1.2fr 1fr; /* 三列：左、中、右 */
    grid-template-rows: auto auto auto; /* 三行：上、中、下 */
    gap: 20px;
    row-gap: 20px;
    max-width: 500px;
    margin: 0 auto;
    padding: 20px 10px;
}

/* 卡牌1：问题现状（底部中心） */
.choice-preview .preview-card-1 {
    grid-column: 2 / 3;
    grid-row: 3 / 4; /* 最底部 */
    justify-self: center;
    align-self: center;
}

/* 卡牌2：选A现状（中间左侧） */
.choice-preview .preview-card-2 {
    grid-column: 1 / 2;
    grid-row: 2 / 3; /* 中间层 */
    justify-self: center;
    align-self: center;
}

/* 卡牌3：选B现状（中间右侧） */
.choice-preview .preview-card-3 {
    grid-column: 3 / 4;
    grid-row: 2 / 3; /* 中间层 */
    justify-self: center;
    align-self: center;
}

/* 卡牌4：选A结果（顶部左侧） */
.choice-preview .preview-card-4 {
    grid-column: 1 / 2;
    grid-row: 1 / 2; /* 最顶部 */
    justify-self: center;
    align-self: center;
}

/* 卡牌5：选B结果（顶部右侧） */
.choice-preview .preview-card-5 {
    grid-column: 3 / 4;
    grid-row: 1 / 2; /* 最顶部 */
    justify-self: center;
    align-self: center;
}

/* 二选一牌阵卡牌样式 */
.choice-preview .preview-card {
    max-width: 90px;
    min-width: 70px;
}

/* 移动端适配 */
@media (max-width: 768px) {
    .choice-preview .spread-preview-cards {
        gap: 12px;
        row-gap: 15px;
        max-width: 95%;
        padding: 15px 5px;
        grid-template-columns: 1fr 1.1fr 1fr;
    }
    
    .choice-preview .preview-card {
        max-width: 70px !important;
        min-width: 60px;
        padding: 2px;
        gap: 2px;
    }
    
    .choice-preview .preview-card-label {
        font-size: 0.5em;
    }
    
    .choice-preview .preview-card-name {
        font-size: 0.45em;
    }
    
    .choice-preview .preview-card-orientation {
        font-size: 0.4em;
    }
}

/* 超小屏幕适配 */
@media (max-width: 480px) {
    .choice-preview .spread-preview-cards {
        gap: 8px;
        row-gap: 12px;
        padding: 10px 3px;
    }
    
    .choice-preview .preview-card {
        max-width: 60px !important;
        min-width: 50px;
    }
}

/* 🎨 凯尔特十字牌阵布局 */
.celtic-cross-preview .spread-preview-cards {
    /* 使用CSS Grid创建十字+右列的布局 */
    /* 调整间距让十字架居中，左右对称 */
    grid-template-columns: 1fr 0.5fr 2fr 0.0825fr 1fr 0.4fr 1fr;
    grid-template-rows: repeat(4, auto);
    max-width: 95%; /* 扩展到95%宽度 */
    width: 100%;
    margin: 0 auto;
    gap: 4px;
    row-gap: 6px;
}

/* 🎨 卡牌位置映射 */
/* 中心十字架 */
.celtic-cross-preview .preview-card-1 {
    grid-column: 3 / 4;
    grid-row: 2 / 4; /* 跨2行，居中在2-3行之间 */
    z-index: 1;
    align-self: center;
}

.celtic-cross-preview .preview-card-2 {
    grid-column: 3 / 4;
    grid-row: 2 / 4; /* 跨2行，居中在2-3行之间 */
    z-index: 3; /* 比1号牌更高，确保在上层 */
    align-self: center;
}

.celtic-cross-preview .preview-card-3 {
    grid-column: 3 / 4;
    grid-row: 1 / 2;
}

.celtic-cross-preview .preview-card-4 {
    grid-column: 3 / 4;
    grid-row: 4 / 5; /* 最底部 */
}

.celtic-cross-preview .preview-card-5 {
    grid-column: 1 / 2;
    grid-row: 2 / 4; /* 跨2行，居中在2-3行之间 */
    align-self: center;
}

.celtic-cross-preview .preview-card-6 {
    grid-column: 5 / 6;
    grid-row: 2 / 4; /* 跨2行，居中在2-3行之间 */
    align-self: center;
}

/* 右侧竖列（从下到上：7、8、9、10） */
.celtic-cross-preview .preview-card-7 {
    grid-column: 7 / 8;
    grid-row: 4 / 5;
}

.celtic-cross-preview .preview-card-8 {
    grid-column: 7 / 8;
    grid-row: 3 / 4;
}

.celtic-cross-preview .preview-card-9 {
    grid-column: 7 / 8;
    grid-row: 2 / 3;
}

.celtic-cross-preview .preview-card-10 {
    grid-column: 7 / 8;
    grid-row: 1 / 2;
}

/* 🎨 单张预览卡牌 */
.preview-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    max-width: 80px; /* 限制最大宽度 */
}

.preview-card:hover .preview-card-image-wrapper {
    transform: translateY(-2px);
    box-shadow: 0 3px 8px rgba(0, 123, 175, 0.4);
}

/* 🎨 卡牌标签（在卡牌下方，白色） */
.preview-card-label {
    font-size: 0.6em;
    font-weight: 600;
    color: #ffffff;
    text-align: center;
    white-space: nowrap;
    order: 4; /* 在名称、正逆位和图片之后 */
    margin-top: 2px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5); /* 增加可读性 */
}

/* 🎨 卡牌图片容器 */
.preview-card-image-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 2.5 / 3.5;
    border-radius: 6px;
    overflow: hidden;
    background: #e8e8e8;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    order: 2; /* 在名称和正逆位之后 */
    margin-bottom: 4px;
}

.preview-card-image-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* 🎨 逆位卡牌 */
.preview-card.reversed .preview-card-image-wrapper img {
    transform: rotate(180deg);
}

/* 🎨 逆位指示器 */
.preview-reversed-indicator {
    position: absolute;
    top: 1px;
    right: 1px;
    width: 14px;
    height: 14px;
    background: rgba(220, 38, 38, 0.9);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: bold;
    z-index: 2;
}

/* 🎨 横向卡牌（2号牌） */
.preview-card.horizontal {
    /* 2号牌整体不旋转，只旋转图片容器 */
}

.preview-card.horizontal .preview-card-image-wrapper {
    width: 133.33%; /* 缩小容器宽度（原200%的2/3） */
    max-width: 133.33%;
    aspect-ratio: 3.5 / 2.5; /* 横向比例 */
    margin-left: -16.67%; /* 向左偏移以居中 */
    background: transparent; /* 移除背景色以显示完整 */
}

.preview-card.horizontal .preview-card-image-wrapper img {
    transform: rotate(90deg) scale(1.4); /* 旋转并等比例放大 */
    width: 100%;
    height: 100%;
    object-fit: contain; /* 完整显示不拉伸 */
    transform-origin: center center; /* 从中心缩放 */
}

/* 🎨 横向+逆位卡牌（2号牌逆位） */
.preview-card.horizontal.reversed .preview-card-image-wrapper img {
    transform: rotate(-90deg) scale(1.4); /* 逆位时旋转-90度并等比例放大 */
}

/* 🎨 2号牌特殊定位（避免和1号牌重叠） */
.celtic-cross-preview .preview-card-2 {
    position: relative;
}

/* 2号牌的名称显示在左侧 */
.celtic-cross-preview .preview-card-2 .preview-card-name {
    position: absolute;
    left: -120px; /* 向左偏移更多 */
    top: 20%;
    transform: translateY(-50%);
    text-align: center; /* 居中对齐 */
    width: 110px;
}

/* 2号牌的正逆位标签显示在名称正下方 */
.celtic-cross-preview .preview-card-2 .preview-card-orientation {
    position: absolute;
    left: -120px; /* 向左偏移更多 */
    top: calc(20% + 18px); /* 名称下方 */
    transform: translateY(0); /* 不需要居中变换 */
    text-align: center; /* 居中对齐 */
    width: 110px;
}

/* 🎨 卡牌名称（显示在卡牌上方） */
.preview-card-name {
    font-size: 0.65em;
    color: #ffffff;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    order: 0; /* 最先显示 */
    margin-bottom: 2px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

/* 🎨 正逆位标签（在名称下方） */
.preview-card-orientation {
    font-size: 0.55em;
    color: rgba(255, 255, 255, 0.8);
    text-align: center;
    white-space: nowrap;
    order: 1; /* 在名称之后 */
    margin-bottom: 4px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

/* 🎨 Hover Tooltip（显示卡牌含义） */
.preview-card-tooltip {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.95);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.7em;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 150;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    max-width: 250px;
    text-align: center;
}

.preview-card:hover .preview-card-tooltip {
    opacity: 1;
}

/* 🎨 点击详情面板（悬浮显示） */
.preview-card-details {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.95);
    color: white;
    padding: 16px 20px;
    border-radius: 10px;
    font-size: 0.85em;
    min-width: 220px;
    max-width: 350px;
    z-index: 200;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
    backdrop-filter: blur(10px);
}

.preview-card-details.active {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, -50%) scale(1.05);
}

.preview-card-details h4 {
    margin: 0 0 8px 0;
    font-size: 1.2em;
    color: #00b4ff;
}

.preview-card-details p {
    margin: 4px 0;
    line-height: 1.5;
}

.preview-card-details .detail-orientation {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 5px;
    background: rgba(0, 180, 255, 0.3);
    font-weight: 600;
    margin-bottom: 10px;
    font-size: 0.9em;
}

/* 🎨 手机端适配 */
@media (max-width: 768px) {
    .spread-preview {
        padding: 10px 3px; /* 减小padding */
        margin: 0 0 20px 0;
    }
    
    .spread-preview-title {
        font-size: 1em;
        margin-bottom: 10px;
    }
    
    .celtic-cross-preview .spread-preview-cards {
        max-width: 100%;
        gap: 3px; /* 减小卡牌间距 */
        row-gap: 3px;
    }
    
    .preview-card {
        padding: 2px;
        gap: 2px;
        max-width: 55px !important; /* 强制统一最大宽度 */
    }
    
    /* 手机端：十字架中心竖列（3、1、2、4号牌）强制缩小 */
    .celtic-cross-preview .preview-card-1,
    .celtic-cross-preview .preview-card-2,
    .celtic-cross-preview .preview-card-3,
    .celtic-cross-preview .preview-card-4 {
        max-width: 52px !important; /* 再缩小5% (55px → 52px) */
        width: 52px !important; /* 强制宽度 */
    }
    
    /* 手机端：2号牌的横向容器需要放大 */
    .preview-card.horizontal .preview-card-image-wrapper {
        width: 140% !important; /* 手机端放大容器宽度 */
        max-width: 140% !important;
        margin-left: -20% !important; /* 调整偏移居中 */
    }
    
    .preview-card.horizontal .preview-card-image-wrapper img {
        transform: rotate(90deg) scale(1.43) !important; /* 手机端放大30% (1.1 × 1.3 ≈ 1.43) */
    }
    
    .preview-card.horizontal.reversed .preview-card-image-wrapper img {
        transform: rotate(-90deg) scale(1.43) !important; /* 手机端放大30% */
    }
    
    /* 手机端：2号牌名称和正逆位标签调整 */
    .celtic-cross-preview .preview-card-2 .preview-card-name {
        left: -75px; /* 手机端减少左偏移 */
        width: 70px;
        font-size: 0.5em;
        text-align: center; /* 居中对齐 */
    }
    
    .celtic-cross-preview .preview-card-2 .preview-card-orientation {
        left: -75px; /* 手机端减少左偏移 */
        top: calc(20% + 14px); /* 名称下方 */
        width: 70px;
        font-size: 0.45em;
        text-align: center; /* 居中对齐 */
        transform: translateY(0); /* 不需要居中变换 */
    }
    
    .preview-card-label {
        font-size: 0.65em;
    }
    
    .preview-card-name {
        font-size: 0.6em;
    }
    
    .preview-card-orientation {
        font-size: 0.5em;
    }
    
    .preview-reversed-indicator {
        width: 16px;
        height: 16px;
        font-size: 10px;
    }
}

/* 🎨 超小屏幕 */
@media (max-width: 480px) {
    .celtic-cross-preview .spread-preview-cards {
        gap: 2px; /* 进一步缩小间距 */
        row-gap: 2px;
    }
    
    .preview-card {
        padding: 2px;
        max-width: 45px !important; /* 超小屏进一步缩小 */
    }
    
    /* 超小屏：十字架中心竖列进一步缩小 */
    .celtic-cross-preview .preview-card-1,
    .celtic-cross-preview .preview-card-2,
    .celtic-cross-preview .preview-card-3,
    .celtic-cross-preview .preview-card-4 {
        max-width: 43px !important; /* 再缩小5% (45px → 43px) */
        width: 43px !important;
    }
    
    /* 超小屏：2号牌横向容器进一步调整 */
    .preview-card.horizontal .preview-card-image-wrapper {
        width: 130% !important; /* 超小屏也放大 */
        max-width: 130% !important;
        margin-left: -15% !important;
    }
    
    .preview-card.horizontal .preview-card-image-wrapper img {
        transform: rotate(90deg) scale(1.2) !important; /* 超小屏适度放大 */
    }
    
    .preview-card.horizontal.reversed .preview-card-image-wrapper img {
        transform: rotate(-90deg) scale(1.2) !important;
    }
    
    /* 超小屏：2号牌名称和正逆位标签隐藏或调整 */
    .celtic-cross-preview .preview-card-2 .preview-card-name {
        left: -60px;
        width: 55px;
        font-size: 0.45em;
        text-align: center; /* 居中对齐 */
    }
    
    .celtic-cross-preview .preview-card-2 .preview-card-orientation {
        left: -60px;
        top: calc(20% + 12px); /* 名称下方 */
        width: 55px;
        font-size: 0.4em;
        text-align: center; /* 居中对齐 */
        transform: translateY(0); /* 不需要居中变换 */
    }
    
    .preview-card-label {
        font-size: 0.6em;
    }
    
    .preview-card-name {
        display: none; /* 超小屏隐藏卡牌名称 */
    }
    
    .preview-card-orientation {
        display: none; /* 超小屏隐藏正逆位标签 */
    }
    
    /* 但是2号牌的保留（因为有特殊定位） */
    .celtic-cross-preview .preview-card-2 .preview-card-name,
    .celtic-cross-preview .preview-card-2 .preview-card-orientation {
        display: block;
    }
}

