/* ==========================================================================
   Siteplayer — Sticky Footer Player (UIkit-kompatibel, Hover-Swap, Progress)
   ========================================================================== */

/* PJAX Loading Overlay -------------------------------------------------- */
#sp-loading {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #fff;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}
#sp-loading.sp-show {
    opacity: 1;
    pointer-events: auto;
}

#siteplayer-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: var(--sp-height, 90px);
    background-color: var(--sp-bg, #1a1a2e);
    color: var(--sp-color, #fff);
    z-index: 9999;
    overflow: hidden;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    user-select: none;
    -webkit-user-select: none;
}
/* Progress: hard fill (::before) + soft trailing fade (::after) that rides
   just past the fill's right edge. The bar's overflow:hidden clips the fade
   near 100% so the fill visibly reaches the very end. */
/* Single element: width extends 140px past the actual progress edge,
   and a mask fades those trailing 140px to transparent. The bar's
   overflow:hidden clips the overflow near 100%, so the hard fill
   visibly reaches the very end without any visible seam. */
#siteplayer-bar::before {
    content: "";
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: calc(var(--sp-pct, 0%) + 140px);
    background: var(--sp-progress, rgba(255,255,255,0.15));
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 140px), rgba(0,0,0,0) 100%);
            mask-image: linear-gradient(to right, #000 calc(100% - 140px), rgba(0,0,0,0) 100%);
    -webkit-mask-repeat: no-repeat;
            mask-repeat: no-repeat;
    pointer-events: none;
    will-change: width;
    z-index: 0;
}
/* Keep actual content above the fill */
#siteplayer-bar > * { position: relative; z-index: 1; }
#siteplayer-bar.sp-visible { transform: translateY(0); }

body.siteplayer-active {
    padding-bottom: var(--sp-height, 90px) !important;
}

/* Cover --------------------------------------------------------------- */
.sp-cover-wrap {
    height: calc(var(--sp-height, 90px) - 10px);
    width: calc(var(--sp-height, 90px) - 10px);
    margin: 5px;
    cursor: pointer;
}
#sp-cover {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 2px;
}
.sp-cover-wrap .sp-btn {
    background: rgba(0, 0, 0, 0.55);
    border: 0;
    color: inherit;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 2px;
    transition: background 0.15s ease, opacity 0.15s ease;
}
.sp-cover-wrap .sp-btn[hidden] { display: none; }
.sp-cover-wrap .sp-btn svg { width: 60%; height: 60%; }
#sp-stop-btn { background: transparent; opacity: 0; }
.sp-cover-wrap:hover #sp-stop-btn:not([hidden]) {
    opacity: 1;
    background: rgba(0, 0, 0, 0.55);
}

/* Spalten ------------------------------------------------------------- */
.sp-col-left { min-width: 0; height: 100%; }
.sp-col-right { height: 100%; }

/* Meta-Zone (Titel/Artist + Controls gestackt) ----------------------- */
.sp-meta-zone {
    position: relative;
    min-width: 0;
    height: 100%;
    padding: 0 12px;
    flex: 1 1 auto;
}

.sp-meta {
    position: absolute;
    inset: 0;
    padding: 0 12px;
    transition: opacity 0.2s ease;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: calc(var(--sp-height, 90px) / 30);
}
/* Three equally-tall rows — each exactly a third of the bar height so the
   gaps between title / artist / album are visually identical. */
.sp-title-text,
.sp-artist-line,
.sp-album-line {
    font-size: calc(var(--sp-height, 90px) / 5.5);
    /* Absolute line-height so smaller-font rows (album) get the same box
       height and visually equal spacing between rows. */
    line-height: calc(var(--sp-height, 90px) / 5.5 * 1.2);
    text-transform: uppercase;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.sp-title-text { font-weight: bold; }
.sp-album-line {
    font-size: calc(var(--sp-height, 90px) / 6.2);
    color: rgba(255, 255, 255, 0.7);
}
#sp-artist-pre,
#sp-album-pre {
    text-transform: none;
}

/* Controls (Hover-Layer) --------------------------------------------- */
.sp-controls {
    position: absolute;
    inset: 0;
    padding: 0 12px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: calc(var(--sp-height, 90px) / 30);
}
.sp-ctrl-row {
    font-size: calc(var(--sp-height, 90px) / 5.5);
    line-height: calc(var(--sp-height, 90px) / 5.5 * 1.2);
    /* Fixed height = line-height → identical total block height as .sp-meta,
       so switching between views doesn't shift vertically. */
    height: calc(var(--sp-height, 90px) / 5.5 * 1.2);
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sp-ctrl-row:first-child {
    font-weight: bold;
    text-transform: uppercase;
}
.sp-ctrl-row:last-child {
    color: rgba(255, 255, 255, 0.7);
    font-size: calc(var(--sp-height, 90px) / 6.2);
}
.sp-meta-zone:hover .sp-controls,
.sp-meta-zone.sp-controls-open .sp-controls {
    opacity: 1;
    pointer-events: auto;
}

/* Hover-Affordance: dezentes Zahnrad inline hinter dem Album-Text. */
.sp-album-line {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}
.sp-album-text {
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.sp-hover-hint {
    display: inline-flex;
    flex: 0 0 auto;
    color: var(--sp-color, #fff);
    opacity: 0.4;
    transition: opacity 0.2s ease;
    pointer-events: none;
}
.sp-meta-zone:hover .sp-hover-hint,
.sp-meta-zone.sp-controls-open .sp-hover-hint {
    opacity: 0;
}
.sp-meta-zone:hover .sp-meta,
.sp-meta-zone.sp-controls-open .sp-meta {
    opacity: 0;
}

.sp-countdown {
    font-family: monospace;
    font-feature-settings: "tnum";
    font-variant-numeric: tabular-nums;
}
.sp-countdown:empty::before { content: "--:--"; opacity: 0.5; }

.sp-ctrl-vol { align-items: center; }
.sp-ctrl-vol .sp-vol-slider { flex: 0 1 160px; max-width: 60%; }
.sp-vol-icon {
    display: inline-flex;
    align-items: center;
    color: var(--sp-color, #fff);
    opacity: 0.85;
    line-height: 1;
    flex: 0 0 auto;
}
.sp-vol-icon svg { height: 1em; width: auto; }

.sp-vol-slider {
    -webkit-appearance: none;
    appearance: none;
    flex: 1 1 auto;
    min-width: 0;
    height: 4px;
    background: transparent;
    cursor: pointer;
    padding: 0;
    margin: 0;
}
.sp-vol-slider::-webkit-slider-runnable-track {
    height: 4px;
    border-radius: 2px;
    background: linear-gradient(
        to right,
        var(--sp-hover, #febf00) 0%,
        var(--sp-hover, #febf00) var(--sp-vol-pct, 100%),
        rgba(255,255,255,0.3) var(--sp-vol-pct, 100%),
        rgba(255,255,255,0.3) 100%
    );
}
.sp-vol-slider::-moz-range-track {
    height: 4px;
    border-radius: 2px;
    background: rgba(255,255,255,0.3);
}
.sp-vol-slider::-moz-range-progress {
    height: 4px;
    border-radius: 2px;
    background: var(--sp-hover, #febf00);
}
.sp-vol-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    height: 14px;
    width: 14px;
    border-radius: 50%;
    background: var(--sp-color, #fff);
    border: 0;
    margin-top: -5px;
    cursor: pointer;
}
.sp-vol-slider::-moz-range-thumb {
    height: 14px;
    width: 14px;
    border-radius: 50%;
    background: var(--sp-color, #fff);
    border: 0;
    cursor: pointer;
}
.sp-vol-slider:focus { outline: none; }
.sp-vol-slider:focus-visible::-webkit-slider-thumb {
    box-shadow: 0 0 0 3px var(--sp-hover, #febf00);
}

.sp-channel-name {
    cursor: pointer;
    min-width: 0;
}
.sp-channel-name:hover { color: var(--sp-color, #fff); }

/* Info/Banner (Spalte 2, permanent, linksbündig) ---------------------- */
.sp-col-right {
    height: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 12px;
    min-width: 0;
    overflow: hidden;
}
.sp-col-right #sp-countdown {
    margin-left: auto;
    flex-shrink: 0;
    font-size: calc(var(--sp-height, 90px) / 5.5);
    font-weight: bold;
}
.sp-info {
    width: 100%;
    font-weight: 100;
    line-height: 1.3;
    overflow: hidden;
    text-align: left;
}
.sp-info .user {
    font-size: calc(var(--sp-height, 90px) / 6.2);
    color: rgba(255, 255, 255, 0.7);
}
.sp-info:empty { display: none; }
.sp-info img { max-height: calc(var(--sp-height, 90px) - 10px); max-width: 100%; display: block; }
.sp-info a { color: inherit; }

.sp-emoji {
    display: inline-block;
    animation: sp-emoji-wiggle 2.4s ease-in-out infinite;
    transform-origin: 50% 70%;
}
@keyframes sp-emoji-wiggle {
    0%, 70%, 100% { transform: rotate(0) scale(1); }
    78% { transform: rotate(-14deg) scale(1.15); }
    86% { transform: rotate(12deg) scale(1.15); }
    94% { transform: rotate(-6deg) scale(1.08); }
}

/* Mobile (<640px): kein Banner, Artist-Line gekürzt, nur Menu-Icon rechts */
@media (max-width: 639px) {
    #sp-album-wrap.sp-album-line { display: none !important; }

    /* Mobile: Hover deaktivieren, Controls nur via Toggle-Klasse */
    .sp-meta-zone:hover .sp-meta { opacity: 1; }
    .sp-meta-zone:hover .sp-controls { opacity: 0; pointer-events: none; }
    .sp-meta-zone.sp-controls-open .sp-meta { opacity: 0; }
    .sp-meta-zone.sp-controls-open .sp-controls { opacity: 1; pointer-events: auto; }

    /* Stattdessen: Floating Menu-Button rechts */
    #sp-mobile-menu {
        position: absolute;
        right: 8px;
        top: 50%;
        transform: translateY(-50%);
        background: transparent;
        border: 0;
        color: var(--sp-color, #fff);
        cursor: pointer;
        padding: 8px;
        font-size: calc(var(--sp-height, 90px) / 3.5);
        display: flex;
        align-items: center;
        justify-content: center;
        opacity: 0.8;
        z-index: 2;
    }
    #sp-mobile-menu:hover { opacity: 1; color: var(--sp-hover, #febf00); }
    .sp-meta { padding-right: 52px; }
}
@media (min-width: 640px) {
    #sp-mobile-menu { display: none; }
}

/* Channel List (Slide-Up über Footer) --------------------------------- */
#siteplayer-channellist {
    position: fixed;
    left: 0;
    width: 100%;
    z-index: 9998;
    bottom: var(--sp-height, 90px);
    transform: translateY(calc(100% + var(--sp-height, 90px)));
    transition: transform 0.3s ease;
    max-height: 50vh;
    overflow-y: auto;
    background: #fff;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.2);
}
#siteplayer-channellist.sp-open { transform: translateY(0); }

.sp-channel-row {
    display: flex;
    align-items: center;
    cursor: pointer;
    width: 100%;
    box-sizing: border-box;
    transition: background 0.12s ease;
}
.sp-channel-row:nth-child(odd)  { background: var(--sp-list-stripe, #cccccc); }
.sp-channel-row:nth-child(even) { background: var(--sp-list-bg, #ffffff); }
.sp-channel-row:hover,
.sp-channel-row.sp-active,
.sp-channel-row:focus-visible {
    background: var(--sp-hover, #febf00);
    outline: none;
}

.sp-ch-cover {
    flex-shrink: 0;
    object-fit: cover;
    margin: 5px;
}
.sp-ch-info {
    flex: 1 1 auto;
    min-width: 0;
    padding: 10px;
    line-height: 1.4;
    color: var(--sp-color, #222);
    overflow: hidden;
}
.sp-ch-title {
    font-weight: bold;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sp-ch-artist {
    font-size: 0.9em;
    color: var(--sp-color, #444);
    opacity: 0.85;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sp-ch-name {
    font-size: 0.8em;
    opacity: 0.6;
}
.sp-ch-countdown {
    font-family: monospace;
    color: var(--sp-color, #666);
    opacity: 0.7;
    padding: 0 12px;
    flex-shrink: 0;
}
