/* 棋谱回放页面样式 */

/* ===== 古谱合集首页 ===== */
.collection-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    justify-content: center;
    margin-bottom: 60px;
}

.collection-card {
    width: calc(25% - 18px);
    min-width: 200px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 12px;
    padding: 32px 20px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

.collection-card:hover {
    background: #fff;
    transform: translateY(-6px);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.12);
}

.collection-card:hover .collection-name {
    color: #c92b30;
}

.collection-cover {
    width: 180px;
    height: 180px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.collection-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: #2c3e50;
    text-align: center;
    margin: 0;
    transition: color 0.3s ease;
}

@media (max-width: 900px) {
    .collection-card {
        width: calc(50% - 12px);
    }
}

@media (max-width: 500px) {
    .collection-card {
        width: 100%;
    }

    .collection-cover {
        width: 140px;
        height: 140px;
    }
}

/* ===== 主布局：左侧目录 + 右侧内容 ===== */
.record-layout {
    display: flex;
    gap: 24px;
    align-items: flex-start;
}

/* ===== 左侧卷目录 ===== */
.volume-sidebar {
    width: 280px;
    flex-shrink: 0;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    overflow: hidden;
    position: sticky;
    top: 80px;
    max-height: calc(100vh - 100px);
    display: flex;
    flex-direction: column;
    transition: width 0.3s;
}

.volume-sidebar.collapsed {
    width: 48px;
}

.volume-sidebar.collapsed .volume-tree,
.volume-sidebar.collapsed .sidebar-header h3 {
    display: none;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid #eee;
    background: #fafafa;
}

.sidebar-header h3 {
    margin: 0;
    font-size: 1rem;
    color: #2c3e50;
    white-space: nowrap;
}

.sidebar-header h3 i {
    margin-right: 8px;
    color: #3498db;
}

.sidebar-toggle {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 6px;
    background: #ecf0f1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #555;
    transition: all 0.2s;
    flex-shrink: 0;
}

.sidebar-toggle:hover {
    background: #3498db;
    color: #fff;
}

.volume-tree {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.volume-tree::-webkit-scrollbar {
    width: 6px;
}

.volume-tree::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 3px;
}

.volume-tree::-webkit-scrollbar-thumb:hover {
    background: #bbb;
}

/* 卷节点 */
.volume-node {
    border-bottom: 1px solid #f5f5f5;
}

.volume-node:last-child {
    border-bottom: none;
}

.volume-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.15s;
    user-select: none;
}

.volume-header:hover {
    background: #f8f9fa;
}

.volume-header.active {
    background: #fff6e5;
    border-left: 3px solid #c92b30;
}

.volume-header .volume-icon {
    width: 20px;
    margin-right: 8px;
    color: #8c8c8c;
    font-size: 0.8rem;
    text-align: center;
    transition: transform 0.2s;
}

.volume-header .volume-icon.expanded {
    transform: rotate(90deg);
}

.volume-header .volume-name {
    flex: 1;
    font-size: 0.95rem;
    font-weight: 600;
    color: #2c3e50;
}

.volume-header .volume-count {
    font-size: 0.75rem;
    color: #999;
    background: #f0f0f0;
    padding: 2px 8px;
    border-radius: 10px;
}

/* 局列表 */
.volume-puzzles {
    display: none;
    padding: 0 0 4px 0;
}

.volume-puzzles.expanded {
    display: block;
}

.puzzle-item {
    display: flex;
    align-items: center;
    padding: 8px 16px 8px 44px;
    cursor: pointer;
    transition: background 0.15s;
    font-size: 0.85rem;
    color: #555;
    border-left: 3px solid transparent;
}

.puzzle-item:hover {
    background: #f0f7ff;
    color: #3498db;
}

.puzzle-item.active {
    background: #e8f4fd;
    color: #3498db;
    border-left-color: #3498db;
    font-weight: 600;
}

.puzzle-item .puzzle-seq {
    width: 36px;
    flex-shrink: 0;
    color: #999;
    font-size: 0.8rem;
}

.puzzle-item .puzzle-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 右侧内容区 */
.record-content {
    flex: 1;
    min-width: 0;
}

/* 移动端目录切换 */
.mobile-sidebar-toggle {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    font-size: 0.95rem;
    color: #2c3e50;
    margin-bottom: 16px;
    transition: all 0.2s;
}

.mobile-sidebar-toggle:hover {
    border-color: #3498db;
    color: #3498db;
}

/* ===== 筛选栏 ===== */
.filter-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    flex-wrap: wrap;
    align-items: center;
}

.filter-select, .filter-input {
    padding: 10px 14px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 0.95rem;
    background: #fff;
    transition: border-color 0.2s;
}

.filter-select:focus, .filter-input:focus {
    outline: none;
    border-color: #3498db;
}

.filter-input {
    flex: 1;
    min-width: 200px;
}

/* ===== 棋谱卡片网格 ===== */
.record-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.record-card {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 2px solid transparent;
}

.record-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    border-color: #3498db;
}

.record-card h3 {
    margin: 0 0 8px;
    font-size: 1.1rem;
    color: #2c3e50;
}

.record-card .card-desc {
    font-size: 0.85rem;
    color: #7f8c8d;
    margin-bottom: 12px;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.record-card .card-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.record-card .card-meta .badge {
    font-size: 0.75rem;
    padding: 3px 8px;
    border-radius: 4px;
    background: #ecf0f1;
    color: #555;
}

.record-card .card-meta .badge.source-badge {
    background: #3498db;
    color: #fff;
}

.record-card .card-meta .badge.difficulty-badge {
    background: #f39c12;
    color: #fff;
}

.record-card .card-preview {
    margin-top: 12px;
    text-align: center;
}

.record-card .card-preview canvas {
    border-radius: 4px;
}

/* ===== 分页 ===== */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    margin: 32px 0 16px;
}

.pagination button {
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    font-size: 0.85rem;
    color: #555;
    transition: all 0.2s;
    line-height: 1;
}

.pagination button:hover:not(:disabled):not(.active) {
    border-color: #3498db;
    color: #3498db;
    background: #f0f7ff;
}

.pagination button.active {
    background: #3498db;
    color: #fff;
    border-color: #3498db;
    font-weight: 600;
    cursor: default;
}

.pagination button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.page-ellipsis {
    padding: 0 4px;
    color: #999;
    font-size: 0.85rem;
    user-select: none;
}

/* ===== 辅文展示区 ===== */
.preface-section {
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    margin-bottom: 24px;
}

.preface-section h2 {
    margin: 0 0 20px;
    font-size: 1.4rem;
    color: #2c3e50;
    border-bottom: 2px solid #3498db;
    padding-bottom: 10px;
}

.preface-content .preface-text {
    margin-bottom: 24px;
}

.preface-content .preface-text p {
    line-height: 1.8;
    font-size: 1rem;
    color: #333;
    margin: 8px 0;
}

.preface-content .preface-images {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-top: 16px;
}

.preface-content .preface-image {
    max-width: 320px;
    max-height: 420px;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    transition: transform 0.2s, box-shadow 0.2s;
}

.preface-content .preface-image:hover {
    transform: scale(1.03);
    box-shadow: 0 6px 20px rgba(0,0,0,0.2);
}

@media (max-width: 600px) {
    .preface-content .preface-image {
        max-width: 100%;
        height: auto;
    }
}

/* ===== 返回按钮 ===== */
.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    background: #ecf0f1;
    color: #2c3e50;
    font-size: 0.95rem;
    cursor: pointer;
    margin-bottom: 20px;
    transition: background 0.2s;
}

.btn-back:hover {
    background: #d5dbdb;
}

/* ===== 回放区布局 ===== */
.replay-container {
    display: flex;
    gap: 24px;
    align-items: flex-start;
}

.replay-board-area {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.replay-board-area canvas {
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

.interactive-banner {
    width: 100%;
    max-width: 750px;
    margin-top: 8px;
    padding: 10px 20px;
    border-radius: 8px;
    background: rgba(39, 174, 96, 0.9);
    color: #fff;
    font-size: 0.95rem;
    font-weight: 600;
    text-align: center;
    letter-spacing: 1px;
    box-sizing: border-box;
}

.replay-info-area {
    width: 340px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ===== 棋局信息卡 ===== */
.record-info-card {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

.record-info-card h2 {
    margin: 0 0 12px;
    font-size: 1.3rem;
    color: #2c3e50;
}

.record-meta {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.badge {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
}

.badge.result-badge {
    background: #27ae60;
    color: #fff;
}

.record-desc {
    font-size: 0.9rem;
    color: #555;
    line-height: 1.6;
    margin-bottom: 12px;
}

.record-players {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 0.95rem;
}

.record-players .vs {
    font-weight: 700;
    color: #e74c3c;
}

.record-players .player-red {
    color: #c0392b;
    font-weight: 600;
}

.record-players .player-black {
    color: #2c3e50;
    font-weight: 600;
}

/* ===== 走法列表 ===== */
.move-list-card {
    background: #fff;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

.move-list-card h3 {
    margin: 0 0 12px;
    font-size: 1rem;
    color: #2c3e50;
}

.move-list {
    max-height: 320px;
    overflow-y: auto;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: #fafafa;
}

.move-list::-webkit-scrollbar {
    width: 6px;
}

.move-list::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.move-list::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}

.move-pair {
    display: flex;
    align-items: stretch;
    border-bottom: 1px solid #eee;
    font-size: 0.95rem;
    line-height: 1.5;
}

.move-pair:nth-child(even) {
    background: #f8f9fa;
}

.move-pair:last-child {
    border-bottom: none;
}

.move-pair .move-number {
    width: 36px;
    font-weight: 700;
    color: #666;
    flex-shrink: 0;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-right: 1px solid #eee;
}

.move-pair .move-cell {
    flex: 1;
    padding: 10px 12px;
    cursor: pointer;
    transition: background 0.15s;
    display: flex;
    align-items: center;
    min-width: 0;
}

.move-pair .move-cell:first-of-type {
    border-right: 1px solid #eee;
}

.move-pair .move-cell:hover {
    background: #e8f0fe;
}

.move-pair .move-cell.active {
    background: #3498db;
    color: #fff;
}

.move-pair .move-notation {
    font-weight: 700;
    font-size: 1rem;
    color: #1a1a1a;
    letter-spacing: 0.5px;
}

.move-pair .move-cell.active .move-notation {
    color: #fff;
}

.move-pair .move-comment-short {
    font-size: 0.8rem;
    color: #888;
    margin-left: 8px;
    font-weight: 400;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.move-pair .move-cell.active .move-comment-short {
    color: rgba(255,255,255,0.8);
}

/* ===== 分支选择器 ===== */
.branch-selector {
    display: flex;
    gap: 4px;
    padding: 4px 12px 4px 48px;
    background: #f8f9fa;
    border-bottom: 1px solid #f0f0f0;
}

.branch-btn {
    padding: 2px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
    font-size: 0.75rem;
    color: #666;
    transition: all 0.15s;
}

.branch-btn:hover {
    border-color: #3498db;
    color: #3498db;
    background: #f0f7ff;
}

.branch-btn.active {
    background: #3498db;
    color: #fff;
    border-color: #3498db;
    font-weight: 600;
}

/* ===== 注释卡 ===== */
.comment-card {
    background: #fff9e6;
    border-radius: 12px;
    padding: 16px;
    border-left: 4px solid #f39c12;
}

.comment-card h3 {
    margin: 0 0 8px;
    font-size: 0.95rem;
    color: #e67e22;
}

.comment-card p {
    margin: 0;
    font-size: 0.9rem;
    color: #555;
    line-height: 1.6;
}

/* ===== 播放控制 ===== */
.playback-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
    background: #fff;
    border-radius: 12px;
    padding: 12px 16px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    flex-wrap: wrap;
}

.ctrl-btn {
    width: 44px;
    height: 44px;
    border: 2px solid #e0e0e0;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    font-size: 1rem;
    color: #555;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.ctrl-btn:hover {
    border-color: #3498db;
    color: #3498db;
    background: #f0f7ff;
}

.ctrl-btn.active {
    background: #27ae60;
    border-color: #27ae60;
    color: #fff;
}

.ctrl-btn.active:hover {
    background: #219a52;
    border-color: #219a52;
}

.ctrl-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.ctrl-btn.play-btn {
    width: 52px;
    height: 52px;
    font-size: 1.2rem;
    border-color: #3498db;
    color: #3498db;
}

.ctrl-btn.play-btn:hover {
    background: #3498db;
    color: #fff;
}

.ctrl-btn.play-btn.playing {
    background: #e74c3c;
    border-color: #e74c3c;
    color: #fff;
}

.speed-control {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 12px;
    font-size: 0.85rem;
    color: #777;
}

.speed-control input[type="range"] {
    width: 80px;
    accent-color: #3498db;
}

/* ===== 步数信息 ===== */
.step-info {
    text-align: center;
    font-size: 0.95rem;
    color: #666;
    font-weight: 500;
}

/* ===== 响应式 ===== */
@media (max-width: 1100px) {
    .volume-sidebar {
        position: fixed;
        left: -300px;
        top: 68px;
        z-index: 100;
        height: calc(100vh - 68px);
        max-height: calc(100vh - 68px);
        border-radius: 0 12px 12px 0;
        transition: left 0.3s;
    }

    .volume-sidebar.mobile-open {
        left: 0;
    }

    .mobile-sidebar-toggle {
        display: inline-flex;
    }

    .record-layout {
        flex-direction: column;
    }
}

@media (max-width: 900px) {
    .replay-container {
        flex-direction: column;
        align-items: center;
    }

    .replay-info-area {
        width: 100%;
        min-width: unset;
    }

    .replay-board-area canvas {
        max-width: 100%;
        height: auto;
    }
}

@media (max-width: 600px) {
    .filter-bar {
        flex-direction: column;
    }

    .filter-select, .filter-input {
        width: 100%;
    }

    .record-grid {
        grid-template-columns: 1fr;
    }

    .playback-controls {
        gap: 6px;
    }

    .speed-control {
        margin-left: 0;
        width: 100%;
        justify-content: center;
        margin-top: 8px;
    }
}

/* ===== 古谱原图展示 ===== */
.ancient-images-section {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    margin-top: 24px;
}

.ancient-images-section h3 {
    margin: 0 0 16px;
    font-size: 1.1rem;
    color: #2c3e50;
}

.ancient-images-section h3 i {
    margin-right: 8px;
    color: #3498db;
}

.ancient-images-gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.ancient-image {
    max-width: 320px;
    max-height: 420px;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    transition: transform 0.2s, box-shadow 0.2s;
}

.ancient-image:hover {
    transform: scale(1.03);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

@media (max-width: 600px) {
    .ancient-image {
        max-width: 100%;
        height: auto;
    }
}

/* ===== 图片灯箱 ===== */
.image-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    opacity: 0;
    transition: opacity 0.3s;
}

.image-lightbox.show {
    opacity: 1;
}

.image-lightbox-close {
    position: absolute;
    top: 16px;
    right: 20px;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    font-size: 1.4rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    z-index: 10001;
}

.image-lightbox-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.lightbox-img-wrapper {
    position: relative;
    max-width: 90vw;
    max-height: 80vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.lightbox-img-wrapper img {
    max-width: 90vw;
    max-height: 80vh;
    object-fit: contain;
    transition: transform 0.3s ease;
    cursor: grab;
    user-select: none;
}

.lightbox-img-wrapper img.dragging {
    cursor: grabbing;
}

.lightbox-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
    z-index: 10001;
}

.lightbox-toolbar button {
    width: 44px;
    height: 44px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.lightbox-toolbar button:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
}

.lightbox-toolbar .lightbox-counter {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.9rem;
    min-width: 60px;
    text-align: center;
}

/* ===== Toast 通知 ===== */
.record-toast {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: rgba(44, 62, 80, 0.92);
    color: #fff;
    padding: 12px 28px;
    border-radius: 8px;
    font-size: 0.95rem;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    pointer-events: none;
    white-space: nowrap;
}

.record-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
