/**
 * Special Sections Frontend Styles
 * All classes use ss- prefix for namespace protection
 */

/* Reset and Base Styles */
.ss-flipbook-wrapper *,
.ss-archive-container *,
.ss-single-container * {
    box-sizing: border-box;
}

/* Main Flipbook Wrapper */
.ss-flipbook-wrapper {
    position: relative;
    margin: 2rem auto;
    max-width: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* DearFlip Wrapper Styles */
.ss-dearflip-wrapper .ss-dearflip-container {
    position: relative;
    background: #f8f9fa;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    margin: 1rem 0;
}

.ss-dearflip-download {
    text-align: center;
    margin-top: 1rem;
}

.ss-dearflip-download .ss-btn-download {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: #0073aa;
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-weight: 500;
    transition: background-color 0.2s;
}

.ss-dearflip-download .ss-btn-download:hover {
    background: #005a87;
    color: white;
}

/* Flipbook Container */
.ss-flipbook-container {
    position: relative;
    background: #f8f9fa;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    margin: 1rem 0;
}

/* Loading State */
.ss-flipbook-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: white;
    z-index: 10;
}

.ss-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #0073aa;
    border-radius: 50%;
    animation: ss-spin 1s linear infinite;
    margin-bottom: 1rem;
}

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

.ss-flipbook-loading p {
    color: #666;
    font-size: 1rem;
    margin: 0;
}

/* Flipbook Core */
.ss-flipbook {
    width: 100%;
    height: 100%;
    background: white;
    position: relative;
}

.ss-flipbook .ss-page {
    background: white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    overflow: hidden;
}

.ss-flipbook .ss-page canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* Page Loading Indicators */
.ss-page-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 2rem;
    background: rgba(248, 249, 250, 0.95);
    font-size: 0.875rem;
    color: #666;
}

.ss-loading-bar {
    width: 80%;
    max-width: 200px;
    height: 4px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 1rem;
    position: relative;
}

.ss-loading-progress {
    height: 100%;
    background: linear-gradient(90deg, #0073aa, #00a0d2);
    border-radius: 2px;
    animation: ss-loading-animation 1.5s ease-in-out infinite;
    width: 30%;
}

@keyframes ss-loading-animation {
    0% {
        transform: translateX(-100%);
    }
    50% {
        transform: translateX(250%);
    }
    100% {
        transform: translateX(-100%);
    }
}

/* Loading for fullscreen */
.ss-flipbook-fullscreen .ss-page-loading {
    background: rgba(0, 0, 0, 0.8);
    color: white;
}

.ss-flipbook-fullscreen .ss-loading-bar {
    background: rgba(255, 255, 255, 0.2);
}

/* Zoom instruction overlay */
.ss-zoom-hint {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.75rem;
    z-index: 100;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    white-space: nowrap;
}

.ss-flipbook-wrapper:hover .ss-zoom-hint {
    opacity: 1;
}

.ss-flipbook-zoomed + .ss-zoom-hint {
    opacity: 0;
}

/* Controls */
.ss-flipbook-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 1rem;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
    flex-wrap: wrap;
}

.ss-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.ss-btn:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

.ss-btn-prev,
.ss-btn-next {
    background: #0073aa;
    color: white;
}

.ss-btn-prev:hover,
.ss-btn-next:hover {
    background: #005a87;
}

.ss-btn-prev:disabled,
.ss-btn-next:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.ss-btn-zoom-in,
.ss-btn-zoom-out,
.ss-btn-fullscreen {
    background: #6c757d;
    color: white;
    min-width: 44px;
    justify-content: center;
}

.ss-btn-zoom-in:hover,
.ss-btn-zoom-out:hover,
.ss-btn-fullscreen:hover {
    background: #5a6268;
}

.ss-btn-download {
    background: #28a745;
    color: white;
}

.ss-btn-download:hover {
    background: #218838;
    color: white;
}

.ss-page-info {
    font-size: 0.875rem;
    color: #666;
    font-weight: 500;
}

/* Prevent body scroll when fullscreen */
body.ss-fullscreen-active {
    overflow: hidden !important;
    height: 100vh !important;
}

/* Fullscreen Mode */
.ss-flipbook-fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 999999 !important;
    background: #000;
    border-radius: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    margin: 0 !important;
}

.ss-flipbook-fullscreen .ss-flipbook-container {
    box-shadow: none !important;
    background: transparent !important;
    flex-shrink: 0;
}

.ss-flipbook-fullscreen .ss-flipbook-controls {
    background: rgba(0, 0, 0, 0.8);
    border-top: none;
    color: white;
}

.ss-flipbook-fullscreen .ss-page-info {
    color: white;
}

/* Zoom functionality */
.ss-flipbook-zoomed {
    overflow: auto;
    cursor: grab;
}

.ss-flipbook-zoomed:active,
.ss-flipbook.ss-dragging {
    cursor: grabbing;
}

/* Zoom indicator */
.ss-zoom-indicator {
    font-size: 0.75rem;
    color: #666;
    background: rgba(255, 255, 255, 0.9);
    padding: 2px 6px;
    border-radius: 3px;
    margin: 0 0.5rem;
    font-weight: 500;
    min-width: 40px;
    text-align: center;
    display: inline-block;
}

.ss-flipbook-fullscreen .ss-zoom-indicator {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

/* Smooth transitions for zoom */
.ss-flipbook-container {
    transition: overflow 0.3s ease;
}

.ss-flipbook {
    transition: transform 0.3s ease-out;
    transform-origin: center center;
}

/* Smoother zoom transitions */
.ss-flipbook-zoomed {
    transition: transform 0.2s ease-out;
}

/* Scroll styling for zoomed content */
.ss-flipbook-container::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.ss-flipbook-container::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}

.ss-flipbook-container::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
}

.ss-flipbook-container::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.5);
}

/* Hide scrollbars in fullscreen for cleaner look */
.ss-flipbook-fullscreen .ss-flipbook-container::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.ss-flipbook-fullscreen .ss-flipbook-container::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
}

/* Sponsors */
.ss-sponsors-above,
.ss-sponsors-below {
    text-align: center;
    padding: 1.5rem;
    background: #f8f9fa;
    border-radius: 8px;
    margin: 1rem 0;
}

.ss-sponsors-above h3,
.ss-sponsors-below h3 {
    margin: 0 0 1rem 0;
    font-size: 1.25rem;
    color: #333;
}

.ss-sponsors-container {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 2rem;
}

.ss-sponsor-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    max-width: 200px;
}

.ss-sponsor-item a {
    text-decoration: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.ss-sponsor-logo {
    max-width: 150px;
    max-height: 80px;
    width: auto;
    height: auto;
    object-fit: contain;
    filter: grayscale(20%);
    transition: filter 0.3s ease;
}

.ss-sponsor-item:hover .ss-sponsor-logo {
    filter: none;
}

.ss-sponsor-name {
    font-size: 0.875rem;
    color: #666;
    text-align: center;
    line-height: 1.3;
}

.ss-sponsor-item:hover .ss-sponsor-name {
    color: #0073aa;
}

/* Archive Styles - Removed: Now handled in template */

/* Error States */
.ss-error {
    text-align: center;
    padding: 2rem;
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-radius: 6px;
    margin: 1rem 0;
}

.ss-flipbook-unavailable {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    background: #f8f9fa;
    border-radius: 8px;
    margin: 1rem 0;
}

.ss-error-message {
    text-align: center;
    color: #6c757d;
}

.ss-error-message h3 {
    margin: 0 0 1rem 0;
    color: #495057;
}

/* Single Section Styles - Removed: Now handled in template */

/* Responsive Design */
@media (max-width: 768px) {
    .ss-flipbook-controls {
        flex-wrap: wrap;
        gap: 0.5rem;
        padding: 0.75rem;
    }
    
    .ss-sponsors-container {
        gap: 1rem;
    }
    
    /* Archive and single page styles removed - handled in templates */
}

@media (max-width: 480px) {
    .ss-flipbook-wrapper {
        margin: 1rem 0;
    }
    
    .ss-flipbook-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .ss-btn {
        justify-content: center;
        width: 100%;
    }
    
    /* Archive and single page styles removed - handled in templates */
}

/* Print Styles */
@media print {
    .ss-flipbook-controls,
    .ss-archive-filters,
    .ss-archive-view-toggle,
    .ss-search-form {
        display: none !important;
    }
    
    .ss-flipbook-container {
        box-shadow: none;
        border: 1px solid #ccc;
    }
    
    .ss-archive-item {
        box-shadow: none;
        border: 1px solid #ccc;
        break-inside: avoid;
    }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .ss-flipbook-container,
    .ss-archive-item {
        border: 2px solid #000;
    }
    
    .ss-btn {
        border: 2px solid currentColor;
    }
    
    .ss-filter-btn.active {
        border: 2px solid #fff;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    .ss-spinner {
        animation: none;
    }
    
    .ss-archive-item,
    .ss-related-item,
    .ss-flipbook-thumbnail img,
    .ss-sponsor-logo,
    .ss-btn,
    .ss-filter-btn,
    .ss-category-link {
        transition: none;
    }
    
    .ss-archive-item:hover {
        transform: none;
    }
}