/**
 * Modern Posts Grid - Carousel Styles
 * Creates a full-width carousel layout with modern card styling
 */

/* Carousel Container */
.mpg-carousel-container {
    position: relative;
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    padding: 20px 0;
}

/* Carousel Wrapper */
.mpg-carousel-wrapper {
    position: relative;
    overflow: hidden;
    width: 100%;
    margin: 0 auto;
    padding: 0 20px;
}

/* Edge Peek Mode - Wrapper adjustments */
.mpg-carousel-container.edge-peek-mode .mpg-carousel-wrapper {
    overflow: visible;
    padding: 0; /* No padding, we'll handle this differently */
}

/* Carousel Track */
.mpg-carousel-track {
    display: flex;
    gap: var(--mpg-carousel-gap, 25px);
    transition: transform 0.3s ease-in-out;
    will-change: transform;
}

/* Carousel Slide */
.mpg-carousel-slide {
    flex: 0 0 var(--mpg-slide-width, calc(33.333% - (var(--mpg-carousel-gap, 25px) * 2 / 3)));
    min-width: var(--mpg-slide-min-width, 250px); /* Prevent slides from getting too small */
}

/* Carousel Card - inherits from grid card styles */
.mpg-carousel-card {
    height: var(--mpg-slide-height, 400px);
    width: 100%;
    min-height: 300px; /* Prevent cards from getting too small on mobile */
}

/* Ensure button colors are applied in carousel */
.mpg-carousel-card .mpg-read-more {
    background: var(--mpg-button-bg, #5e4caf);
    color: var(--mpg-button-text, white);
    transition: background 0.3s ease;
}

.mpg-carousel-card:hover .mpg-read-more {
    background: var(--mpg-button-hover, #4a3a8c);
}

/* Edge Peek Mode Styles - Simple approach */
.mpg-carousel-container.edge-peek-mode {
    overflow: visible; /* Allow slides to show outside container */
}

/* Edge peek mode styles are dynamically generated in PHP based on slides_to_show */
/* This ensures proper spacing for any number of slides */

/* Navigation Container */
.mpg-carousel-navigation {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 10;
}

/* Navigation position variations */
.mpg-carousel-navigation.mpg-nav-bottom_left {
    left: 20px;
    right: auto;
}

.mpg-carousel-navigation.mpg-nav-bottom_center {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
}

.mpg-carousel-navigation.mpg-nav-top_right {
    top: 20px;
    bottom: auto;
}

.mpg-carousel-navigation.mpg-nav-top_left {
    top: 20px;
    bottom: auto;
    left: 20px;
    right: auto;
}

.mpg-carousel-navigation.mpg-nav-top_center {
    top: 20px;
    bottom: auto;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
}

/* Navigation Buttons */
.mpg-carousel-prev,
.mpg-carousel-next {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--mpg-button-bg, #5e4caf);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.mpg-carousel-prev:hover,
.mpg-carousel-next:hover {
    background: var(--mpg-button-bg, #5e4caf);
    color: white;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.mpg-carousel-prev:disabled,
.mpg-carousel-next:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.mpg-carousel-prev svg,
.mpg-carousel-next svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* Dots Navigation */
.mpg-carousel-dots {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 10px;
}

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

.mpg-carousel-dot:hover {
    background: rgba(0, 0, 0, 0.5);
    transform: scale(1.2);
}

.mpg-carousel-dot.active {
    background: var(--mpg-button-bg, #5e4caf);
    width: 24px;
    border-radius: 12px;
}

/* Autoplay Pause on Hover */
.mpg-carousel-container:hover .mpg-carousel-track {
    animation-play-state: paused;
}

/* Center Mode */
.mpg-carousel-container.center-mode .mpg-carousel-slide {
    opacity: 0.6;
    transform: scale(0.9);
    transition: all 0.3s ease;
}

.mpg-carousel-container.center-mode .mpg-carousel-slide.active {
    opacity: 1;
    transform: scale(1);
}

/* Responsive Design */
@media (max-width: 1024px) {
    .mpg-carousel-slide {
        flex: 0 0 var(--mpg-slide-width, calc(50% - (var(--mpg-carousel-gap, 20px) / 2))) !important;
        min-width: var(--mpg-slide-min-width, 280px);
    }

    .mpg-carousel-card {
        height: var(--mpg-slide-height, min(45vh, 380px)) !important;
        min-height: 320px;
    }

    /* Edge peek responsive styles are dynamically generated */
}

@media (max-width: 768px) {
    .mpg-carousel-container {
        padding: 10px 0;
    }

    .mpg-carousel-wrapper {
        padding: 0 10px;
    }

    .mpg-carousel-slide {
        flex: 0 0 var(--mpg-slide-width, calc(30vw)) !important; /* Show 3+ items */
        min-width: var(--mpg-slide-min-width, 140px);
        max-width: 220px;
    }

    .mpg-carousel-card {
        height: var(--mpg-slide-height, min(35vw, 240px)) !important;
        min-height: 200px;
    }

    /* Restructure card for mobile to position subtitle at bottom */
    .mpg-carousel-card {
        position: relative;
    }

    .mpg-carousel-card .mpg-card-content {
        display: flex;
        flex-direction: column;
        height: 100%;
        position: relative;
        padding-bottom: 32px; /* Extra space for subtitle at bottom */
    }

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

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

    .mpg-carousel-card .mpg-card-top {
        padding: 8px;
    }

    .mpg-carousel-card .mpg-card-bottom {
        padding: 8px;
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
        margin-top: auto;
        margin-bottom: 20px; /* Space for subtitle below */
    }

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

    .mpg-carousel-card .mpg-card-meta {
        font-size: 10px;
    }

    /* Edge peek mobile styles are dynamically generated */

    /* Stack navigation on mobile */
    .mpg-carousel-navigation {
        bottom: 10px;
        right: 10px;
        flex-direction: column;
        gap: 8px;
    }

    .mpg-carousel-navigation.mpg-nav-bottom_left {
        left: 10px;
    }

    .mpg-carousel-navigation.mpg-nav-top_right,
    .mpg-carousel-navigation.mpg-nav-top_left,
    .mpg-carousel-navigation.mpg-nav-top_center {
        top: 10px;
    }

    /* Smaller buttons on mobile */
    .mpg-carousel-prev,
    .mpg-carousel-next {
        width: 36px;
        height: 36px;
    }

    .mpg-carousel-prev svg,
    .mpg-carousel-next svg {
        width: 18px;
        height: 18px;
    }

    /* Horizontal dots on mobile */
    .mpg-carousel-dots {
        flex-direction: row;
        padding: 0;
    }

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

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

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

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

@media (max-width: 480px) {
    .mpg-carousel-slide {
        flex: 0 0 var(--mpg-slide-width, calc(31vw)) !important; /* Show 3+ items on small screens */
        min-width: var(--mpg-slide-min-width, 110px);
        max-width: 180px;
    }

    .mpg-carousel-card {
        height: var(--mpg-slide-height, min(38vw, 200px)) !important;
        min-height: 180px;
    }

    .mpg-carousel-wrapper {
        padding: 0 8px;
    }

    /* Further reduce text size */
    .mpg-carousel-card .mpg-card-content {
        padding-bottom: 28px; /* Extra space for subtitle at bottom */
    }

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

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

    .mpg-carousel-card .mpg-card-top {
        padding: 6px;
    }

    .mpg-carousel-card .mpg-card-bottom {
        padding: 6px;
        margin-bottom: 16px; /* Space for subtitle below */
    }

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

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

    /* Extra small buttons on very small screens */
    .mpg-carousel-prev,
    .mpg-carousel-next {
        width: 32px;
        height: 32px;
    }

    .mpg-carousel-prev svg,
    .mpg-carousel-next svg {
        width: 16px;
        height: 16px;
    }
}

/* Smooth transitions for infinite loop */
.mpg-carousel-track.transitioning {
    transition: transform 0.3s ease-in-out;
}

.mpg-carousel-track.no-transition {
    transition: none;
}

/* Loading state */
.mpg-carousel-container.loading .mpg-carousel-track {
    opacity: 0.5;
}

/* Hide navigation when only one slide group */
.mpg-carousel-container.single-group .mpg-carousel-navigation {
    display: none;
}

/* Touch interaction feedback */
.mpg-carousel-container.grabbing {
    cursor: grabbing;
}

.mpg-carousel-container.grabbing .mpg-carousel-track {
    transition: none;
}

/* Accessibility */
.mpg-carousel-container:focus-visible {
    outline: 2px solid var(--mpg-button-bg, #5e4caf);
    outline-offset: 2px;
}

.mpg-carousel-prev:focus-visible,
.mpg-carousel-next:focus-visible,
.mpg-carousel-dot:focus-visible {
    outline: 2px solid var(--mpg-button-bg, #5e4caf);
    outline-offset: 2px;
}

/* Print styles */
@media print {
    .mpg-carousel-navigation {
        display: none;
    }
    
    .mpg-carousel-track {
        display: block;
    }
    
    .mpg-carousel-slide {
        display: block;
        page-break-inside: avoid;
        margin-bottom: 20px;
    }
}