/* ============================================================
   Before After Slider — slider.css
   ============================================================ */

/* ── Gallery grid ────────────────────────────────────────── */
.bas-gallery {
    width: 100%;
}

.bas-gallery-title {
    font-size: 1.6em;
    margin-bottom: 24px;
    text-align: center;
}

.bas-gallery-grid {
    display: grid;
    /* gap overridden inline by shortcode via --bas-gap custom property */
    gap: var(--bas-gap, 28px);
}

/* ── Column layouts: 1–5 ─────────────────────────────────── */
.bas-gallery-cols-1 .bas-gallery-grid { grid-template-columns: 1fr; }
.bas-gallery-cols-2 .bas-gallery-grid { grid-template-columns: repeat(2, 1fr); }
.bas-gallery-cols-3 .bas-gallery-grid { grid-template-columns: repeat(3, 1fr); }
.bas-gallery-cols-4 .bas-gallery-grid { grid-template-columns: repeat(4, 1fr); }
.bas-gallery-cols-5 .bas-gallery-grid { grid-template-columns: repeat(5, 1fr); }

/* ── Responsive breakpoints ──────────────────────────────── */

/* ≥ 4 cols → cap to 3 on mid-size screens */
@media (max-width: 1100px) {
    .bas-gallery-cols-4 .bas-gallery-grid,
    .bas-gallery-cols-5 .bas-gallery-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ≥ 3 cols → 2 on tablets */
@media (max-width: 768px) {
    .bas-gallery-cols-3 .bas-gallery-grid,
    .bas-gallery-cols-4 .bas-gallery-grid,
    .bas-gallery-cols-5 .bas-gallery-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Everything → 1 col on small phones */
@media (max-width: 480px) {
    .bas-gallery-cols-2 .bas-gallery-grid,
    .bas-gallery-cols-3 .bas-gallery-grid,
    .bas-gallery-cols-4 .bas-gallery-grid,
    .bas-gallery-cols-5 .bas-gallery-grid {
        grid-template-columns: 1fr;
    }
}

/* ── Aspect ratio mode ───────────────────────────────────── */
/*
 * When aspect_ratio is set the shortcode adds .bas-has-ratio
 * and an inline aspect-ratio style. Images switch to absolute
 * positioning so they fill the fixed-height box.
 */
.bas-container.bas-has-ratio {
    height: auto; /* aspect-ratio CSS property drives the height */
}

.bas-container.bas-has-ratio .bas-img.bas-after {
    position: absolute !important;
    top: 0; left: 0;
    width: 100% !important;
    height: 100% !important;
    -o-object-fit: cover !important;
       object-fit: cover !important;
}

.bas-gallery-item {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
        -ms-flex-direction: column;
            flex-direction: column;
}

/* Caption below each slider */
.bas-gallery-caption {
    padding: 12px 4px 0;
}

.bas-gallery-case-title {
    display: block;
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 4px;
    color: inherit;
}

.bas-gallery-desc {
    font-size: 13px;
    color: #666;
    margin: 0;
    line-height: 1.5;
}

.bas-no-results {
    color: #888;
    font-style: italic;
}

/* ============================================================
   Slider core
   ============================================================ */

.bas-container {
    position: relative;
    width: 100%;
    /* box-sizing so theme padding/borders don't break layout */
    -webkit-box-sizing: border-box;
            box-sizing: border-box;
    overflow: hidden;
    cursor: col-resize;
    -webkit-user-select: none;
       -moz-user-select: none;
        -ms-user-select: none;
            user-select: none;
    /* allow vertical scroll on touch; horizontal is handled by JS */
    -ms-touch-action: pan-y;
        touch-action: pan-y;
    border-radius: var(--bas-radius, 12px);
    -webkit-box-shadow: 0 4px 24px rgba(0, 0, 0, 0.18);
            box-shadow: 0 4px 24px rgba(0, 0, 0, 0.18);
    background: #111;
    line-height: 0;
}

/* ── Images ──────────────────────────────────────────────── */
.bas-container .bas-img {
    display: block;
    width: 100%;
    height: auto;
    pointer-events: none;
    /* override object-fit theme resets */
    -o-object-fit: fill;
       object-fit: fill;
}

/* After image — base layer */
.bas-container .bas-after {
    position: relative;
    z-index: 1;
}

/* Before image — clipped wrapper */
.bas-container .bas-before-wrap {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    overflow: hidden;
    z-index: 2;
}

/*
 * Specificity: .bas-container .bas-before (two classes) beats
 * .entry-content img (tag + class) used by Twenty Twenty, Astra, etc.
 * height !important guards against theme "img { height: auto !important }"
 */
.bas-container .bas-before {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    /* intrinsic width set by JS — must never be constrained */
    max-width: none !important;
    height: 100% !important;
    -o-object-fit: cover;
       object-fit: cover;
}

/* ── Divider handle ──────────────────────────────────────── */
.bas-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    -webkit-transform: translateX(-50%);
        -ms-transform: translateX(-50%);
            transform: translateX(-50%);
    z-index: 10;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
        -ms-flex-direction: column;
            flex-direction: column;
    -webkit-box-align: center;
        -ms-flex-align: center;
            align-items: center;
    cursor: col-resize;
}

.bas-handle-line {
    -webkit-box-flex: 1;
        -ms-flex: 1;
            flex: 1;
    width: 3px;
    background: #fff;
    -webkit-box-shadow: 0 0 6px rgba(0, 0, 0, 0.5);
            box-shadow: 0 0 6px rgba(0, 0, 0, 0.5);
}

.bas-handle-circle {
    -ms-flex-negative: 0;
        flex-shrink: 0;
    width: 48px;
    height: 48px;
    background: #fff;
    border-radius: 50%;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
        -ms-flex-align: center;
            align-items: center;
    -webkit-box-pack: center;
        -ms-flex-pack: center;
            justify-content: center;
    -webkit-box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
            box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
    color: #222;
    -webkit-transition: -webkit-transform 0.15s ease, -webkit-box-shadow 0.15s ease;
            transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.bas-handle-circle svg {
    width: 22px;
    height: 22px;
    pointer-events: none;
}

.bas-handle:hover  .bas-handle-circle,
.bas-handle.active .bas-handle-circle {
    -webkit-transform: scale(1.1);
        -ms-transform: scale(1.1);
            transform: scale(1.1);
    -webkit-box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

/* ── Focus ring ─────────────────────────────────────────── */
/*
 * Keep a visible ring on :focus as a baseline (IE11, old Edge).
 * :focus-visible suppresses it for mouse users in modern browsers.
 */
.bas-handle:focus {
    outline: 3px solid #4d90fe;
    outline-offset: 2px;
}

/* Modern browsers: hide ring for mouse, show for keyboard */
.bas-handle:focus:not(:focus-visible) {
    outline: none;
}

.bas-handle:focus-visible {
    outline: 3px solid #4d90fe;
    outline-offset: 2px;
}

/* ── Labels ──────────────────────────────────────────────── */
.bas-label {
    position: absolute;
    top: 16px;
    z-index: 9;
    padding: 4px 12px;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.03em;
    border-radius: 4px;
    pointer-events: none;
    line-height: 1.4;
    /* reset common theme overrides */
    text-transform: none;
    -webkit-box-shadow: none;
            box-shadow: none;
    -webkit-transition: opacity 0.25s ease;
            transition: opacity 0.25s ease;
}

.bas-label-before { left: 16px; }
.bas-label-after  { right: 16px; }

/* ── Mobile ──────────────────────────────────────────────── */
@media (max-width: 480px) {
    .bas-handle-circle {
        width: 40px;
        height: 40px;
    }
    .bas-handle-circle svg {
        width: 18px;
        height: 18px;
    }
    .bas-label {
        font-size: 11px;
        padding: 3px 8px;
        top: 10px;
    }
}
