
:root {
    --background: #050505;

    --arm-angle: 23deg;
    --arm-duration: 1.5s;

    --sleeve-color: #87532f;
    --sleeve-border: #60391f;
    --sleeve-selected: #e0b483;
    --sleeve-text: #fff0df;

    --vinyl-rotation-duration: 1.8s;
}

/* ========================================
   RESET
======================================== */

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    min-height: 100vh;
    min-height: 100dvh;

    background-color: var(--background);
    background-image: url("/music/bg.webp?v=2");
    background-repeat: repeat;
    background-position: top left;
    background-size: auto;
}

/* ========================================
   PAGE
======================================== */

.page {
    min-height: 100vh;
    min-height: 100dvh;

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

    padding: 32px 24px;
}

/* ========================================
   MAIN LAYOUT
======================================== */

.music-layout {
    width: min(100%, 1700px);

    display: grid;
    grid-template-columns:
        minmax(0, 933fr)
        minmax(0, 700fr);

    align-items: center;
    gap: 36px;
}

/* ========================================
   PLAYER COLUMN
======================================== */

.player-column {
    width: 100%;
    min-width: 0;

    display: flex;
    flex-direction: column;
    align-items: center;

    gap: 24px;
}

/* ========================================
   TURNTABLE
======================================== */

.turntable {
    position: relative;

    width: 100%;
    aspect-ratio: 933 / 699;

    isolation: isolate;
}

.turntable-base {
    display: block;

    width: 100%;
    height: 100%;

    object-fit: fill;

    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
}

/* ========================================
   VINYL
======================================== */

.vinyl-record {
    position: absolute;

    width: 70.7%;
    aspect-ratio: 1;

    left: 46.3%;
    top: 50.4%;

    transform: translate(-50%, -50%);
    object-fit: contain;

    z-index: 1;

    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;

    animation:
        vinyl-spin var(--vinyl-rotation-duration)
        linear infinite paused;
}

.vinyl-record[hidden] {
    display: none;
}

@keyframes vinyl-spin {
    from {
        transform:
            translate(-50%, -50%)
            rotate(0deg);
    }

    to {
        transform:
            translate(-50%, -50%)
            rotate(360deg);
    }
}

.turntable.is-playing .vinyl-record {
    animation-play-state: running;
}

/* ========================================
   TONEARM
======================================== */

.tonearm {
    position: absolute;

    left: 81.24%;
    top: 6.44%;

    width: 16.40%;
    height: auto;

    transform-origin: 39% 19.8%;
    transform: rotate(0deg);

    transition:
        transform var(--arm-duration)
        ease-in-out;

    z-index: 2;

    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
}

.turntable.is-on .tonearm {
    transform: rotate(var(--arm-angle));
}

/* ========================================
   POWER BUTTON
======================================== */

.power-button {
    position: absolute;

    left: 7.72%;
    top: 91.27%;

    width: 3.43%;
    aspect-ratio: 32 / 18;

    display: block;

    padding: 0;
    margin: 0;

    border: none;
    background: transparent;

    cursor: pointer;
    z-index: 4;

    -webkit-tap-highlight-color: transparent;
}

.power-button::after {
    content: "";
    position: absolute;
    inset: -45%;
}

.power-image {
    display: block;

    width: 100%;
    height: 100%;

    object-fit: fill;

    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;

    transform: scaleX(-1);
}

.turntable.is-on .power-image {
    transform: scaleX(1);
}

/* ========================================
   SPOTIFY PLAYER
======================================== */

.spotify-player {
    width: 100%;
    max-width: 700px;
    min-height: 152px;
}

.spotify-player[hidden] {
    display: none;
}

#spotifyEmbed {
    width: 100%;
    min-height: 152px;
}

#spotifyEmbed iframe {
    display: block;

    width: 100%;
    max-width: 100%;
    height: 152px;

    border: 0;
    border-radius: 12px;
}

/* ========================================
   MUSIC LIBRARY
======================================== */

.music-library {
    width: 100%;
    min-width: 0;

    display: flex;
    flex-direction: column;

    justify-content: center;
}

/* ========================================
   RECORD COLLECTION
======================================== */

.record-collection {
    display: flex;
    flex-direction: column;

    align-items: center;

    width: 100%;
    min-width: 0;

    max-height: min(70vh, 640px);
    max-height: min(70dvh, 640px);

    overflow-y: auto;
    overflow-x: hidden;

    gap: 12px;

    padding: 4px 8px 8px;

    scrollbar-width: thin;
    scrollbar-color:
        #87532f transparent;
}

.record-collection::-webkit-scrollbar {
    width: 6px;
}

.record-collection::-webkit-scrollbar-thumb {
    background: #87532f;
    border-radius: 4px;
}

.record-collection::-webkit-scrollbar-track {
    background: transparent;
}

/* ========================================
   THIN RECORD SLEEVES
======================================== */

.record-sleeve {
    display: flex;
    align-items: center;
    justify-content: center;

    width: 100%;
    height: 18px;
    min-height: 18px;
    flex-shrink: 0;

    padding: 0 8px;

    background: var(--sleeve-color);

    border: 1px solid var(--sleeve-border);
    border-radius: 0;

    box-shadow:
        0 2px 0 #4a2b1a,
        0 4px 5px rgba(0, 0, 0, 0.25);

    cursor: pointer;

    transition:
        border-color 0.2s ease,
        background-color 0.2s ease;

    -webkit-tap-highlight-color: transparent;
}

.sleeve-title {
    display: block;
    max-width: 100%;

    color: var(--sleeve-text);

    font-family: Arial, Helvetica, sans-serif;
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.02em;
    line-height: 1;

    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (hover: hover) {
    .record-sleeve:hover {
        background: #996038;
        border-color: #a36e47;
    }
}

.record-sleeve.selected {
    background: #945c34;
    border-color: var(--sleeve-selected);
}

/* ========================================
   ACCESSIBILITY
======================================== */

.power-button:focus-visible,
.record-sleeve:focus-visible {
    outline: 2px solid white;
    outline-offset: 5px;
}

/* ========================================
   TABLET / MOBILE
======================================== */

@media (max-width: 900px) {
    .page {
        padding: 28px 16px 48px;
    }

    .music-layout {
        width: min(100%, 700px);

        grid-template-columns: minmax(0, 1fr);
        justify-items: center;

        gap: 40px;
    }

    .player-column {
        width: 100%;
        gap: 20px;
    }

    .turntable {
        width: 100%;
    }

    .spotify-player {
        width: 100%;
        max-width: 100%;
    }

    /*
       Vinyl diameter: 70.7%.
       Sleeve width: 74%.
    */

    .music-library {
        width: 74%;
    }

    .record-collection {
        width: 100%;
        max-height: 380px;
    }
}

/* ========================================
   SMALL PHONES
======================================== */

@media (max-width: 600px) {
    .page {
        padding: 20px 12px 48px;
    }

    .music-layout {
        gap: 32px;
    }

    .player-column {
        gap: 16px;
    }

    .music-library {
        width: 74%;
    }

    .record-collection {
        max-height: 340px;
        gap: 10px;
    }

    .record-sleeve {
        height: 18px;
    }

    .sleeve-title {
        font-size: 9px;
    }
}

/* ========================================
   REDUCED MOTION
======================================== */

@media (prefers-reduced-motion: reduce) {
    .tonearm,
    .record-sleeve {
        transition: none;
    }

    .vinyl-record {
        animation: none;
    }
}
