/**
 * Custom Instagram-Style Lightbox
 */

/* Overlay and Modal Base */
.sp-lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.sp-lightbox-overlay.sp-lightbox-active {
    opacity: 1;
    visibility: visible;
}

/* Main Modal Container */
.sp-lightbox-modal {
    position: relative;
    width: 1200px;
    height: 800px;
    max-width: 95vw;
    max-height: 90vh;
    background: #fff;
    border-radius: 0 6px 6px 0;
    overflow: hidden;
    transform: scale(0.7);
    transition: transform 0.3s ease, width 0.3s ease;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.sp-lightbox-active .sp-lightbox-modal {
    transform: scale(1);
}

/* Modal Content Layout */
.sp-modal-content {
    display: flex;
    width: 100%;
    height: 100%;
}

/* Image Section (Left Side - 800x800) */
.sp-image-section {
    position: relative;
    width: 800px;
    height: 800px;
    background: #f9f9f9;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    transition: width 0.3s ease;
}

.sp-current-image {
    width: 100%;
    height: 100%;
    display: block;
}

/* Content Section (Right Side - 400x800) */
.sp-content-section {
    width: 400px;
    height: 800px;
    background: #fff;
    display: flex;
    flex-direction: column;
    position: relative;
    border-left: 1px solid #cccccc;
}

.sp-post-content {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.sp-post-title {
    margin: 0 0 16px 0;
    font-size: 18px;
    font-weight: 600;
    line-height: 1.3;
    color: #262626;
}

.sp-post-excerpt {
    margin: 0;
    font-size: 14px;
    line-height: 1.4;
    color: #262626;
}

/* Navigation Buttons */
.sp-nav-inner,
.sp-nav-outer,
.sp-close-btn {
    position: absolute;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 24px;
    font-weight: bold;
    color: #262626;
    transition: all 0.2s ease;
    z-index: 10001;
    user-select: none;
    line-height: 1;
    padding-bottom: 4px;
}

.sp-nav-outer:hover,
.sp-close-btn:hover {
    background: rgba(255, 255, 255, 1);
}

/* Inner Navigation (Image Navigation) */
.sp-nav-prev-image {
    top: 50%;
    left: 16px;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
}

.sp-nav-next-image {
    top: 50%;
    right: 16px;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
}

.sp-nav-prev-image:hover,
.sp-nav-next-image:hover {
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
}


/* Close Button */
.sp-close-btn {
    top: -50px;
    right: 0;
    font-size: 28px;
    background: rgba(255, 255, 255, 0.95);
}

/* External Post Navigation (Screen Edges) */
.sp-nav-external {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 24px;
    font-weight: bold;
    color: #262626;
    transition: all 0.3s ease;
    z-index: 10002;
    user-select: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    line-height: 1;
    padding-bottom: 4px;
}

.sp-nav-external:hover {
    background: rgba(255, 255, 255, 1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.sp-nav-external-prev {
    left: 30px;
}

.sp-nav-external-next {
    right: 30px;
}

.sp-nav-external:focus {
    outline: 2px solid #0066cc;
    outline-offset: 2px;
}

/* Image Dots Navigation */
.sp-image-dots {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 6px;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    padding: 8px 12px;
    border-radius: 20px;
    backdrop-filter: blur(4px);
}

.sp-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
}

.sp-dot:hover {
    background: rgba(255, 255, 255, 0.8);
    transform: scale(1.2);
}

.sp-dot.active {
    background: rgba(255, 255, 255, 1);
    transform: scale(1.3);
}

.sp-dot:focus {
    outline: 2px solid rgba(255, 255, 255, 0.8);
    outline-offset: 2px;
}

/* Hide navigation when not needed */
.sp-nav-inner.sp-hidden,
.sp-nav-outer.sp-hidden,
.sp-nav-external.sp-hidden {
    display: none;
}

/* Loading State */
.sp-image-section.sp-loading {
    background: #f5f5f5;
}

.sp-image-section.sp-loading::after {
    content: '';
    position: absolute;
    width: 40px;
    height: 40px;
    border: 4px solid #dbdbdb;
    border-top: 4px solid #262626;
    border-radius: 50%;
    animation: sp-spin 1s linear infinite;
}

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

/* Responsive Design */

/* When content area would be less than 300px wide, stack vertically */
@media (max-width: 1000px) {
    .sp-lightbox-modal {
        width: 95vw;
        max-width: 1000px;
        height: auto;
        max-height: 90vh;
    }
    
    .sp-modal-content {
        flex-direction: column;
    }
    
    .sp-image-section {
        width: 100%;
        height: 500px;
        max-height: 60vh;
    }
    
    .sp-content-section {
        width: 100%;
        height: auto;
        max-height: 300px;
        min-height: 200px;
        border-left: none;
        border-top: 1px solid #cccccc;
    }
    
    /* Hide external arrows when they would overlay content */
    .sp-nav-external {
        display: none;
    }
    
    .sp-close-btn {
        top: 20px;
        right: 20px;
    }
}

/* Medium screens - keep side-by-side but adjust proportions */
@media (min-width: 1001px) and (max-width: 1500px) {
    .sp-lightbox-modal {
        max-width: 90vw;
        max-height: 90vh;
    }
    
    .sp-image-section {
        height: 750px;
    }
    
    .sp-content-section {
        height: 750px;
        border-left: 1px solid #cccccc;
    }
}

@media (max-width: 800px) {
    .sp-lightbox-modal {
        width: 95vw;
        border-radius: 0 4px 4px 0;
    }
    
    .sp-image-section {
        height: 69vh;
        min-height: 300px;
    }
    
    .sp-content-section {
        height: 21vh;
        min-height: 150px;
        max-height: none;
        border-left: none;
        border-top: 1px solid #cccccc;
    }
    
    .sp-post-content {
        padding: 16px;
    }
    
    .sp-post-title {
        font-size: 16px;
        margin-bottom: 12px;
    }
    
    .sp-post-excerpt {
        font-size: 13px;
    }
    
    /* Smaller navigation buttons on mobile */
    .sp-nav-inner,
    .sp-nav-outer,
    .sp-close-btn {
        width: 28px;
        height: 28px;
        font-size: 20px;
        padding-bottom: 3px;
    }
    
    .sp-nav-prev-image {
        left: 12px;
    }
    
    .sp-nav-next-image {
        right: 12px;
    }
    
    /* Adjust dots for mobile */
    .sp-image-dots {
        padding: 6px 10px;
        border-radius: 16px;
    }
    
    .sp-dot {
        width: 6px;
        height: 6px;
    }
    
    /* Adjust external navigation for mobile */
    .sp-nav-external {
        width: 28px;
        height: 28px;
        font-size: 20px;
        padding-bottom: 3px;
    }
    
    .sp-nav-external-prev {
        left: 15px;
    }
    
    .sp-nav-external-next {
        right: 15px;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .sp-nav-outer,
    .sp-nav-external,
    .sp-close-btn {
        background: rgba(255, 255, 255, 0.95);
    }
    
    .sp-nav-inner {
        background: rgba(0, 0, 0, 0.8);
        color: #fff;
    }
}

/* Focus styles for accessibility */
.sp-nav-inner:focus {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
}

.sp-nav-outer:focus,
.sp-nav-external:focus,
.sp-close-btn:focus {
    outline: 2px solid #0066cc;
    outline-offset: 2px;
}

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

/* Smooth transitions for content changes */
.sp-current-image,
.sp-post-title,
.sp-post-excerpt {
    transition: opacity 0.2s ease;
}

.sp-content-loading .sp-current-image,
.sp-content-loading .sp-post-title,
.sp-content-loading .sp-post-excerpt {
    opacity: 0.5;
}