/* ============================================================
   Before/After Slider & Cycle — Styles
   ============================================================
   Supports two modes:
   1. Interactive drag slider (.ba-slider)
   2. Auto-cycling before/after (.ba-cycle)
   ============================================================ */

/* ── Grid: multiple sliders ────────────────────────────────── */
.ba-slider-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
    padding: 1rem 0;
}

/* ================================================================
   MODE 1: INTERACTIVE DRAG SLIDER
   ================================================================ */

.ba-slider {
    position: relative;
    overflow: hidden;
    border-radius: 16px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    outline: none;
}

.ba-slider:focus-visible {
    box-shadow:
        0 4px 16px rgba(0, 0, 0, 0.15),
        0 0 0 3px rgba(0, 168, 232, 0.4);
}

.ba-slider-container {
    position: relative;
    aspect-ratio: 3 / 2;
    cursor: col-resize;
    user-select: none;
    -webkit-user-select: none;
    overflow: hidden;
}

.ba-before,
.ba-after {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.ba-after {
    clip-path: inset(0 0 0 50%);
}

.ba-before img,
.ba-after img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
}

/* ── Labels (BEFORE / AFTER badges) ────────────────────────── */
.ba-label {
    position: absolute;
    bottom: 16px;
    background: rgba(255, 255, 255, 0.92);
    color: #333333;
    font-family: 'Prompt', sans-serif;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 5px 12px;
    border-radius: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    pointer-events: none;
    z-index: 5;
}

.ba-label-before {
    left: 16px;
}

.ba-label-after {
    right: 16px;
}

/* ── Handle (vertical divider) ─────────────────────────────── */
.ba-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 44px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
    pointer-events: none;
    transition: left 0.05s ease-out;
}

.ba-handle-line {
    width: 2px;
    flex-grow: 1;
    background: #ffffff;
    filter: drop-shadow(0 0 3px rgba(0, 0, 0, 0.35));
}

.ba-handle-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.25),
        0 0 0 2px rgba(0, 168, 232, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    pointer-events: auto;
    flex-shrink: 0;
    transition: box-shadow 0.2s ease, transform 0.15s ease;
}

.ba-handle-circle:active {
    cursor: grabbing;
    transform: scale(1.08);
    box-shadow:
        0 3px 12px rgba(0, 0, 0, 0.3),
        0 0 0 3px rgba(0, 168, 232, 0.5);
}

.ba-handle-circle i {
    font-size: 16px;
    color: #00A8E8;
}

/* ── Bounce hint animation ─────────────────────────────────── */
@keyframes ba-bounce-hint {
    0%   { left: 50%; }
    20%  { left: 35%; }
    40%  { left: 60%; }
    60%  { left: 42%; }
    80%  { left: 55%; }
    100% { left: 50%; }
}

.ba-slider.ba-hint-active .ba-handle {
    animation: ba-bounce-hint 1.2s ease-in-out;
    transition: none;
}

.ba-slider.ba-hint-active .ba-after {
    animation: ba-clip-hint 1.2s ease-in-out;
}

@keyframes ba-clip-hint {
    0%   { clip-path: inset(0 0 0 50%); }
    20%  { clip-path: inset(0 0 0 35%); }
    40%  { clip-path: inset(0 0 0 60%); }
    60%  { clip-path: inset(0 0 0 42%); }
    80%  { clip-path: inset(0 0 0 55%); }
    100% { clip-path: inset(0 0 0 50%); }
}

/* ── Optional title above slider ───────────────────────────── */
.ba-slider-title {
    font-family: 'Prompt', sans-serif;
    font-size: 1.25rem;
    font-weight: 600;
    color: #333333;
    text-align: center;
    margin-bottom: 0.75rem;
}

/* ================================================================
   MODE 2: AUTO-CYCLING BEFORE/AFTER
   ================================================================ */

.ba-cycle {
    position: relative;
    overflow: hidden;
    border-radius: 16px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    outline: none;
}

.ba-cycle:focus-visible {
    box-shadow:
        0 4px 16px rgba(0, 0, 0, 0.15),
        0 0 0 3px rgba(0, 168, 232, 0.4);
}

.ba-cycle-container {
    position: relative;
    aspect-ratio: 3 / 2;
    overflow: hidden;
}

.ba-cycle-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 0.6s ease-in-out;
}

.ba-cycle-image.active {
    opacity: 1;
}

.ba-cycle-image img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Cycle controls (Before / After toggle buttons) */
.ba-cycle-controls {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 4px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 25px;
    padding: 4px;
    z-index: 10;
}

.ba-cycle-btn {
    background: transparent;
    color: rgba(255, 255, 255, 0.7);
    border: none;
    font-family: 'Prompt', sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 6px 16px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.ba-cycle-btn:hover {
    color: #ffffff;
}

.ba-cycle-btn.active {
    background: #00A8E8;
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(0, 168, 232, 0.3);
}

/* Progress bar */
.ba-cycle-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: rgba(255, 255, 255, 0.2);
    z-index: 10;
}

.ba-cycle-progress-bar {
    height: 100%;
    background: #00A8E8;
    width: 0%;
    transition: width 0.1s linear;
}

/* ================================================================
   SHOWCASE SECTION
   ================================================================ */

.ba-showcase {
    background: linear-gradient(135deg, #f0f7fb 0%, #e8f4f8 50%, #f5f9fc 100%);
    border-top: 3px solid #00A8E8;
    border-bottom: 1px solid #e0edf3;
    position: relative;
}

.ba-showcase .section-title h2 {
    color: #1a3a4a;
}

.ba-showcase .section-title p {
    color: #5a7a8a;
}

.ba-showcase-hint {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 1.5rem;
    font-size: 0.85rem;
    color: #7a9aaa;
    font-style: italic;
}

.ba-showcase-hint i {
    color: #00A8E8;
    font-size: 1rem;
}

/* Single slider: center it with a max-width */
.ba-slider-grid:has(> :only-child) {
    grid-template-columns: 1fr;
    max-width: 700px;
    margin: 0 auto;
}

/* Two sliders: 2 columns */
.ba-slider-grid:has(> :nth-child(2)):not(:has(> :nth-child(3))) {
    grid-template-columns: repeat(2, 1fr);
}

/* ================================================================
   RESPONSIVE
   ================================================================ */

@media (max-width: 1024px) {
    .ba-slider-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 767px) {
    .ba-showcase > .container {
        padding-left: 6px;
        padding-right: 6px;
    }

    .ba-slider-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
        padding: 0.5rem 0;
    }

    .ba-slider-grid:has(> :only-child) {
        max-width: 100%;
    }

    .ba-slider,
    .ba-cycle {
        border-radius: 8px;
        max-width: 100%;
    }

    .ba-handle-circle {
        width: 34px;
        height: 34px;
    }

    .ba-handle-circle i {
        font-size: 14px;
    }

    .ba-handle {
        width: 38px;
    }

    .ba-label {
        font-size: 0.6rem;
        padding: 4px 10px;
        bottom: 10px;
    }

    .ba-label-before {
        left: 10px;
    }

    .ba-label-after {
        right: 10px;
    }

    .ba-slider-title {
        font-size: 1.1rem;
    }

    .ba-cycle-controls {
        bottom: 10px;
    }

    .ba-cycle-btn {
        font-size: 0.65rem;
        padding: 5px 12px;
    }
}

@media (max-width: 480px) {
    .ba-handle-circle {
        width: 30px;
        height: 30px;
    }

    .ba-handle-circle i {
        font-size: 12px;
    }

    .ba-handle {
        width: 34px;
    }
}
