/* ===== player.css - 播放器样式 ===== */

/* ===== 全局重置 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #1a1a2e;
    font-family: 'Microsoft YaHei', 'PingFang SC', sans-serif;
}

/* ===== 播放器容器 - 居中 ===== */
.player-wrapper {
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #1a1a2e;
    overflow: hidden;
}

/* ===== 9:16 容器 ===== */
.slide-container {
    container-type: inline-size;
    position: relative;
    width: 100%;
    height: 100%;
    max-width: calc(100vh * 9 / 16);
    max-height: calc(100vw * 16 / 9);
    aspect-ratio: 9 / 16;
    overflow: hidden;
    background: #ffffff;
}

/* ===== 电脑端 ===== */
@media (min-width: 768px) {
    .player-wrapper {
        background: #1a1a2e;
    }
    .slide-container {
        background: #ffffff;
        box-shadow: 0 20px 80px rgba(0, 0, 0, 0.6);
        border-radius: 0;
    }
}

/* ===== 手机/平板 - 全屏填满 ===== */
@media (max-width: 767px) {
    .player-wrapper {
        background: #ffffff;
    }
    .slide-container {
        width: 100vw !important;
        height: 100vh !important;
        max-width: 100vw !important;
        max-height: 100vh !important;
        aspect-ratio: auto !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        background: #ffffff;
    }
}

/* ===== 全屏模式 ===== */
.slide-container:fullscreen,
.slide-container:-webkit-full-screen,
.slide-container:-moz-full-screen,
.slide-container:-ms-fullscreen {
    max-width: 100vw !important;
    max-height: 100vh !important;
    width: 100vw !important;
    height: 100vh !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    aspect-ratio: auto !important;
    background: #ffffff;
}

/* ===== 幻灯片 ===== */
.slide {
    display: none;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    padding: 0;
    margin: 0;
    transition: opacity 0.5s ease;
    background-size: cover !important;
    background-position: center center !important;
    background-repeat: no-repeat !important;
}

.slide.active {
    display: block;
}

/* ===== 元素定位 ===== */
.slide .element {
    position: absolute;
    opacity: 0;
    transform: translateY(3%);
    transition: all 0.6s ease;
    overflow: visible;
    word-wrap: break-word;
    box-sizing: border-box;
}

.slide .element.show {
    opacity: 1;
    transform: translateY(0);
}

/* ================================================================
   字体大小 - 使用 vw/vh 组合
   电脑端：80%
   手机端：1.5倍
   ================================================================ */

/* ===== 电脑端 (≥768px) - 80% ===== */
@media (min-width: 768px) {
    .slide .element h1 {
        font-size: min(3.6vh, 3.6vw) !important;
        margin: 0;
        padding: 0;
        line-height: 1.3;
        word-break: break-word;
        font-weight: bold;
    }
    .slide .element p {
        font-size: min(2.24vh, 2.24vw) !important;
        margin: 0;
        padding: 0;
        line-height: 1.8;
        word-break: break-word;
    }
    .slide .element.small-text p {
        font-size: min(1.6vh, 1.6vw) !important;
        margin: 0;
        padding: 0;
        line-height: 1.6;
        word-break: break-word;
        color: #999;
    }
    .slide .element.table table {
        font-size: min(2.24vh, 2.24vw) !important;
        width: 100% !important;
        table-layout: auto !important;
    }
    .slide .element.table td,
    .slide .element.table th {
        padding: 0.5% 0.8% !important;
        font-size: min(2.24vh, 2.24vw) !important;
        word-break: break-word !important;
    }
    .slide-toc .toc-title {
        font-size: min(2.8vh, 2.8vw);
    }
    .slide-toc .toc-item {
        font-size: min(1.8vh, 1.8vw);
        padding: min(0.6vh, 0.6vw) 0;
    }
    .slide-toc .toc-item .toc-number {
        font-size: min(1.4vh, 1.4vw);
    }
    .slide-toc .toc-close {
        font-size: min(2.8vh, 2.8vw);
        width: min(4vh, 4vw);
        height: min(4vh, 4vw);
    }
    .slide-toc .toc-more {
        font-size: min(1.6vh, 1.6vw);
    }
    .controls button {
        font-size: min(1.28vh, 1.28vw);
        padding: 6px 12px;
    }
    .controls .btn-auto .btn-icon {
        font-size: min(1.6vh, 1.6vw);
    }
    .controls .btn-toc .btn-icon {
        font-size: min(1.6vh, 1.6vw);
    }
}

/* ===== 手机端 (≤767px) - 1.5倍 ===== */
@media (max-width: 767px) {
    .slide .element h1 {
        font-size: min(6.75vh, 6.75vw) !important;
        margin: 0;
        padding: 0;
        line-height: 1.3;
        word-break: break-word;
        font-weight: bold;
    }
    .slide .element p {
        font-size: min(4.2vh, 4.2vw) !important;
        margin: 0;
        padding: 0;
        line-height: 1.8;
        word-break: break-word;
    }
    .slide .element.small-text p {
        font-size: min(3vh, 3vw) !important;
        margin: 0;
        padding: 0;
        line-height: 1.6;
        word-break: break-word;
        color: #999;
    }
    .slide .element.table table {
        font-size: min(4.2vh, 4.2vw) !important;
        width: 100% !important;
        table-layout: auto !important;
    }
    .slide .element.table td,
    .slide .element.table th {
        padding: 0.5% 0.8% !important;
        font-size: min(4.2vh, 4.2vw) !important;
        word-break: break-word !important;
    }
    .slide-toc .toc-title {
        font-size: min(5.25vh, 5.25vw);
    }
    .slide-toc .toc-item {
        font-size: min(3.2vh, 3.2vw);
        padding: min(1vh, 1vw) 0;
    }
    .slide-toc .toc-item .toc-number {
        font-size: min(2.4vh, 2.4vw);
    }
    .slide-toc .toc-close {
        font-size: min(5vh, 5vw);
        width: min(8vh, 8vw);
        height: min(8vh, 8vw);
        max-width: 50px;
        max-height: 50px;
    }
    .slide-toc .toc-more {
        font-size: min(2.6vh, 2.6vw);
    }
    .controls button {
        font-size: min(2.4vh, 2.4vw);
        padding: 4px 10px;
    }
    .controls .btn-auto .btn-icon {
        font-size: min(3vh, 3vw);
    }
    .controls .btn-toc .btn-icon {
        font-size: min(3vh, 3vw);
    }
}

/* ===== 标题通用样式 ===== */
.slide .element.title {
    font-weight: bold;
    text-align: left;
    line-height: 1.3;
    width: auto !important;
    max-width: 90%;
    padding-right: 2%;
}

.slide .element.text {
    text-align: left;
    line-height: 1.8;
    width: auto !important;
    max-width: 90%;
    padding-right: 2%;
}

.slide .element.small-text {
    text-align: left;
    line-height: 1.6;
    width: auto !important;
    max-width: 90%;
    padding-right: 2%;
}

/* ================================================================
   图片
   ================================================================ */
.slide .element.image {
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: transparent;
}

.slide .element.image img {
    width: 100%;
    height: 100%;
    display: block;
    border: none;
    outline: none;
    box-shadow: none;
    border-radius: 0;
    object-fit: contain;
}

/* ================================================================
   表格
   ================================================================ */
.slide .element.table {
    overflow: auto;
    padding: 1% 0.5%;
}

.slide .element.table table {
    width: 100% !important;
    table-layout: auto !important;
}

.slide .element.table td,
.slide .element.table th {
    padding: 0.5% 0.8% !important;
    word-break: break-word !important;
}

/* ================================================================
   动画效果
   ================================================================ */
.slide .element.fade {
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.slide .element.slide_left {
    transition: opacity 0.6s ease, transform 0.6s ease;
    transform: translateX(-10%);
}

.slide .element.slide_left.show {
    transform: translateX(0);
}

.slide .element.slide_right {
    transition: opacity 0.6s ease, transform 0.6s ease;
    transform: translateX(10%);
}

.slide .element.slide_right.show {
    transform: translateX(0);
}

.slide .element.scale {
    transition: opacity 0.6s ease, transform 0.6s ease;
    transform: scale(0.5);
}

.slide .element.scale.show {
    transform: scale(1);
}

/* ================================================================
   目录浮层 - 白底黑字简洁版（最多20行）
   ================================================================ */
.slide-toc {
    background: #ffffff !important;
    display: none;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    padding: 5% 4% 3%;
    overflow-y: auto;
    z-index: 1001;
    flex-direction: column;
}

.slide-toc.active {
    display: flex;
}

.slide-toc .toc-title {
    color: #333;
    font-weight: bold;
    text-align: center;
    padding-bottom: 2%;
    border-bottom: 2px solid #eee;
    margin-bottom: 2%;
    letter-spacing: 2px;
    flex-shrink: 0;
}

.slide-toc .toc-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 2%;
}

.slide-toc .toc-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #333;
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 1px solid #f0f0f0;
    line-height: 1.6;
}

.slide-toc .toc-item:hover {
    background: #f5f5f5;
    padding-left: 1%;
    padding-right: 1%;
    border-radius: 4px;
}

.slide-toc .toc-item .toc-number {
    color: #999;
    font-weight: 400;
    min-width: 10%;
    text-align: right;
    flex-shrink: 0;
}

.slide-toc .toc-item .toc-name {
    flex: 1;
    font-weight: 500;
    color: #333;
    padding: 0 3%;
}

.slide-toc .toc-item .toc-arrow {
    color: #ddd;
    flex-shrink: 0;
    transition: color 0.2s ease;
}

.slide-toc .toc-item:hover .toc-arrow {
    color: #667eea;
}

.slide-toc .toc-more {
    text-align: center;
    color: #ccc;
    padding: 2% 0;
    flex-shrink: 0;
    border-top: 1px solid #f0f0f0;
    margin-top: 1%;
}

.slide-toc .toc-close {
    position: fixed;
    top: 2%;
    right: 4%;
    background: rgba(0, 0, 0, 0.06);
    border: none;
    color: #999;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 1002;
    display: flex;
    align-items: center;
    justify-content: center;
}

.slide-toc .toc-close:hover {
    background: rgba(0, 0, 0, 0.12);
    transform: rotate(90deg);
    color: #333;
}

/* ================================================================
   控制栏
   ================================================================ */
.controls-wrapper {
    position: fixed;
    bottom: 5%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.5s ease;
    width: auto;
    max-width: 96vw;
}

.controls-wrapper:hover,
.controls-wrapper.show {
    opacity: 1;
}

.controls {
    display: flex;
    gap: 6px;
    align-items: center;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(12px);
    padding: 8px 14px;
    border-radius: 30px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.4);
    flex-wrap: nowrap;
}

.controls button {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    padding: 6px 12px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    font-family: 'Microsoft YaHei', sans-serif;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.controls button:hover {
    background: rgba(255, 255, 255, 0.12);
    color: white;
}

.controls button:active {
    transform: scale(0.92);
}

.controls .btn-toc {
    color: rgba(255, 255, 255, 0.5);
    padding: 6px 10px;
}

.controls .btn-toc:hover {
    color: #f093fb;
    background: rgba(240, 147, 251, 0.15);
}

.controls .btn-toc .btn-icon {
    font-size: min(1.8vh, 1.8vw);
}

.controls .btn-auto {
    color: rgba(255, 255, 255, 0.7);
    font-weight: 500;
    padding: 6px 14px;
}

.controls .btn-auto:hover {
    color: #4ecdc4;
    background: rgba(78, 205, 196, 0.15);
}

.controls .btn-auto .btn-icon {
    font-size: min(1.8vh, 1.8vw);
}

.controls .btn-exit {
    color: rgba(255, 255, 255, 0.4);
    padding: 6px 10px;
}

.controls .btn-exit:hover {
    color: #ff6b6b;
    background: rgba(255, 107, 107, 0.15);
}

.controls .btn-exit .btn-icon {
    font-size: min(1.6vh, 1.6vw);
}

.controls .divider {
    width: 1px;
    height: 20px;
    background: rgba(255, 255, 255, 0.1);
    margin: 0 2px;
}

/* ================================================================
   右上角退出按钮（仅电脑显示）
   ================================================================ */
.btn-exit-top {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.4);
    padding: 8px 14px;
    border-radius: 20px;
    cursor: pointer;
    font-size: min(1.5vh, 1.5vw);
    font-family: 'Microsoft YaHei', sans-serif;
    transition: all 0.3s ease;
    opacity: 0;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.btn-exit-top:hover {
    background: rgba(255, 107, 107, 0.2);
    border-color: rgba(255, 107, 107, 0.3);
    color: #ff6b6b;
    opacity: 1 !important;
}

.btn-exit-top.show {
    opacity: 0.5;
}
.btn-exit-top:hover {
    opacity: 1 !important;
}

@media (max-width: 768px) {
    .btn-exit-top {
        display: none !important;
    }
}

/* ================================================================
   网格参考线
   ================================================================ */
.slide.show-grid {
    background-image:
        linear-gradient(rgba(0, 0, 0, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 0, 0, 0.05) 1px, transparent 1px);
    background-size: 5% 5%;
}

.slide.show-grid::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        linear-gradient(rgba(0, 0, 0, 0.08) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 0, 0, 0.08) 1px, transparent 1px);
    background-size: 1% 1%;
    pointer-events: none;
    z-index: 1;
}

/* ================================================================
   预加载遮罩
   ================================================================ */
#preloadOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #ffffff;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: #333;
    transition: opacity 0.6s ease;
}

#preloadOverlay.hidden {
    opacity: 0;
    pointer-events: none;
}

#preloadOverlay .logo {
    margin-bottom: 16px;
}

#preloadOverlay .logo img {
    max-height: 50px;
    width: auto;
    display: block;
    margin: 0 auto;
}

#preloadOverlay .title {
    font-size: min(2.2vh, 2.2vw);
    color: #666;
    margin-bottom: 6px;
    font-weight: 400;
}

#preloadOverlay .status {
    font-size: min(1.8vh, 1.8vw);
    color: #999;
    margin-bottom: 20px;
    font-family: 'Consolas', monospace;
    text-align: center;
    padding: 0 20px;
}

#preloadOverlay .progress-track {
    width: 240px;
    max-width: 70%;
    height: 3px;
    background: #eee;
    border-radius: 2px;
    overflow: hidden;
}

#preloadOverlay .progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    border-radius: 2px;
    transition: width 0.3s ease;
}

#preloadOverlay .btn-start {
    margin-top: 24px;
    padding: 10px 36px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border: none;
    border-radius: 24px;
    color: white;
    font-size: min(2.2vh, 2.2vw);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    opacity: 0;
    transform: translateY(12px);
    pointer-events: none;
}

#preloadOverlay .btn-start.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

#preloadOverlay .btn-start:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 8px 30px rgba(102, 126, 234, 0.35);
}

#preloadOverlay .btn-start:active {
    transform: scale(0.97);
}

#preloadOverlay .skip-link {
    margin-top: 12px;
    color: #ddd;
    font-size: min(1.6vh, 1.6vw);
    cursor: pointer;
    text-decoration: underline;
    transition: color 0.3s ease;
}

#preloadOverlay .skip-link:hover {
    color: #aaa;
}

/* ===== 滑动引导提示 ===== */
.swipe-hint {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    opacity: 0.6;
    animation: bounceSwipe 2s ease-in-out infinite;
}

.swipe-hint .swipe-icon {
    font-size: min(4vh, 4vw);
    display: block;
}

.swipe-hint .swipe-text {
    font-size: min(1.4vh, 1.4vw);
    color: #aaa;
    letter-spacing: 1px;
}

@keyframes bounceSwipe {
    0%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    50% {
        transform: translateY(8px);
        opacity: 0.8;
    }
}

/* ================================================================
   ★★★ 打印样式 - 跳过目录页 ★★★
   ================================================================ */
@media print {
    /* 重置 html, body 打印样式 */
    html, body {
        overflow: visible !important;
        background: #ffffff !important;
        height: auto !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* 播放器容器 */
    .player-wrapper {
        display: block !important;
        height: auto !important;
        width: 100% !important;
        background: #ffffff !important;
        padding: 0 !important;
        overflow: visible !important;
        align-items: flex-start !important;
    }

    /* 幻灯片容器 */
    .slide-container {
        display: block !important;
        width: 100% !important;
        height: auto !important;
        max-width: 100% !important;
        max-height: none !important;
        aspect-ratio: auto !important;
        overflow: visible !important;
        box-shadow: none !important;
        border-radius: 0 !important;
        background: #ffffff !important;
        container-type: none !important;
        position: static !important;
    }

    /* 强制所有幻灯片显示 */
    #slidesWrapper {
        display: block !important;
        width: 100% !important;
        height: auto !important;
        position: static !important;
        overflow: visible !important;
    }

    /* ★★★ 默认隐藏所有幻灯片 ★★★ */
    .slide {
        display: none !important;
    }

    /* ★★★ 只显示非目录页的幻灯片 ★★★ */
    .slide:not(.slide-toc-page) {
        display: block !important;
        position: relative !important;
        page-break-after: always !important;
        page-break-inside: avoid !important;
        width: 100% !important;
        height: 100vh !important;
        max-height: 100vh !important;
        aspect-ratio: 9 / 16 !important;
        margin: 0 auto !important;
        padding: 0 !important;
        opacity: 1 !important;
        transform: none !important;
        background: #ffffff !important;
        overflow: hidden !important;
        box-shadow: none !important;
        border-radius: 0 !important;
        float: none !important;
        clear: both !important;
        border: none !important;
        top: auto !important;
        left: auto !important;
        right: auto !important;
        bottom: auto !important;
        visibility: visible !important;
    }

    /* 强制显示所有元素 */
    .slide .element {
        opacity: 1 !important;
        transform: none !important;
        transition: none !important;
        visibility: visible !important;
        display: block !important;
    }

    .slide .element.show {
        opacity: 1 !important;
        transform: none !important;
    }

    /* 隐藏控制栏和预加载遮罩 */
    .controls-wrapper,
    .btn-exit-top,
    #preloadOverlay,
    .swipe-hint,
    .slide-toc {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }

    /* 确保图片正常显示 */
    .slide .element.image img {
        max-width: 100%;
        max-height: 100%;
        object-fit: contain;
    }

    /* 表格样式保留 */
    .slide .element.table table {
        border-collapse: collapse;
        width: 100% !important;
    }
    .slide .element.table td,
    .slide .element.table th {
        border: 1px solid #ccc;
        padding: 4px 8px;
    }

    /* 去除页面边距 */
    body {
        margin: 0 !important;
        padding: 0 !important;
        background: #ffffff !important;
    }

    /* 所有元素可见 */
    .slide .element.title,
    .slide .element.text,
    .slide .element.small-text,
    .slide .element.image,
    .slide .element.table {
        opacity: 1 !important;
        visibility: visible !important;
    }
}