/* Comparateur avant / après. */

.compare-wrap {
    max-width: 920px;
    margin-inline: auto;
}

.compare-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2);
    justify-content: center;
    margin-bottom: var(--sp-6);
}

.compare-tab {
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 999px;
    padding: 8px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    color: var(--text-soft);
    min-height: 38px;
}

.compare-tab[aria-selected="true"] {
    background: var(--c-green-deep);
    border-color: var(--c-green-deep);
    color: #fff;
}

.ba-slider {
    position: relative;
    width: 100%;
    aspect-ratio: 3 / 2;
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--line);
    background: var(--bg-alt);
    /* `pan-y` : le doigt fait défiler la page verticalement, mais le geste
       horizontal appartient au comparateur. Sans cela, tirer la poignée fait
       défiler la page sur les navigateurs mobiles. */
    touch-action: pan-y;
    cursor: ew-resize;
    user-select: none;
}

.ba-slider img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
}

.ba-slider .ba-after {
    z-index: 1;
}

.ba-slider .ba-before-wrap {
    position: absolute;
    inset: 0;
    z-index: 2;
    overflow: hidden;
    width: 50%;
}

/*
  L'image « après » garde la largeur du cadre, pas celle de sa fenêtre : sans
  cela elle se comprimerait au fur et à mesure du glissement, et les deux
  photos ne seraient plus superposables — ce qui ruine la comparaison.
*/
.ba-slider .ba-before-wrap img {
    width: var(--ba-img-w, 100%);
    max-width: none;
    height: 100%;
}

.ba-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 0;
    z-index: 3;
    transform: translateX(-50%);
    cursor: ew-resize;
}

.ba-handle::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: -1px;
    width: 2px;
    background: #fff;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.ba-handle-knob {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: #fff;
    border: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-soft);
}

.ba-handle-knob svg {
    width: 20px;
    height: 20px;
    color: var(--c-anthracite);
}

.ba-tag {
    position: absolute;
    top: var(--sp-3);
    z-index: 4;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 5px 11px;
    border-radius: 999px;
    background: rgba(26, 29, 31, 0.72);
    color: #fff;
    backdrop-filter: blur(3px);
}

.ba-tag.before {
    left: var(--sp-3);
}

.ba-tag.after {
    right: var(--sp-3);
    background: rgba(29, 91, 60, 0.85);
}

/* La transition n'est active que pendant la démonstration automatique : au
   glissement, la poignée doit suivre le doigt sans latence. */
.ba-before-wrap,
.ba-handle {
    transition: none;
}

.ba-slider.is-demo .ba-before-wrap,
.ba-slider.is-demo .ba-handle {
    transition:
        width 0.8s var(--ease-editorial),
        left 0.8s var(--ease-editorial);
}

.compare-caption {
    margin-top: var(--sp-5);
    text-align: center;
}

.compare-caption .cap-title {
    font-family: var(--font-serif);
    font-size: 1.15rem;
    margin-bottom: 4px;
}

.compare-caption .cap-text {
    font-style: italic;
    font-family: var(--font-serif);
    color: var(--text-soft);
}

.compare-caption p {
    max-width: none;
}
