/* ============================================================
   mod_jdslider - slider.css
   Campaign slider module for Joom Donation.
   All classes are prefixed with "jdslider-" to avoid conflicts.
   Mobile-first approach.
   Compatible with Joomla 4, 5, 6.
   ============================================================ */

/* ---- Reset scoped to this module ---- */
.jdslider-wrapper *,
.jdslider-wrapper *::before,
.jdslider-wrapper *::after {
    box-sizing: border-box;
}

/* ---- Outer wrapper ---- */
.jdslider-wrapper {
    position: relative;
    width: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    /* Arrows now overlay the viewport – no horizontal padding needed */
}

/* When arrows are hidden the no-arrows class is added by JS (kept for back-compat). */
.jdslider-wrapper.no-arrows {
    padding: 0;
}

/* ---- Viewport wrapper: arrows are positioned relative to this element ---- */
.jdslider-viewport-wrapper {
    position: relative;
}

/* ---- Viewport: clips overflow so only N cards are visible ---- */
.jdslider-viewport {
    overflow: hidden;
    width: 100%;
}

/* ---- Track: contains all slides side-by-side ---- */
.jdslider-track {
    display: flex;
    transition: transform 0.45s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
    /* Gap is set inline by JS as a CSS custom property: --jdslider-gap */
    gap: var(--jdslider-gap, 20px);
}

/* Disable transition during drag */
.jdslider-track.is-dragging {
    transition: none;
}

/* ---- Individual slide ---- */
.jdslider-slide {
    /* Width is calculated and applied by JS */
    flex: 0 0 auto;
    min-width: 0;
}

/* ---- Campaign card ---- */
.jdslider-card {
    display: flex;
    flex-direction: column;
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.09);
    transition: box-shadow 0.25s ease, transform 0.25s ease;
    height: 100%;
}

.jdslider-card:hover {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    transform: translateY(-3px);
}

/* ---- Card image (aspect-ratio via padding-bottom trick) ---- */
.jdslider-card-image {
    position: relative;
    width: 100%;
    overflow: hidden;
    background: #f0f2f5;
    /* padding-bottom is set inline in PHP to achieve the chosen aspect ratio */
}

.jdslider-card-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.4s ease;
}

.jdslider-card:hover .jdslider-card-img {
    transform: scale(1.04);
}

/* Image placeholder */
.jdslider-card-img-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #c0c4cc;
    background: linear-gradient(135deg, #f5f7fa 0%, #e4e8ef 100%);
}

/* ---- Status badge (days-left / open / closed) ---- */
.jdslider-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    background: rgba(255, 140, 66, 0.92);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    padding: 4px 10px;
    border-radius: 20px;
    line-height: 1.4;
    pointer-events: none;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.jdslider-badge--open {
    background: rgba(16, 185, 129, 0.9);
}

.jdslider-badge--closed {
    background: rgba(100, 116, 139, 0.85);
}

/* ---- Card body ---- */
.jdslider-card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 18px 20px 20px;
    gap: 10px;
}

/* ---- Title ---- */
.jdslider-card-title {
    font-size: 17px;
    font-weight: 700;
    color: #1e293b;
    margin: 0;
    line-height: 1.4;
    /* Prevent runaway long titles */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.jdslider-card-title-link {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s ease;
}

.jdslider-card-title-link:hover,
.jdslider-card-title-link:focus {
    color: #ff6b35;
    text-decoration: none;
}

/* ---- Summary ---- */
.jdslider-card-summary {
    font-size: 13.5px;
    color: #64748b;
    line-height: 1.6;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ---- Progress section ---- */
.jdslider-card-progress {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Progress bar track */
.jdslider-progress-bar {
    height: 6px;
    background: #e9ecef;
    border-radius: 10px;
    overflow: hidden;
}

/* Progress bar fill */
.jdslider-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #ff8c42 0%, #ff6b35 100%);
    border-radius: 10px;
    transition: width 0.7s ease 0.2s;
    width: 0;
}

/* Stats row */
.jdslider-stats {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.jdslider-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.jdslider-stat-value {
    font-size: 16px;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.2;
}

.jdslider-stat-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #94a3b8;
}

/* ---- Social sharing ---- */
.jdslider-social {
    display: flex;
    gap: 8px;
    align-items: center;
}

.jdslider-social-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    text-decoration: none;
    color: #fff;
    transition: transform 0.2s ease, opacity 0.2s ease;
    flex-shrink: 0;
}

.jdslider-social-btn:hover,
.jdslider-social-btn:focus {
    transform: scale(1.12);
    opacity: 0.88;
    text-decoration: none;
    color: #fff;
}

.jdslider-social-btn--fb  { background: #1877f2; }
.jdslider-social-btn--tw  { background: #1da1f2; }
.jdslider-social-btn--li  { background: #0a66c2; }

/* ---- Donate CTA button ---- */
.jdslider-card-action {
    margin-top: auto;
}

.jdslider-donate-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 22px;
    background: linear-gradient(135deg, #ff8c42 0%, #ff6b35 100%);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.3px;
    text-decoration: none;
    border-radius: 50px;
    box-shadow: 0 4px 14px rgba(255, 107, 53, 0.38);
    transition: transform 0.22s ease, box-shadow 0.22s ease, background 0.22s ease;
}

.jdslider-donate-btn:hover,
.jdslider-donate-btn:focus {
    background: linear-gradient(135deg, #ff7a2e 0%, #ff5822 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 107, 53, 0.5);
    color: #fff;
    text-decoration: none;
}

.jdslider-donate-btn:active {
    transform: translateY(0);
}

/* ---- Navigation arrows ---- */
.jdslider-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.92);
    color: #475569;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.14);
    transition: background 0.22s ease, color 0.22s ease, box-shadow 0.22s ease, transform 0.22s ease, opacity 0.25s ease;
    padding: 0;
    /* Hidden by default; revealed when the slider is hovered or focused */
    opacity: 0;
    pointer-events: none;
}

/* Reveal arrows when the wrapper is hovered or an arrow receives keyboard focus */
.jdslider-wrapper:hover .jdslider-arrow,
.jdslider-arrow:focus {
    opacity: 1;
    pointer-events: auto;
}

.jdslider-arrow:hover {
    background: #ff8c42;
    color: #fff;
    box-shadow: 0 4px 16px rgba(255, 140, 66, 0.45);
    transform: translateY(-50%) scale(1.06);
}

.jdslider-arrow:focus {
    outline: 2px solid #ff8c42;
    outline-offset: 2px;
}

/* Disabled state is always applied, even on wrapper hover */
.jdslider-wrapper:hover .jdslider-arrow:disabled,
.jdslider-arrow:disabled {
    opacity: 0.35;
    cursor: default;
    pointer-events: none;
}

.jdslider-arrow--prev {
    left: 8px;
}

.jdslider-arrow--next {
    right: 8px;
}

.jdslider-arrow svg {
    pointer-events: none;
    flex-shrink: 0;
}

/* ---- Dot indicators ---- */
.jdslider-dots {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 16px 0 4px;
    flex-wrap: wrap;
}

.jdslider-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: none;
    background: #cbd5e1;
    cursor: pointer;
    padding: 0;
    transition: background 0.22s ease, width 0.22s ease, border-radius 0.22s ease, transform 0.22s ease;
    flex-shrink: 0;
}

.jdslider-dot.is-active {
    background: #ff8c42;
    width: 24px;
    border-radius: 4px;
}

.jdslider-dot:hover {
    background: rgba(255, 140, 66, 0.65);
    transform: scale(1.2);
}

.jdslider-dot:focus {
    outline: 2px solid #ff8c42;
    outline-offset: 2px;
}

/* ---- Empty state ---- */
.jdslider-empty {
    text-align: center;
    padding: 60px 20px;
    background: #f8fafc;
    border: 2px dashed #e2e8f0;
    border-radius: 12px;
    color: #94a3b8;
}

.jdslider-empty svg {
    display: block;
    margin: 0 auto 12px;
    opacity: 0.35;
}

.jdslider-empty p {
    font-size: 15px;
    margin: 0;
}

/* ---- Drag cursor ---- */
.jdslider-viewport.is-grab {
    cursor: grab;
}

.jdslider-viewport.is-grabbing {
    cursor: grabbing;
    user-select: none;
}

/* ---- Responsive ---- */

/* Tablet (≤ 1024px): handled by JS breakpoints, CSS only adjusts aesthetics */
@media (max-width: 1024px) {
    /* No wrapper padding adjustments needed – arrows are overlaid */
}

/* Mobile (≤ 640px) */
@media (max-width: 640px) {
    .jdslider-card-body {
        padding: 14px 16px 16px;
    }

    .jdslider-card-title {
        font-size: 15px;
    }

    .jdslider-card-summary {
        font-size: 13px;
        -webkit-line-clamp: 2;
    }

    .jdslider-stat-value {
        font-size: 14px;
    }

    .jdslider-donate-btn {
        padding: 9px 18px;
        font-size: 12px;
    }

    /* Always show arrows on small/touch screens – hover isn't available */
    .jdslider-arrow {
        opacity: 1;
        pointer-events: auto;
        width: 32px;
        height: 32px;
    }
}

/* ---- Accessibility: reduced-motion ---- */
@media (prefers-reduced-motion: reduce) {
    .jdslider-track {
        transition: none !important;
    }

    .jdslider-card,
    .jdslider-card-img,
    .jdslider-progress-fill,
    .jdslider-arrow,
    .jdslider-dot,
    .jdslider-donate-btn,
    .jdslider-social-btn {
        transition: none !important;
        animation: none !important;
    }
}
