/* --- general body styles --- */
body {
    background-color: #121212;
    color: #ffffff;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    margin: 0;
    padding: 2rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

/* --- main layout & responsiveness --- */
.music-container {
    display: flex;
    flex-direction: column;
    max-width: 375px;
    width: 100%;
    background-color: #181818;
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    transition: max-width 0.4s ease;
}
@media (min-width: 768px) {
    .music-container {
        flex-direction: row;
        max-width: 800px;
    }
    .music-container.collapsed {
        max-width: 375px;
    }
}

/* --- player --- */
.player {
    padding: 24px;
    box-sizing: border-box;
    position: relative;
    width: 100%;
}
@media (min-width: 768px) {
    .player {
        width: 375px;
        flex-shrink: 0;
    }
}
.player__header {
    display: flex;
    justify-content: center;
    margin-top: 20px;
}
.player__img {
    width: 100%;
    max-width: 300px;
    aspect-ratio: 1 / 1;
    border-radius: 8px;
    object-fit: cover;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}
.song-details {
    text-align: center;
    margin-top: 20px;
}
.player__title {
    font-size: 20px;
    font-weight: 600;
    margin: 0;
}
.player__artist {
    font-size: 14px;
    color: #b3b3b3;
    margin: 4px 0 0;
}

/* --- progress bar --- */
.player__progress-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 20px;
}
.time-current, .time-duration {
    font-size: 12px;
    color: #b3b3b3;
    min-width: 35px;
    text-align: center;
}
.player__timeline {
    flex-grow: 1;
    background-color: #535353;
    height: 4px;
    border-radius: 2px;
    cursor: pointer;
}
.player__timeline-progress {
    background-color: #ffffff;
    width: 0;
    height: 100%;
    border-radius: 2px;
    position: relative;
    transition: width 0.1s linear;
}
.progress-handle {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: white;
    position: absolute;
    right: -6px;
    top: -4px;
    opacity: 0;
    transition: opacity 0.2s;
}
.player__timeline:hover .progress-handle {
    opacity: 1;
}

/* --- player controls --- */
.player__controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 24px;
    margin-top: 20px;
}
.player__button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #b3b3b3;
}
.player__button--play {
    background-color: #FF9500;
    border-radius: 50%;
    width: 56px;
    height: 56px;
    padding: 0;
    color: black;
}
.player__icon {
    width: 24px;
    height: 24px;
}
.player__button--play .player__icon {
    width: 28px;
    height: 28px;
}

/* --- playlist section --- */
.playlist-section {
    background-color: #242424;
    max-height: 400px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: max-height 0.4s ease, padding 0.4s ease;
}
.playlist-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    position: sticky;
    top: 0;
    background-color: #242424;
    z-index: 1;
    flex-shrink: 0;
}
.playlist-header h4 {
    margin: 0;
    font-size: 16px;
}
.playlist-controls {
    display: flex;
    gap: 8px;
}
.playlist {
    padding: 0 16px 16px 16px;
    overflow-y: auto;
}
.playlist__song {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: background-color 0.2s ease-in-out;
}
.playlist__song:hover {
    background-color: #3a3a3a;
}
.playlist__song--active {
    background-color: #535353;
}
.playlist__song-image {
    width: 48px;
    height: 48px;
    border-radius: 4px;
    margin-right: 16px;
    object-fit: cover;
    flex-shrink: 0;
}
.playlist__song-details h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 500;
}
.loading-text {
    padding: 16px;
    text-align: center;
    color: #b3b3b3;
}
@media (min-width: 768px) {
    .playlist-section {
        width: 425px;
        flex-shrink: 0;
        max-height: 580px;
        transition: max-width 0.4s ease;
    }
    .music-container.collapsed .playlist-section {
        max-width: 0;
    }
}

/* --- collapse & control button states --- */
.player__collapse-btn {
    position: absolute;
    top: 16px;
    left: 16px;
    padding: 0;
    background: none;
    border: none;
    cursor: pointer;
    width: 24px;
    height: 24px;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"></polyline></svg>');
    background-repeat: no-repeat;
    background-position: center;
    transition: transform 0.4s ease;
}
.music-container.collapsed .player__collapse-btn {
    transform: rotate(-180deg);
}
.music-container.collapsed .playlist-section {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
}
@media (min-width: 768px) {
    .player__collapse-btn {
        transform: rotate(90deg);
    }
    .music-container.collapsed .player__collapse-btn {
        transform: rotate(-90deg);
    }
}
.btn-loop.active, .btn-shuffle.active { }

/* --- footer --- */
footer {
    margin-top: 2rem;
    text-align: center;
    color: #b3b3b3;
    font-size: 0.875rem;
    line-height: 1.5;
    max-width: 375px;
    width: 100%;
    padding: 1rem;
    background-color: #242424;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transition: background-color 0.3s ease;
}

footer a {
    color: #FF9500;
    text-decoration: none;
    transition: color 0.2s ease;
}

/* w3 svg icons, svg size generator used to size properly */
.player__button--prev img { content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="19 20 9 12 19 4 19 20"></polygon><line x1="5" y1="19" x2="5" y2="5"></line></svg>'); }
.player__button--next img { content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="5 4 15 12 5 20 5 4"></polygon><line x1="19" y1="5" x2="19" y2="19"></line></svg>'); }
.player__button--play img[alt="play"] { content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="28" height="28" viewBox="0 0 24 24" fill="white" stroke="white" stroke-width="1"><polygon points="5 3 19 12 5 21 5 3"></polygon></svg>'); }
.player__button--play img[alt="pause"] { content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="28" height="28" viewBox="0 0 24 24" fill="white"><rect x="6" y="4" width="4" height="16"></rect><rect x="14" y="4" width="4" height="16"></rect></svg>'); }
.btn-shuffle img { content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="16 3 21 3 21 8"></polyline><line x1="4" y1="20" x2="21" y2="3"></line><polyline points="21 16 21 21 16 21"></polyline><line x1="15" y1="15" x2="21" y2="21"></line><line x1="4" y1="4" x2="9" y2="9"></line></svg>'); }
.btn-loop img { content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10.5 14.5L9 13v-2.5m1.5 0V9.4M17 1l4 4-4 4"/><path d="M3 11V9a4 4 0 0 1 4-4h14M7 23l-4-4 4-4"/><path d="M21 13v2a4 4 0 0 1-4 4H3"/></svg>'); }
.btn-shuffle.active img { content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="%23FF9500" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="16 3 21 3 21 8"></polyline><line x1="4" y1="20" x2="21" y2="3"></line><polyline points="21 16 21 21 16 21"></polyline><line x1="15" y1="15" x2="21" y2="21"></line><line x1="4" y1="4" x2="9" y2="9"></line></svg>'); }
.btn-loop.active img { content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="%23FF9500" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10.5 14.5L9 13v-2.5m1.5 0V9.4M17 1l4 4-4 4"/><path d="M3 11V9a4 4 0 0 1 4-4h14M7 23l-4-4 4-4"/><path d="M21 13v2a4 4 0 0 1-4 4H3"/></svg>'); }