/* 页面级加载遮罩：全屏阴影 + 居中 CSS 转圈，页面渲染完成后移除 */
.comic-page-loading {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

/* 纯 CSS 转圈：不依赖 iconify 网络资源，加载即显示 */
.comic-page-loading .spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e2e8f0;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: comic-spin 0.8s linear infinite;
}

.comic-page-loading p {
    font-size: 12px;
    color: #6b7280;
}

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

.comic-info-bar {
    display: flex;
    gap: 24px;
    background: #ffffff;
    border-radius: 4px;
    padding: 24px;
    margin-bottom: 24px;
    border: 1px solid #e9edf3;
}

.comic-cover-box {
    width: 200px;
    min-height: 280px;
    align-self: stretch;
    flex-shrink: 0;
    overflow: hidden;
    border-radius: 4px;
    background: #f1f5f9 url('/assets/images/default_cover.png') center/cover no-repeat;
}

.comic-cover-box .comic-cover {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 4px;
    /* 覆盖 common.css 中错误的 .comic-cover 容器样式 */
    position: static;
    padding-top: 0;
    overflow: visible;
    display: block;
}

.comic-meta-box {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

.comic-meta-box .comic-title {
    margin: 0 0 12px;
    font-size: 28px;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 12px;
    line-height: 1.3;
    max-width: 100%;
    min-width: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
    word-break: break-all;
    overflow-wrap: anywhere;
    box-sizing: border-box;
}

.comic-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.category-tag {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 2px;
    font-size: 12px;
    color: #2563eb;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
}

.comic-author {
    font-size: 15px;
    color: #6b7280;
    margin-bottom: 8px;
}

.comic-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #6b7280;
    margin-bottom: 10px;
}

.status-tag {
    display: inline-flex;
    align-items: center;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    line-height: 1.5;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.status-tag.is-serial {
    background: rgba(16, 185, 129, 0.1);
    color: #059669;
    border: 1px solid rgba(16, 185, 129, 0.25);
}

.status-tag.is-end {
    background: rgba(107, 114, 128, 0.08);
    color: #6b7280;
    border: 1px solid rgba(107, 114, 128, 0.2);
}

.comic-stats {
    font-size: 14px;
    color: #6b7280;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px 8px;
}

.stats-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: #475569;
}

.stats-item .iconify {
    font-size: 16px;
    color: #2563eb;
}

.stats-item:first-child .iconify {
    color: #f97316;
}

.stats-divider {
    color: #cbd5e1;
}

.comic-top-bar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 8px;
    height: 48px;
    padding: 0 12px;
    padding-top: env(safe-area-inset-top);
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(15, 23, 42, 0.06);
}

.comic-top-bar .top-back {
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #1e293b;
    text-decoration: none;
    border-radius: 4px;
    transition: background 0.2s;
}

.comic-top-bar .top-back:hover {
    background: rgba(37, 99, 235, 0.1);
}

.comic-top-bar .top-back .iconify {
    font-size: 24px;
}

.comic-top-bar .top-title {
    flex: 1;
    min-width: 0;
    font-size: 16px;
    font-weight: 600;
    color: #0f172a;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
}

.comic-top-bar .top-spacer {
    flex: 0 0 32px;
}

.comic-action-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    gap: 10px;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid rgba(15, 23, 42, 0.08);
    z-index: 100;
}

.action-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 44px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    font-family: inherit;
}

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

.action-favorite {
    flex: 0 0 44px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    color: #64748b;
}

.action-favorite:hover {
    background: #eff6ff;
    border-color: rgba(37, 99, 235, 0.5);
    color: #2563eb;
}

.action-favorite.is-active {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    border-color: transparent;
    color: #fff;
}

.action-favorite.is-active .action-label {
    display: none;
}

.action-favorite .action-label {
    display: none;
}

.action-read {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: #fff;
    position: relative;
    overflow: hidden;
}

.action-read::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.action-read:active {
    transform: scale(0.98);
}

.action-read:hover::before {
    left: 100%;
}

.chapter-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px;
    color: #94a3b8;
    font-size: 13px;
}

.chapter-loading .iconify {
    font-size: 18px;
    animation: spin 1s linear infinite;
}

.chapter-end {
    text-align: center;
    padding: 16px;
    color: #94a3b8;
    font-size: 12px;
}

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

/* 底部操作栏占位，避免内容被遮挡 */
.site-main {
    padding-bottom: 70px;
}

.comic-description {
    background: #ffffff;
    border-radius: 4px;
    padding: 20px;
    border: 1px solid #e9edf3;
}

/* 有广告时（中间隔了 ad-slot），广告自带 12px 上下边距，收回 8px 避免间距过大 */
.ad-slot + .chapter-section {
    margin-top: 8px;
}

.desc-title {
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 12px;
    padding-left: 10px;
    border-left: 3px solid #2563eb;
}

.desc-content {
    color: #6b7280;
    font-size: 14px;
    line-height: 1.8;
    text-overflow: ellipsis;
    word-break: break-all;
    overflow-wrap: anywhere;
    max-width: 100%;
    min-width: 0;
    position: relative; /* 供浮动的展开按钮相对定位 */
}

.desc-content .desc-text {
    display: block;
    max-width: 100%;
    min-width: 0;
}

/* 折叠态：使用 -webkit-line-clamp 截断到三行 */
.desc-content.is-clamped .desc-text.is-clamp-text {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* 展开态：按钮也固定在右下角，和折叠态位置一致 */
.desc-content.is-expanded .desc-toggle {
    display: inline;
    position: absolute;
    right: 0;
    bottom: 0;
    padding-left: 10px;
    animation: none;
    white-space: nowrap;
    background: linear-gradient(to right, transparent, #fff 25%);
}

/* 简介展开/收起按钮：默认隐藏 */
.desc-toggle {
    display: none;
    padding: 0;
    border: 0;
    background: none;
    font-size: 13px;
    font-weight: 600;
    color: #2563eb;
    cursor: pointer;
    user-select: none;
    vertical-align: baseline;
    line-height: inherit;
}

/* 折叠态：按钮绝对定位到第三行右下角，渐变遮挡下方文字 */
.desc-content.is-clamped .desc-toggle.is-float {
    position: absolute;
    right: 0;
    bottom: 0;
    display: inline;
    padding-left: 10px;
    background: linear-gradient(to right, transparent, #fff 25%);
    animation: none;
    z-index: 2;
    white-space: nowrap;
}

.desc-toggle .toggle-icon {
    font-size: 12px;
    transition: transform 0.2s ease;
}

.desc-toggle.is-open .toggle-icon {
    transform: rotate(180deg);
}

@keyframes desc-toggle-in {
    from { opacity: 0; transform: translateY(-2px); }
    to { opacity: 1; transform: translateY(0); }
}

.chapter-section {
    background: #ffffff;
    border-radius: 4px;
    padding: 20px;
    border: 1px solid #e9edf3;
    margin-top: 16px;
}

.chapter-section .section-header {
    margin-bottom: 16px;
}

.chapter-count {
    color: #94a3b8;
    font-size: 13px;
    margin-left: auto;
    margin-right: 12px;
}

.source-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid #eef1f6;
}

.source-tab {
    display: inline-flex;
    align-items: center;
    padding: 6px 16px;
    border-radius: 4px;
    font-size: 13px;
    color: #64748b;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    text-decoration: none;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

.source-tab:hover {
    color: #2563eb;
    background: #eff6ff;
    border-color: #bfdbfe;
}

.source-tab.active {
    color: #fff;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    border-color: transparent;
}

.chapter-list {
    display: block;
    max-height: 600px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    position: relative;
}

/* 正序/倒序切换 */
.chapter-sort {
    display: flex;
    gap: 6px;
}

.sort-btn {
    padding: 4px 14px;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    background: #ffffff;
    color: #64748b;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.sort-btn:hover {
    border-color: #2563eb;
    color: #2563eb;
}

.sort-btn.is-active {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
}

.chapter-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #f8fafc;
    border-radius: 4px;
    text-decoration: none;
    color: inherit;
    transition: all 0.3s ease;
    border: 1px solid transparent;
    margin-bottom: 10px;
    box-sizing: border-box;
}

.chapter-item:hover {
    background: #eff6ff;
    border-color: rgba(37, 99, 235, 0.2);
}

.chapter-num {
    color: #2563eb;
    font-size: 13px;
    font-weight: 500;
    margin-right: 12px;
}

.chapter-title {
    flex: 1;
    color: #334155;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chapter-date {
    color: #94a3b8;
    font-size: 12px;
}

@media (max-width: 768px) {
    .comic-cover-box {
        width: 120px;
        min-height: 168px;
        align-self: stretch;
    }

    .comic-cover-box .comic-cover {
        height: 100%;
    }

    .comic-cover-box .comic-cover {
        height: 100%;
    }

    .comic-meta-box .comic-title {
        font-size: 17px;
        /* 最多两行，过长省略，不超出 comic-info-bar */
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: normal;
        word-break: break-all;
        overflow-wrap: anywhere;
        max-width: 100%;
        min-width: 0;
        width: 100%;
        box-sizing: border-box;
    }
}

/* 猜你喜欢 */
.guess-section {
    margin-top: 24px;
}

/* 横向滑动布局：覆盖全局的 3 列 grid */
.guess-section .comic-grid-3 {
    display: flex;
    grid-template-columns: none;
    gap: 14px;
    margin-bottom: 0;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
    scrollbar-width: none;
}

.guess-section .comic-grid-3::-webkit-scrollbar {
    display: none;
}

.guess-section .comic-card-sm {
    flex: 0 0 110px;
    width: 110px;
    scroll-snap-align: start;
}

.guess-section .card-sm-cover {
    position: relative;
    padding-top: 140%;
    overflow: hidden;
    background: #f1f5f9 url('/assets/images/default_cover.png') center/cover no-repeat;
    border-radius: 4px;
}

.guess-section .card-sm-cover img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* 徽章在右上角（与 index.css / category.css 的 .card-sm-badge 保持一致） */
.guess-section .card-sm-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    padding: 2px 7px;
    border-radius: 2px;
    font-size: 10px;
    color: #fff;
    line-height: 1.4;
}

/* 漫画名叠加在图片底部，带渐变遮罩 */
.guess-section .card-sm-info {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 16px 10px 8px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0.4) 60%, transparent 100%);
    pointer-events: none;
}

.guess-section .card-sm-title {
    font-size: 12px;
    font-weight: 500;
    color: #fff;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.guess-section .card-sm-author {
    display: none;
}
