/* ============================================
   tarot.css - 塔罗占卜样式（左右布局 · 多牌阵）
   ============================================ */

/* ---------- 全局重置 ---------- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: linear-gradient(135deg, #0d0610 0%, #1a0a2e 30%, #2d1b3d 60%, #1a0a2e 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 8px;
    position: relative;
}

/* 背景星光 */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        radial-gradient(2px 2px at 20px 30px, #ffd700, transparent),
        radial-gradient(2px 2px at 40px 70px, #ffd700, transparent),
        radial-gradient(2px 2px at 50px 160px, #ffd700, transparent),
        radial-gradient(2px 2px at 90px 40px, #ffd700, transparent),
        radial-gradient(2px 2px at 130px 80px, #ffd700, transparent),
        radial-gradient(2px 2px at 160px 30px, #ffd700, transparent);
    background-size: 200px 200px;
    opacity: 0.3;
    pointer-events: none;
    z-index: 0;
}

/* ---------- 主容器 ---------- */
.app-container {
    max-width: 100%;
    min-height: 100vh;
    width: 100%;
    background: rgba(255, 255, 255, 0.04);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 40px;
    padding: 10px 16px;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.8), inset 0 1px 0 rgba(255, 215, 0, 0.1);
    border: 1px solid rgba(255, 215, 0, 0.08);
    position: relative;
    z-index: 1;
}

/* ---------- 头部 ---------- */
.app-header {
    text-align: center;
    margin-bottom: 24px;
}

.app-header h1 {
    color: #ffd700;
    font-size: 2.4rem;
    font-weight: 300;
    letter-spacing: 6px;
    text-shadow: 0 0 30px rgba(255, 215, 0, 0.2), 0 0 60px rgba(255, 215, 0, 0.05);
}

.app-header h1::before {
    content: '✦ ';
    opacity: 0.6;
}
.app-header h1::after {
    content: ' ✦';
    opacity: 0.6;
}

.subtitle {
    color: #b8a0c0;
    font-size: 0.95rem;
    letter-spacing: 2px;
    opacity: 0.8;
}

/* ---------- 主体：左右布局 ---------- */
.main-layout {
    flex: 1;
    display: flex;
    gap: 30px;
    align-items: stretch;
}

/* ===== 左侧面板 ===== */
.sidebar {
    flex: 0 0 360px;
    min-width: 260px;
    background: rgba(0, 0, 0, 0.35);
    border-radius: 24px;
    padding: 22px 18px;
    border: 1px solid rgba(255, 215, 0, 0.06);
    display: flex;
    flex-direction: column;
    gap: 18px;
}

@media (min-width: 1025px) {
    .sidebar {
        position: sticky;
        top: 20px;
        height: calc(80vh);
        align-self: flex-start;
        max-height: calc(80vh);
        /* 关键：禁止整个 sidebar 滚动，让内部子元素各自控制滚动 */
        overflow: hidden;
    }

    /* ===== 牌阵选择面板：占据剩余空间，内部滚动 ===== */
    .sidebar .panel-section:first-child {
        flex: 1;
        display: flex;
        flex-direction: column;
        min-height: 0;
        /* 防止 flex 溢出 */
    }

    .sidebar .panel-section:first-child h3 {
        flex-shrink: 0;
        /* 标题固定不滚动 */
    }

    /* ===== 牌阵选项容器：独立滚动 ===== */
    .spread-options {
        flex: 1;
        overflow-y: auto;
        min-height: 0;
        padding-right: 4px;
        /* 为滚动条预留空间 */
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    /* 其他元素固定不滚动 */
    .sidebar .panel-section:not(:first-child),
    .sidebar .divider,
    .sidebar .btn,
    .sidebar .sidebar-footer {
        flex-shrink: 0;
    }

    /* ---------- 滚动条美化（仅桌面端） ---------- */
    .spread-options::-webkit-scrollbar {
        width: 4px;
    }
    .spread-options::-webkit-scrollbar-track {
        background: rgba(255, 255, 255, 0.04);
        border-radius: 4px;
    }
    .spread-options::-webkit-scrollbar-thumb {
        background: rgba(255, 215, 0, 0.25);
        border-radius: 4px;
    }
    .spread-options::-webkit-scrollbar-thumb:hover {
        background: rgba(255, 215, 0, 0.4);
    }
    /* Firefox 兼容 */
    .spread-options {
        scrollbar-width: thin;
        scrollbar-color: rgba(255, 215, 0, 0.25) rgba(255, 255, 255, 0.04);
    }
}

.panel-section h3 {
    color: #d8c8e0;
    font-size: 0.95rem;
    font-weight: 400;
    letter-spacing: 2px;
    margin-bottom: 12px;
    border-bottom: 1px solid rgba(255, 215, 0, 0.06);
    padding-bottom: 6px;
}

/* 牌阵选项（全局基础样式） */
.spread-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.spread-option {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 215, 0, 0.1);
    border-radius: 12px;
    padding: 10px 14px;
    color: #b8a8c0;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.spread-option:hover {
    background: rgba(255, 215, 0, 0.06);
    border-color: rgba(255, 215, 0, 0.2);
    color: #fff;
}

.spread-option.active {
    background: rgba(255, 215, 0, 0.12);
    border-color: #ffd700;
    color: #ffd700;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.05);
}

.spread-option .badge {
    margin-left: auto;
    background: rgba(255, 215, 0, 0.15);
    color: #ffd700;
    font-size: 0.65rem;
    padding: 2px 10px;
    border-radius: 20px;
}

/* 分隔线 */
.divider {
    border-top: 1px solid rgba(255, 255, 255, 0.04);
    margin: 4px 0;
}

/* 输入框 */
#questionInput {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 215, 0, 0.08);
    border-radius: 12px;
    padding: 10px 14px;
    color: #d8c8e0;
    font-size: 0.9rem;
    resize: vertical;
    font-family: inherit;
    transition: border 0.2s;
}

#questionInput:focus {
    outline: none;
    border-color: rgba(255, 215, 0, 0.3);
}

#questionInput::placeholder {
    color: #5a4a6a;
}

/* 按钮 */
.btn {
    border: none;
    border-radius: 50px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    padding: 12px 20px;
}

.btn-primary {
    background: linear-gradient(135deg, #ffd700, #f0a500);
    color: #1a0a1e;
    box-shadow: 0 8px 30px rgba(255, 215, 0, 0.2);
    width: 100%;
}

.btn-primary:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 12px 45px rgba(255, 215, 0, 0.35);
}

.btn-primary:active {
    transform: scale(0.96);
}

.btn-reset {
    background: rgba(255, 255, 255, 0.04);
    color: #8a7a9a;
    border: 1px solid rgba(255, 255, 255, 0.06);
    width: 100%;
    font-size: 0.8rem;
    padding: 8px 16px;
}

.btn-reset:hover {
    background: rgba(255, 50, 50, 0.08);
    color: #ff7a7a;
    border-color: rgba(255, 50, 50, 0.15);
}

.sidebar-footer {
    margin-top: auto;
    text-align: center;
    color: #4a3a5a;
    font-size: 0.7rem;
    letter-spacing: 0.5px;
    border-top: 1px solid rgba(255, 255, 255, 0.03);
    padding-top: 12px;
}

.sidebar-footer a {
    color: #f7aa04;
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* ===== 右侧主内容 ===== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 0;
}

/* 牌阵展示区 */
.spread-area {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 30px;
    min-height: 320px;
    padding: 30px 20px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 24px;
    border: 1px solid rgba(255, 215, 0, 0.06);
    transition: all 0.4s ease;
    position: relative;
}

.spread-area .placeholder-text {
    color: #6a5a7a;
    font-size: 1.1rem;
    letter-spacing: 2px;
}

/* ------- 单张牌 ------- */
.card-slot {
    width: 150px;
    height: 250px;
    perspective: 1200px;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.card-slot:hover {
    transform: translateY(-6px) scale(1.02);
}
.card-slot:active {
    transform: scale(0.95);
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.8s cubic-bezier(0.23, 1, 0.32, 1);
    transform-style: preserve-3d;
}

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

.card-front,
.card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.6), inset 0 0 40px rgba(0, 0, 0, 0.3);
}

.card-front {
    transform: rotateY(180deg);
    background: linear-gradient(145deg, #1e1028, #2d1a38);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    border: 2px solid rgba(255, 215, 0, 0.25);
}

.card-front img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    border-radius: 12px;
    transition: transform 0.4s ease;
}

.card-front.reversed img {
    transform: rotate(180deg);
}

.card-front::after {
    content: attr(data-name);
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 215, 0, 0.5);
    font-size: 0.6rem;
    letter-spacing: 1px;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8);
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.card-slot.flipped .card-front::after {
    opacity: 1;
}

.card-back {
    background: linear-gradient(145deg, #12081a, #2d1a3d);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid rgba(255, 215, 0, 0.3);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.6), inset 0 0 60px rgba(255, 215, 0, 0.05);
}

.card-back img {
    width: 80%;
    height: 80%;
    object-fit: contain;
    opacity: 0.85;
    filter: drop-shadow(0 0 20px rgba(255, 215, 0, 0.1));
}

.card-back::before {
    content: '';
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    bottom: 10px;
    border: 1px solid rgba(255, 215, 0, 0.08);
    border-radius: 12px;
    pointer-events: none;
}

.card-back::after {
    content: '✦';
    position: absolute;
    font-size: 2.5rem;
    color: #ffd700;
    opacity: 0.1;
    text-shadow: 0 0 30px rgba(255, 215, 0, 0.2);
}

/* 牌上标签（位置说明） */
.card-label {
    position: absolute;
    top: -28px;
    left: 50%;
    transform: translateX(-50%);
    color: #b8a0c0;
    font-size: 0.7rem;
    background: rgba(0, 0, 0, 0.6);
    padding: 2px 12px;
    border-radius: 12px;
    white-space: nowrap;
    letter-spacing: 0.5px;
    border: 1px solid rgba(255, 215, 0, 0.08);
    pointer-events: none;
}

/* 牌阵容器（用于特殊布局） */
.spread-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 30px 50px;
    position: relative;
}

.spread-container .card-slot {
    position: relative;
}

/* 抉择牌阵的左右分支 */
.spread-branch {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.spread-branch .branch-label {
    color: #b8a0c0;
    font-size: 0.8rem;
    background: rgba(0, 0, 0, 0.4);
    padding: 2px 16px;
    border-radius: 20px;
    letter-spacing: 1px;
}

.spread-branch .branch-cards {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* ---------- 解读区 ---------- */
.reading-result {
    padding: 22px 28px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 18px;
    border-left: 4px solid #ffd700;
    color: #d8c8e0;
    min-height: 120px;
    transition: all 0.5s ease;
}

.reading-result h3 {
    color: #ffd700;
    margin-bottom: 12px;
    font-size: 1.2rem;
    font-weight: 400;
    letter-spacing: 3px;
}
.reading-result h3::before {
    content: '▸ ';
    opacity: 0.6;
}

.reading-result .card-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.reading-result .card-item:last-child {
    border-bottom: none;
}

.reading-result .card-name {
    color: #ffffff;
    font-weight: 500;
    font-size: 1.05rem;
}
.reading-result .card-en {
    color: #8a7a9a;
    font-size: 0.85rem;
    margin-left: 4px;
}

.orientation {
    display: inline-block;
    padding: 2px 14px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 1px;
    margin-left: 8px;
}
.orientation.upright {
    background: rgba(0, 220, 100, 0.2);
    color: #69f0ae;
    border: 1px solid rgba(0, 220, 100, 0.15);
}
.orientation.reversed {
    background: rgba(255, 50, 50, 0.2);
    color: #ff7a7a;
    border: 1px solid rgba(255, 50, 50, 0.15);
}

.reading-result .reading-note {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid rgba(255, 215, 0, 0.06);
    color: #a890b0;
    font-size: 0.9rem;
    letter-spacing: 0.5px;
}

.reading-result .placeholder-text {
    color: #6a5a7a;
    text-align: center;
    font-style: italic;
}

/* ---------- Markdown 内容 ---------- */
.markdown-body {
    color: #d8c8e0;
    line-height: 1.8;
    font-size: 0.95rem;
}
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
    color: #ffd700;
    margin: 16px 0 8px 0;
    font-weight: 600;
}
.markdown-body h1 {
    font-size: 1.6rem;
}
.markdown-body h2 {
    font-size: 1.3rem;
    border-bottom: 1px solid rgba(255, 215, 0, 0.1);
    padding-bottom: 4px;
}
.markdown-body h3 {
    font-size: 1.1rem;
}
.markdown-body p {
    margin: 8px 0;
    color: #d8c8e0;
}
.markdown-body ul,
.markdown-body ol {
    padding-left: 24px;
    margin: 8px 0;
}
.markdown-body li {
    margin: 4px 0;
    color: #d8c8e0;
}
.markdown-body blockquote {
    border-left: 4px solid #ffd700;
    padding: 8px 16px;
    margin: 12px 0;
    background: rgba(255, 215, 0, 0.05);
    border-radius: 0 8px 8px 0;
    color: #c8b8d0;
}
.markdown-body code {
    background: rgba(255, 255, 255, 0.08);
    padding: 2px 8px;
    border-radius: 4px;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 0.85rem;
    color: #ffd700;
}
.markdown-body pre {
    background: rgba(0, 0, 0, 0.4);
    padding: 12px 16px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 12px 0;
    border: 1px solid rgba(255, 215, 0, 0.05);
}
.markdown-body pre code {
    background: transparent;
    padding: 0;
    color: #b8a8c0;
}
.markdown-body strong {
    color: #ffd700;
    font-weight: 700;
}
.markdown-body em {
    color: #c8b0d0;
    font-style: italic;
}
.markdown-body hr {
    border: none;
    border-top: 1px solid rgba(255, 215, 0, 0.1);
    margin: 16px 0;
}
.markdown-body a {
    color: #ffd700;
    text-decoration: underline;
}
.markdown-body a:hover {
    color: #fff;
}
.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
}
.markdown-body th,
.markdown-body td {
    padding: 8px 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    text-align: left;
}
.markdown-body th {
    background: rgba(255, 215, 0, 0.08);
    color: #ffd700;
    font-weight: 600;
}
.markdown-body td {
    color: #d8c8e0;
}
.markdown-body img {
    max-width: 100%;
    border-radius: 8px;
}

/* ---------- 动画 ---------- */
@keyframes cardAppear {
    from {
        opacity: 0;
        transform: scale(0.8) rotateY(90deg);
    }
    to {
        opacity: 1;
        transform: scale(1) rotateY(0deg);
    }
}
.card-slot {
    animation: cardAppear 0.6s ease forwards;
}
.card-slot:nth-child(2) {
    animation-delay: 0.1s;
}
.card-slot:nth-child(3) {
    animation-delay: 0.2s;
}
.card-slot:nth-child(4) {
    animation-delay: 0.3s;
}
.card-slot:nth-child(5) {
    animation-delay: 0.4s;
}

/* ---------- 响应式 ---------- */
@media (max-width: 1024px) {
    .main-layout {
        flex-direction: column;
    }
    .sidebar {
        flex: none;
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        gap: 12px;
        padding: 16px;
        /* 移动端恢复默认 overflow */
        overflow: visible;
    }
    .sidebar .panel-section {
        flex: 1 1 200px;
        min-width: 140px;
    }
    .sidebar .btn-primary,
    .sidebar .btn-reset {
        flex: 0 1 auto;
        width: auto;
        padding: 10px 24px;
    }
    .sidebar-footer {
        display: none;
    }
    .spread-options {
        flex-direction: row;
        flex-wrap: wrap;
        /* 移动端不限制高度，也不滚动 */
        overflow: visible;
        max-height: none;
        flex: 0 1 auto;
    }
    .spread-option {
        padding: 6px 14px;
        font-size: 0.8rem;
    }
}

@media (max-width: 768px) {
    .app-container {
        padding: 16px;
    }
    .app-header h1 {
        font-size: 1.8rem;
    }
    .card-slot {
        width: 120px;
        height: 200px;
    }
    .spread-area {
        gap: 20px;
        padding: 20px 12px;
        min-height: 240px;
    }
    .spread-container {
        gap: 20px 30px;
    }
    .reading-result {
        padding: 16px 18px;
        min-height: 80px;
    }
    .sidebar {
        padding: 12px;
    }
}

@media (max-width: 480px) {
    .card-slot {
        width: 90px;
        height: 155px;
    }
    .spread-area {
        gap: 12px;
        padding: 12px 6px;
        min-height: 180px;
    }
    .card-label {
        font-size: 0.5rem;
        top: -20px;
        padding: 1px 8px;
    }
    .reading-result .card-name {
        font-size: 0.85rem;
    }
    .btn {
        font-size: 0.75rem;
        padding: 8px 14px;
    }
}



/* ---------- 解读区滚动条美化 ---------- */
/* WebKit 浏览器 (Chrome, Edge, Safari) */
.markdown-body::-webkit-scrollbar,
#typewriter-content::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
.markdown-body::-webkit-scrollbar-track,
#typewriter-content::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.04);
    border-radius: 6px;
}
.markdown-body::-webkit-scrollbar-thumb,
#typewriter-content::-webkit-scrollbar-thumb {
    background: rgba(255, 215, 0, 0.25);
    border-radius: 6px;
    transition: background 0.3s ease;
}
.markdown-body::-webkit-scrollbar-thumb:hover,
#typewriter-content::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 215, 0, 0.5);
}

/* Firefox 兼容 */
.markdown-body,
#typewriter-content {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 215, 0, 0.25) rgba(255, 255, 255, 0.04);
}