
/* ===========================
   Base
   =========================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap');

* {
    box-sizing: border-box;
}

/* Prevent horizontal scroll */
html {
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', system-ui, sans-serif;
    background: linear-gradient(135deg, #0f1117, #1b1d27);
    color: #e6e6eb;
    margin: 0;
    padding: 2rem;
    line-height: 1.6;
}

/* ===========================
   Headings
   =========================== */

h1 {
    text-align: center;
    font-size: 2.8rem;
    margin-bottom: .5rem;
    background: linear-gradient(90deg, #9ad1ff, #ff9ad1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 2px 10px rgba(0,0,0,0.3);
    letter-spacing: -0.02em;
}

h2 {
    text-align: center;
    color: #9ad1ff;
    font-weight: 500;
    margin-bottom: 2rem;
    letter-spacing: 0.02em;
}

h3, h4, h5, h6 {
    letter-spacing: 0.01em;
}

/* ===========================
   Hero Section
   =========================== */

.hero {
    text-align: center;
    padding: 2rem 1rem 3rem;
    max-width: 800px;
    margin: 0 auto;
}

.hero-subtitle {
    font-size: 1.1rem;
    color: #a0a0a8;
    margin-top: 0.5rem;
    line-height: 1.6;
}

.playlist-track-count {
    font-size: 0.9rem;
    color: #9ad1ff;
    margin-top: 0.5rem;
    font-weight: 600;
}

.track-count {
    font-size: 0.9rem;
    color: #9ad1ff;
    font-weight: 600;
}

/* ===========================
   Grid
   =========================== */

.playlist-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1.6rem;
    max-width: 1400px;
    margin: 0 auto;
}

/* ===========================
   Card
   =========================== */

.playlist-card {
    background: rgba(22, 26, 34, 0.85);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 14px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: .4rem;
    box-shadow: 0 2px 6px rgba(0,0,0,.45);
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
    animation: fadeInUp 0.5s ease-out backwards;
}

.playlist-preview .thumb {
    aspect-ratio: 16/9;
}

.playlist-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 26px rgba(0,0,0,.6);
    border-color: rgba(154, 209, 255, 0.3);
}

/* Stagger animations for grid items */
.playlist-grid .playlist-card:nth-child(1) { animation-delay: 0.05s; }
.playlist-grid .playlist-card:nth-child(2) { animation-delay: 0.1s; }
.playlist-grid .playlist-card:nth-child(3) { animation-delay: 0.15s; }
.playlist-grid .playlist-card:nth-child(4) { animation-delay: 0.2s; }
.playlist-grid .playlist-card:nth-child(5) { animation-delay: 0.25s; }
.playlist-grid .playlist-card:nth-child(6) { animation-delay: 0.3s; }
.playlist-grid .playlist-card:nth-child(7) { animation-delay: 0.35s; }
.playlist-grid .playlist-card:nth-child(8) { animation-delay: 0.4s; }

/* Card entrance animation */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Playing state animation */
.playlist-card.playing {
    animation: playing-pulse 2s ease-in-out infinite;
}

@keyframes playing-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(154, 209, 255, 0.4); }
    50% { box-shadow: 0 0 20px 5px rgba(154, 209, 255, 0.2); }
}

/* ===========================
   Playlist Preview Card
   =========================== */

.playlist-preview {
    text-align: center;
}

.playlist-preview .thumb {
    margin-bottom: 0.8rem;
}

.playlist-preview .card-title {
    font-size: 1.1rem;
    margin-bottom: 0.3rem;
}

.playlist-preview .card-artist {
    font-size: 0.9rem;
    margin-bottom: 0.2rem;
}

.playlist-preview .card-mood {
    margin-bottom: 0.8rem;
}

/* ===========================
   View Playlist Button
   =========================== */

.view-playlist-btn {
    display: inline-block;
    background: linear-gradient(135deg, #9ad1ff, #7ab8e8);
    color: #0f1117;
    text-decoration: none;
    padding: 0.75rem 1.4rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    margin-top: auto;
    min-height: 44px;
}

.view-playlist-btn:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 4px 12px rgba(154, 209, 255, 0.4);
    background: linear-gradient(135deg, #a8dbff, #88c8f0);
    filter: brightness(1.1);
}

/* ===========================
   Thumbnail
   =========================== */

.thumb {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    background-size: cover;
    background-position: center;
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.4s ease;
}

.thumb:hover {
    transform: scale(1.02);
}

.thumb::after {
    content: "▶";
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-size: 3rem;
    color: white;
    background: rgba(0,0,0,.35);
    opacity: 0;
    transition: opacity 0.4s ease;
}

.thumb:hover::after {
    opacity: 1;
}

/* Smooth image loading effect */
.thumb {
    animation: image-load 0.4s ease-out;
}

@keyframes image-load {
    from {
        opacity: 0;
        transform: scale(1.05);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ===========================
   Text
   =========================== */

.card-title {
    font-weight: 700;
}

.card-artist {
    font-size: .85rem;
    color: #9ad1ff;
}

.card-mood {
    font-size: .8rem;
    color: #c1c1c8;
    font-style: italic;
}

/* ===========================
   Modal Player
   =========================== */

.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.75);
    display: none;
    place-items: center;
    z-index: 999;
}

.modal.active {
    display: grid;
}

.modal video {
    width: min(90vw, 900px);
    max-height: 80vh;
    border-radius: 12px;
    background: black;
}

/* ===========================
   Footer
   =========================== */

footer {
    text-align: center;
    opacity: .6;
    margin-top: 3rem;
    font-size: .85rem;
}

/* ===========================
   Mobile
   =========================== */

/* Small mobile */
@media (max-width: 400px) {
    body { 
        padding: 0.75rem; 
        font-size: 14px;
    }
    h1 {
        font-size: 1.8rem;
    }
    .hero {
        padding: 1.5rem 0.5rem 2rem;
    }
    .playlist-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
}

/* Large mobile */
@media (max-width: 500px) {
    body { padding: 1rem; }
    h1 { font-size: 2rem; }
    .hero { padding: 1.5rem 1rem 2.5rem; }
    .hero-subtitle { font-size: 1rem; }
    .playlist-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 1.2rem;
    }
}

/* Tablet */
@media (max-width: 768px) {
    .hero { max-width: 100%; }
    .playlist-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 1.4rem;
    }
}

/* Mobile card adjustments */
@media (max-width: 500px) {
    .playlist-card {
        padding: 0.75rem;
        border-radius: 12px;
    }
    
    .playlist-preview .thumb {
        aspect-ratio: 4/3;
    }
    
    .audio-player {
        padding: 0.5rem;
    }
    
    .play-btn {
        width: 36px;
        height: 36px;
        min-width: 36px;
        font-size: 0.85rem;
    }
    
    .volume-btn {
        width: 32px;
        height: 32px;
        min-width: 32px;
        font-size: 0.8rem;
    }
    
    .time-display {
        font-size: 0.65rem;
    }
}

/* ===========================
   Collapsible Side Menu
   =========================== */

.menu-toggle {
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1000;
    background: #161a22;
    border: none;
    border-radius: 8px;
    padding: 0.75rem;
    cursor: pointer;
    color: #e6e6eb;
    font-size: 1.5rem;
    transition: background .25s ease;
    width: 44px;
    height: 44px;
    min-width: 44px;
}

.menu-toggle:hover {
    background: #1f2430;
}

.side-menu {
    position: fixed;
    top: 0;
    left: -320px;
    width: 280px;
    height: 100vh;
    background: #161a22;
    z-index: 999;
    padding: 4rem 1.5rem 1.5rem;
    transition: left .3s ease;
    overflow-y: auto;
}

.side-menu::before {
    content: "✕ Close";
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 0.9rem;
    color: #a0a0a8;
    cursor: pointer;
    padding: 0.5rem;
}

.side-menu.open {
    left: 0;
}

.menu-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 998;
    opacity: 0;
    visibility: hidden;
    transition: opacity .3s ease;
    backdrop-filter: blur(4px);
}

.menu-overlay.active {
    opacity: 1;
    visibility: visible;
}

.menu-section {
    margin-bottom: 1rem;
}

.menu-header {
    padding: .5rem 1rem;
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: #6b6b75;
    font-weight: 600;
}

.menu-item {
    display: block;
    padding: 0.75rem 1rem;
    color: #e6e6eb;
    text-decoration: none;
    border-radius: 6px;
    margin: .15rem 0;
    transition: background .2s ease;
    font-size: .95rem;
    min-height: 44px;
}

.menu-item:hover {
    background: #1f2430;
}

.menu-item.active {
    background: #9ad1ff;
    color: #0f1117;
}

.playlist-header {
    padding: .6rem 1rem;
    color: #e6e6eb;
    font-weight: 600;
    font-size: .95rem;
}

/* ===========================
   Skeleton Loading States
   =========================== */

.skeleton {
    background: linear-gradient(90deg, #1f2430 25%, #2a303c 50%, #1f2430 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
    border-radius: 4px;
}

@keyframes skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Skeleton card placeholder */
.skeleton-card {
    background: #161a22;
    border-radius: 14px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.skeleton-thumb {
    width: 100%;
    aspect-ratio: 16/9;
    border-radius: 10px;
}

.skeleton-title {
    height: 1.2rem;
    width: 70%;
}

.skeleton-artist {
    height: 0.9rem;
    width: 50%;
}

.skeleton-mood {
    height: 0.8rem;
    width: 40%;
}

.skeleton-track-count {
    height: 0.9rem;
    width: 30%;
}

/* Loading spinner */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(154, 209, 255, 0.3);
    border-top-color: #9ad1ff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Track count loading state */
.track-count.loading {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.track-count.loading::before {
    content: '';
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(154, 209, 255, 0.3);
    border-top-color: #9ad1ff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.playlist-header:hover {
    background: #1f2430;
    border-radius: 6px;
}

.playlist-header::before {
    content: "📀";
    font-size: 1rem;
}

.playlist-items {
    max-height: 0;
    overflow: hidden;
    transition: max-height .3s ease;
}

.playlist-items.expanded {
    max-height: 300px;
}

.menu-subitem {
    display: block;
    padding: .5rem 1.5rem .5rem 2.5rem;
    color: #a0a0a8;
    text-decoration: none;
    font-size: .9rem;
}

.menu-subitem:hover {
    color: #e6e6eb;
}

body.menu-open {
    padding-left: 1rem;
}

/* ===========================
   Audio Player
   =========================== */

.audio-player {
    background: #1f2430;
    border-radius: 8px;
    padding: 0.6rem;
    margin-top: 0.4rem;
}

.audio-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.play-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    background: linear-gradient(135deg, #9ad1ff, #7ab8e8);
    border: none;
    border-radius: 50%;
    color: #0f1117;
    font-size: 0.9rem;
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.play-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 0 12px rgba(154, 209, 255, 0.5);
}

.play-btn:active {
    transform: scale(0.95);
}

.progress-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: #2a303c;
    border-radius: 3px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #9ad1ff, #ff9ad1);
    border-radius: 3px;
    transition: width 0.1s linear;
}

.progress-bar:hover .progress-fill {
    background: linear-gradient(90deg, #a8dbff, #ffb0dc);
}

.time-display {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.7rem;
    color: #a0a0a8;
    font-family: 'Inter', monospace;
}

.time-separator {
    opacity: 0.5;
}

.volume-btn {
    width: 36px;
    height: 36px;
    min-width: 36px;
    background: transparent;
    border: none;
    color: #a0a0a8;
    font-size: 0.85rem;
    cursor: pointer;
    border-radius: 4px;
    transition: color 0.2s ease, background 0.2s ease;
}

.volume-btn:hover {
    color: #e6e6eb;
    background: #2a303c;
}

.volume-btn.muted {
    color: #ff6b6b;
}

.playlist-card.playing .audio-player {
    border: 1px solid rgba(154, 209, 255, 0.3);
    box-shadow: 0 0 16px rgba(154, 209, 255, 0.15);
}

.playlist-card.playing .play-btn {
    background: linear-gradient(135deg, #ff9ad1, #e87ab8);
}

.audio-player.loading .progress-fill {
    animation: loading-pulse 1.5s ease-in-out infinite;
}

@keyframes loading-pulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.8; }
}

/* ===========================
   Accessibility - Focus States
   =========================== */

:focus-visible {
    outline: 2px solid #9ad1ff;
    outline-offset: 2px;
}

.playlist-card:focus-within {
    border-color: rgba(154, 209, 255, 0.5);
}

.menu-toggle:focus-visible {
    outline: 2px solid #9ad1ff;
    outline-offset: 2px;
}

.view-playlist-btn:focus-visible {
    outline: 2px solid #9ad1ff;
    outline-offset: 2px;
}

.play-btn:focus-visible {
    outline: 2px solid #9ad1ff;
    outline-offset: 2px;
}

.volume-btn:focus-visible {
    outline: 2px solid #9ad1ff;
    outline-offset: 2px;
}

/* ===========================
   Persistent Audio Player
   =========================== */

.persistent-player {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(15, 17, 23, 0.95);
    backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.75rem 1.5rem;
    z-index: 1000;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.persistent-player.visible {
    transform: translateY(0);
}

.persistent-player-info {
    flex: 1;
    min-width: 0;
}

.persistent-player-title {
    font-weight: 600;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #e6e6eb;
}

.persistent-player-artist {
    font-size: 0.85rem;
    color: #a0a0a8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.persistent-player-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.persistent-player-btn {
    width: 40px;
    height: 40px;
    min-width: 40px;
    background: linear-gradient(135deg, #9ad1ff, #7ab8e8);
    border: none;
    border-radius: 50%;
    color: #0f1117;
    font-size: 1rem;
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.persistent-player-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 0 12px rgba(154, 209, 255, 0.5);
}

.persistent-player-btn.secondary {
    background: transparent;
    color: #e6e6eb;
    width: 36px;
    height: 36px;
    min-width: 36px;
}

.persistent-player-btn.secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

.persistent-player-progress {
    flex: 2;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.persistent-player-progress-bar {
    width: 100%;
    height: 4px;
    background: #2a303c;
    border-radius: 2px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.persistent-player-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #9ad1ff, #ff9ad1);
    border-radius: 2px;
    transition: width 0.1s linear;
}

.persistent-player-time {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.75rem;
    color: #a0a0a8;
}

/* Add padding to body when player is visible */
body.player-visible {
    padding-bottom: 80px;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .persistent-player {
        padding: 0.6rem 1rem;
        gap: 0.75rem;
    }
    
    .persistent-player-info {
        flex: 1;
    }
    
    .persistent-player-title {
        font-size: 0.85rem;
    }
    
    .persistent-player-artist {
        font-size: 0.75rem;
    }
    
    .persistent-player-progress {
        display: none; /* Hide progress bar on mobile */
    }
    
    body.player-visible {
        padding-bottom: 70px;
    }
}
