/* Story Module Styles */
/*
Theme Name: Betruyen
Version: 2.3.2
*/

:root {
    --td-primary: #ff4b72;
    /* Pink/Coral */
    --td-primary-hover: #e83a5f;
    /* Darker Pink */
    --td-secondary: #222222;
    /* Dark */
    --td-bg-light: #f6f6f6;
    --td-radius: 1rem;
    /* 16px */
    --td-radius-lg: 1.5rem;
    /* 24px */
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 800;
    letter-spacing: -0.025em;
}

.single-post h1.fw-black {
    color: var(--bs-gray-100);
}

/* --- Utilities Custom --- */
.fw-black {
    font-weight: 900;
}

.ls-wide {
    letter-spacing: 0.05em;
}

.cursor-pointer {
    cursor: pointer;
}

/* FIX LỖI ẢNH HEIGHT 0: Bắt buộc ảnh phải fill đầy khung cha */
.object-fit-cover {
    object-fit: cover;
    width: 100%;
    height: 100%;
    display: block;
}

/* --- BOOTSTRAP RATIO CUSTOM FIX --- */
/* Thêm class này để khung ratio-2x3 hoạt động */
.ratio-2x3 {
    --bs-aspect-ratio: 150%;
    /* (3 / 2) * 100% = 150% */
}

/* Rounded & Shadows */
.rounded-4 {
    border-radius: var(--td-radius) !important;
}

.rounded-5 {
    border-radius: var(--td-radius-lg) !important;
}

.shadow-lg-soft {
    box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.1);
}

/* Effects */
.hover-scale {
    transition: transform 0.3s ease;
}

.group:hover .hover-scale {
    transform: scale(1.05);
}

.backdrop-blur {
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

/* Gradients */
.bg-gradient-primary {
    background: linear-gradient(135deg, #ff4b72 0%, #ff7ea5 100%);
}

.bg-gradient-dark {
    background: linear-gradient(to right, #222 0%, #333 100%);
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in {
    animation: fadeIn 0.5s ease-out forwards;
}

/* --- Components --- */

/* Hero Card */
.hero-card {
    position: relative;
    overflow: hidden;
}

.hero-card img.bg-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.4;
    filter: blur(4px);
    transition: transform 0.7s ease;
}

.hero-card:hover img.bg-img {
    transform: scale(1.1);
}

/* Story Card (Listing) */
.story-card-img {
    position: relative;
    aspect-ratio: 2/3;
    /* Tỷ lệ chuẩn cho truyện */
    overflow: hidden;
    border-radius: var(--td-radius);
    background: #e2e8f0;
    /* Màu nền chờ load ảnh */
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.story-card-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8) 0%, transparent 50%);
    opacity: 0;
    transition: opacity 0.3s ease;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 1rem;
    z-index: 2;
}

.group:hover .story-card-overlay {
    opacity: 1;
}

.story-card-btn {
    background: white;
    color: #0f172a;
    font-weight: 700;
    font-size: 0.75rem;
    padding: 0.5rem 1rem;
    border-radius: 99px;
    transform: translateY(10px);
    transition: transform 0.3s ease;
}

.group:hover .story-card-btn {
    transform: translateY(0);
}

/* --- SINGLE STORY COVER --- */
/* Class riêng cho ảnh bìa trang chi tiết */
.single-story-cover-wrapper {
    position: relative;
    border-radius: var(--td-radius);
    overflow: hidden;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    border: 4px solid #fff;
    background: #fff;
    margin: 0 auto;
}

/* Mặc định Mobile: Tỷ lệ 2:3 */
.single-story-cover-wrapper {
    aspect-ratio: 2/3;
    width: 100%;
}

/* DESKTOP (Width >= 992px): FIX cứng 300x400px theo yêu cầu */
@media (min-width: 992px) {
    .single-story-cover-wrapper {
        width: 300px;
        height: 400px;
        aspect-ratio: auto;
        /* Bỏ aspect ratio để dùng px cứng */
    }
}

/* --- BOOK COVER FALLBACK --- */
.book-cover-fallback {
    width: 100%;
    height: 100%;
    background-color: #faebd7;
    /* Màu be */
    border: 1px solid #e0d0b8;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    text-align: center;
    overflow: hidden;
    transition: transform 0.3s ease;
}

/* Viền trang trí bên trong */
.book-cover-fallback::after {
    content: '';
    position: absolute;
    top: 8px;
    left: 8px;
    right: 8px;
    bottom: 8px;
    border: 2px solid #fff;
    border-radius: 8px;
    pointer-events: none;
}

/* Text tên truyện */
.book-cover-fallback span {
    font-family: 'Merriweather', serif;
    font-weight: 800;
    color: #5d4037;
    font-size: 1.25rem;
    line-height: 1.4;
    text-transform: uppercase;
    display: -webkit-box;
    -webkit-line-clamp: 5;
    line-clamp: 5;
    -webkit-box-orient: vertical;
    overflow: hidden;
    z-index: 1;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
}

.group:hover .book-cover-fallback {
    transform: scale(1.05);
}

/* Badges */
.badge-hot {
    background-color: rgba(244, 63, 94, 0.1);
    color: #e11d48;
    border: 1px solid rgba(244, 63, 94, 0.2);
}

.badge-vip {
    background-color: rgba(245, 158, 11, 0.1);
    color: #d97706;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.badge-full {
    background-color: rgba(16, 185, 129, 0.1);
    color: #059669;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

/* Pagination Override */
.pagination {
    gap: 6px;
}

.page-link {
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #64748b;
    background: white;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.page-link:hover {
    background-color: #f1f5f9;
    color: var(--td-primary);
}

.page-item.active .page-link {
    background-color: var(--td-primary);
    color: white;
}

/* Buttons */
.btn-primary {
    background-color: var(--td-primary);
    border-color: var(--td-primary);
}

.btn-primary:hover {
    background-color: var(--td-primary-hover);
    border-color: var(--td-primary-hover);
}

/* Utilities */
.object-fit-cover {
    object-fit: cover;
}

.blur-lg {
    filter: blur(20px);
}

.scale-110 {
    transform: scale(1.1);
}

.backdrop-blur {
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.bg-gradient-to-t {
    background: linear-gradient(to top, #212529 0%, rgba(33, 37, 41, 0.1) 100%);
}

.text-shadow {
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.ls-wide {
    letter-spacing: 1px;
}

/* Chapter List */
.chapter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 10px;
}

.chap-item {
    transition: all 0.2s;
    font-size: 0.95rem;
}

.chap-item:hover {
    background-color: #f8f9fa;
    /* bg-light */
    color: var(--bs-primary) !important;
}

/* Reading Settings */
.bg-sepia {
    background-color: #f4ecd8 !important;
    color: #5b4636 !important;
}

.reading-container {
    transition: background-color 0.3s, color 0.3s;
}

/* Sticky Bar Auto Hide */
.reading-bar {
    transition: transform 0.3s;
}

.reading-bar.hidden {
    transform: translateY(-100%);
}

/* Chapter Search Input (ztruyen style) */
.td-chap-search-wrap {
    position: relative;
    width: 230px;
    max-width: 100%;
}

#search-chap-input {
    background-color: #ffffff !important;
    border: 1px solid #cbd5e1 !important;
    color: #0f172a !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    transition: all 0.2s ease;
    font-size: 0.85rem;
}

#search-chap-input::placeholder {
    color: #94a3b8 !important;
}

#search-chap-input:focus {
    border-color: var(--td-primary, #ff4b72) !important;
    box-shadow: 0 0 0 3px rgba(255, 75, 114, 0.15) !important;
    background-color: #ffffff !important;
    color: #0f172a !important;
    outline: none;
}

body.dark-mode #search-chap-input {
    background-color: #1e293b !important;
    border-color: #334155 !important;
    color: #f8fafc !important;
}

body.dark-mode #search-chap-input::placeholder {
    color: #64748b !important;
}

body.dark-mode #search-chap-input:focus {
    background-color: #1e293b !important;
    color: #f8fafc !important;
    border-color: var(--td-primary, #ff4b72) !important;
    box-shadow: 0 0 0 3px rgba(255, 75, 114, 0.25) !important;
}

/* Story Synopsis Expand / Collapse */
#story-synopsis-content {
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.story-synopsis-fade {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 80px;
    background: linear-gradient(to top, #ffffff 15%, rgba(255, 255, 255, 0) 100%);
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

body.dark-mode .story-synopsis-fade,
body.theme-dark .story-synopsis-fade,
body.theme-night .story-synopsis-fade,
body.theme-onyx .story-synopsis-fade,
body.theme-dusk .story-synopsis-fade {
    background: linear-gradient(to top, #1e1e24 15%, rgba(30, 30, 36, 0) 100%);
}

body.theme-sepia .story-synopsis-fade {
    background: linear-gradient(to top, #f4ecd8 15%, rgba(244, 236, 216, 0) 100%);
}

body.theme-silver .story-synopsis-fade {
    background: linear-gradient(to top, #cbd5e1 15%, rgba(203, 213, 225, 0) 100%);
}

.story-synopsis-expanded .story-synopsis-fade {
    opacity: 0;
    visibility: hidden;
}

#btn-toggle-synopsis {
    transition: transform 0.2s ease, opacity 0.2s ease;
    cursor: pointer;
    font-size: 0.95rem;
}

#btn-toggle-synopsis:hover {
    transform: translateY(-1px);
    opacity: 0.9;
}