/**
 * Image Compare CSS - Bildvergleich
 *
 * Zwei Bilder übereinander; der Regler gibt über --akt-compare-pos
 * mehr vom linken oder rechten Bild frei. Das rechte Bild wird per
 * clip-path beschnitten, das linke liegt vollflächig darunter.
 *
 * Konsumiert Theme-Tokens (--aktd-*) mit Fallbacks.
 */

.akt-image-compare {
    --akt-compare-pos: 50%;

    width: 100%;
    margin: 0 0 32px;
}

/* Bühne mit festem Bildformat */
.akt-image-compare__stage {
    position: relative;
    width: 100%;
    aspect-ratio: 3 / 2;
    overflow: hidden;
    background: var(--aktd-color-surface, #f1f5f4);
    touch-action: pan-y; /* vertikales Scrollen bleibt möglich */
}

.akt-image-compare--ratio-wide .akt-image-compare__stage {
    aspect-ratio: 16 / 9;
}

.akt-image-compare--ratio-classic .akt-image-compare__stage {
    aspect-ratio: 4 / 3;
}

.akt-image-compare--ratio-square .akt-image-compare__stage {
    aspect-ratio: 1 / 1;
}

/* Bildebenen */
.akt-image-compare__layer {
    position: absolute;
    inset: 0;
}

.akt-image-compare__layer--right {
    /* zeigt nur den Bereich rechts der Reglerposition */
    clip-path: inset(0 0 0 var(--akt-compare-pos));
}

.akt-image-compare .akt-image-compare__img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Beschriftungen */
.akt-image-compare__label {
    position: absolute;
    bottom: 16px;
    padding: 7px 14px;
    background: rgba(0, 0, 0, 0.45);
    color: var(--aktd-color-white, #ffffff);
    font-family: var(--aktd-font-accent, sans-serif);
    font-size: 15px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    line-height: 1.2;
    pointer-events: none;
}

.akt-image-compare__label--left {
    left: 16px;
}

.akt-image-compare__label--right {
    right: 16px;
}

/* Trennlinie mit Griff */
.akt-image-compare__handle {
    position: absolute;
    top: 0;
    bottom: 0;
    left: var(--akt-compare-pos);
    width: 2px;
    margin-left: -1px;
    background: var(--aktd-color-white, #ffffff);
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.35);
    pointer-events: none;
}

.akt-image-compare__grip {
    position: absolute;
    top: 50%;
    left: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: var(--aktd-color-white, #ffffff);
    color: var(--aktd-color-script-heading, #2b957e);
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.3);
}

/* Regler: liegt unsichtbar über der Bühne und bleibt voll bedienbar
   (Maus, Touch, Tastatur). `opacity: 0` statt transparenter Flächen,
   weil Browser den Track sonst als feine Linie zeichnen. Die sichtbare
   Bedienung übernehmen Trennlinie und Griff. */
.akt-image-compare__range {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    opacity: 0;
    -webkit-appearance: none;
    appearance: none;
    cursor: ew-resize;
}

/* Native Track-Darstellung ausblenden (Chrome zeichnet sonst eine Linie) */
.akt-image-compare__range::-webkit-slider-runnable-track {
    height: 100%;
    border: 0;
    background: transparent;
}

.akt-image-compare__range::-moz-range-progress {
    background: transparent;
}

.akt-image-compare__range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: transparent;
    cursor: ew-resize;
}

.akt-image-compare__range::-moz-range-thumb {
    width: 46px;
    height: 46px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    cursor: ew-resize;
}

.akt-image-compare__range::-moz-range-track {
    height: 100%;
    border: 0;
    background: transparent;
}

/* Sichtbarer Fokus für Tastaturbedienung: der Griff wird hervorgehoben
   (der Regler selbst ist unsichtbar). */
.akt-image-compare__range:focus-visible ~ .akt-image-compare__handle .akt-image-compare__grip {
    box-shadow: 0 0 0 3px var(--aktd-color-script-heading, #2b957e), 0 3px 12px rgba(0, 0, 0, 0.3);
}

/* Leerzustand (nur für Redakteure sichtbar) */
.akt-image-compare__no-content {
    padding: 16px;
    border: 2px dashed #c3c4c7;
    border-radius: 3px;
    color: #646970;
    font-size: 14px;
    text-align: center;
}

/* Responsive */
@media (max-width: 544px) {

    .akt-image-compare {
        margin-bottom: 24px;
    }

    .akt-image-compare__grip {
        width: 38px;
        height: 38px;
    }

    .akt-image-compare__label {
        bottom: 10px;
        padding: 5px 10px;
        font-size: 13px;
    }

    .akt-image-compare__label--left {
        left: 10px;
    }

    .akt-image-compare__label--right {
        right: 10px;
    }
}

/* Barrierefreiheit / Print */
@media (prefers-contrast: high) {

    .akt-image-compare__handle {
        width: 4px;
    }
}

@media print {

    /* Im Druck beide Bilder nebeneinander zeigen */
    .akt-image-compare__layer--right {
        clip-path: inset(0 0 0 50%);
    }

    .akt-image-compare__handle,
    .akt-image-compare__range {
        display: none;
    }
}
