/* 全局样式 */
html, body {
    margin: 0;
    padding: 0;
    overflow: hidden; /* 关键：禁止整个页面的滚动条 */
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: #2c3e50; /* 深色背景，突出书本 */
}

/* 书本视口容器 */
.book-viewport {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    padding-bottom: 80px; /* 为下方的控制栏留出空间 */
    box-sizing: border-box;
    transition: padding 0.3s ease;
    background: linear-gradient(135deg, #2c3e50, #34495e); /* 渐变背景 */
}

/* 全屏模式下的视口 */
.book-viewport.fullscreen {
    padding: 10px;
    padding-bottom: 60px;
}

/* 书本容器 */
.flip-book-container {
    position: relative; /* 为角部热区提供定位参考 */
    width: 100%;
    height: 100%;
    max-width: 1200px; /* 限制最大宽度 */
    max-height: 800px; /* 限制最大高度 */
    display: flex;
    justify-content: center;
    align-items: center;
}

/* PageFlip 书本实例 - 简化样式，避免干扰 */
#my-book {
    width: 100%;
    height: 100%;
    position: relative;
}

/* PageFlip 内部元素基础样式 */
.stf__parent {
    width: 100% !important;
    height: 100% !important;
}

.stf__wrapper {
    width: 100% !important;
    height: 100% !important;
}

.stf__block {
    width: 100% !important;
    height: 100% !important;
    perspective: 2000px !important;
}

/* 确保PageFlip项目有正确的3D变换 */
.stf__item {
    transform-style: preserve-3d;
}

/* 修复翻页时可能出现的问题 */
.stf__item.--simple {
    transform: none !important;
}

/* 确保翻页页面有正确的尺寸 */
.stf__item > div,
.stf__item > .page {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* 防止图片在翻页时溢出 */
.stf__item img {
    max-width: 100%;
    max-height: 100%;
    object-fit: cover;
    display: block;
    width: 100%;
    height: 100%;
}

/* 页面图片样式 - 只针对我们生成的页面 */
#my-book .page img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border: none;
    outline: none;
}

/* 确保页面容器样式正确 */
#my-book .page {
    width: 100%;
    height: 100%;
    display: block;
    position: relative;
    overflow: hidden;
    background: white;
}

/* 封面页面样式 */
#my-book .page.cover-page {
    background: white;
}

/* 封底页面样式 */
#my-book .page.back-cover-page {
    background: white;
}

/* 内容页面样式 */
#my-book .page.content-page {
    background: white;
}

/* --- 角部翻页热区 --- */
.corner-hotspot {
    position: absolute;
    width: 15%;
    height: 25%;
    /* background-color: rgba(255, 0, 0, 0.3); */ /* 取消注释以调试热区位置 */
    z-index: 100;
    cursor: pointer;
    transition: background-color 0.3s;
    border-radius: 4px;
}
.corner-hotspot:hover {
    background-color: rgba(52, 152, 219, 0.2);
}
.corner-hotspot.top-left { top: 0; left: 0; }
.corner-hotspot.bottom-left { bottom: 0; left: 0; }
.corner-hotspot.top-right { top: 0; right: 0; }
.corner-hotspot.bottom-right { bottom: 0; right: 0; }

/* --- 控制面板 --- */
.controls {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 15px 0;
    background: linear-gradient(to top, rgba(44, 62, 80, 0.95), rgba(44, 62, 80, 0.8));
    backdrop-filter: blur(10px); /* 现代毛玻璃效果 */
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 25px;
    z-index: 200;
}

.controls button {
    background: linear-gradient(145deg, #34495e, #2c3e50);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #ecf0f1;
    font-size: 20px;
    font-weight: 600;
    cursor: pointer;
    padding: 10px 18px;
    border-radius: 8px;
    transition: all 0.3s ease;
    line-height: 1;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.controls button:hover {
    background: linear-gradient(145deg, #3498db, #2980b9);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

.controls button:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.controls button:disabled {
    color: #7f8c8d;
    cursor: not-allowed;
    background: linear-gradient(145deg, #2c3e50, #34495e);
    transform: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* 自动播放激活状态 */
.controls button#autoplay-btn.active {
    background: linear-gradient(145deg, #e74c3c, #c0392b);
    color: #fff;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 4px 8px rgba(231, 76, 60, 0.3); }
    50% { box-shadow: 0 6px 16px rgba(231, 76, 60, 0.5); }
    100% { box-shadow: 0 4px 8px rgba(231, 76, 60, 0.3); }
}

/* 页面导航 */
.page-nav {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #ecf0f1;
    font-weight: 500;
}

.page-nav input[type="number"] {
    width: 60px;
    padding: 10px 8px;
    text-align: center;
    font-size: 16px;
    font-weight: 600;
    border: 2px solid #34495e;
    border-radius: 6px;
    background: linear-gradient(145deg, #2c3e50, #34495e);
    color: #ecf0f1;
    -moz-appearance: textfield; /* 隐藏增减箭头 */
    transition: all 0.3s ease;
}

.page-nav input[type="number"]:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

.page-nav input[type="number"]::-webkit-outer-spin-button,
.page-nav input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.page-nav button {
    font-size: 14px;
    font-weight: 600;
    padding: 10px 16px;
    background: linear-gradient(145deg, #3498db, #2980b9);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    color: white;
    transition: all 0.3s ease;
}

.page-nav button:hover {
    background: linear-gradient(145deg, #2980b9, #21618c);
    transform: translateY(-1px);
}

/* 响应式设计 */
@media (max-width: 768px) {
    .book-viewport {
        padding: 10px;
        padding-bottom: 70px;
    }
    
    .controls {
        padding: 12px 0;
        gap: 15px;
    }
    
    .controls button {
        font-size: 18px;
        padding: 8px 14px;
    }
    
    .page-nav {
        gap: 8px;
    }
    
    .page-nav input[type="number"] {
        width: 50px;
        padding: 8px 6px;
        font-size: 14px;
    }
    
    .page-nav button {
        font-size: 12px;
        padding: 8px 12px;
    }
    
    .corner-hotspot {
        width: 20%;
        height: 30%;
    }
}

@media (max-width: 480px) {
    .controls {
        gap: 10px;
        padding: 10px 0;
    }
    
    .controls button {
        font-size: 16px;
        padding: 6px 10px;
    }
    
    .corner-hotspot {
        width: 25%;
        height: 35%;
    }
}