/* ==========================================================================
   1. ОСНОВНОЙ КОНТЕЙНЕР ПЛЕЕРА
   ========================================================================== */
/* Плеер внутри шапки — position: relative, flows в .vrk-header-right */
.audio-player {
    position: relative;
    top: auto;
    right: auto;
    z-index: 1001;
    background: #000;
    border: none;
    
    outline-offset: -1.5px;
    padding: 4px 4px 4px 4px;
    border-radius: 15px;
    color: #fff;
    width: 280px;
    max-width: 320px;
    height: 32px;
    transition: none;
    box-sizing: border-box;
    overflow: visible !important;
}

/* Минималистичный вид (шапка плеера) */
.minimal-view {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    cursor: pointer;
    width: 100%;
}

/* Play слева от названия трека */
.minimal-view .mini-play-btn {
    order: -1;
}

/* Время — прижато вправо */
.minimal-view .mini-time {
    margin-left: auto;
}

/* ==========================================================================
   2. БЕСШОВНАЯ БЕГУЩАЯ СТРОКА (БЕЗ ТРОЕТОЧИЯ)
   ========================================================================== */
/* Контейнер-маска (по умолчанию в свернутом виде на ПК) */
.track-title-container {
    overflow: hidden;
    white-space: nowrap;
    flex: 1;
    position: relative;
}

/* Маска применяется только когда текст бегущий (.marquee) */
.track-title-container:has(.track-title.marquee) {
    -webkit-mask-image: linear-gradient(to right, transparent, black 8%, black 92%, transparent);
    mask-image: linear-gradient(to right, transparent, black 8%, black 92%, transparent);
}

/* Флекс-блок для выстраивания текстовых копий в одну линию */
.track-title {
    font-size: 14px;
    line-height: 1;
    letter-spacing: 0.5px;
    display: inline-flex !important; 
    white-space: nowrap;
    text-overflow: clip !important; /* Полностью убираем три точки (...) */
    overflow: visible !important;
    max-width: none !important;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}

/* Стилизация копий текста внутри строки */
.track-title span {
    display: inline-block;
    padding-right: 40px; /* Отступ между концом одной строки и началом следующей */
}

/* Стили для текста в плейлисте */
.option-content span {
    font-size: 14px;
    letter-spacing: 0.3px;
}

/* Анимация бесконечной прокрутки */
.track-title.marquee {
    animation: seamlessMarquee 12s linear infinite; 
}

/* Смещение ровно на 50% флекс-контейнера (на одну полную длину копии текста) */
@keyframes seamlessMarquee {
    0% {
        transform: translate3d(0, 0, 0);
    }
    100% {
        transform: translate3d(-50%, 0, 0); 
    }
}

/* Вспомогательные элементы времени и микро-плей */
.mini-time {
    font-size: 11px;
    line-height: 1;
    color: #ccc;
    min-width: 28px;
    text-align: right;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-top: 2px;
}

.mini-play-btn {
    background: rgba(255, 255, 255, 0.08);
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    flex-shrink: 0;
    font-size: 11px;
    transition: background 0.2s ease;
}

.mini-play-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* ==========================================================================
   3. ЭЛЕМЕНТЫ УПРАВЛЕНИЯ (СКРЫТЫ ПО УМОЛЧАНИЮ)
   ========================================================================== */
.player-controls,
.player-progress,
.custom-select-container {
    display: flex;
    visibility: hidden;
    opacity: 0;
    height: 0;
    overflow: hidden;
    margin: 0;
    padding: 0;
    transition: none;
}

.player-progress {
    flex-direction: column;
    width: 100%;
    box-sizing: border-box;
}

.player-controls {
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
}

/* Инфо о времени под треком */
.time-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 10px;
    color: #aaa;
    width: 100%;
    margin-top: 2px;
}

/* Контейнер громкости */
.volume-container {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 28px;
    flex: 1;
}

/* Ползунки (Прогресс и Громкость) */
.progress-slider {
    width: 100%;
    margin: 0;
}

.volume-slider {
    width: 100%; 
    margin: 0;
}

.slider {
    -webkit-appearance: none;
    appearance: none;
    background: #444;
    height: 4px;
    border-radius: 2px;
    outline: none;
    touch-action: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
}

/* ==========================================================================
   4. КНОПКИ И ИКОНКИ УПРАВЛЕНИЯ (CSS-рисунки)
   ========================================================================== */
.btn {
    background: none;
    border: none;
    color: #888; 
    cursor: pointer;
    transition: color 0.2s, background-color 0.2s;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px; 
    height: 28px;
    border-radius: 6px;
}

.btn:hover {
    color: #fff;
}

.btn-main {
    color: #fff;
    font-size: 16px;
}

.btn-loop.active, 
.btn-shuffle.active {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.2);
}

/* Иконка паузы */
.css-pause-icon {
    display: flex;
    justify-content: space-between;
    width: 10px;
    height: 12px;
}
.css-pause-icon span {
    display: block;
    width: 3px;
    height: 100%;
    background-color: #fff;
}
.btn .css-pause-icon {
    width: 12px;
    height: 14px;
}
.btn .css-pause-icon span {
    width: 4px;
}

/* Иконка назад */
.css-prev-icon {
    display: flex;
    align-items: center;
    width: 12px;
    height: 12px;
}
.css-prev-icon .line {
    width: 2px;
    height: 100%;
    background-color: currentColor;
}
.css-prev-icon .arrow {
    width: 0;
    height: 0;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-right: 8px solid currentColor;
}

/* Иконка вперед */
.css-next-icon {
    display: flex;
    align-items: center;
    width: 12px;
    height: 12px;
}
.css-next-icon .line {
    width: 2px;
    height: 100%;
    background-color: currentColor;
}
.css-next-icon .arrow {
    width: 0;
    height: 0;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-left: 8px solid currentColor;
}

/* Иконка перемешивания */
.css-shuffle-icon {
    position: relative;
    width: 14px;
    height: 12px;
    color: currentColor;
}
.css-shuffle-icon::before {
    content: "";
    position: absolute;
    left: 0;
    top: 2px;
    width: 10px;
    height: 2px;
    background: currentColor;
    transform: skewY(22deg);
    transform-origin: left top;
}
.css-shuffle-icon::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: 2px;
    width: 10px;
    height: 2px;
    background: currentColor;
    transform: skewY(-22deg);
    transform-origin: left bottom;
}
.css-shuffle-icon .arrow-top,
.css-shuffle-icon .arrow-bottom {
    position: absolute;
    right: -1px;
    width: 0;
    height: 0;
    border-left: 4px solid currentColor;
}
.css-shuffle-icon .arrow-top {
    top: 0;
    border-top: 3px solid transparent;
    border-bottom: 3px solid transparent;
}
.css-shuffle-icon .arrow-bottom {
    bottom: 0;
    border-top: 3px solid transparent;
    border-bottom: 3px solid transparent;
}

/* Иконка повтора */
.css-loop-icon {
    position: relative;
    width: 14px;
    height: 14px;
    border: 2px solid currentColor;
    border-right-color: transparent; 
    border-radius: 50%;
    box-sizing: border-box;
}
.css-loop-icon::after {
    content: "";
    position: absolute;
    top: -3px;
    right: -3px;
    width: 0;
    height: 0;
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    border-left: 5px solid currentColor;
    transform: rotate(-35deg);
}

/* Иконка динамика звука */
.css-volume-icon {
    position: relative;
    width: 11px;
    height: 10px;
    color: #888;
    display: flex;
    align-items: center;
}
.css-volume-icon::before {
    content: "";
    position: absolute;
    left: 0;
    width: 4px;
    height: 4px;
    background: currentColor;
}
.css-volume-icon::after {
    content: "";
    position: absolute;
    left: 2px;
    width: 0;
    height: 0;
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
    border-right: 5px solid currentColor;
}
.css-volume-icon .volume-wave {
    position: absolute;
    right: -2px;
    width: 6px;
    height: 6px;
    border: 2px solid currentColor;
    border-left: 0;
    border-top: 0;
    border-bottom: 0;
    border-radius: 0 50% 50% 0;
}

/* ==========================================================================
   5. КАСТОМНЫЙ ВЫПАДАЮЩИЙ СПИСОК (СЕЛЕКТ)
   ========================================================================== */
.custom-select-container {
    width: 100%;
    font-size: 12px;
    box-sizing: border-box;
    letter-spacing: 0.3px;
    user-select: none;
    position: relative;
}

.custom-select-trigger {
    background-color: #111;
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 8px 32px 8px 10px;
    border-radius: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: border-color 0.2s, background-color 0.2s;
    position: relative;
    width: 100%;
    box-sizing: border-box;
}

.custom-select-trigger::after {
    content: '';
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    border-top: 5px solid #888;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    pointer-events: none;
}

.custom-select-container.open .custom-select-trigger {
    border-color: rgba(255, 255, 255, 0.3);
    background-color: #161616;
}

.custom-options {
    position: absolute;
    display: block;
    top: 100%;
    left: 0;
    right: 0;
    background-color: #111;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 14px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    z-index: 1002;
    max-height: 200px;
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-5px);
    transition: all 0.2s ease;
    width: 100%;
    box-sizing: border-box;
    margin-top: 0px; 
    padding-top: 0px; 
}

.custom-options::before {
    content: "";
    position: absolute;
    top: -8px;
    left: 0;
    width: 100%;
    height: 8px;
    background: transparent;
}

.custom-options .custom-option:first-child {
    border-top-left-radius: 7px;
    border-top-right-radius: 7px;
}
.custom-options .custom-option:last-child {
    border-bottom-left-radius: 7px;
    border-bottom-right-radius: 7px;
}

.custom-select-container.open .custom-options {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(4px);
}

.custom-option {
    padding: 4px 4px;
    color: #aaa;
    cursor: pointer;
    transition: background-color 0.1s, color 0.1s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.option-content {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
}

.track-cover {
    width: 24px;
    height: 24px;
    min-width: 24px;
    max-width: 24px;
    min-height: 24px;
    max-height: 24px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    align-self: center;
    background: #222; /* Фон, пока обложка грузится */
}

.custom-option:hover {
    background-color: #2a2a2a !important;
    color: #fff !important;
    border-radius: 14px;
}

.custom-option.selected {
    background-color: #2a2a2a;
    color: #fff;
    border-radius: 14px;
}

/* Кастомизация скроллбара списка треков */
.custom-options::-webkit-scrollbar {
    width: 4px;
}
.custom-options::-webkit-scrollbar-track {
    background: #111;
    border-radius: 14px;
}
.custom-options::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 2px;
}
.custom-options::-webkit-scrollbar-thumb:hover {
    background: #222; 
}

/* ==========================================================================
   6. ХОВЕР НА ДЕСКТОПАХ (ПК) ИЛИ СОСТОЯНИЕ С ОТКРЫТЫМ СЕЛЕКТОМ
   ========================================================================== */
@media (min-width: 769px) {
    /* При hover/expanded — absolute, верх на центре шапки - 20px,
       контент раскрывается вниз. */
    .audio-player:hover,
    .audio-player.has-open-select,
    .audio-player.expanded {
        position: relative;
        top: auto;
        left: auto;
        transform: none;
        align-self: flex-start;
    }

    /* Фон при hover — полупрозрачный чёрный, чтобы контролы были видны */
    .audio-player:hover,
    .audio-player.has-open-select {
        background: rgba(0, 0, 0, 1) !important;
        border: none;
        border-radius: 15px;
        
        outline-offset: -1.5px;
        padding: 4px 4px 4px 4px;
        height: auto !important;
    }

    .audio-player:hover .player-controls,
    .audio-player:hover .player-progress,
    .audio-player:hover .custom-select-container,
    .audio-player.has-open-select .player-controls,
    .audio-player.has-open-select .player-progress,
    .audio-player.has-open-select .custom-select-container {
        visibility: visible;
        opacity: 1;
        height: auto;
        justify-content: flex-start !important;
        overflow: visible;
    }

    .audio-player:hover .player-progress,
    .audio-player.has-open-select .player-progress {
        margin-bottom: 24px;
    }
    .audio-player:hover .player-controls,
    .audio-player.has-open-select .player-controls {
        display: flex;
        margin-bottom: 24px;
    }
    .audio-player:hover .custom-select-container,
    .audio-player.has-open-select .custom-select-container {
        margin: 0 !important;
        width: 100% !important;
    }

    .audio-player:hover .custom-options,
    .audio-player.has-open-select .custom-options {
        border-radius: 14px !important;
        border: none !important;
        overflow: hidden;
    }

    .audio-player:hover .minimal-view,
    .audio-player.has-open-select .minimal-view {
        margin-bottom: 24px;
    }
    
    /* Расширяем контейнер бегущей строки при ховере на ПК */
    .audio-player:hover .track-title-container,
    .audio-player.has-open-select .track-title-container {
        flex: 1;
    }
    
    .audio-player:hover .track-title,
    .audio-player.has-open-select .track-title {
        font-size: 14px;
    }
    
    /* mini-time остаётся видимой при раскрытии (продолжение свёрнутого) */
}

/* ==========================================================================
   7. РАСКРЫТОЕ СОСТОЯНИЕ (ПРИ КЛИКЕ / EXPANDED)
   ========================================================================== */
.audio-player.expanded {
    position: relative;
    top: auto;
    left: auto;
    transform: none;
    background: rgba(0, 0, 0, 1) !important;
    border: none !important;
    border-radius: 14px !important;
    
    height: auto !important;
    padding: 4px 4px 4px 4px !important;
}

.audio-player.expanded .player-controls,
.audio-player.expanded .player-progress,
.audio-player.expanded .custom-select-container {
    visibility: visible !important;
    opacity: 1 !important;
    height: auto !important;
    overflow: visible !important;
}

.audio-player.expanded .player-progress {
    margin-bottom: 24px !important;
}
.audio-player.expanded .player-controls {
    display: flex !important;
    width: 100% !important;
    margin-bottom: 24px !important;
}
.audio-player.expanded .custom-select-container {
    margin: 0 !important;
    width: 100% !important;
}

.audio-player.expanded .custom-options {
    border-radius: 14px !important;
    border: none !important;
    overflow: hidden;
}

.audio-player.expanded .minimal-view {
    margin-bottom: 24px;
}

.audio-player.expanded .track-title-container {
    flex: 1;
}

.audio-player.expanded .track-title {
    font-size: 14px;
}

/* mini-time остаётся видимой при раскрытии (продолжение свёрнутого) */

/* ==========================================================
   Плейлист всегда виден при раскрытии плеера
   ========================================================== */

.playlist-container {
    width: 100%;
}

.playlist-container .custom-options {
    position: static !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    transform: none !important;
    max-height: 220px;
    overflow-y: auto;
    margin-top: 0;
}

.playlist-container {
    display: none;
}

.audio-player.expanded .playlist-container,
.audio-player:hover .playlist-container,
.audio-player.has-open-select .playlist-container {
    display: block;
}

/* ==========================================================================
   8. АДАПТИВ ПОД МОБИЛЬНЫЕ УСТРОЙСТВА (ЭКРАНЫ <= 768px)
   ========================================================================== */
@media (max-width: 768px) {
    .audio-player {
        position: relative;
        top: auto;
        left: auto;
        right: auto;
        width: 100%;
        max-width: calc(100vw - 24px);
        flex: 1 1 100%;
        min-width: 0;
        height: 32px;
        min-height: 32px;
        background: #000;
        border: none;
        
        outline-offset: -1.5px;
        border-radius: 24px;
        padding: 4px 4px 4px 4px;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        align-items: center;
        align-self: flex-start;
        box-sizing: border-box;
        z-index: 1001;
        overflow: visible;
    }

    /* Expanded — fixed поверх шапки, контент ниже */
    .audio-player.expanded {
        position: relative;
        top: auto;
        left: auto;
        width: 100%;
        max-width: calc(100vw - 24px);
        z-index: 1003;
        background: rgba(0, 0, 0, 0.95) !important;
        border: none !important;
        
        border-radius: 14px;
        padding: 4px 4px 4px 4px !important;
        justify-content: flex-start !important;
        overflow: visible;
    }

    .minimal-view {
        justify-content: space-between;
        height: 24px;
        width: 100%;
        flex-shrink: 0;
        overflow: hidden;
    }

    /* Ограничиваем строку, когда плеер СВЕРНУТ в мобильную плашку верхнего бара */
    .track-title-container {
        max-width: 100%;
        width: calc(100% - 30px);
    }

    /* Когда плеер РАСКРЫТ (.expanded) на мобильном телефоне */
    .audio-player.expanded .track-title-container {
        max-width: 100%;               /* Снимаем ограничение в 60% */
        width: calc(100% - 30px);      /* Бегущая строка использует весь экран плеера */
        margin-bottom: 0;
    }
    
    .audio-player.expanded .track-title {
        font-size: 14px; 
    }

    .audio-player.expanded .player-progress {
        margin-top: 8px !important;
        margin-bottom: 24px !important;
    }

    .audio-player.expanded .player-controls {
        margin-bottom: 24px !important;
    }

    /* Растягиваем плейлист на всю ширину на мобиле (padding 16px по бокам) */
    .audio-player.expanded .custom-select-container {
        margin: 0 !important;
        width: 100% !important;
    }

    .audio-player.expanded .minimal-view {
        justify-content: flex-start;
        gap: 10px;
        margin-bottom: 24px;
    }

    .custom-option {
        padding: 4px 4px;
    }

    /* Обложка и название в плейлисте на мобильных — в один ряд */
    .option-content {
        gap: 10px;
        width: 100%;
    }

    .track-cover {
        width: 24px;
        height: 24px;
        min-width: 24px;
        max-width: 24px;
        min-height: 24px;
        max-height: 24px;
        flex-shrink: 0;
        align-self: center;
        border-radius: 50%;
    }
}