/* ===== Переменные ===== */
:root {
    --bg: #0a0507;
    --surface: rgba(24, 13, 16, 0.66);
    --surface-solid: #170c10;
    --line: rgba(255, 255, 255, 0.09);
    --text: #f4eceb;
    --muted: #a08c8b;
    --accent: #e51e39;
    --accent-soft: rgba(229, 30, 57, 0.16);
    --radius: 16px;
    --pad: clamp(16px, 4.5vw, 26px);
    --player-h: 104px;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

/* ===== Сброс ===== */
*,
*::before,
*::after {
    box-sizing: border-box;
}

* {
    margin: 0;
    padding: 0;
}

body {
    min-height: 100dvh;
    padding-bottom: calc(var(--player-h) + 24px);
    font-family: var(--font);
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

button {
    font: inherit;
    color: inherit;
    background: none;
    border: none;
    cursor: pointer;
}

ul {
    list-style: none;
}

img {
    display: block;
    max-width: 100%;
}

/* Атрибут hidden должен побеждать любые display в стилях — иначе скрытые
   блоки (экран ключа, обложка без картинки) вылезают на экран */
[hidden] {
    display: none !important;
}

/* ===== Фон ===== */
.bg {
    position: fixed;
    inset: 0;
    z-index: -2;
    background: url("/assets/bg.jpg") center / cover no-repeat;
    /* лёгкое размытие: гасит пиксели от растянутой картинки, но рисунок видно */
    filter: blur(5px) saturate(1.15) brightness(0.95);
    /* чуть увеличиваем, иначе по краям видно мягкую кайму от блюра */
    transform: scale(1.05);
}

/* Затемнение ровно настолько, чтобы текст читался, но картинку было видно */
.bg::after {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(110% 70% at 50% 0%, rgba(229, 30, 57, 0.28), transparent 65%),
        linear-gradient(180deg, rgba(10, 5, 7, 0.42), rgba(10, 5, 7, 0.82));
}

/* ===== Контейнер ===== */
.container {
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
    padding-inline: var(--pad);
}

/* ===== Шапка ===== */
.head {
    padding-block: 16px;
    border-bottom: 1px solid var(--line);
    background: rgba(10, 5, 7, 0.4);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 5;
}

.head__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.logo {
    font-size: 0.92rem;
    font-weight: 800;
    letter-spacing: 0.16em;
}

.logo__slash {
    color: var(--accent);
    padding-inline: 1px;
}

.head__count {
    font-size: 0.8rem;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

/* ===== Секции ===== */
section.container {
    padding-block: clamp(22px, 5vw, 34px);
}

.section__head {
    margin-bottom: 18px;
}

h1 {
    font-size: clamp(1.5rem, 6vw, 2rem);
    line-height: 1.1;
    letter-spacing: -0.02em;
}

h2 {
    font-size: 1.1rem;
    letter-spacing: -0.01em;
}

.section__head p {
    margin-top: 6px;
    font-size: 0.88rem;
    color: var(--muted);
}

/* ===== Список треков ===== */
.tracks {
    display: grid;
    gap: 8px;
}

.track {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 12px;
    text-align: left;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    backdrop-filter: blur(14px);
    transition: border-color 160ms ease, background 160ms ease, transform 120ms ease;
}

.track:active {
    transform: scale(0.99);
}

.track.is-active {
    border-color: rgba(229, 30, 57, 0.55);
    background: linear-gradient(90deg, var(--accent-soft), var(--surface) 70%);
}

.track__cover {
    position: relative;
    flex: 0 0 auto;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    overflow: hidden;
    background:
        repeating-radial-gradient(circle at 50% 50%, #2a1519 0 2px, #1b0d10 2px 4px);
    border: 1px solid var(--line);
}

.track__cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Заглушка, пока обложки нет: красная наклейка на пластинке */
.track__cover::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 28%;
    height: 28%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.4);
}

.track__cover:has(img)::after {
    display: none;
}

.track__meta {
    flex: 1;
    min-width: 0;
}

.track__title {
    font-size: 0.95rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.track__artist {
    font-size: 0.8rem;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.track.is-active .track__title {
    color: var(--accent);
}

.track__time {
    flex: 0 0 auto;
    font-size: 0.78rem;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

/* ===== Пустое состояние ===== */
.empty {
    padding: 28px 20px;
    text-align: center;
    background: var(--surface);
    border: 1px dashed var(--line);
    border-radius: var(--radius);
}

.empty__title {
    font-weight: 600;
    margin-bottom: 6px;
}

.empty__text {
    font-size: 0.88rem;
    color: var(--muted);
}

/* ===== Плеер ===== */
.player {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    padding-bottom: env(safe-area-inset-bottom, 0);
    background: rgba(16, 8, 10, 0.86);
    border-top: 1px solid var(--line);
    backdrop-filter: blur(20px);
}

.player__inner {
    padding-block: 10px 12px;
}

.player__top {
    display: flex;
    align-items: center;
    gap: 10px;
}

.player__cover {
    position: relative;
    flex: 0 0 auto;
    width: 46px;
    height: 46px;
    border-radius: 12px;
    overflow: hidden;
    background: repeating-radial-gradient(circle at 50% 50%, #2a1519 0 2px, #1b0d10 2px 4px);
    border: 1px solid var(--line);
}

.player__cover::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.4);
}

.player__cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Наклейка на заглушке; как только появилась настоящая обложка — убираем */
.player__cover-stub {
    position: absolute;
    inset: 0;
}

.player__cover-stub::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 28%;
    height: 28%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: var(--accent);
}

.player__cover:has(img:not([hidden])) .player__cover-stub {
    display: none;
}

.player__meta {
    flex: 1;
    min-width: 0;
}

.player__title {
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.player__artist {
    font-size: 0.78rem;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.player__icon {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    color: var(--muted);
    transition: color 140ms ease;
}

.player__icon:hover {
    color: var(--text);
}

.player__play {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    color: #fff;
    background: var(--accent);
    transition: transform 120ms ease, filter 140ms ease;
}

.player__play:hover {
    filter: brightness(1.1);
}

.player__play:active {
    transform: scale(0.94);
}

.player__bottom {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
}

.player__time {
    flex: 0 0 auto;
    font-size: 0.72rem;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
    min-width: 34px;
}

.player__bottom .player__time:last-child {
    text-align: right;
}

/* ===== Ползунок ===== */
.player__seek {
    flex: 1;
    appearance: none;
    height: 20px;
    background: transparent;
    cursor: pointer;
}

.player__seek::-webkit-slider-runnable-track {
    height: 4px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.14);
}

.player__seek::-webkit-slider-thumb {
    appearance: none;
    width: 14px;
    height: 14px;
    margin-top: -5px;
    border-radius: 50%;
    background: var(--accent);
    border: none;
}

.player__seek::-moz-range-track {
    height: 4px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.14);
}

.player__seek::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border: none;
    border-radius: 50%;
    background: var(--accent);
}

/* ===== Полноэкранный плеер ===== */
.now {
    position: fixed;
    inset: 0;
    z-index: 30;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: rgba(8, 4, 6, 0.86);
    backdrop-filter: blur(22px);
}

/* Пока открыт полный экран, страница под ним не скроллится */
body.is-locked {
    overflow: hidden;
}

.now__inner {
    display: flex;
    flex-direction: column;
    gap: clamp(12px, 2.6vh, 20px);
    min-height: 100dvh;
    padding-block: max(10px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-bottom));
}

.now__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.now__close,
.now__gap {
    width: 40px;
    height: 40px;
}

.now__close {
    display: grid;
    place-items: center;
    margin-left: -6px;
    border-radius: 50%;
    color: var(--muted);
    transition: color 140ms ease;
}

.now__close:hover {
    color: var(--text);
}

.now__label {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--muted);
}

/* Обложка: квадрат, но не больше того, что влезает в экран */
.now__cover {
    position: relative;
    display: block;
    width: min(100%, 46vh, 340px);
    aspect-ratio: 1;
    margin-inline: auto;
    border-radius: 22px;
    overflow: hidden;
    background: repeating-radial-gradient(circle at 50% 50%, #2a1519 0 3px, #1b0d10 3px 7px);
    border: 1px solid var(--line);
    box-shadow: 0 26px 60px rgba(0, 0, 0, 0.6);
}

.now__cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.now__cover-stub {
    position: absolute;
    inset: 0;
}

.now__cover-stub::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24%;
    height: 24%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: var(--accent);
}

.now__cover:has(img:not([hidden])) .now__cover-stub {
    display: none;
}

.now__meta {
    text-align: center;
}

.now__title {
    font-size: clamp(1.05rem, 4.6vw, 1.3rem);
    font-weight: 700;
    letter-spacing: -0.01em;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.now__artist {
    margin-top: 4px;
    font-size: 0.9rem;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.now__seek {
    display: flex;
    flex-direction: column;
}

.now__seek .player__seek {
    width: 100%;
}

.now__times {
    display: flex;
    justify-content: space-between;
    font-size: 0.72rem;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

/* Кнопки вразноброс: крайние — режимы, в центре — переключение треков */
.now__controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2px;
    margin-top: auto;
    padding-inline: 2px;
}

.now__icon {
    position: relative;
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    color: var(--muted);
    transition: color 140ms ease, background 140ms ease;
}

.now__icon:hover {
    color: var(--text);
}

.now__icon.is-on {
    color: var(--accent);
}

/* У повтора режим «один трек» — дорисовываем единичку */
.now__icon[data-mode="one"]::after {
    content: "1";
    position: absolute;
    right: 3px;
    bottom: 5px;
    font-size: 0.58rem;
    font-weight: 700;
    line-height: 1;
    color: var(--accent);
}

.now__icon--big {
    width: 52px;
    height: 52px;
    color: var(--text);
}

.now__play {
    display: grid;
    place-items: center;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    color: #fff;
    background: var(--accent);
    box-shadow: 0 14px 34px rgba(229, 30, 57, 0.35);
    transition: transform 120ms ease, filter 140ms ease;
}

.now__play:hover {
    filter: brightness(1.1);
}

.now__play:active {
    transform: scale(0.95);
}

.now__hint {
    text-align: center;
    font-size: 0.72rem;
    color: var(--muted);
    opacity: 0.75;
}

/* ===== Футер ===== */
.footer {
    padding-block: 20px 28px;
    font-size: 0.8rem;
    color: var(--muted);
}

/* Метка сборки: по ней видно, свежая ли страница в браузере */
.build {
    color: var(--accent);
    opacity: 0.75;
    font-size: 0.72rem;
    letter-spacing: 0.04em;
}

/* ===== Экран с ключом ===== */
.gate {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(8, 4, 6, 0.94);
    backdrop-filter: blur(8px);
}

.gate__box {
    width: 100%;
    max-width: 340px;
    padding: 22px;
    background: var(--surface-solid);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.gate__title {
    margin-bottom: 8px;
}

.gate__text {
    margin-bottom: 14px;
    font-size: 0.86rem;
    color: var(--muted);
}

.gate__input {
    width: 100%;
    padding: 11px 14px;
    font: inherit;
    color: var(--text);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--line);
    border-radius: 10px;
    margin-bottom: 10px;
}

.gate__btn {
    width: 100%;
    padding: 11px 14px;
    font-weight: 600;
    color: #fff;
    background: var(--accent);
    border-radius: 10px;
}

.gate__error {
    margin-top: 10px;
    font-size: 0.82rem;
    color: var(--accent);
}

/* ===== Фокус ===== */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 8px;
}

/* ===== Мобилка ===== */
@media (max-width: 640px) {
    :root {
        --player-h: 112px;
    }

    .head__count {
        font-size: 0.74rem;
    }

    .track__time {
        font-size: 0.72rem;
    }

    .player__icon {
        width: 32px;
    }

    .footer {
        padding-bottom: 24px;
    }
}

/* ===== Уважение к настройкам анимации ===== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}
