/* Audio packs in the gallery: shares .collection's frame, context and title styles from gallery-style.css */

/* Player Canvas, sized and shaded like .model-canvas */
.audio-collection .audio-canvas{
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    gap: 14px;

    border-radius: 5px;
    box-shadow: 0 0px 10px rgba(0, 0, 0, 0.5);

    background-color: rgb(0, 0, 0, 0.1);

    margin: 10px;
    padding: 0 16px 20px 16px;

    user-select: none;

    container-type: inline-size; /* the controls scale with the player's own width (cqi units) */
}

.audio-collection .audio-canvas h3{
    padding-left: 0;
    padding-top: 14px;
    padding-bottom: 0;
}

/* Waveform seek bar: the played layer is the same bars in white, clipped to --progress */
.audio-collection .waveform{
    position: relative;
    flex: 1 1 auto;
    min-height: clamp(60px, 17cqi, 120px); /* shrinks with the player, like the controls */

    cursor: pointer;
    touch-action: pan-y; /* vertical swipes scroll the page; taps and sideways drags seek */
    -webkit-tap-highlight-color: transparent;
}

.audio-collection .waveform .bars{
    position: absolute;
    inset: 0;

    display: flex;
    align-items: center;
    gap: 4px;
}

.audio-collection .waveform .bars span{
    flex: 1 1 0;
    min-height: 2px;
    border-radius: 2px;
    background-color: rgba(255, 255, 255, 0.18);
}

.audio-collection .waveform .bars.played{
    clip-path: inset(0 calc(100% - var(--progress, 0%)) 0 0);
}

.audio-collection .waveform .bars.played span{
    background-color: rgba(255, 255, 255, 0.85);
}

.audio-collection .waveform:focus-visible,
.audio-collection .audio-btn:focus-visible,
.audio-collection .track:focus-visible{
    outline: 2px solid white;
    outline-offset: 2px;
}

.audio-collection .waveform:focus{
    outline: none;
}

/* Controls row: time on the left, transport in the middle, volume on the right; the equal-basis sides keep the transport centred.
   Every size derives from --control, which scales with the player's width (cqi) so narrow players shrink the whole row together. */
.audio-collection .audio-controls{
    --control: clamp(24px, 8.5cqi, 64px);
    --time-scale: 0.33;

    display: flex;
    align-items: center;
    gap: calc(var(--control) * 0.3);
}

.audio-collection .audio-buttons{
    display: flex;
    flex: none;
    align-items: center;
    gap: calc(var(--control) * 0.18);
}

/* Time */
.audio-collection .audio-time{
    flex: 1 1 0;
    white-space: nowrap;

    font-family: "Roboto-Condensed", sans-serif;
    font-size: max(10px, calc(var(--control) * var(--time-scale)));
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.5);

    font-variant-numeric: tabular-nums;
}

/* Buttons, shaped like the gallery Download button: blue for play, the 3D prompt's grey for the rest */
.audio-collection .audio-btn{
    --btn-color: 98, 104, 118;

    display: inline-flex;
    justify-content: center;
    align-items: center;

    flex: none;
    width: calc(var(--control) * 1.1);
    height: var(--control);

    color: white;
    border: none;
    border-radius: calc(var(--control) * 0.14);
    background-color: rgb(var(--btn-color));

    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;

    transition: background-color 0.3s ease;
}

.audio-collection .audio-btn svg{
    width: calc(var(--control) * 0.5);
    height: calc(var(--control) * 0.5);
    pointer-events: none;
}

.audio-collection .audio-btn.play-btn{
    --btn-color: 87, 114, 172;
    width: calc(var(--control) * 2);
}

.audio-collection .audio-btn:disabled{
    opacity: 0.35;
    cursor: default;
}

@media (hover: hover) and (pointer: fine) {
    .audio-collection .audio-btn:not(:disabled):hover{
        background-color: rgb(var(--btn-color), 0.65);
    }
}

/* Press and loading feedback only change colours: transforming or fading the button would put it on its own compositing
   layer, and at a fractional position that layer can flash a dark hairline beside the icon (most visibly in Safari). */
.audio-collection .audio-btn:not(:disabled):active{
    background-color: rgb(var(--btn-color), 0.5);
    transition: none;
}

.audio-collection .play-btn .pause-icon,
.audio-collection .audio-canvas:is([data-state="playing"], [data-state="loading"]) .play-btn .play-icon{
    display: none;
}

.audio-collection .audio-canvas:is([data-state="playing"], [data-state="loading"]) .play-btn .pause-icon{
    display: block;
}

/* The icons fill with currentColor, so pulsing the button's colour pulses the icon */
.audio-collection .audio-canvas[data-state="loading"] .play-btn{
    animation: audio-loading 1s ease-in-out infinite alternate;
}

@keyframes audio-loading {
    from { color: rgb(255, 255, 255); }
    to { color: rgba(255, 255, 255, 0.35); }
}

/* Volume: the speaker icon shows the level, and the ticked slider pops up above the button */
.audio-collection .volume{
    position: relative;
    flex: 1 1 0;
    display: flex;
    justify-content: flex-end;
}

.audio-collection .audio-btn.volume-btn{
    width: var(--control);
    touch-action: none; /* with a mouse, vertical drags set the volume */
}

.audio-collection .volume.mute-only .volume-btn{
    touch-action: manipulation;
}

.audio-collection .volume[data-level="muted"] :is(.wave-low, .wave-high),
.audio-collection .volume[data-level="low"] :is(.wave-high, .wave-mute),
.audio-collection .volume[data-level="high"] .wave-mute{
    display: none;
}

/* Sits over the button (the slider is as wide as it); padding bridges the gap so moving the mouse up keeps it open */
.audio-collection .volume-popup{
    position: absolute;
    bottom: 100%;
    right: 0;
    z-index: 3;
    padding-bottom: calc(var(--control) * 0.15);

    visibility: hidden;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0s linear 0.15s;
}

.audio-collection .volume.open .volume-popup,
.audio-collection .volume:has(:focus-visible) .volume-popup{
    visibility: visible;
    opacity: 1;
    transform: none;
    transition: opacity 0.15s ease, transform 0.15s ease;
}

@media (hover: hover) and (pointer: fine) {
    .audio-collection .volume:hover .volume-popup{
        visibility: visible;
        opacity: 1;
        transform: none;
        transition: opacity 0.15s ease, transform 0.15s ease;
    }
}

.audio-collection .volume.mute-only .volume-popup{
    display: none;
}

.audio-collection .volume-slider{
    display: flex;
    flex-direction: column-reverse;
    justify-content: space-between;
    align-items: center;

    box-sizing: border-box;
    width: var(--control);
    height: calc(var(--control) * 3);
    padding: calc(var(--control) * 0.22) calc(var(--control) * 0.2);

    border-radius: calc(var(--control) * 0.14);
    background-color: rgb(34, 35, 37);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);

    cursor: pointer;
    touch-action: none;
}

.audio-collection .volume-slider span{
    height: max(2px, calc(var(--control) * 0.08));
    border-radius: 2px;
    background-color: rgba(255, 255, 255, 0.18);
    pointer-events: none;
}

.audio-collection .volume-slider span.lit{
    background-color: rgba(255, 255, 255, 0.85);
}

.audio-collection .volume-slider:focus{
    outline: none;
}

.audio-collection .volume-slider:focus-visible{
    outline: 2px solid white;
    outline-offset: 2px;
}

/* Track List, styled like the model selector tiles */
.audio-collection .track-list{
    display: flex;
    flex-direction: column;
    gap: 10px;

    margin: 10px;
}

.audio-collection .track{
    display: grid;
    grid-template-columns: 1.2em auto 1fr auto; /* number, divider, name, length */
    align-items: center;
    gap: 0.5em;
    width: 100%;

    font-size: 28px;
    color: rgba(255, 255, 255, 0.85);
    text-align: left;

    padding: 18px 24px;
    border: 2px solid transparent;
    border-radius: 12px;
    background-color: rgb(0, 0, 0, 0.1);

    cursor: pointer;
    user-select: none;
    touch-action: manipulation; /* no double-tap-zoom wait before the tap registers */
    -webkit-tap-highlight-color: transparent;

    transition: background-color 0.2s ease;
}

/* Hover only where it exists, so a tapped row doesn't stay highlighted on touch screens */
@media (hover: hover) and (pointer: fine) {
    .audio-collection .track:hover{
        background-color: rgb(255, 255, 255, 0.06);
    }
}

.audio-collection .track:active{
    background-color: rgb(255, 255, 255, 0.1);
    transition: none;
}

.audio-collection .track.active{
    border-color: white;
}

.audio-collection .track-number,
.audio-collection .track-length{
    font-family: "Roboto-Condensed", sans-serif;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.5);
    font-variant-numeric: tabular-nums;
}

/* Wide enough for two digits or the equalizer, so names line up across tracks */
.audio-collection .track-number{
    text-align: center;
}

.audio-collection .track-divider{
    width: 1px;
    height: 0.9em;
    background-color: rgba(255, 255, 255, 0.25);
}

.audio-collection .track-name{
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* The playing track swaps its number for a small equalizer */
.audio-collection .track-eq{
    display: none;
    align-items: flex-end;
    gap: 3px;
    height: 0.8em;
}

.audio-collection .track-eq span{
    width: 4px;
    height: 100%;
    border-radius: 1px;
    background-color: white;
    animation: track-eq 0.9s ease-in-out infinite alternate;
}

.audio-collection .track-eq span:nth-child(2){ animation-delay: -0.3s; }
.audio-collection .track-eq span:nth-child(3){ animation-delay: -0.6s; }

@keyframes track-eq {
    from { transform: scaleY(0.25); }
    to { transform: scaleY(1); }
}

.audio-collection .track-eq span{
    transform-origin: bottom;
}

.audio-collection.is-playing .track.active .track-number{
    font-size: 0;
}

.audio-collection.is-playing .track.active .track-eq{
    display: inline-flex;
    font-size: 28px;
}

@media (prefers-reduced-motion: reduce) {
    .audio-collection .track-eq span,
    .audio-collection .audio-canvas[data-state="loading"] .play-btn{
        animation: none;
    }
}

/* Media Query for Larger Screens */
@media ((min-width: 768px) and (min-aspect-ratio: 7/10)) {
    .audio-collection .audio-canvas{
        gap: 10px;
        padding: 0 16px 16px 16px;
    }

    .audio-collection .waveform{
        min-height: 64px;
    }

    .audio-collection .waveform .bars{
        gap: 3px;
    }

    .audio-collection .audio-controls{
        --control: clamp(28px, 8cqi, 40px);
        --time-scale: 0.4;
    }

    .audio-collection .track{
        font-size: 20px;
        padding: 8px 18px;
    }

    .audio-collection.is-playing .track.active .track-eq{
        font-size: 20px;
    }
}

/* Wide screens put model canvases beside their context; the player stays full width above it instead */
@media ((min-width: 1300px)) {
    .audio-collection .display{
        flex-direction: column;
    }
}
