/* ============ 阅读页样式 ============ */

* {
    -webkit-tap-highlight-color: transparent;
}

body {
    background: #f5f7fb;
    user-select: none;
}

/* 阅读页 main 占满整宽，无 padding */
.site-main {
    max-width: 100%;
    margin: 0;
    padding: 0;
}

/* ============ 顶部栏（默认隐藏，单击切换） ============ */
.chapter-header {
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(15, 23, 42, 0.06);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    transform: translateY(-100%);
    transition: transform 0.28s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.chapter-header.show {
    transform: translateY(0);
}

.chapter-nav {
    max-width: 1400px;
    margin: 0 auto;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #475569;
    text-decoration: none;
    font-size: 14px;
    padding: 6px 10px;
    border-radius: 4px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.nav-back:active {
    background: rgba(37, 99, 235, 0.1);
}

.nav-back .iconify {
    font-size: 18px;
}

.chapter-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 0;
    overflow: hidden;
    text-align: center;
}

.comic-name,
.chapter-name {
    display: block;
    max-width: 100%;
    width: 100%;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.comic-name {
    font-size: 14px;
    color: #1f2937;
    font-weight: 500;
    line-height: 1.3;
}

.chapter-name {
    font-size: 12px;
    color: #94a3b8;
    margin-top: 2px;
    line-height: 1.3;
}

.btn-chapter-list {
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 8px;
    color: #475569;
    cursor: pointer;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-chapter-list .iconify {
    font-size: 18px;
}

.btn-chapter-list:active {
    background: rgba(15, 23, 42, 0.06);
}

/* ============ 阅读内容区 ============ */
.chapter-content {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 0;
}

/* 底部广告强制跟随内容流：仅覆盖广告主体（ins/iframe/img），保留广告内部定位（如关闭按钮） */
.ad-slot-pos-4,
.ad-slot-pos-4 ins,
.ad-slot-pos-4 iframe,
.ad-slot-pos-4 img,
.ad-slot-pos-5,
.ad-slot-pos-5 ins,
.ad-slot-pos-5 iframe,
.ad-slot-pos-5 img {
    position: relative !important;
    bottom: auto !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    display: block;
    margin: 12px 0;
    text-align: center;
}

.image-wrapper {
    width: 100%;
    margin: 0;
    position: relative;
    background: #eef1f6;
    min-height: 240px;
}

.chapter-image {
    width: 100%;
    height: auto;
    display: block;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.chapter-image.loaded {
    opacity: 1;
}

.image-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: #94a3b8;
    background: #eef1f6;
    z-index: 1;
    transition: opacity 0.3s ease;
}

.image-placeholder .iconify {
    font-size: 32px;
    color: #94a3b8;
}

.image-placeholder .iconify.placeholder-spin,
.image-placeholder .placeholder-spin {
    animation: spin 1s linear infinite;
    display: inline-flex;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.image-placeholder .placeholder-text {
    font-size: 12px;
    color: #94a3b8;
}

.image-wrapper.loaded .image-placeholder {
    opacity: 0;
    pointer-events: none;
}

/* 图片加载完成后取消最小高度，避免底部露出灰色占位背景造成"间距" */
.image-wrapper.loaded {
    min-height: 0;
}

/* ============ 底部栏（默认隐藏，单击切换） ============ */
.chapter-footer-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid rgba(15, 23, 42, 0.08);
    padding: 10px 16px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    z-index: 100;
    transform: translateY(100%);
    transition: transform 0.28s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.chapter-footer-bar.show {
    transform: translateY(0);
}

.bar-btn {
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 10px 14px;
    color: #475569;
    cursor: pointer;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.bar-btn:active {
    background: rgba(15, 23, 42, 0.06);
}

.bar-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.bar-btn .iconify {
    font-size: 18px;
}

.page-indicator {
    font-size: 13px;
    color: #94a3b8;
    font-variant-numeric: tabular-nums;
}

#currentPage {
    color: #2563eb;
    font-weight: 600;
}

/* ============ 章节列表弹窗 ============ */
.chapter-list-modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: stretch;
    justify-content: flex-start;
    visibility: hidden;
    opacity: 0;
    transition: visibility 0s linear 0.28s, opacity 0.28s ease;
}

.chapter-list-modal.show {
    visibility: visible;
    opacity: 1;
    transition: visibility 0s linear 0s, opacity 0.28s ease;
}

.modal-mask {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    opacity: 0;
    transition: opacity 0.28s ease;
}

.chapter-list-modal.show .modal-mask {
    opacity: 1;
}

.modal-panel {
    position: relative;
    width: 75vw;
    max-width: 420px;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.chapter-list-modal.show .modal-panel {
    transform: translateX(0);
}

.modal-header {
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid #eef1f6;
    flex-shrink: 0;
}

.modal-title {
    font-size: 15px;
    color: #1f2937;
    font-weight: 600;
    flex: 1;
    min-width: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-all;
    line-height: 1.3;
}

.modal-count {
    font-size: 12px;
    color: #94a3b8;
    flex: none;
    flex-shrink: 0;
}

.modal-close {
    background: transparent;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 4px;
    display: inline-flex;
}

.modal-close .iconify {
    font-size: 20px;
}

.modal-search {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f5f7fb;
    flex-shrink: 0;
}

.modal-search .iconify {
    font-size: 18px;
    color: #94a3b8;
}

.modal-search input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #1f2937;
    font-size: 13px;
}

.modal-search input::placeholder {
    color: #9aa3b2;
}

/* ============ 虚拟滚动列表 ============ */
.virtual-list {
    flex: 1;
    overflow-y: auto;
    position: relative;
    -webkit-overflow-scrolling: touch;
    margin-top: 8px; /* 与上方搜索框留间距（对称小说目录弹窗） */
}

.virtual-spacer {
    position: relative;
    width: 100%;
}

.virtual-items {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
}

.v-item {
    height: 56px;
    padding: 0 16px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid #f1f5f9;
    cursor: pointer;
    box-sizing: border-box;
    background: #ffffff;
}

.v-item:active {
    background: #eff6ff;
}

.v-item.active {
    background: #eff6ff;
}

.v-item-title {
    font-size: 13px;
    color: #475569;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.v-item.active .v-item-title {
    color: #2563eb;
    font-weight: 500;
}

.v-empty {
    padding: 40px 16px;
    text-align: center;
    color: #94a3b8;
    font-size: 13px;
}

/* ============ 响应式 ============ */
@media (max-width: 768px) {
    .chapter-nav {
        padding: 10px 12px;
        gap: 8px;
    }

    .nav-back-text {
        display: none;
    }

    .chapter-footer-bar {
        padding: 8px 12px;
    }

    .bar-btn {
        padding: 8px 12px;
        font-size: 12px;
    }
}
