/**
 * FWA Player v2 - Ultra-thin Modern Player
 * 48px desktop / 42px mobile
 */

/* ==========================================================================
   CSS Variables
   ========================================================================== */
:root {
    --fwap-height: 48px;
    --fwap-height-mobile: 42px;
    --fwap-bg: #121218;
    --fwap-bg-hover: #2a2a2a;
    --fwap-text: #ffffff;
    --fwap-text-muted: #888888;
    --fwap-accent: var(--theme-palette-color-1, #bd93f9);
    --fwap-waveform-progress: var(--theme-palette-color-1, #bd93f9);
    --fwap-waveform-wave: #ffffff;
    --fwap-waveform-cursor: #ffffff;
    --fwap-vinyl-size: 36px;
    --fwap-vinyl-size-mobile: 32px;
    --fwap-btn-size: 32px;
    --fwap-btn-size-mobile: 28px;
    --fwap-transition: 0.2s ease;
    --fwap-z-index: 9999;
}

/* ==========================================================================
   Main Container
   ========================================================================== */
.fwap-player-v2 {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--fwap-height);
    background: var(--fwap-bg);
    color: var(--fwap-text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 12px;
    z-index: var(--fwap-z-index);
    transform: translateY(100%);
    transition: transform 0.3s ease;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3);
}

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

.fwap-player-v2.fwap-loading {
    /* No visual change during loading - transitions handled in JS */
    pointer-events: none;
}

/* ==========================================================================
   Inner Layout
   ========================================================================== */
.fwap-inner {
    display: flex;
    align-items: center;
    height: 100%;
    padding: 0 12px;
    gap: 12px;
    max-width: 100%;
}

/* ==========================================================================
   Vinyl Macaron
   ========================================================================== */
.fwap-vinyl {
    flex-shrink: 0;
    width: var(--fwap-vinyl-size);
    height: var(--fwap-vinyl-size);
}

.fwap-vinyl-wrapper {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    overflow: hidden;
    background: #333;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.1);
}

.fwap-vinyl-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    animation: fwap-spin 3s linear infinite;
    animation-play-state: paused;
}

.fwap-player-v2.fwap-playing .fwap-vinyl-image {
    animation-play-state: running;
}

@keyframes fwap-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ==========================================================================
   Metadata & Playlist Dropdown
   ========================================================================== */
.fwap-meta {
    flex-shrink: 0;
    width: 180px;
    min-width: 120px;
    position: relative;
}

.fwap-meta-toggle {
    display: flex;
    flex-direction: column;
    width: 100%;
    padding: 4px 8px;
    background: transparent;
    border: none;
    color: inherit;
    cursor: pointer;
    text-align: left;
    border-radius: 4px;
    transition: background var(--fwap-transition);
}

.fwap-meta-toggle:hover {
    background: var(--fwap-bg-hover);
}

.fwap-meta-info {
    line-height: 1.3;
}

.fwap-meta-line1 {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fwap-meta-line2 {
    font-size: 10px;
    color: var(--fwap-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fwap-track-display {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 2px;
    font-size: 10px;
    color: var(--fwap-accent);
}

.fwap-track-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.fwap-dropdown-arrow {
    font-size: 8px;
    margin-left: 4px;
    transition: transform var(--fwap-transition);
}

.fwap-meta-toggle[aria-expanded="true"] .fwap-dropdown-arrow {
    transform: rotate(180deg);
}

.fwap-separator {
    opacity: 0.5;
}

/* Playlist Dropdown */
.fwap-playlist-dropdown {
    position: absolute;
    bottom: 100%;
    left: 0;
    width: 280px;
    max-height: 300px;
    overflow-y: auto;
    background: var(--fwap-bg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px 8px 0 0;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);
    display: none;
    z-index: 10;
}

.fwap-playlist-dropdown.fwap-open {
    display: block;
}

.fwap-playlist-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    cursor: pointer;
    transition: background var(--fwap-transition);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.fwap-playlist-item:hover {
    background: var(--fwap-bg-hover);
}

.fwap-playlist-item.fwap-active {
    background: rgba(74, 158, 255, 0.15);
    color: var(--fwap-accent);
}

.fwap-playlist-item:last-child {
    border-bottom: none;
}

.fwap-playlist-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fwap-playlist-duration {
    font-size: 10px;
    color: var(--fwap-text-muted);
    margin-left: 8px;
}

/* ==========================================================================
   Waveform
   ========================================================================== */
.fwap-waveform {
    flex: 1;
    min-width: 100px;
    height: 32px;
    position: relative;
    cursor: pointer;
}

#fwap-waveform-container {
    width: 100%;
    height: 100%;
}

/* Fallback progress bar */
.fwap-waveform-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
}

.fwap-progress-bar {
    width: 100%;
    height: 4px;
    background: var(--fwap-waveform-wave);
    border-radius: 2px;
    overflow: hidden;
}

.fwap-progress-fill {
    height: 100%;
    width: 0;
    background: var(--fwap-waveform-progress);
    transition: width 0.1s linear;
}

/* ==========================================================================
   Controls
   ========================================================================== */
.fwap-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.fwap-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--fwap-btn-size);
    height: var(--fwap-btn-size);
    padding: 0;
    background: transparent;
    border: none;
    color: var(--fwap-text);
    cursor: pointer;
    border-radius: 50%;
    transition: background var(--fwap-transition), color var(--fwap-transition);
    font-size: 10px;
}

.fwap-btn:hover {
    background: var(--fwap-bg-hover);
    color: var(--fwap-accent);
}

.fwap-btn:focus-visible {
    outline: 2px solid var(--fwap-accent);
    outline-offset: 2px;
}

.fwap-btn-main {
    width: 36px;
    height: 36px;
    background: var(--fwap-accent);
    color: white;
}

.fwap-btn-main:hover {
    background: #5aafff;
    color: white;
}

/* Prev/Next buttons same size */
.fwap-prev,
.fwap-next {
    width: 32px;
    height: 32px;
}

.fwap-prev svg,
.fwap-next svg {
    width: 18px;
    height: 18px;
}

/* Play/Pause icon states */
.fwap-player-v2.fwap-playing .fwap-icon-play {
    display: none;
}

.fwap-player-v2.fwap-playing .fwap-icon-pause {
    display: block !important;
}

/* ==========================================================================
   Volume Control
   ========================================================================== */
.fwap-volume {
    position: relative;
}

.fwap-volume-popup {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 8px;
    background: var(--fwap-bg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.3);
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.fwap-volume-popup.fwap-open {
    display: flex;
}

.fwap-volume-slider {
    width: 80px;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--fwap-waveform-wave);
    border-radius: 2px;
    cursor: pointer;
}

.fwap-volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    background: var(--fwap-accent);
    border-radius: 50%;
    cursor: pointer;
}

.fwap-volume-slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    background: var(--fwap-accent);
    border-radius: 50%;
    border: none;
    cursor: pointer;
}

.fwap-volume-value {
    font-size: 10px;
    color: var(--fwap-text-muted);
    min-width: 30px;
    text-align: center;
}

/* Volume icon states */
.fwap-volume-btn svg {
    width: 18px;
    height: 18px;
}

/* ==========================================================================
   Pitch Control (Desktop only)
   ========================================================================== */
.fwap-pitch {
    position: relative;
}

.fwap-pitch-popup {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 8px;
    background: var(--fwap-bg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.3);
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.fwap-pitch-popup.fwap-open {
    display: flex;
}

.fwap-pitch-slider {
    width: 100px;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: linear-gradient(to right,
        var(--fwap-waveform-wave) 0%,
        var(--fwap-waveform-wave) 50%,
        var(--fwap-waveform-wave) 100%
    );
    border-radius: 2px;
    cursor: pointer;
}

.fwap-pitch-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: var(--fwap-accent);
    border-radius: 50%;
    cursor: pointer;
}

.fwap-pitch-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: var(--fwap-accent);
    border-radius: 50%;
    border: none;
    cursor: pointer;
}

.fwap-pitch-value {
    font-size: 10px;
    color: var(--fwap-text-muted);
    min-width: 20px;
    text-align: center;
}

/* ==========================================================================
   Cart Button
   ========================================================================== */
.fwap-cart-btn svg {
    width: 16px;
    height: 16px;
}

.fwap-cart-btn.fwap-added {
    color: #4caf50;
}

/* ==========================================================================
   Wishlist Button
   ========================================================================== */
.fwap-wishlist-btn svg {
    width: 18px;
    height: 18px;
}

.fwap-wishlist-btn.fwap-wishlisted {
    color: #e74c3c;
}

.fwap-wishlist-btn.fwap-wishlisted svg {
    fill: #e74c3c;
}

/* ==========================================================================
   Vinyl Link (clickable)
   ========================================================================== */
.fwap-vinyl-link {
    display: block;
    width: 100%;
    height: 100%;
    text-decoration: none;
}

.fwap-vinyl-link:hover .fwap-vinyl-wrapper {
    box-shadow: 0 0 0 2px var(--fwap-accent);
}

/* ==========================================================================
   Status Indicator
   ========================================================================== */
.fwap-status {
    position: fixed;
    bottom: calc(var(--fwap-height) + 12px);
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 16px;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    font-size: 12px;
    border-radius: 20px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: calc(var(--fwap-z-index) + 1);
}

.fwap-status.fwap-show {
    opacity: 1;
    visibility: visible;
}

.fwap-status.fwap-success {
    background: rgba(76, 175, 80, 0.95);
}

.fwap-status.fwap-error {
    background: rgba(244, 67, 54, 0.95);
}

/* ==========================================================================
   Desktop Only
   ========================================================================== */
.fwap-desktop-only {
    display: flex;
}

/* ==========================================================================
   Mobile Styles
   ========================================================================== */
@media (max-width: 768px) {
    :root {
        --fwap-height: var(--fwap-height-mobile);
        --fwap-vinyl-size: var(--fwap-vinyl-size-mobile);
        --fwap-btn-size: var(--fwap-btn-size-mobile);
    }

    .fwap-inner {
        padding: 0 8px;
        gap: 8px;
    }

    .fwap-meta {
        width: 140px;
        min-width: 100px;
    }

    .fwap-meta-line1 {
        font-size: 11px;
    }

    .fwap-meta-line2,
    .fwap-track-display {
        font-size: 9px;
    }

    .fwap-waveform {
        height: 28px;
        min-width: 60px;
    }

    .fwap-btn-main {
        width: 32px;
        height: 32px;
        font-size: 10px;
    }

    .fwap-desktop-only {
        display: none !important;
    }

    .fwap-playlist-dropdown {
        width: 100%;
        left: 0;
        right: 0;
        max-height: 250px;
    }

    .fwap-status {
        bottom: calc(var(--fwap-height-mobile) + 8px);
        font-size: 11px;
        padding: 6px 12px;
    }
}

/* ==========================================================================
   Very Small Screens - Optimized for waveform interaction
   ========================================================================== */
@media (max-width: 480px) {
    /* Reduce meta section to minimum */
    .fwap-meta {
        width: 85px;
        min-width: 70px;
    }

    .fwap-meta-line1 {
        font-size: 10px;
    }

    .fwap-meta-line2,
    .fwap-track-display {
        font-size: 8px;
    }

    /* Hide vinyl on small screens */
    .fwap-vinyl {
        display: none;
    }

    /* Hide volume and wishlist on mobile - not essential, saves space for waveform */
    .fwap-volume,
    .fwap-wishlist-btn {
        display: none !important;
    }

    /* Compact controls */
    .fwap-controls {
        gap: 1px;
    }

    /* Smaller prev/next buttons */
    .fwap-prev,
    .fwap-next {
        display: flex;
        width: 24px;
        height: 24px;
    }

    .fwap-prev svg,
    .fwap-next svg {
        width: 14px;
        height: 14px;
    }

    /* Smaller play button */
    .fwap-play-pause {
        width: 32px !important;
        height: 32px !important;
        min-width: 32px !important;
    }

    .fwap-play-pause svg {
        width: 14px !important;
        height: 14px !important;
    }

    /* Smaller cart button */
    .fwap-cart-btn {
        width: 26px;
        height: 26px;
    }

    .fwap-cart-btn svg {
        width: 14px;
        height: 14px;
    }

    /* Waveform takes remaining space - now much larger */
    .fwap-waveform {
        flex: 1;
        min-width: 80px;
        height: 30px;
    }

    /* Tighter inner padding */
    .fwap-inner {
        padding: 0 6px;
        gap: 6px;
    }
}

/* ==========================================================================
   Reduced Motion
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
    .fwap-vinyl-image {
        animation: none;
    }

    .fwap-player-v2,
    .fwap-btn,
    .fwap-meta-toggle,
    .fwap-dropdown-arrow {
        transition: none;
    }
}

/* ==========================================================================
   High Contrast Mode
   ========================================================================== */
@media (prefers-contrast: high) {
    .fwap-player-v2 {
        border-top: 2px solid white;
    }

    .fwap-btn:focus-visible {
        outline-width: 3px;
    }
}




/* =============================================================================
   YOYAKU Theme Override
   Single Source of Truth: --theme-palette-color-1 (Blocksy Customizer)
   ========================================================================== */

/* Override FWA Player CSS variables to use theme color */
:root {
  --fwap-primary-color: var(--theme-palette-color-1) !important;
  --fwap-accent-color: var(--theme-palette-color-1) !important;
  --fwap-loader-primary-color: var(--theme-palette-color-1) !important;
  --fwap-notice-accent: var(--theme-palette-color-1) !important;
}

/* Player container */
#fwap-player.fwap-player-v2 {
  background: var(--theme-palette-color-5, #212529) !important;
  border-top: 1px solid var(--theme-palette-color-6, #272b2f) !important;
}

#fwap-player .fwap-inner {
  background: var(--theme-palette-color-5, #212529) !important;
}

/* Text colors */
#fwap-player .fwap-title,
#fwap-player .fwap-track-name {
  color: var(--theme-palette-color-4, #ffffff) !important;
}

#fwap-player .fwap-artist,
#fwap-player .fwap-label,
#fwap-player .fwap-sku {
  color: var(--theme-palette-color-3, #a6a7a9) !important;
}

/* Buttons */
#fwap-player .fwap-btn {
  color: var(--theme-palette-color-4, #ffffff) !important;
}

#fwap-player .fwap-btn:hover {
  color: var(--theme-palette-color-1) !important;
}

/* Play button - elegant filled circle */
#fwap-player .fwap-play-pause {
  width: 40px !important;
  height: 40px !important;
  min-width: 40px !important;
  border: none !important;
  border-radius: 50% !important;
  background: var(--theme-palette-color-1) !important;
  color: var(--theme-palette-color-5, #212529) !important;
  box-shadow: 0 2px 8px rgba(189, 147, 249, 0.3) !important;
  transition: all 0.2s ease !important;
}

#fwap-player .fwap-play-pause:hover {
  transform: scale(1.05) !important;
  box-shadow: 0 4px 12px rgba(189, 147, 249, 0.5) !important;
}

#fwap-player .fwap-play-pause svg,
#fwap-player .fwap-play-pause .fwap-icon-play,
#fwap-player .fwap-play-pause .fwap-icon-pause {
  width: 16px !important;
  height: 16px !important;
  color: var(--theme-palette-color-5, #212529) !important;
  fill: var(--theme-palette-color-5, #212529) !important;
}

/* Waveform background */
#fwap-player .fwap-waveform,
#fwap-player .fwap-waveform-container,
#fwap-player .fwap-progress-bar {
  background: var(--theme-palette-color-6, #272b2f) !important;
}

/* Cart button */
#fwap-player .fwap-cart-btn {
  background: var(--theme-palette-color-1) !important;
  color: var(--theme-palette-color-5, #212529) !important;
  border-radius: 4px !important;
}

#fwap-player .fwap-cart-btn:hover {
  filter: brightness(1.15) !important;
}

/* Dropdowns */
#fwap-player .fwap-playlist-dropdown,
#fwap-player .fwap-volume-popup,
#fwap-player .fwap-pitch-popup {
  background: var(--theme-palette-color-6, #272b2f) !important;
  border-color: var(--theme-palette-color-7, #2a2e32) !important;
}

#fwap-player .fwap-meta-toggle {
  color: var(--theme-palette-color-3, #a6a7a9) !important;
}

#fwap-player .fwap-meta-toggle:hover {
  color: var(--theme-palette-color-1) !important;
}

/* =============================================================================
   B2B Site Optimizations (YYDistribution)
   Improved readability: larger text, better contrast, clearer icons
   ========================================================================== */

/* B2B detection via body class or data attribute */
body.yyd-site #fwap-player,
body[data-site="b2b"] #fwap-player,
#fwap-player.fwap-b2b {
    --fwap-text-muted: #b0b0b0; /* Lighter muted text for better contrast */
}

/* Improved text readability for B2B */
body.yyd-site #fwap-player .fwap-meta-line1,
body[data-site="b2b"] #fwap-player .fwap-meta-line1,
#fwap-player.fwap-b2b .fwap-meta-line1 {
    font-size: 13px !important;
    font-weight: 600 !important;
    letter-spacing: 0.2px !important;
}

body.yyd-site #fwap-player .fwap-meta-line2,
body[data-site="b2b"] #fwap-player .fwap-meta-line2,
#fwap-player.fwap-b2b .fwap-meta-line2 {
    font-size: 11px !important;
    color: #c0c0c0 !important; /* Better contrast */
    font-weight: 500 !important;
}

body.yyd-site #fwap-player .fwap-track-name,
body[data-site="b2b"] #fwap-player .fwap-track-name,
#fwap-player.fwap-b2b .fwap-track-name {
    font-size: 11px !important;
    font-weight: 500 !important;
}

/* Larger, clearer icons for B2B */
body.yyd-site #fwap-player .fwap-btn svg,
body[data-site="b2b"] #fwap-player .fwap-btn svg,
#fwap-player.fwap-b2b .fwap-btn svg {
    width: 20px !important;
    height: 20px !important;
    opacity: 0.95 !important;
}

body.yyd-site #fwap-player .fwap-prev svg,
body.yyd-site #fwap-player .fwap-next svg,
body[data-site="b2b"] #fwap-player .fwap-prev svg,
body[data-site="b2b"] #fwap-player .fwap-next svg,
#fwap-player.fwap-b2b .fwap-prev svg,
#fwap-player.fwap-b2b .fwap-next svg {
    width: 20px !important;
    height: 20px !important;
}

/* Slightly larger buttons for B2B */
body.yyd-site #fwap-player .fwap-btn,
body[data-site="b2b"] #fwap-player .fwap-btn,
#fwap-player.fwap-b2b .fwap-btn {
    width: 36px !important;
    height: 36px !important;
}

body.yyd-site #fwap-player .fwap-play-pause,
body[data-site="b2b"] #fwap-player .fwap-play-pause,
#fwap-player.fwap-b2b .fwap-play-pause {
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
}

/* Better separator visibility */
body.yyd-site #fwap-player .fwap-separator,
body[data-site="b2b"] #fwap-player .fwap-separator,
#fwap-player.fwap-b2b .fwap-separator {
    opacity: 0.7 !important;
    color: #a0a0a0 !important;
}

/* Wider meta section for B2B (more room for category names) */
body.yyd-site #fwap-player .fwap-meta,
body[data-site="b2b"] #fwap-player .fwap-meta,
#fwap-player.fwap-b2b .fwap-meta {
    width: 220px !important;
    min-width: 160px !important;
}

/* Dropdown improvements for B2B */
body.yyd-site #fwap-player .fwap-playlist-dropdown,
body[data-site="b2b"] #fwap-player .fwap-playlist-dropdown,
#fwap-player.fwap-b2b .fwap-playlist-dropdown {
    width: 320px !important;
}

body.yyd-site #fwap-player .fwap-playlist-item,
body[data-site="b2b"] #fwap-player .fwap-playlist-item,
#fwap-player.fwap-b2b .fwap-playlist-item {
    padding: 12px 14px !important;
    font-size: 13px !important;
}

/* Improved waveform contrast for B2B */
body.yyd-site #fwap-player .fwap-waveform,
body[data-site="b2b"] #fwap-player .fwap-waveform,
#fwap-player.fwap-b2b .fwap-waveform {
    height: 36px !important;
}

/* IMPORTANT: Hide wishlist button on B2B (no TI Wishlist plugin) */
body.yyd-site #fwap-player .fwap-wishlist-btn,
body[data-site="b2b"] #fwap-player .fwap-wishlist-btn,
#fwap-player.fwap-b2b .fwap-wishlist-btn {
    display: none !important;
}
