/**
 * Fullscreen Comic Reader Styles
 */

/* Main overlay - hidden by default */
.comic-reader-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    z-index: 99999;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.comic-reader-overlay.active {
    display: flex;
    opacity: 1;
}

/* Main container */
.comic-reader-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Close button */
.comic-reader-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 10;
    transition: background-color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.comic-reader-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Page counter */
.comic-reader-counter {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    z-index: 10;
    user-select: none;
}

/* Viewport - the visible area for slides */
.comic-reader-viewport {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* Slides container - this moves left/right */
.comic-reader-slides {
    display: flex;
    height: 100%;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
}

/* Individual slide */
.comic-reader-slide {
    flex-shrink: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 80px;
    box-sizing: border-box;
}

.comic-reader-slide img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
    transform-origin: center center;
}

.comic-reader-slide img.zoomed {
    cursor: grab;
}

.comic-reader-slide img.zoomed:active {
    cursor: grabbing;
}

/* Navigation arrows */
.comic-reader-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 10;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
}

.comic-reader-nav:hover {
    background: rgba(255, 255, 255, 0.2);
    opacity: 1;
}

.comic-reader-nav:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.comic-reader-nav-prev {
    left: 20px;
}

.comic-reader-nav-next {
    right: 20px;
}

/* Loading indicator */
.comic-reader-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 5;
}

.comic-reader-loading .spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.comic-reader-overlay.loaded .comic-reader-loading {
    display: none;
}

/* Message display for errors/restrictions */
.comic-reader-message {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    background: rgba(0, 0, 0, 0.95) !important;
    border: 2px solid rgba(255, 255, 255, 0.3) !important;
    border-radius: 12px;
    padding: 40px;
    max-width: 500px;
    width: calc(100% - 40px); /* 20px margin on each side */
    box-sizing: border-box; /* THIS is the key */
    text-align: center;
    z-index: 99999 !important;
}

.comic-reader-message.hidden {
    display: none !important;
}

.comic-reader-message .message-content {
    color: white;
    font-size: 18px;
    line-height: 1.6;
}

.comic-reader-message a {
    color: #4a9eff;
    text-decoration: underline;
    font-weight: 500;
}

.comic-reader-message a:hover {
    color: #6eb4ff;
}

/* Click zones for navigation (invisible areas on left/right of screen) */
.comic-reader-viewport::before,
.comic-reader-viewport::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    width: 30%;
    z-index: 2;
    cursor: pointer;
}

.comic-reader-viewport::before {
    left: 0;
}

.comic-reader-viewport::after {
    right: 0;
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
    .comic-reader-slide {
        padding: 80px 20px 20px 20px;
    }
    
    .comic-reader-nav {
        width: 40px;
        height: 40px;
    }
    
    .comic-reader-nav-prev {
        left: 10px;
    }
    
    .comic-reader-nav-next {
        right: 10px;
    }
    
    .comic-reader-close {
        top: 10px;
        right: 10px;
        width: 40px;
        height: 40px;
    }
    
    .comic-reader-counter {
        top: 10px;
        font-size: 12px;
        padding: 6px 12px;
    }
    
    /* Hide navigation arrows on mobile (rely on swipe instead) */
    .comic-reader-nav {
        opacity: 0.4;
    }
}

/* Prevent body scroll when reader is open */
body.comic-reader-open {
    overflow: hidden;
}

/* Thumbnail navigation */
/* To disable thumbnails, uncomment the next 3 lines:*/
.comic-reader-thumbnails {
    display: none !important;
}

.comic-reader-thumbnails {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.8);
    padding: 10px 0;
    z-index: 11;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
}

.thumbnails-container {
    display: flex;
    gap: 8px;
    padding: 0 20px;
    min-width: min-content;
}

.comic-thumbnail {
    flex-shrink: 0;
    width: 60px;
    height: 80px;
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 4px;
    overflow: hidden;
    transition: all 0.2s ease;
    opacity: 0.6;
    position: relative;
}

.comic-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.comic-thumbnail:hover {
    opacity: 0.9;
    transform: translateY(-2px);
}

.comic-thumbnail.active {
    border-color: #fff;
    opacity: 1;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.comic-thumbnail .page-number {
    position: absolute;
    bottom: 2px;
    right: 2px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 10px;
    padding: 2px 4px;
    border-radius: 2px;
}

/* Hide thumbnails on very small screens */
@media (max-width: 480px) {
    .comic-reader-thumbnails {
        display: none;
    }
}

/* Optional: Style for standalone trigger links (not already in buttons or images) */
a.open-comic-reader:not(.wp-block-button__link):not(.wp-element-button):not(:has(img)) {
    display: inline-block;
    padding: 12px 24px;
    background-color: #0073aa;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

a.open-comic-reader:not(.wp-block-button__link):not(.wp-element-button):not(:has(img)):hover {
    background-color: #005177;
    color: white;
}