/* reader.css - Complete version with proper viewport sizing */
* { 
    margin: 0; 
    padding: 0; 
    box-sizing: border-box; 
}

:root {
    --bg-primary: #0f0f0f;
    --bg-secondary: #1a1a1a;
    --accent-red: #ff4444;
    --text-primary: #ffffff;
    --text-secondary: #aaaaaa;
    --text-muted: #666666;
    --border-color: #333333;
}

body { 
    background: var(--bg-primary); 
    color: var(--text-primary); 
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
}

/* Header - matches old styles */
.header {
    background: var(--bg-secondary);
    padding: 12px 20px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    font-size: 18px;
    font-weight: 800;
    color: var(--accent-red);
    text-decoration: none;
    letter-spacing: 1px;
}

.chapter-info {
    font-size: 14px;
    color: var(--text-muted);
}

.live-cta {
    background: var(--accent-red);
    color: white;
    padding: 8px 20px;
    border-radius: 25px;
    text-decoration: none;
    font-weight: bold;
}

.live-cta:hover {
    background: #ff3333;
}

/* Main Reader Container */
.reader-container {
    margin-top: 50px;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 20px 80px;
}

.chapter-title {
    font-size: 24px;
    color: var(--text-primary);
    margin: 20px;
    text-align: center;
    font-weight: 600;
}

/* CRITICAL: Manga Viewport with proper height calculation */
.manga-viewport {
    position: relative;
    width: 100%;
    max-width: 900px;
    height: calc(100vh - 240px);  /* Matches old styles */
    max-height: 80vh;  /* Matches old styles */
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: var(--bg-secondary);
    border-radius: 8px;
    overflow: hidden;
}

/* Manga Page Image */
.manga-page {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.manga-page.loaded {
    opacity: 1;
}

/* Loading indicator */
.loading {
    position: absolute;
    color: var(--text-muted);
    font-size: 14px;
}
/* Navigation Controls - Fixed to align in one line */
.navigation-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 30px;
    margin-top: 30px;
}

.nav-btn {
    display: inline-flex;  /* Changed from flex to inline-flex */
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    white-space: nowrap;  /* Prevent text wrapping */
}

.nav-btn:hover:not(.disabled) {
    background: #252525;
    border-color: var(--accent-red);
}

.nav-btn.disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;  /* Properly disable clicking */
}

.nav-btn svg {
    width: 20px;  /* Reduced from 24px */
    height: 20px;
    flex-shrink: 0;  /* Prevent SVG from shrinking */
}

.page-indicator {
    font-size: 14px;
    color: var(--text-secondary);
    min-width: 100px;
    text-align: center;
    white-space: nowrap;  /* Keep "Page X of Y" on one line */
}
.navigation-hint {
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
    margin-top: 10px;
}

/* Tap Zones */
.tap-zones {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    pointer-events: none;
}

.tap-zone {
    flex: 1;
    pointer-events: auto;
}

.tap-zone.prev {
    cursor: w-resize;
}

.tap-zone.next {
    cursor: e-resize;
}

/* Desktop/Mobile visibility */
.desktop-only {
    display: block;
}

.mobile-only {
    display: none;
}

/* Mobile Navigation (hidden by default) */
/* Mobile Navigation (hidden by default) */
.mobile-navigation {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 10px;
    display: none;
    justify-content: space-between;
    align-items: center;
    z-index: 100;
}

/* Only show mobile nav on mobile */
@media (max-width: 768px) {
    .horizontal-mode .mobile-navigation {
        display: flex;
    }
}

.mobile-nav-btn {
    padding: 8px 16px;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}

.mobile-nav-btn.disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.mobile-page-indicator {
    color: var(--text-secondary);
    font-size: 13px;
    min-width: 70px;
    text-align: center;
}

/* ============ VIEW TOGGLE ============ */

.view-toggle {
    display: flex;
    gap: 5px;
}

.view-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.view-btn:hover {
    border-color: var(--text-secondary);
    color: var(--text-secondary);
}

.view-btn.active {
    background: var(--accent-red);
    border-color: var(--accent-red);
    color: white;
}

/* ============ VERTICAL MODE ============ */

.vertical-mode .manga-viewport {
    height: auto;
    max-height: none;
    flex-direction: column;
    gap: 20px;
}

.vertical-mode .manga-page-wrapper {
    width: 100%;
    display: block;
}

.vertical-mode .manga-page {
    width: 100%;
    height: auto;
    max-width: 900px;
    margin: 0 auto;
    display: block;
}

.vertical-mode .tap-zones {
    display: none;
}

/* ============ HORIZONTAL MODE ============ */

.horizontal-mode .manga-viewport {
    height: calc(100vh - 240px);
    max-height: 80vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.horizontal-mode .manga-page-wrapper {
    display: none;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
}

.horizontal-mode .manga-page-wrapper.active {
    display: flex;
}

.horizontal-mode .manga-page {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}
/* ============ CHAPTER END CTA ============ */

.chapter-end {
    text-align: center;
    padding: 40px 20px;
    margin-top: 20px;
}

.chapter-end p {
    color: var(--text-secondary);
    margin-bottom: 20px;
    font-size: 18px;
}

.chapter-end .btn {
    display: inline-block;
    background: var(--accent-red);
    color: white;
    padding: 12px 30px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: bold;
}

.chapter-end .btn:hover {
    background: #ff3333;
}

/* ============ HORIZONTAL CONTROLS ============ */

#horizontalControls {
    display: none;
}

.horizontal-mode #horizontalControls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 30px;
    margin-top: 20px;
}

/* ============ MOBILE OVERRIDES ============ */

@media (max-width: 768px) {
    .view-toggle {
        display: flex;
    }
    
    .vertical-mode .manga-page {
        max-width: 100%;
        padding: 5px 0;
    }
    
    .horizontal-mode .manga-viewport {
        height: auto;
        max-height: calc(100vh - 120px);
    }
    
    .horizontal-mode #mobileNav {
        display: flex;
    }
    
    .vertical-mode #mobileNav {
        display: none;
    }
    
    .chapter-end {
        padding: 30px 15px 100px;
    }
}
/* Responsive Design - Mobile */
@media (max-width: 768px) {
    .header {
        padding: 10px 15px;
    }
    
    .logo {
        font-size: 16px;
    }
    
    .chapter-info {
        font-size: 12px;
    }
    
    .chapter-title {
        font-size: 18px;
        margin: 10px;
        padding: 0 15px;
    }
    
    .reader-container {
        padding: 10px 0;
        margin-top: 45px;
    }
    
    /* CRITICAL MOBILE FIX: Let viewport size naturally to image */
    .manga-viewport {
        height: auto;
        max-height: none;
        width: 100vw;
        max-width: 100vw;
        background: var(--bg-primary);
        border-radius: 0;
        margin: 0;
        display: block;
    }
    
    /* Make image fill width naturally on mobile */
    .manga-page {
        width: 100%;
        height: auto;
        max-width: 100%;
        max-height: none;
        object-fit: contain;
        padding: 10px 0px;
    }
    
    /* Disable tap zones on mobile */
    .tap-zones {
        display: none;
    }
    
    .desktop-only {
        display: none !important;
    }
    
    .mobile-only {
        display: block;
    }
    
    .mobile-navigation {
        display: flex;
    }
    
    .navigation-controls {
        display: none;
    }
}

/* Large Desktop */
@media (min-width: 1400px) {
    .manga-viewport {
        max-width: 1000px;
    }
}

/* Desktop specific minimum height */
@media (min-width: 769px) {
    .manga-viewport {
        min-height: 500px;
    }
}

/* Chapter title link */
a.chapter-title {
    color: var(--text-primary);
    text-decoration: none;
}
a.chapter-title:visited,
a.chapter-title:hover,
a.chapter-title:active {
    color: var(--text-primary);
}
a.chapter-title:hover {
    text-decoration: underline;
}

/* Promo page inline */
.promo-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    padding: 40px 20px;
    text-align: center;
}

.promo-page .offer-badge {
    background: var(--accent-red);
    color: white;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: bold;
    margin-bottom: 20px;
}

.promo-page h2 {
    font-size: 28px;
    margin-bottom: 12px;
}

.promo-page .offer-desc {
    color: var(--text-secondary);
    font-size: 16px;
    max-width: 400px;
    margin-bottom: 24px;
}

.promo-page .price-struck {
    color: var(--text-muted);
    text-decoration: line-through;
    font-size: 18px;
    margin-right: 10px;
}

.promo-page .price-free {
    color: var(--accent-red);
    font-size: 32px;
    font-weight: bold;
}

.promo-page .price-note {
    display: block;
    color: var(--text-muted);
    font-size: 14px;
    margin-top: 4px;
}

.promo-page .btn-primary {
    background: var(--accent-red);
    color: white;
    padding: 14px 32px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: bold;
    font-size: 16px;
}

.promo-page .skip-link {
    color: var(--text-muted);
    font-size: 14px;
    margin-top: 20px;
    text-decoration: underline;
}

/* Discord CTA page */
.discord-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    padding: 40px 20px;
    text-align: center;
}

.discord-page h2 {
    font-size: 24px;
    margin-bottom: 12px;
}

.discord-page p {
    color: var(--text-secondary);
    max-width: 400px;
    margin-bottom: 24px;
}

.discord-page .btn-discord {
    background: #5865F2;
    color: white;
    padding: 14px 32px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: bold;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}
/* View Toggle Float Button */
.view-toggle-float {
    position: fixed;
    bottom: 80px;
    right: 20px;
    z-index: 999;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 25px;
    padding: 10px 16px;
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.view-toggle-float:hover {
    background: var(--accent-red);
    border-color: var(--accent-red);
    color: white;
}

.view-toggle-float svg {
    width: 16px;
    height: 16px;
}

@media (max-width: 768px) {
    .vertical-mode .view-toggle-float {
        bottom: 20px;
        padding: 8px 12px;
        font-size: 11px;
    }
}

/* Chapter End Section */
.chapter-end {
    text-align: center;
    padding: 60px 20px;
    border-top: 1px solid var(--border-color);
    margin-top: 40px;
}

.chapter-end p {
    font-size: 18px;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.chapter-end-buttons {
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
}

.chapter-end-buttons .btn {
    min-width: 180px;
}

/* Hide chapter end in horizontal mode */
.horizontal-mode .chapter-end {
    display: none;
}

/* Promo Overlay */
.promo-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-primary);
    z-index: 1000;
    overflow-y: auto;
}

.promo-overlay.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.promo-interstitial {
    width: 100%;
    max-width: 500px;
    padding: 40px 20px;
}

.promo-content {
    text-align: center;
}

.promo-content h2 {
    font-size: 28px;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.promo-content p {
    color: var(--text-secondary);
    margin-bottom: 24px;
    line-height: 1.6;
    font-size: 16px;
}

.promo-image {
    width: 100%;
    max-width: 350px;
    border-radius: 12px;
    margin-bottom: 24px;
}

.offer-badge {
    display: inline-block;
    background: var(--accent-red);
    color: white;
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 20px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.offer-desc {
    font-size: 15px;
}

.price-block {
    margin: 24px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.price-struck {
    text-decoration: line-through;
    color: var(--text-muted);
    font-size: 20px;
}

.price-free {
    font-size: 36px;
    font-weight: 700;
    color: var(--accent-green, #22c55e);
}

.price-note {
    font-size: 14px;
    color: var(--text-secondary);
    width: 100%;
}

.livestream-countdown {
    background: var(--bg-secondary);
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 28px;
    border: 1px solid var(--border-color);
}

.livestream-countdown .countdown-label {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.livestream-countdown .countdown-time {
    font-size: 28px;
    font-weight: 700;
    color: var(--accent-red);
}

.promo-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
}

.promo-buttons .btn {
    min-width: 250px;
    padding: 16px 32px;
    font-size: 16px;
}

.promo-buttons .btn-primary {
    background: var(--accent-red);
    color: white;
    border: none;
}

.promo-buttons .btn-primary:hover {
    background: var(--accent-red-hover, #dc2626);
}

.promo-buttons .btn-secondary {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.promo-buttons .btn-secondary:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* A/B Test variants hidden by default */
[data-v] {
    display: none;
}

/* Hide prev chapter button if no prev chapter */
#prevChapterBtn[href="null"],
#prevChapterBtn[href=""] {
    display: none;
}
/* Skip link button reset */
button.skip-link {
    background: none;
    border: 1px solid var(--border-color);
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

button.skip-link:hover {
    background: var(--bg-secondary);
    border-color: var(--text-secondary);
}

a.skip-link {
    display: inline-block;
    padding: 10px 20px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    transition: all 0.2s;
}

a.skip-link:hover {
    background: var(--bg-secondary);
    border-color: var(--text-secondary);
}

/* Promo page images */
.promo-image {
    width: 100%;
    max-width: 300px;
    border-radius: 12px;
    margin-bottom: 20px;
}

/* Countdown block styling */
.countdown-block {
    background: var(--bg-secondary);
    padding: 16px 24px;
    border-radius: 12px;
    margin-bottom: 24px;
    border: 1px solid var(--border-color);
    text-align: center;
}

.countdown-block .countdown-label {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.countdown-block .countdown-time {
    font-size: 28px;
    font-weight: 700;
    color: var(--accent-red);
}

/* Price main styling */
.price-main {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
}

/* Chapter end buttons */
.chapter-end-nav {
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 30px;
    padding: 30px 20px;
    border-top: 1px solid var(--border-color);
}

.chapter-end-nav .btn {
    padding: 12px 24px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s;
}

.chapter-end-nav .btn-primary {
    background: var(--accent-red);
    color: white;
}

.chapter-end-nav .btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

/* CTA pulse animation */
@keyframes ctaPulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 68, 68, 0.7); }
    50% { transform: scale(1.05); box-shadow: 0 0 0 10px rgba(255, 68, 68, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 68, 68, 0); }
}

.btn-primary.pulse {
    animation: ctaPulse 0.6s ease-out;
}
.btn-secondary {
    display: block;
    margin-top: 15px;
    padding: 12px 24px;
    background: transparent;
    border: 1px solid var(--text-secondary);
    border-radius: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s;
}

.btn-secondary:hover {
    border-color: var(--text-primary);
    color: var(--text-primary);
}
/* Promo Popup */
.promo-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.promo-popup {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    max-width: 400px;
    width: 100%;
    padding: 40px 30px;
    position: relative;
    text-align: center;
}

.popup-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 28px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 30px;
    height: 30px;
}

.popup-close:hover {
    color: var(--text-primary);
}

.popup-content .offer-badge {
    display: inline-block;
    background: var(--accent-red);
    color: white;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: bold;
    margin-bottom: 15px;
}

.popup-content h2 {
    font-size: 24px;
    margin: 0 0 10px;
    color: var(--text-primary);
}

.popup-content p {
    color: var(--text-secondary);
    font-size: 15px;
    margin-bottom: 25px;
    line-height: 1.5;
}

.popup-content .btn-primary {
    display: block;
    width: 100%;
    padding: 14px 20px;
    margin-bottom: 15px;
    background: var(--accent-red);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: bold;
    font-size: 16px;
}

.popup-content .btn-primary:hover {
    background: #ff3333;
}

.popup-dismiss {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 14px;
    cursor: pointer;
    text-decoration: underline;
}

.popup-dismiss:hover {
    color: var(--text-secondary);
}