/**
 * Modern Posts Grid - Infinite Loading Carousel CSS
 * 
 * Smooth infinite carousel with dynamic content loading
 */

/* Main carousel container - Full width with peek effect */
.mpg-infinite-loading-carousel {
    position: relative;
    width: 100vw;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
    margin-top: 2rem;
    margin-bottom: 2rem;
    overflow: hidden;
    background: transparent;
}

/* Hide progress indicator - not needed for infinite carousel */
.mpg-carousel-progress {
    display: none !important;
}

/* Carousel container - Full width with padding for peek effect */
.mpg-carousel-container {
    position: relative;
    width: 100%;
    height: var(--mpg-slide-height, 450px);
    overflow: hidden;
    padding: 0 calc(50vw - 50%);
}

/* Loading indicator - Completely hidden for seamless infinite experience */
.mpg-carousel-loading {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
}

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

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

/* Carousel track - Discrete slide transitions with peek effect */
.mpg-carousel-track {
    display: flex;
    gap: var(--mpg-carousel-gap, 20px);
    height: 100%;
    transition: transform 0.5s ease-in-out;
    will-change: transform;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
}

.mpg-carousel-track:active {
    cursor: grabbing;
}

/* Individual slides */
.mpg-carousel-slide {
    flex: 0 0 var(--mpg-slide-width, 400px);
    height: 100%;
    min-width: var(--mpg-slide-min-width, 250px); /* Prevent slides from getting too small */
    /* Removed hardcoded max-width to allow full control via CSS variables */
    position: relative;
    background-size: cover;
    background-position: center top;
    background-repeat: no-repeat;
    border-radius: var(--mpg-border-radius, 4px);
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Slide hover effects */
.mpg-infinite-loading-carousel.pause-on-hover .mpg-carousel-slide:hover {
    transform: scale(1.03);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    z-index: 2;
}

/* Slide link - full clickable area */
.mpg-slide-link {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 100%;
    height: 100%;
    text-decoration: none;
    color: white;
    padding: 20px;
    background: linear-gradient(to bottom, 
        var(--mpg-overlay-top, rgba(0,0,0,0.4)) 0%, 
        rgba(0,0,0,0) 50%, 
        var(--mpg-overlay-bottom, rgba(0,0,0,0.6)) 100%);
    transition: background 0.3s ease;
}

.mpg-carousel-slide:hover .mpg-slide-link {
    background: linear-gradient(to bottom, 
        var(--mpg-overlay-top, rgba(0,0,0,0.5)) 0%, 
        rgba(0,0,0,0.1) 50%, 
        var(--mpg-overlay-bottom, rgba(0,0,0,0.7)) 100%);
}

/* Slide content sections */
.mpg-slide-top {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Text positioning variants for infinite carousel */
/* Bottom Left (Default) - left-aligned, move to bottom */
.mpg-text-pos-bottom-left .mpg-slide-top {
    order: 1;
    align-self: flex-start;
    text-align: left;
}

.mpg-text-pos-bottom-left .mpg-slide-bottom {
    order: 0;
}

/* Bottom Right - right-aligned, move to bottom */
.mpg-text-pos-bottom-right .mpg-slide-top {
    order: 1;
    align-self: flex-end;
    text-align: right;
}

.mpg-text-pos-bottom-right .mpg-slide-bottom {
    order: 0;
}

/* Top Right - keep at top, right-aligned */
.mpg-text-pos-top-right .mpg-slide-top {
    align-self: flex-end;
    text-align: right;
}

.mpg-slide-bottom {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 15px;
}

/* Slide title */
.mpg-slide-title {
    margin: 0;
    padding: 0;
    font-size: 18px;
    font-weight: var(--mpg-heading-weight, 700);
    line-height: 1.3;
    color: white;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.7);
}

/* Slide subtitle */
.mpg-slide-subtitle {
    margin: 0;
    padding: 0;
    font-size: 15px;
    font-weight: 400;
    line-height: 1.3;
    color: rgba(255, 255, 255, 0.85);
    text-shadow: 1px 1px 3px rgba(0,0,0,0.5);
}

/* Slide excerpt */
.mpg-slide-excerpt {
    margin: 0;
    font-size: 14px;
    line-height: 1.4;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}

/* Read more button */
.mpg-read-more {
    display: inline-block;
    background: var(--mpg-button-bg, #5e4caf);
    color: var(--mpg-button-text, white);
    padding: 8px 16px;
    border-radius: 3px;
    font-size: 14px;
    font-weight: 600;
    text-transform: lowercase;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.mpg-carousel-slide:hover .mpg-read-more {
    background: var(--mpg-button-hover, #4a3a8c);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* Slide meta */
.mpg-slide-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.8);
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
    text-align: right;
    flex-shrink: 0;
}

.mpg-slide-meta .mpg-separator {
    color: rgba(255, 255, 255, 0.6);
    margin: 0 2px;
}

/* Control buttons - Navigation style */
.mpg-carousel-controls {
    position: absolute;
    bottom: 30px;
    right: 30px;
    display: flex;
    gap: 10px;
    z-index: 5;
}

.mpg-carousel-btn {
    background: #001a70 !important;
    color: white;
    border: none;
    padding: 0;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    transition: all 0.2s ease;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 26, 112, 0.3);
    position: relative;
    overflow: hidden;
}

.mpg-carousel-btn:hover {
    background: #003399;
    box-shadow: 0 3px 12px rgba(0, 26, 112, 0.4);
    transform: scale(1.05);
}

.mpg-carousel-btn:active {
    transform: scale(0.95);
}

.mpg-carousel-btn:disabled {
    background: #666;
    cursor: not-allowed;
    opacity: 0.5;
}

/* Navigation arrows */
.mpg-prev-btn,
.mpg-next-btn {
    font-family: Arial, sans-serif;
    font-weight: bold;
}

.mpg-prev-btn {
    padding-right: 2px; /* Center the < arrow visually */
}

.mpg-next-btn {
    padding-left: 2px; /* Center the > arrow visually */
}

/* Pause state */
.mpg-infinite-loading-carousel.paused .mpg-carousel-track {
    animation-play-state: paused !important;
}

/* Responsive design */
@media (max-width: 1024px) {
    /* Only apply default dimensions if not set via configuration */
    .mpg-infinite-loading-carousel:not([style*="--mpg-slide-width"]) {
        --mpg-slide-width: min(45vw, 380px);
    }

    .mpg-infinite-loading-carousel:not([style*="--mpg-slide-height"]) {
        --mpg-slide-height: min(55vw, 420px);
    }

    .mpg-infinite-loading-carousel {
        --mpg-carousel-gap: 15px;
    }

    .mpg-carousel-container {
        padding: 0 calc(50vw - 45%);
        height: var(--mpg-slide-height, 420px) !important;
    }

    .mpg-carousel-slide {
        min-width: var(--mpg-slide-min-width, 280px);
        /* Removed hardcoded max-width to allow custom dimensions */
    }

    .mpg-slide-title {
        font-size: 16px;
    }

    .mpg-slide-link {
        padding: 15px;
    }
}

@media (max-width: 768px) {
    /* Only apply default dimensions if not set via configuration */
    .mpg-infinite-loading-carousel:not([style*="--mpg-slide-width"]) {
        --mpg-slide-width: min(30vw, 220px);
    }

    .mpg-infinite-loading-carousel:not([style*="--mpg-slide-height"]) {
        --mpg-slide-height: min(35vw, 240px);
    }

    .mpg-infinite-loading-carousel {
        --mpg-carousel-gap: 10px;
        margin-left: 0;
        margin-right: 0;
    }

    .mpg-carousel-container {
        padding: 0 10px;
        height: var(--mpg-slide-height, 240px) !important;
    }

    .mpg-carousel-slide {
        min-width: var(--mpg-slide-min-width, 140px);
        /* Removed hardcoded max-width to allow custom dimensions */
        position: relative;
    }

    /* Restructure slide for mobile */
    .mpg-slide-link {
        padding: 8px;
        padding-bottom: 32px; /* Extra space for subtitle at bottom */
        display: flex;
        flex-direction: column;
        position: relative;
    }

    /* Top section - only show title */
    .mpg-slide-top {
        display: flex;
        flex-direction: column;
        gap: 0;
    }

    .mpg-slide-title {
        font-size: 13px;
        line-height: 1.2;
    }

    /* Position subtitle absolutely at the bottom */
    .mpg-slide-subtitle {
        position: absolute;
        bottom: 8px;
        left: 8px;
        right: 8px;
        font-size: 11px;
        margin: 0;
        padding: 0;
    }

    /* Bottom section - push to actual bottom above subtitle */
    .mpg-slide-bottom {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
        margin-top: auto;
        margin-bottom: 20px; /* Space for subtitle below */
    }

    .mpg-slide-meta {
        text-align: left;
        font-size: 10px;
    }

    .mpg-carousel-controls {
        bottom: 12px;
        right: 12px;
        gap: 6px;
    }

    .mpg-carousel-btn {
        width: 38px;
        height: 38px;
        font-size: 16px;
    }

    .mpg-read-more {
        display: none !important; /* Hide button on mobile */
    }

    /* Mobile Button Control - Show button when enabled */
    .mpg-show-mobile-button .mpg-read-more {
        display: inline-block !important;
    }

    /* Mobile Layout Styles */
    /* Compact - Everything together at bottom */
    .mpg-mobile-compact .mpg-slide-subtitle {
        position: relative !important;
        bottom: auto !important;
        left: auto !important;
        right: auto !important;
        margin-top: 5px;
    }

    .mpg-mobile-compact .mpg-slide-bottom {
        margin-bottom: 0 !important;
    }

    /* Minimal - Hide date/author, show only subtitle */
    .mpg-mobile-minimal .mpg-slide-meta {
        display: none !important;
    }
}

@media (max-width: 480px) {
    /* Only apply default dimensions if not set via configuration */
    .mpg-infinite-loading-carousel:not([style*="--mpg-slide-width"]) {
        --mpg-slide-width: min(31vw, 180px);
    }

    .mpg-infinite-loading-carousel:not([style*="--mpg-slide-height"]) {
        --mpg-slide-height: min(38vw, 200px);
    }

    .mpg-infinite-loading-carousel {
        --mpg-carousel-gap: 8px;
    }

    .mpg-carousel-container {
        padding: 0 8px;
        height: var(--mpg-slide-height, 200px) !important;
    }

    .mpg-carousel-slide {
        min-width: var(--mpg-slide-min-width, 110px);
        /* Removed hardcoded max-width to allow custom dimensions */
    }

    .mpg-slide-link {
        padding: 6px;
        padding-bottom: 28px; /* Extra space for subtitle at bottom */
    }

    .mpg-slide-title {
        font-size: 12px;
        line-height: 1.2;
    }

    /* Position subtitle absolutely at the bottom */
    .mpg-slide-subtitle {
        position: absolute;
        bottom: 6px;
        left: 6px;
        right: 6px;
        font-size: 10px;
        margin: 0;
        padding: 0;
    }

    .mpg-slide-excerpt {
        font-size: 11px;
        display: none; /* Hide excerpt on very small screens */
    }

    /* Bottom section - push to actual bottom above subtitle */
    .mpg-slide-bottom {
        gap: 4px;
        margin-bottom: 16px; /* Space for subtitle below */
    }

    .mpg-slide-meta {
        font-size: 9px;
    }

    .mpg-carousel-controls {
        bottom: 10px;
        right: 10px;
        gap: 5px;
    }

    .mpg-carousel-btn {
        width: 34px;
        height: 34px;
        font-size: 15px;
    }

    .mpg-read-more {
        display: none !important; /* Hide button on mobile */
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .mpg-carousel-loading {
        background: rgba(0, 26, 112, 0.95);
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    .mpg-carousel-track {
        transition: none;
    }
    
    .mpg-carousel-slide {
        transition: none;
    }
    
    .mpg-slide-link {
        transition: none;
    }
    
    .mpg-read-more {
        transition: none;
    }
    
    .mpg-loading-spinner {
        animation: none;
        border: 2px solid rgba(255, 255, 255, 0.6);
        border-top-color: white;
    }
}