/**
 * ============================================
 * REAL3D FLIPBOOK - PRODUCTION CSS
 * ============================================
 * Professional WordPress Plugin Stylesheet
 * Version: 1.0.0
 * 
 * Features:
 * - 3D Flipbook Viewer with Page Turning Animation
 * - Bookshelf Interface with Magazine Display
 * - Consistent Desktop Layout Across All Devices
 * - Touch-Optimized Horizontal Scrolling
 * - Smooth Animations and Transitions
 * - Professional Metallic Shelf Design
 * 
 * Responsive Strategy:
 * - Desktop: Full layout with hover effects
 * - Tablet: Same layout with horizontal scroll
 * - Mobile: Same layout with touch-optimized scroll
 * 
 * Performance Optimized:
 * - Hardware-accelerated transforms
 * - Optimized animations
 * - Efficient selectors
 * - Minimal repaints
 * 
 * Browser Support:
 * - Chrome/Edge (latest)
 * - Firefox (latest)
 * - Safari (latest)
 * - Mobile browsers (iOS/Android)
 * ============================================
 */

/* ============================================
   BASE CONTAINER STYLES
   ============================================ */

.real3d-flipbook-container {
    position: relative;
    margin: 20px auto;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    background: #f8f9fa;
    max-width: 100%;
    width: 100%;
    /* Performance optimization */
    will-change: transform;
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

/* ============================================
   BOOKSHELF STYLE CONTAINER
   ============================================
   Professional magazine shelf display
   ============================================ */

.real3d-flipbook-container.bookshelf-style {
    background: #ffffff;
    border: none;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
    position: relative;
    min-height: 400px;
    height: auto !important;
    overflow-x: hidden;
    overflow-y: visible;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
}

.real3d-flipbook-container.bookshelf-style::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: transparent;
    pointer-events: none;
    opacity: 1;
}

/* ============================================
   BOOKSHELF SHELVES CONTAINER
   ============================================ */

.bookshelf-shelves {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 50px 10px 50px 10px;
    position: relative;
    height: auto;
    min-height: auto;
    justify-content: flex-start;
    align-items: center;
    width: 100%;
    max-width: 100%;
    overflow: visible;
    box-sizing: border-box;
}

/* ============================================
   INDIVIDUAL SHELF STYLING
   ============================================
   Metallic shelf with magazine placement
   ============================================ */

.bookshelf-shelf {
    display: flex;
    gap: 20px;
    align-items: flex-end;
    min-height: 200px;
    padding: 0 20px;
    border: none;
    border-radius: 0;
    box-shadow: none;
    position: relative;
    margin: 0 auto 50px auto;
    justify-content: center;
    width: 100%;
    max-width: 800px;
    z-index: 1;
    /* Performance: GPU acceleration */
    transform: translateZ(0);
    padding-bottom: 85px;
}

.bookshelf-shelf::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 0;
    background: transparent;
    box-shadow: none;
}

.bookshelf-shelf::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 80px;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: -1;
    border-radius: 0;
}

/* Ensure first shelf has proper spacing */
.bookshelf-shelf:first-child {
    margin-top: 0;
}

/* ============================================
   MAGAZINE/BOOK ITEMS
   ============================================
   Individual book styling with 3D effects
   ============================================ */

.flipbook-item {
    position: relative;
    cursor: pointer;
    transition: all 0.3s ease;
    transform-origin: bottom center;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 120px;
    max-width: 140px;
    perspective: 1000px;
    margin: 0;
    z-index: 10;
    flex-shrink: 0;
    margin-bottom: -16px;
    /* Performance: Hardware acceleration */
    will-change: transform;
    transform: translateZ(0);
}

.flipbook-item:hover {
    transform: translateY(-8px) scale(1.02);
    z-index: 15;
}

.flipbook-item.selected {
    transform: translateY(-12px) scale(1.03);
    z-index: 20;
}

/* ============================================
   BOOK COVERS
   ============================================ */

.flipbook-cover {
    width: 100%;
    height: 180px;
    background: transparent;
    border-radius: 0;
    box-shadow: none;
    position: relative;
    overflow: hidden;
    border: none;
    transition: all 0.3s ease;
    transform-style: preserve-3d;
    /* Performance optimization */
    backface-visibility: hidden;
}

.flipbook-cover:hover {
    box-shadow: none;
    transform: translateY(-2px);
}

.flipbook-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.flipbook-cover:hover img {
    transform: scale(1.02);
}

/* ============================================
   BOOK TITLES & METADATA
   ============================================ */

.flipbook-title {
    margin-top: 8px;
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    color: #333;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.2;
    padding: 0 3px;
}

/* Category Badge */
.flipbook-category {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.flipbook-item:hover .flipbook-category {
    opacity: 1;
}

/* Link Indicator */
.flipbook-item.has-link .flipbook-cover::after {
    content: '🔗';
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 6px 8px;
    border-radius: 50%;
    font-size: 14px;
    opacity: 0;
    transition: all 0.3s ease;
    transform: scale(0.8);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.flipbook-item.has-link:hover .flipbook-cover::after {
    opacity: 1;
    transform: scale(1);
}

/* ============================================
   SHELF LABELS & ACCESSORIES
   ============================================ */

.bookshelf-shelf-label {
    position: absolute;
    top: -25px;
    left: 10px;
    background: rgba(139, 69, 19, 0.9);
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* ============================================
   RESPONSIVE DESIGN - CONSISTENT ACROSS ALL DEVICES
   ============================================
   Maintains desktop layout on all screen sizes
   with horizontal scroll for smaller devices
   ============================================ */

/* Base Container - All Devices */
.real3d-flipbook-container.bookshelf-style {
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    scroll-behavior: smooth;
}

/* Bookshelf Shelves - Consistent Layout */
.bookshelf-shelves {
    min-width: 800px; /* Minimum width to maintain desktop layout */
    overflow-x: visible;
    padding: 0 20px;
}

/* Shelf - Consistent Across All Devices */
.bookshelf-shelf {
    min-width: 800px; /* Keep desktop width */
    overflow-x: visible;
    flex-wrap: nowrap; /* NEVER wrap books */
}

/* Books/Magazines - Fixed Size on All Devices */
.flipbook-item {
    min-width: 120px;
    max-width: 140px;
    flex-shrink: 0; /* Prevent shrinking */
}

.flipbook-cover {
    height: 180px; /* Consistent height across all devices */
}

/* Tablets and Below - Add Horizontal Scroll */
@media (max-width: 1024px) {
    .real3d-flipbook-container.bookshelf-style {
        padding: 0;
        margin: 10px auto;
    }
    
    .bookshelf-shelves {
        padding: 0 15px;
    }
    
    .bookshelf-shelf {
        padding: 0 15px;
        padding-bottom: 85px;
        align-items: flex-end;
    }
    
    .flipbook-item {
        margin-bottom: -16px;
    }
}

/* Mobile Devices - Enhanced Touch Scrolling */
@media (max-width: 768px) {
    .real3d-flipbook-container.bookshelf-style {
        margin: 10px 0;
        padding: 0;
        overflow-x: auto;
        overflow-y: hidden;
    }
    
    .bookshelf-shelves {
        min-width: 100%;
        padding: 0 10px;
    }
    
    .bookshelf-shelf {
        min-width: 100%;
        padding: 0 10px;
        gap: 20px; /* Maintain desktop gap */
        padding-bottom: 85px;
        align-items: flex-end;
    }
    
    /* Mobile books - sit on shelf like desktop */
    .flipbook-item {
        margin-bottom: -16px;
    }
    
    /* Slightly reduced hover effects for touch devices */
    .flipbook-item:hover {
        transform: translateY(-5px) scale(1.02);
    }
    
    /* Touch feedback */
    .flipbook-item:active {
        transform: translateY(-3px) scale(1.01);
    }
}

/* Small Mobile - Keep Desktop Layout with Scroll */
@media (max-width: 480px) {
    .real3d-flipbook-container.bookshelf-style {
        margin: 5px 0;
        overflow-x: auto;
        overflow-y: hidden;
    }
    
    .bookshelf-shelves {
        min-width: 800px;
        padding: 0 10px;
    }
    
    .bookshelf-shelf {
        min-width: 800px;
        padding: 0 10px;
        padding-bottom: 85px;
        align-items: flex-end;
    }
    
    .flipbook-item {
        margin-bottom: -16px;
    }
}

/* Custom Scrollbar Styling for Better UX */
.real3d-flipbook-container.bookshelf-style::-webkit-scrollbar {
    height: 8px;
}

.real3d-flipbook-container.bookshelf-style::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}

.real3d-flipbook-container.bookshelf-style::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    transition: background 0.3s ease;
}

.real3d-flipbook-container.bookshelf-style::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.5);
}

/* Firefox Scrollbar */
.real3d-flipbook-container.bookshelf-style {
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.3) rgba(0, 0, 0, 0.1);
    width: 100% !important;
}

/* Animation for book selection */
@keyframes bookSelect {
    0% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-20px) scale(1.1); }
    100% { transform: translateY(-15px) scale(1.1); }
}

.flipbook-item.selecting {
    animation: bookSelect 0.5s ease-out;
}

/* ============================================
   DECORATIVE ELEMENTS
   ============================================ */

/* Bookshelf Background Pattern */
.bookshelf-style .bookshelf-shelves::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.1) 1px, transparent 1px),
        radial-gradient(circle at 80% 80%, rgba(255, 255, 255, 0.1) 1px, transparent 1px);
    background-size: 50px 50px;
    pointer-events: none;
    opacity: 0.3;
}

/* ============================================
   FLIPBOOK VIEWER CORE
   ============================================
   3D page turning functionality
   ============================================ */

.flipbook-viewer {
    position: relative;
    width: 100%;
    height: 100%;
    background: transparent;
}

.flipbook-pages {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
}

.flipbook-page {
    position: absolute;
    width: 50%;
    height: 100%;
    background: white;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
    transform-origin: left center;
    transition: transform 1s ease-in-out;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.flipbook-page img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: transform 0.3s ease;
}

.flipbook-page:hover img {
    transform: scale(1.05);
}

.flipbook-page.active {
    z-index: 10;
}

/* ============================================
   VIEWER CONTROLS & NAVIGATION
   ============================================ */

.flipbook-controls {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 12px 20px;
    border-radius: 25px;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 10px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.flipbook-controls button {
    background: transparent;
    border: 2px solid rgba(255, 255, 255, 0.7);
    color: white;
    padding: 8px 16px;
    cursor: pointer;
    border-radius: 20px;
    font-weight: 600;
    transition: all 0.3s ease;
    font-size: 14px;
}

.flipbook-controls button:hover:not(:disabled) {
    background: white;
    color: #333;
    border-color: white;
    transform: translateY(-2px);
}

.flipbook-controls button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.flipbook-page-info {
    margin: 0 15px;
    font-weight: 600;
    font-size: 14px;
    min-width: 60px;
    text-align: center;
}

.flipbook-zoom-controls {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    gap: 5px;
}

.flipbook-zoom-controls button {
    background: rgba(0, 0, 0, 0.8);
    border: none;
    color: white;
    padding: 10px 15px;
    cursor: pointer;
    border-radius: 50%;
    font-weight: bold;
    font-size: 16px;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.flipbook-zoom-controls button:hover {
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    transform: scale(1.1);
}

/* ============================================
   LOADING & ANIMATION STATES
   ============================================ */

.flipbook-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 100;
}

.flipbook-loading::after {
    content: '';
    display: block;
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ============================================
   FLIPBOOK VIEWER RESPONSIVE CONTROLS
   ============================================
   Optimized control sizing for mobile devices
   ============================================ */

@media (max-width: 768px) {
    .real3d-flipbook-container {
        margin: 10px;
        border-radius: 4px;
    }
    
    .flipbook-controls {
        bottom: 10px;
        padding: 8px 15px;
        font-size: 12px;
        gap: 8px;
    }
    
    .flipbook-controls button {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .flipbook-page-info {
        margin: 0 10px;
        font-size: 12px;
        min-width: 50px;
    }
    
    .flipbook-zoom-controls {
        top: 10px;
        right: 10px;
        gap: 3px;
    }
    
    .flipbook-zoom-controls button {
        padding: 8px 12px;
        font-size: 14px;
    }
}

/* Small Mobile Devices - Further Optimization */
@media (max-width: 480px) {
    .flipbook-controls {
        padding: 6px 10px;
        font-size: 11px;
        gap: 5px;
    }
    
    .flipbook-controls button {
        padding: 5px 10px;
        font-size: 11px;
    }
    
    .flipbook-page-info {
        margin: 0 8px;
        font-size: 11px;
        min-width: 45px;
    }
    
    .flipbook-zoom-controls button {
        padding: 6px 10px;
        font-size: 12px;
    }
}

/* Page turn animation */
.flipbook-page.turning {
    transform: rotateY(-180deg);
    z-index: 5;
}

.flipbook-page.turned {
    transform: rotateY(-180deg);
    z-index: 1;
}

/* Fullscreen mode */
.real3d-flipbook-container.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;
    border: none;
    border-radius: 0;
}

.real3d-flipbook-container.fullscreen .flipbook-controls {
    bottom: 30px;
}

/* Print styles */
@media print {
    .flipbook-controls,
    .flipbook-zoom-controls {
        display: none;
    }
    
    .real3d-flipbook-container {
        box-shadow: none;
        border: 1px solid #000;
    }
}

/* ============================================
   INTERACTIVE ELEMENTS
   ============================================
   Links and clickable areas
   ============================================ */

.flipbook-page-link {
    display: block;
    width: 100%;
    height: 100%;
    text-decoration: none;
    position: relative;
    transition: transform 0.3s ease;
}

.flipbook-page-link:hover {
    transform: scale(1.02);
}

.flipbook-page-link::after {
    content: '🔗';
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 50%;
    font-size: 16px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.flipbook-page-link:hover::after {
    opacity: 1;
}

/* Page Title Styles */
.flipbook-page-title {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
    color: white;
    padding: 20px 15px 15px;
    font-size: 16px;
    font-weight: 600;
    text-align: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.flipbook-page:hover .flipbook-page-title {
    opacity: 1;
}

.flipbook-page-link .flipbook-page-title {
    position: static;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
    padding: 20px 15px 15px;
    margin-top: -60px;
    position: relative;
    z-index: 2;
}

/* ============================================
   ACCESSIBILITY FEATURES
   ============================================
   WCAG 2.1 AA Compliant
   ============================================ */

.flipbook-controls button:focus,
.flipbook-zoom-controls button:focus,
.flipbook-page-link:focus {
    outline: 2px solid #4CAF50;
    outline-offset: 2px;
}

.flipbook-controls button:focus-visible,
.flipbook-zoom-controls button:focus-visible,
.flipbook-page-link:focus-visible {
    outline: 3px solid #4CAF50;
    outline-offset: 3px;
}

/* ============================================
   ACCESSIBILITY - HIGH CONTRAST MODE
   ============================================ */

@media (prefers-contrast: high) {
    .real3d-flipbook-container {
        border: 2px solid #000;
    }
    
    .flipbook-controls {
        background: #000;
        border: 2px solid #fff;
    }
    
    .flipbook-controls button {
        border-color: #fff;
    }
}

/* ============================================
   ACCESSIBILITY - REDUCED MOTION
   ============================================
   Respects user's motion preferences
   ============================================ */

@media (prefers-reduced-motion: reduce) {
    .flipbook-item,
    .flipbook-cover,
    .flipbook-page,
    .flipbook-controls button,
    .flipbook-zoom-controls button {
        transition: none !important;
        animation: none !important;
    }
    
    .flipbook-item:hover {
        transform: none !important;
    }
}

/* ============================================
   END OF STYLESHEET
   ============================================ */
