/* 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%);
}