/**
 * MES Expanding Projects Carousel - Scoped Styles
 * v2.1.0 - Fixed white flash on expand/collapse + infinite loop support
 * All styles scoped to .mes-carousel-wrapper to prevent site-wide conflicts
 */

/* CSS Variables scoped to carousel only */
.mes-carousel-wrapper {
    --mes-primary-blue: #0099FF;
    --mes-primary-dark: #0077CC;
    --mes-text-dark: #1a1a1a;
    --mes-text-medium: #444;
    --mes-text-light: #666;
    --mes-border-light: #e5e5e5;
    --mes-shadow-sm: 0 2px 8px rgba(0,0,0,0.08);
    --mes-shadow-md: 0 4px 16px rgba(0,0,0,0.12);
    --mes-shadow-lg: 0 8px 32px rgba(0,0,0,0.16);
}

/* Main Carousel Wrapper */
.mes-carousel-wrapper {
    max-width: 100% !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 20px 0 0 0 !important;
    overflow: hidden;
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    box-sizing: border-box;
}

/* Carousel Container */
.mes-carousel-wrapper .mes-carousel-container {
    position: relative;
    padding: 0;
    padding-bottom: 95px;
    min-height: auto;
}

.mes-carousel-wrapper .mes-carousel-track-container {
    overflow: visible;
    padding: 0;
    position: relative;
}

.mes-carousel-wrapper .mes-carousel-track {
    display: flex;
    gap: 20px;
    will-change: transform;
}

/* Smooth transition - toggled by JS only when sliding */
.mes-carousel-wrapper .mes-carousel-track.animating {
    transition: transform 0.7s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Individual Project Card */
.mes-carousel-wrapper .mes-project-card {
    min-width: 440px;
    width: 440px;
    height: 570px;
    background: white;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: none;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1),
                min-width 0.5s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    flex-shrink: 0;
    position: relative;
}

.mes-carousel-wrapper .mes-project-card:hover:not(.expanded) {
    box-shadow: none;
    transform: translateY(-4px);
}

.mes-carousel-wrapper .mes-project-card.expanded {
    min-width: 780px;
    width: 780px;
    height: 570px;
    z-index: 10;
    box-shadow: none;
    transform: translateY(-4px);
}

/* Card Inner - stacking context for crossfade */
.mes-carousel-wrapper .mes-card-inner {
    position: relative;
    height: 570px;
    width: 100%;
}

/* ============================================================
   CROSSFADE FIX: Both layers are absolutely positioned and
   overlap. On expand, the expanded layer fades IN on top of
   the collapsed layer (which stays visible underneath).
   No white gap = no flash.
   ============================================================ */

/* Main Card (collapsed view) - stays visible as base layer */
.mes-carousel-wrapper .mes-card-main {
    position: absolute;
    top: 0;
    left: 0;
    width: 440px;
    height: 570px;
    display: flex;
    flex-direction: column;
    z-index: 1;
}

.mes-carousel-wrapper .mes-project-image {
    width: 100%;
    height: 80%;
    flex-shrink: 0;
    object-fit: cover;
    display: block;
}

.mes-carousel-wrapper .mes-card-content {
    padding: 20px;
    height: 20%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
}

.mes-carousel-wrapper .mes-project-title {
    font-size: 18px;
    font-weight: 500;
    color: var(--mes-text-dark);
    line-height: 1.3;
    text-align: center;
    margin: 0;
}

/* Expanded Content - fades in ON TOP, never hides the base */
.mes-carousel-wrapper .mes-card-expanded-content {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 570px;
    padding: 0;
    background: white;
    opacity: 0;
    z-index: 2;
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    pointer-events: none;
}

.mes-carousel-wrapper .mes-project-card.expanded .mes-card-expanded-content {
    opacity: 1;
    pointer-events: auto;
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1) 0.12s;
}

/* Landscape design image - 56% height (320px) */
.mes-carousel-wrapper .mes-expanded-image {
    width: 100%;
    height: 320px;
    object-fit: cover;
    display: block;
    flex-shrink: 0;
}

/* Content area - flexible layout */
.mes-carousel-wrapper .mes-expanded-info {
    padding: 12px 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: visible;
    min-height: 0;
}

/* Custom scrollbar */
.mes-carousel-wrapper .mes-expanded-info::-webkit-scrollbar {
    width: 6px;
}

.mes-carousel-wrapper .mes-expanded-info::-webkit-scrollbar-track {
    background: #f0f0f0;
    border-radius: 3px;
}

.mes-carousel-wrapper .mes-expanded-info::-webkit-scrollbar-thumb {
    background: var(--mes-primary-blue);
    border-radius: 3px;
}

.mes-carousel-wrapper .mes-expanded-info::-webkit-scrollbar-thumb:hover {
    background: var(--mes-primary-dark);
}

/* Title - 1 line only, truncate with ellipsis */
.mes-carousel-wrapper .mes-expanded-info .mes-project-title {
    font-size: 16px !important;
    font-weight: 500;
    margin-bottom: 4px;
    text-align: left;
    line-height: 1.3 !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
}

/* Location - natural height, never shrinks */
.mes-carousel-wrapper .mes-expanded-info .mes-project-location {
    display: flex;
    font-size: 13px;
    color: var(--mes-text-light);
    margin-bottom: 6px;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.mes-carousel-wrapper .mes-expanded-info .mes-project-location::before {
    content: '';
    width: 16px;
    height: 16px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%230099FF'%3E%3Cpath d='M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7zm0 9.5c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5z'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    flex-shrink: 0;
}

/* Status badge - natural height, never shrinks */
.mes-carousel-wrapper .mes-expanded-info .mes-project-status {
    display: block;
    margin-bottom: 8px;
    flex-shrink: 0;
}

.mes-carousel-wrapper .status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    background: #ECF7FF !important;
    color: #0099FF !important;
}

/* Excerpt - max 6 lines with ellipsis */
.mes-carousel-wrapper .mes-expanded-info .mes-project-excerpt {
    font-size: 13px;
    color: var(--mes-text-medium);
    line-height: 1.5;
    word-wrap: break-word;
    display: -webkit-box !important;
    -webkit-line-clamp: 6 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
    text-overflow: ellipsis;
    margin: 0;
}

/* Navigation Arrows */
.mes-carousel-wrapper .mes-carousel-nav {
    position: absolute;
    top: 590px;
    transform: none;
    width: 52px;
    height: 52px;
    background: white;
    border: 2px solid var(--mes-border-light);
    border-radius: 50%;
    box-shadow: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 30;
    transition: all 0.2s ease-out;
    color: var(--mes-text-dark);
    pointer-events: auto;
}

.mes-carousel-wrapper .mes-carousel-nav:hover {
    background: var(--mes-primary-blue);
    border-color: var(--mes-primary-blue);
    color: white;
    transform: scale(1.08);
    box-shadow: none;
}

.mes-carousel-wrapper .mes-carousel-nav:active {
    transform: scale(0.95);
}

.mes-carousel-wrapper .mes-carousel-nav.prev {
    right: 70px;
}

.mes-carousel-wrapper .mes-carousel-nav.next {
    right: 10px;
}

.mes-carousel-wrapper .mes-carousel-nav:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

/* Responsive */
@media (max-width: 768px) {
    .mes-carousel-wrapper .mes-project-card,
    .mes-carousel-wrapper .mes-card-main {
        min-width: 320px;
        width: 320px;
    }
    
    .mes-carousel-wrapper .mes-project-card {
        pointer-events: auto !important;
        cursor: default !important;
    }
    
    .mes-carousel-wrapper .mes-project-card:hover {
        transform: none !important;
        box-shadow: none !important;
    }
    
    .mes-carousel-wrapper .mes-project-card.expanded {
        min-width: 320px !important;
        width: 320px !important;
    }
    
    .mes-carousel-wrapper .mes-project-card.expanded .mes-card-main {
        opacity: 1 !important;
        pointer-events: auto !important;
    }
    
    .mes-carousel-wrapper .mes-card-expanded-content {
        display: none !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }
}

@media (max-width: 480px) {
    .mes-carousel-wrapper .mes-project-card,
    .mes-carousel-wrapper .mes-card-main {
        min-width: 280px;
        width: 280px;
    }
}