/* Reset & Base Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    /* Fallback default M3 colors */
    --m3-background: #0d0c11;
    --m3-primary: #d0bcff;
    --m3-primary-rgb: 208, 188, 255;
    --m3-secondary: #381e72;
    --m3-text-primary: #e6e1e5;
    --m3-text-secondary: #938f99;
}

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--m3-background);
    /* Google Sans Flex primary font support with fallback values */
    font-family: 'Google Sans Flex', 'Google Sans', 'Product Sans', 'Outfit', sans-serif;
    color: var(--m3-text-primary);
    -webkit-font-smoothing: antialiased;
    transition: background-color 1.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}

#app-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

/* Cast Media Player base layer (invisible to user) */
cast-media-player {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    opacity: 0;
    pointer-events: none;
}

/* Flat Edge-to-Edge Material 3 Layout */
#m3-player-layout {
    position: relative;
    z-index: 10;
    width: 85%;
    max-width: 1100px;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 80px;
}

/* Left Column: Big Album Art */
.player-left {
    position: relative;
    flex-shrink: 0;
    width: 440px;
    height: 440px;
}

#artwork-wrapper {
    width: 100%;
    height: 100%;
    border-radius: 48px;
    overflow: hidden;
    background-color: rgba(255, 255, 255, 0.02);
    /* Clean flat M3 design: no borders, no shadows */
    border: none;
    box-shadow: none;
    position: relative; /* Vital for overlay positioning */
}

#album-art {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Pause Overlay on Artwork */
#pause-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.35);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), visibility 0.3s ease;
    z-index: 5;
}

#pause-overlay.visible {
    opacity: 1;
    visibility: visible;
}

#pause-overlay svg {
    width: 80px;
    height: 80px;
    color: #ffffff;
    filter: drop-shadow(0 4px 16px rgba(0, 0, 0, 0.4));
}

/* Right Column: Metadata & Progress */
.player-right {
    flex-grow: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    text-align: left;
}

/* Status row & M3 badge */
.status-row {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 30px;
}

.m3-badge {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 1.5px;
    padding: 6px 18px;
    /* Clean flat layout: solid transparent badge background, no border stroke */
    background: rgba(var(--m3-primary-rgb), 0.16);
    color: var(--m3-primary);
    border: none;
    border-radius: 24px;
    text-transform: uppercase;
    transition: all 1.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Equalizer Bouncing Bars */
#activity-indicator {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    width: 28px;
    height: 16px;
    gap: 3px;
}

#activity-indicator .bar {
    width: 4px;
    height: 100%;
    background-color: var(--m3-primary);
    border-radius: 2px;
    transform-origin: bottom;
    animation: bounce 1.1s ease-in-out infinite alternate;
    opacity: 0.95;
    transition: background-color 1.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}

#activity-indicator.paused .bar {
    animation-play-state: paused;
    height: 4px !important;
}

#activity-indicator .bar:nth-child(1) { animation-delay: 0.1s; height: 30%; }
#activity-indicator .bar:nth-child(2) { animation-delay: 0.4s; height: 75%; }
#activity-indicator .bar:nth-child(3) { animation-delay: 0.2s; height: 50%; }
#activity-indicator .bar:nth-child(4) { animation-delay: 0.5s; height: 90%; }

@keyframes bounce {
    0% { transform: scaleY(0.25); }
    100% { transform: scaleY(1.2); }
}

/* Metadata Text */
#metadata-container {
    width: 100%;
    margin-bottom: 45px;
}

#track-title {
    font-size: 56px;
    font-weight: 800;
    letter-spacing: -1.5px;
    line-height: 1.15;
    color: var(--m3-text-primary);
    margin-bottom: 12px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 1.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}

#track-artist {
    font-size: 24px;
    font-weight: 500;
    color: var(--m3-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 1.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Playback Progress Slider (Segmented look) */
#playback-controls {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

#progress-bar-track {
    width: 100%;
    height: 4px; /* Thin inactive track */
    background: rgba(255, 255, 255, 0.12);
    border-radius: 2px;
    position: relative;
    display: flex;
    align-items: center; /* Center the active fill vertically */
}

#progress-bar-fill {
    height: 12px; /* Thick active track */
    width: 0%;
    background-color: var(--m3-primary);
    border-radius: 6px;
    transition: width 0.25s linear, background-color 1.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* M3 Expressive: Wavy active seekbar fill when music is playing */
#progress-bar-fill.wavy {
    /* SVG sine wave pattern mask */
    -webkit-mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="40" height="12" viewBox="0 0 40 12"><path d="M 0 6 Q 10 1, 20 6 T 40 6" fill="none" stroke="black" stroke-width="4" stroke-linecap="round"/></svg>');
    -webkit-mask-repeat: repeat-x;
    -webkit-mask-size: 40px 12px;
    -webkit-mask-position: 0px center;
    
    mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="40" height="12" viewBox="0 0 40 12"><path d="M 0 6 Q 10 1, 20 6 T 40 6" fill="none" stroke="black" stroke-width="4" stroke-linecap="round"/></svg>');
    mask-repeat: repeat-x;
    mask-size: 40px 12px;
    mask-position: 0px center;
    
    /* Scroll animation for the wave */
    animation: wave-scroll 1.2s linear infinite;
}

/* Pause: flat seekbar look */
#progress-bar-fill.paused {
    -webkit-mask-image: none;
    mask-image: none;
    height: 8px; /* Thinner flat pill on pause */
    border-radius: 4px;
}

@keyframes wave-scroll {
    from {
        -webkit-mask-position: 0px center;
        mask-position: 0px center;
    }
    to {
        -webkit-mask-position: 40px center;
        mask-position: 40px center;
    }
}

.time-row {
    width: 100%;
    display: flex;
    justify-content: space-between;
    font-variant-numeric: tabular-nums;
}

#time-current, #time-total {
    font-size: 15px;
    font-weight: 500;
    color: var(--m3-text-secondary);
    opacity: 0.6;
}
