/**
 * Moving Cards Carousel Styles
 *
 * @package Moving_Cards
 */

/* ============================================
   CSS Variables (defaults)
   ============================================ */
.moving-cards,
.dajana-carousel {
    --dc-gap: 16px;
    --dc-card-radius: 20px;
    --dc-card-bg: rgba(0,0,0,0.6);
    --dc-card-border: none;
    --dc-card-ratio: 75%;
    --dc-title-font: inherit;
    --dc-title-size: 1.25rem;
    --dc-title-color: #ffffff;
    --dc-date-color: rgba(255,255,255,0.8);
    --dc-overlay-color: rgba(0,0,0,0.5);
}

/* ============================================
   Main Container
   ============================================ */
.moving-cards,
.dajana-carousel {
    position: relative;
    /* Break out of parent container to full viewport width */
    /* JS sets --dc-viewport-width to clientWidth (excludes scrollbar) */
    width: var(--dc-viewport-width, 100vw);
    max-width: var(--dc-viewport-width, 100vw);
    margin-left: var(--dc-viewport-offset, calc(-50vw + 50%));
    padding: 20px 0;
    /* Clip horizontal overflow, allow vertical for shadows */
    overflow-x: clip;
    overflow-y: visible;
}

/* Prevent horizontal scroll caused by full-width carousel */
/* Using clip instead of hidden: hidden forces overflow-y to auto (CSS spec), */
/* creating dual scroll containers on html+body = double scrollbar bug. */
/* clip does NOT create a scroll container, so overflow-y stays unaffected. */
html.has-moving-cards,
html.has-moving-cards body {
    overflow-x: clip;
}

.dc-swiper {
    overflow: visible; /* Allow shadows to render outside */
    padding: 50px 0; /* Space for shadows above and below cards */
}

/* Contained edge style - only full cards visible */
.moving-cards[data-edge="contained"] .dc-swiper {
    max-width: var(--dc-contained-width, 100%);
    margin-left: auto;
    margin-right: auto;
    overflow-x: clip;
    overflow-y: visible;
}

.dc-swiper .swiper-wrapper {
    align-items: center;
    /* 3D enabled for coverflow depth effect */
}

/* ============================================
   Slide / Card Container
   ============================================ */
.dc-slide {
    width: var(--dc-card-width, 280px);
    transition: transform 0.3s ease, opacity 0.3s ease;
    transform-origin: center center;
    /* Note: transform-style removed to allow coverflow depth to work */
}

/* Slides not visible - handled by JS scale effect */
/* opacity controlled by JS progress callback */

/* Card width override for responsive - only if not using custom card_width */
.moving-cards:not([style*="--dc-card-width"]) .dc-slide {
    width: 280px;
}

@media (min-width: 768px) {
    .moving-cards:not([style*="--dc-card-width"]) .dc-slide {
        width: 320px;
    }
}

@media (min-width: 1024px) {
    .moving-cards:not([style*="--dc-card-width"]) .dc-slide {
        width: 360px;
    }
}

/* Mobile card width override (from admin setting) */
@media (max-width: 767px) {
    .moving-cards[style*="--dc-card-width-mobile"] .dc-slide {
        width: var(--dc-card-width-mobile);
    }
    .moving-cards[style*="--dc-card-ratio-mobile"] .dc-card {
        padding-bottom: var(--dc-card-ratio-mobile);
    }
}

/* ============================================
   Card
   ============================================ */
.dc-card {
    position: relative;
    width: 100%;
    padding-bottom: var(--dc-card-ratio);
    height: var(--dc-card-height, auto);
    border-radius: var(--dc-card-radius);
    overflow: hidden;
    cursor: pointer !important;
    background: var(--dc-card-bg);
    border: var(--dc-card-border);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    /* Note: transform-style removed to allow coverflow depth to work */
}

/* Ensure pointer cursor on all card children */
.dc-card * {
    cursor: pointer !important;
}

.dc-card:hover {
    /* No transform - prevents click issues from card movement */
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
}

/* Squircle Corner Style (iOS-like smooth corners) */
.dc-corner-squircle .dc-card,
.dc-corner-squircle .dc-card-image,
.dc-corner-squircle .dc-expanded-card {
    /* Fallback: regular border-radius is already applied */
    /* Modern browsers with corner-shape support */
    corner-shape: squircle;
    -webkit-corner-shape: squircle;
}

/* Card Image */
.dc-card-image {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    background-color: #2a2a2a;
    transition: transform 0.4s ease;
    /* Fix Chrome squircle rendering during animation */
    will-change: transform;
    backface-visibility: hidden;
}

.dc-card:hover .dc-card-image {
    transform: scale(1.05);
}

.dc-card-no-image {
    background: linear-gradient(135deg, #374151 0%, #1f2937 100%);
}

/* Card Overlay */
.dc-card-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.dc-overlay-gradient {
    background: linear-gradient(
        to top,
        var(--dc-overlay-color) 0%,
        rgba(0, 0, 0, 0.3) 40%,
        transparent 70%
    );
}

.dc-overlay-solid {
    background: var(--dc-overlay-color);
}

/* Card Content - uses JS-calculated responsive values */
.dc-card-content {
    position: absolute;
    bottom: var(--dc-content-padding, clamp(6px, 2vw, 20px));
    left: var(--dc-content-padding, clamp(8px, 2.5vw, 24px));
    right: var(--dc-content-padding, clamp(8px, 2.5vw, 24px));
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: var(--dc-content-gap, clamp(4px, 1vw, 8px));
}

/* Card Type Badge - uses JS-calculated responsive values */
.dc-card-type {
    display: inline-block;
    width: fit-content;
    padding: var(--dc-type-padding, clamp(2px, 1%, 4px) clamp(6px, 2.5%, 10px));
    font-size: var(--dc-type-font-size, clamp(0.6rem, 2%, 0.7rem));
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(4px);
}

.dc-type-mec {
    background: rgba(59, 130, 246, 0.3);
}

.dc-type-post {
    background: rgba(16, 185, 129, 0.3);
}

/* Card Title - uses JS-calculated responsive size if available */
.dc-card-title {
    margin: 0;
    font-family: var(--dc-title-font);
    font-size: var(--dc-title-size-scaled, var(--dc-title-size));
    font-weight: 600;
    line-height: 1.3;
    color: var(--dc-title-color);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Date Badge (top right corner) - uses JS-calculated responsive values */
.dc-card-date-badge {
    position: absolute;
    top: var(--dc-badge-top, 8px);
    right: var(--dc-badge-right, 8px);
    z-index: 5;
    padding: var(--dc-badge-padding, 4px 8px);
    font-size: var(--dc-badge-font-size, 0.75rem);
    font-weight: 600;
    color: #ffffff;
    background: var(--dc-date-badge-bg, rgba(0, 0, 0, 0.6));
    border-radius: 4px;
    backdrop-filter: blur(4px);
}

/* Legacy Card Date (bottom, hidden by default) */
.dc-card-date {
    font-size: 0.875rem;
    color: var(--dc-date-color);
    display: none;
}

/* Card "Read More" - moved to popup only */
.dc-card-more {
    display: none;
    font-weight: 500;
    color: var(--dc-title-color);
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.dc-card:hover .dc-card-more {
    opacity: 1;
    transform: translateY(0);
}

.dc-card-more svg {
    transition: transform 0.2s ease;
}

.dc-card:hover .dc-card-more svg {
    transform: translateX(4px);
}

/* ============================================
   Navigation Arrows
   - Uses .moving-cards prefix for specificity
     to override Elementor/theme button styles
   ============================================ */
.moving-cards .dc-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    transition: all 0.2s ease;
    padding: 0;
    margin: 0;
    color: #374151;
    line-height: 1;
    text-decoration: none;
}

.moving-cards .dc-nav:hover {
    background: #ffffff;
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.moving-cards .dc-nav:active {
    transform: translateY(-50%) scale(0.95);
}

.moving-cards .dc-nav svg {
    width: 24px;
    height: 24px;
    color: #374151;
}

.moving-cards .dc-nav-prev {
    left: 20px;
}

.moving-cards .dc-nav-next {
    right: 20px;
}

@media (max-width: 768px) {
    .moving-cards .dc-nav {
        width: 40px;
        height: 40px;
    }

    .moving-cards .dc-nav svg {
        width: 20px;
        height: 20px;
    }

    .moving-cards .dc-nav-prev {
        left: 10px;
    }

    .moving-cards .dc-nav-next {
        right: 10px;
    }
}

/* Arrows at bottom (next to pagination) */
.moving-cards .dc-nav-bottom-wrapper .dc-nav {
    position: static;
    transform: none;
}

.moving-cards .dc-nav-bottom-wrapper .dc-nav:hover {
    transform: scale(1.1);
}

.moving-cards .dc-nav-bottom-wrapper .dc-nav:active {
    transform: scale(0.95);
}

.moving-cards .dc-nav-bottom-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: var(--dc-nav-gap, 48px);
}

.moving-cards .dc-nav-bottom-wrapper .dc-nav {
    width: 32px;
    height: 32px;
}

.moving-cards .dc-nav-bottom-wrapper .dc-nav svg {
    width: 18px;
    height: 18px;
}

.dc-nav-bottom-wrapper .dc-pagination {
    margin-top: 0 !important;
    width: auto !important;
    flex: 0 0 auto;
    display: flex !important;
    align-items: center !important;
    height: 32px;
    line-height: 32px;
}

.dc-nav-bottom-wrapper .dc-pagination .swiper-pagination-bullet {
    margin: 0 4px !important;
    transform: translateY(10px);
}

/* ============================================
   Pagination
   ============================================ */
.dc-pagination {
    position: relative;
    margin-top: 24px;
    display: flex;
    justify-content: center;
    gap: 8px;
}

.dc-pagination .swiper-pagination-bullet {
    width: 10px;
    height: 10px;
    background: rgba(0, 0, 0, 0.2);
    opacity: 1;
    transition: all 0.2s ease;
}

.dc-pagination .swiper-pagination-bullet-active {
    background: #3b82f6;
    transform: scale(1.2);
}

/* Fraction pagination */
.dc-pagination.swiper-pagination-fraction {
    font-size: 0.875rem;
    color: #6b7280;
}

/* Progress bar pagination */
.dc-pagination.swiper-pagination-progressbar {
    position: relative;
    height: 4px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 2px;
    max-width: 200px;
    margin: 24px auto 0;
}

.dc-pagination .swiper-pagination-progressbar-fill {
    background: #3b82f6;
    border-radius: 2px;
}

/* ============================================
   Overlay for Expand
   ============================================ */
.dc-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 9998;
}

.dc-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* ============================================
   Expanded Card
   ============================================ */
.dc-expanded-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.dc-expanded-container.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translate(-50%, -50%) scale(1);
}

.dc-expanded-card {
    position: relative;
    width: 500px;
    max-width: 90vw;
    max-height: 90vh;
    background: #ffffff;
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
}

.dc-expanded-image {
    width: 100%;
    height: 250px;
    background-size: cover;
    background-position: center;
    background-color: #2a2a2a;
    flex-shrink: 0;
}

.dc-expanded-content {
    padding: 28px;
    overflow-y: auto;
    min-height: 0;
}

.dc-expanded-type {
    display: inline-block;
    padding: 4px 10px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: 4px;
    margin-bottom: 12px;
}

.dc-expanded-type.dc-type-mec {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
}

.dc-expanded-type.dc-type-post {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

.dc-expanded-title {
    margin: 0 0 12px;
    font-size: 1.5rem;
    font-weight: 700;
    color: #1a1a1a;
    line-height: 1.3;
}

.dc-expanded-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e5e7eb;
    font-size: 0.875rem;
    color: #6b7280;
}

.dc-expanded-meta span {
    display: flex;
    align-items: center;
    gap: 6px;
}

.dc-expanded-meta svg {
    width: 16px;
    height: 16px;
    opacity: 0.7;
}

.dc-expanded-excerpt {
    margin: 0 0 20px;
    font-size: 0.95rem;
    line-height: 1.6;
    color: #4b5563;
}

.dc-expanded-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: #ffffff;
    font-size: 0.95rem;
    font-weight: 600;
    text-decoration: none;
    border-radius: 12px;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.dc-expanded-button:hover {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4);
    color: #ffffff;
}

.dc-expanded-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    transition: background 0.2s ease, box-shadow 0.2s ease;
    font-size: 26px;
    line-height: 1;
    text-align: center;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-bottom: 4px;
    color: #374151;
}

.dc-expanded-close:hover {
    background: #ffffff;
    box-shadow: 0 2px 14px rgba(0, 0, 0, 0.3);
    color: #374151;
}

/* ============================================
   Preset: Glass
   ============================================ */
.dc-preset-glass .dc-card {
    /* Glass border */
    border: 2px solid rgba(255, 255, 255, 0.6);
    /* 3D depth with inset shadows */
    box-shadow:
        inset 4px 4px 16px rgba(255, 255, 255, 0.6),
        inset -2px -2px 12px rgba(0, 0, 0, 0.15),
        inset 0 0 30px rgba(255, 255, 255, 0.2),
        0 10px 40px rgba(0, 0, 0, 0.3);
}

/* Glass reflection overlay on top of image */
.dc-preset-glass .dc-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    z-index: 1;
    /* Multi-layer gradients for glass shine */
    background:
        /* Top-left shine */
        linear-gradient(
            145deg,
            rgba(255, 255, 255, 0.7) 0%,
            rgba(255, 255, 255, 0.35) 10%,
            rgba(255, 255, 255, 0.1) 25%,
            transparent 40%
        ),
        /* Center radial glow */
        radial-gradient(
            ellipse 70% 50% at 50% 50%,
            rgba(255, 255, 255, 0.15) 0%,
            rgba(255, 255, 255, 0.05) 40%,
            transparent 70%
        ),
        /* Bottom-right subtle highlight */
        linear-gradient(
            -30deg,
            transparent 60%,
            rgba(255, 255, 255, 0.1) 80%,
            rgba(255, 255, 255, 0.2) 100%
        );
}

/* Additional center shine spot */
.dc-preset-glass .dc-card::after {
    content: '';
    position: absolute;
    top: 20%;
    left: 20%;
    width: 30%;
    height: 30%;
    border-radius: 50%;
    background: radial-gradient(
        circle,
        rgba(255, 255, 255, 0.25) 0%,
        rgba(255, 255, 255, 0.1) 30%,
        transparent 70%
    );
    filter: blur(6px);
    pointer-events: none;
    z-index: 2;
}

/* Ensure content is above glass effects */
.dc-preset-glass .dc-card-content {
    z-index: 3;
}

.dc-preset-glass .dc-nav {
    background: rgba(255, 255, 255, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow:
        inset 1px 1px 4px rgba(255, 255, 255, 0.4),
        0 2px 8px rgba(0, 0, 0, 0.1);
}

.dc-preset-glass .dc-nav:hover {
    background: rgba(255, 255, 255, 0.35);
    filter: brightness(1.1);
}

.dc-preset-glass .dc-nav svg {
    color: #ffffff;
}

/* ============================================
   Preset: Dark
   ============================================ */
.dc-preset-dark .dc-card {
    background: rgba(0, 0, 0, 0.85);
}

.dc-preset-dark .dc-nav {
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.dc-preset-dark .dc-nav:hover {
    background: rgba(0, 0, 0, 0.9);
}

.dc-preset-dark .dc-nav svg {
    color: #ffffff;
}

/* ============================================
   Preset: Light
   ============================================ */
.dc-preset-light .dc-card {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.dc-preset-light .dc-card-title {
    color: #1a1a1a;
    text-shadow: none;
}

.dc-preset-light .dc-card-date {
    color: #6b7280;
}

.dc-preset-light .dc-card-more {
    color: #3b82f6;
}

.dc-preset-light .dc-card-type {
    background: rgba(0, 0, 0, 0.1);
    color: #374151;
}

/* ============================================
   Preset: Minimal
   ============================================ */
.dc-preset-minimal .dc-card {
    background: transparent;
    border: none;
    box-shadow: none;
    border-radius: 8px;
}

.dc-preset-minimal .dc-card:hover {
    box-shadow: none;
}

.dc-preset-minimal .dc-card-image {
    border-radius: 8px;
}

/* ============================================
   No items message
   ============================================ */
.dc-no-items {
    text-align: center;
    padding: 40px;
    color: #6b7280;
    font-style: italic;
}

/* ============================================
   Responsive
   ============================================ */

/* Fix: force GPU layers on card content to prevent disappearing during swipe animation */
.dc-card-overlay,
.dc-card-content,
.dc-card-date-badge {
    transform: translateZ(0);
    backface-visibility: hidden;
}

@media (max-width: 768px) {
    /* Reduce swiper shadow padding on mobile */
    .dc-swiper {
        padding: 20px 0;
    }

    /* Reduce nav-to-cards gap on mobile */
    .moving-cards .dc-nav-bottom-wrapper {
        margin-top: 16px;
    }
}

/* Expanded card mobile adjustments */
@media (max-width: 768px) {
    .dc-expanded-container {
        max-width: 96vw;
        max-height: 94vh;
    }

    .dc-expanded-card {
        max-width: 96vw;
        max-height: 94vh;
        width: 96%;
    }

    .dc-expanded-image {
        height: 180px;
    }

    .dc-expanded-content {
        padding: 16px;
    }
}

@media (max-width: 640px) {
    .dajana-carousel {
        padding: 20px 0;
    }

    .dc-slide {
        width: 260px;
    }

    /* Card content padding now handled by clamp() */

    .dc-card-title {
        font-size: 1rem;
    }

    .dc-expanded-card {
        width: 96%;
        border-radius: 16px;
    }

    .dc-expanded-image {
        height: 150px;
    }

    .dc-expanded-content {
        padding: 16px;
    }

    .dc-expanded-title {
        font-size: 1.25rem;
    }

    .dc-expanded-button {
        width: 100%;
        justify-content: center;
    }
}
