/* Waveform bar: two tinted channels, played/unplayed shading, needle, seek slider. */

.waveform {
    --progress: 0;

    position: relative;
    position: relative;
    height: clamp(6rem, 16vh, 9.5rem);
    overflow: hidden;
    border-block: 2px solid #000;
    background-color: rgb(255 255 255 / 0.1);

    &.is-empty .waveform__channel {
        opacity: 0;
    }

    &:has(.waveform__seek:focus-visible) {
        outline: 3px solid var(--kp-focus);
        outline-offset: -3px;
    }
}

.waveform__channel {
    position: absolute;
    inset: 0;
    background: var(--waveform, none) no-repeat;
    background-size: 100% 200%;
    opacity: 0.5;

    &.waveform__channel--left {
        background-position: top;
    }

    &.waveform__channel--right {
        background-position: bottom;
        filter: hue-rotate(45deg);
    }
}

/* Unplayed part greyed out, like the old player's hue overlay. */
.waveform__played {
    position: absolute;
    inset: 0 0 0 calc(var(--progress) * 100%);
    background: #000;
    mix-blend-mode: hue;
    pointer-events: none;
}

.waveform__needle {
    position: absolute;
    inset-block: 0;
    left: calc(var(--progress) * 100%);
    width: 1px;
    background: #000;
    box-shadow: 0 0 14px 6px rgb(255 255 255 / 0.76);
    pointer-events: none;
}

.waveform__marks {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

/* The native slider covers the bar: click and drag anywhere to seek. */
.waveform__seek {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: pointer;
    appearance: none;
}

@media (orientation: portrait), (max-width: 56rem) {
    .waveform {
        height: 4.5rem;
    }
}
