/**
 * SP Sections Frontend Styles
 */

/* Base Container */
.special-sections-container {
    position: relative;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    box-sizing: border-box;
}

/* Loading State */
.special-sections-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: #7f8c8d;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #ecf0f1;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: sp-spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes sp-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Flipbook Wrapper */
.special-sections-flipbook-wrapper {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    padding: 40px 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

.special-sections-flipbook-wrapper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #3498db, #2ecc71, #e74c3c, #f39c12);
    background-size: 400% 100%;
    animation: sp-gradient-shift 8s ease infinite;
}

@keyframes sp-gradient-shift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

/* Flipbook */
.special-sections-flipbook {
    position: relative;
    margin: 0 auto;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    max-width: 100%;
    width: 800px;
    height: 600px;
}

.special-sections-flipbook.loading {
    display: none;
}

/* Pages */
.special-sections-flipbook .page {
    width: 50%;
    height: 100%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    backface-visibility: hidden;
    border-radius: 4px;
    overflow: hidden;
}

.special-sections-flipbook .page img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    border-radius: 4px;
}

/* Turn.js Styles */
.turn-page {
    background: white;
    border-radius: 4px;
}

.turn-page-wrapper {
    perspective: 1000px;
}

.hard {
    background: #fff !important;
    color: #333 !important;
    border: 1px solid #ccc;
}

/* Controls */
.special-sections-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-top: 30px;
    flex-wrap: wrap;
}

.flipbook-control {
    background: #3498db;
    color: white;
    border: none;
    padding: 12px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 16px;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.3);
}

.flipbook-control:hover {
    background: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.4);
}

.flipbook-control:active {
    transform: translateY(0);
}

.flipbook-control:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 2px 8px rgba(189, 195, 199, 0.3);
}

.flipbook-control .dashicons {
    font-size: 20px;
    width: 20px;
    height: 20px;
    line-height: 1;
}

/* Page Info */
.flipbook-page-info {
    background: #34495e;
    color: white;
    padding: 8px 16px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 600;
    min-width: 80px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(52, 73, 94, 0.3);
}

/* Zoom Overlay */
.special-sections-zoom-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.special-sections-zoom-overlay.active {
    opacity: 1;
    visibility: visible;
}

.zoom-container {
    position: relative;
    max-width: 95vw;
    max-height: 95vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.zoom-close {
    position: absolute;
    top: -50px;
    right: -20px;
    background: #e74c3c;
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.zoom-close:hover {
    background: #c0392b;
    transform: scale(1.1);
}

.zoom-content img {
    max-width: 100%;
    max-height: 100%;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

/* Sponsors */
.special-sections-sponsors {
    margin: 30px 0;
}

.sponsors-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 30px;
    padding: 30px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.sponsor-item {
    transition: all 0.3s ease;
    border-radius: 8px;
    overflow: hidden;
    max-width: 200px;
}

.sponsor-item:hover {
    transform: translateY(-5px);
}

.sponsor-item a {
    display: block;
    text-decoration: none;
    color: inherit;
    padding: 15px;
    border-radius: 8px;
    background: #f8f9fa;
    transition: all 0.3s ease;
}

.sponsor-item a:hover {
    background: #e9ecef;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.sponsor-item img {
    width: 100%;
    height: auto;
    max-height: 80px;
    object-fit: contain;
    border-radius: 4px;
}

.sponsor-text {
    text-align: center;
    font-weight: 600;
    color: #2c3e50;
    font-size: 14px;
    padding: 10px 0;
}

/* Processing Messages */
.special-sections-processing,
.special-sections-message,
.special-sections-error {
    text-align: center;
    padding: 60px 20px;
    background: white;
    border-radius: 12px;
    margin: 20px 0;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.special-sections-processing .processing-icon,
.special-sections-message .processing-icon,
.special-sections-error .processing-icon {
    margin-bottom: 20px;
}

.special-sections-processing .dashicons,
.special-sections-message .dashicons,
.special-sections-error .dashicons {
    font-size: 48px;
    margin-bottom: 20px;
}

.special-sections-processing .dashicons {
    color: #f39c12;
}

.special-sections-error .dashicons {
    color: #e74c3c;
}

.sp-rotate {
    animation: sp-spin 2s linear infinite;
}

/* Archive Grid (when used in frontend) */
.special-sections-archive {
    margin: 40px 0;
}

.sections-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 30px;
    margin-bottom: 40px;
}

.section-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
}

.section-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

.section-link {
    display: block;
    text-decoration: none;
    color: inherit;
}

.section-thumbnail {
    position: relative;
    height: 200px;
    overflow: hidden;
    background: #f8f9fa;
}

.section-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.section-card:hover .section-thumbnail img {
    transform: scale(1.05);
}

.no-thumbnail {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #95a5a6;
}

.no-thumbnail .dashicons {
    font-size: 48px;
    margin-bottom: 10px;
}

.page-count {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 6px 12px;
    border-radius: 15px;
    font-size: 12px;
    font-weight: 600;
}

.section-info {
    padding: 25px;
}

.section-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 15px;
    color: #2c3e50;
    line-height: 1.4;
}

.section-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 15px;
}

.category-tag {
    background: #3498db;
    color: white;
    padding: 4px 12px;
    border-radius: 15px;
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.section-excerpt {
    color: #7f8c8d;
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 15px;
}

.section-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #95a5a6;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Responsive Design */

/* Tablet */
@media (max-width: 1024px) {
    .special-sections-container {
        padding: 15px;
    }
    
    .special-sections-flipbook-wrapper {
        padding: 30px 15px;
    }
    
    .special-sections-flipbook {
        width: 100%;
        max-width: 700px;
        height: auto;
        aspect-ratio: 4/3;
    }
    
    .sponsors-container {
        gap: 20px;
        padding: 25px 15px;
    }
    
    .sections-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 25px;
    }
}

/* Mobile */
@media (max-width: 768px) {
    .special-sections-container {
        padding: 10px;
    }
    
    .special-sections-flipbook-wrapper {
        padding: 20px 10px;
        border-radius: 8px;
    }
    
    .special-sections-flipbook {
        width: 100%;
        max-width: 500px;
        height: auto;
        aspect-ratio: 4/3;
    }
    
    .special-sections-controls {
        gap: 10px;
        margin-top: 20px;
    }
    
    .flipbook-control {
        width: 40px;
        height: 40px;
        font-size: 14px;
    }
    
    .flipbook-page-info {
        font-size: 12px;
        padding: 6px 12px;
    }
    
    .sponsors-container {
        flex-direction: column;
        gap: 15px;
        padding: 20px 10px;
    }
    
    .sponsor-item {
        max-width: 150px;
    }
    
    .sections-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .section-info {
        padding: 20px;
    }
    
    .section-title {
        font-size: 16px;
    }
    
    /* Touch-friendly controls for mobile */
    .flipbook-control {
        min-height: 44px;
        min-width: 44px;
    }
}

/* Small Mobile */
@media (max-width: 480px) {
    .special-sections-flipbook {
        max-width: 100%;
        aspect-ratio: 3/4;
    }
    
    .special-sections-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }
    
    .flipbook-control {
        width: 100%;
        max-width: 200px;
        margin: 0 auto;
        border-radius: 25px;
        height: 50px;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
    }
    
    .flipbook-control .dashicons {
        margin-right: 5px;
    }
    
    .flipbook-prev::after {
        content: " Previous";
        font-size: 14px;
    }
    
    .flipbook-next::after {
        content: " Next";
        font-size: 14px;
    }
    
    .flipbook-zoom::after {
        content: " Zoom";
        font-size: 14px;
    }
    
    .flipbook-fullscreen::after {
        content: " Fullscreen";
        font-size: 14px;
    }
    
    .flipbook-page-info {
        order: -1;
        align-self: center;
    }
    
    .zoom-close {
        top: 20px;
        right: 20px;
        width: 50px;
        height: 50px;
        font-size: 28px;
    }
    
    .sponsor-item {
        max-width: 120px;
    }
    
    .section-thumbnail {
        height: 150px;
    }
    
    .section-info {
        padding: 15px;
    }
}

/* Print Styles */
@media print {
    .special-sections-controls,
    .special-sections-zoom-overlay {
        display: none !important;
    }
    
    .special-sections-flipbook {
        box-shadow: none;
        border: 1px solid #ccc;
    }
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .special-sections-flipbook .page img {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    .special-sections-flipbook-wrapper::before,
    .loading-spinner,
    .sp-rotate {
        animation: none;
    }
    
    .section-card,
    .flipbook-control,
    .sponsor-item {
        transition: none;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .special-sections-flipbook-wrapper {
        background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    }
    
    .special-sections-flipbook {
        background: #fff;
    }
    
    .sponsors-container {
        background: #34495e;
        color: #ecf0f1;
    }
    
    .sponsor-item a {
        background: #2c3e50;
        color: #ecf0f1;
    }
    
    .sponsor-item a:hover {
        background: #1a252f;
    }
}

/* Full-width override for themes */
.special-sections-single .special-sections-container {
    width: 100vw;
    max-width: none;
    margin-left: calc(-50vw + 50%);
    margin-right: calc(-50vw + 50%);
}

/* Turn.js specific fixes */
.turn-page {
    background-color: white !important;
}

.turn-page img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}