/* =============================================================
   buildlog_beforeafter.css
   Before / after image comparison slider
   ============================================================= */

/* ---------------------------------------------------------------
   1. VIEWER — slider component
   --------------------------------------------------------------- */
.ba-section {
    margin-bottom: 2rem;
}

.ba-section__heading {
    font-size: 1rem;
    font-weight: 600;
    color: #343a40;
    margin-bottom: 0.75rem;
}

.ba-wrap {
    position: relative;
    width: 100%;
    overflow: hidden;
    border-radius: 12px;
    border: 1px solid #dee2e6;
    cursor: col-resize;
    /* Prevent text selection while dragging */
    user-select: none;
    -webkit-user-select: none;
    /* Let the range input own touch events on its track */
    touch-action: none;
    /* Aspect ratio keeps images from jumping on load */
    aspect-ratio: 16 / 9;
    background: #111;
}

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

.ba-before img,
.ba-after img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
    pointer-events: none; /* clicks fall through to range input */
    /* No drag on images */
    -webkit-user-drag: none;
    user-drag: none;
}

.ba-after {
    clip-path: inset(0 50% 0 0); /* right side hidden by default */
}

/* Divider line */
.ba-divider {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 3px;
    background: #fff;
    transform: translateX(-50%);
    pointer-events: none;
    will-change: left;
}

/* Handle circle */
.ba-handle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    will-change: left;
}

.ba-handle svg {
    width: 22px;
    height: 22px;
    color: #555;
    flex-shrink: 0;
}

/* Labels */
.ba-label {
    position: absolute;
    bottom: 14px;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    pointer-events: none;
}

.ba-label--before { left: 14px; }
.ba-label--after  { right: 14px; }

/* 
   The range input is the actual interactive element.
   It's transparent and stretched over the entire component.
   This makes it keyboard-accessible and screen-reader-friendly.
*/
.ba-range {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: col-resize;
    /* WebKit needs explicit sizing */
    -webkit-appearance: none;
    appearance: none;
}

/* Visible focus ring on the wrap when range is focused */
.ba-wrap:focus-within {
    outline: 3px solid #0d6efd;
    outline-offset: 2px;
}

/* Hint text below slider */
.ba-hint {
    text-align: center;
    font-size: 0.82rem;
    color: #6c757d;
    margin-top: 0.5rem;
}

/* ---------------------------------------------------------------
   2. OWNER PICKER — admin UI inside the edit form
   --------------------------------------------------------------- */
.ba-picker {
    border: 1px solid #dee2e6;
    border-radius: 10px;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.ba-picker__legend {
    font-size: 0.95rem;
    font-weight: 600;
    color: #212529;
    padding: 0 0.5rem;
}

.ba-picker__hint {
    font-size: 0.85rem;
    color: #6c757d;
    margin-bottom: 1rem;
}

.ba-picker__hint--muted {
    font-style: italic;
}

.ba-picker__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
}

.ba-picker__item {
    border: 2px solid #dee2e6;
    border-radius: 8px;
    overflow: hidden;
    transition: border-color 0.15s;
}

.ba-picker__item.is-before {
    border-color: #0d6efd;
}

.ba-picker__item.is-after {
    border-color: #198754;
}

.ba-picker__thumb {
    width: 100%;
    height: 80px;
    object-fit: cover;
    display: block;
}

.ba-picker__actions {
    display: flex;
    gap: 4px;
    padding: 6px;
}

.ba-picker__btn {
    flex: 1;
    padding: 4px 0;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 5px;
    border: 1px solid #dee2e6;
    background: #f8f9fa;
    color: #495057;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.ba-picker__btn[data-role="before"].active {
    background: #0d6efd;
    border-color: #0d6efd;
    color: #fff;
}

.ba-picker__btn[data-role="after"].active {
    background: #198754;
    border-color: #198754;
    color: #fff;
}

.ba-picker__btn:hover:not(.active) {
    background: #e9ecef;
}

/* Focus visible for keyboard users */
.ba-picker__btn:focus-visible {
    outline: 3px solid #ffbf47;
    outline-offset: 2px;
}

/* ---------------------------------------------------------------
   3. RESPONSIVE
   --------------------------------------------------------------- */
@media (max-width: 576px) {
    .ba-wrap {
        aspect-ratio: 4 / 3; /* Taller crop on small screens */
        border-radius: 8px;
    }

    .ba-handle {
        width: 40px;
        height: 40px;
    }

    .ba-label {
        font-size: 0.7rem;
        padding: 3px 8px;
        bottom: 10px;
    }

    .ba-picker__grid {
        grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    }

    .ba-picker__thumb {
        height: 65px;
    }
}