/* ── Preview panel shell ── */
#song-preview-panel {
    position: fixed;
    right: 32px;
    top: 32px;                  /* fallback; JS overwrites dynamically on load/scroll */
    height: calc(100vh - 64px); /* JS overwrites */
    overflow: visible; /* allow key dropdown to escape the panel bounds */
    opacity: 0;
    /* z-index intentionally below #header (902) so header always covers the panel */
    z-index: 100;
    background: #fff;
    border: 1px solid #E2E8F0;
    border-radius: 18px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.08);
    /* translateX slide: GPU-composited, no layout reflow */
    transform: translateX(calc(100% + 64px));
    transition: transform 0.3s ease, opacity 0.25s ease;
    will-change: transform, opacity;
}
#song-preview-panel.panel--open {
    transform: translateX(0);
    opacity: 1;
}

.song-preview-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden; /* clips scrollable body content inside the rounded panel */
    padding: 16px;
    box-sizing: border-box;
    border-radius: 18px; /* match panel so clipping respects rounded corners */
}

/* ── Toolbar (key selector + play controls + close) ── */
.song-preview-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 0 14px;
    border-bottom: none;
    flex-shrink: 0;
    overflow: visible; /* allow key dropdown to escape the panel's overflow:hidden */
}

/* Key selector dropdown — matches PDP inline arrangements style */
.song-preview-key-wrap {
    position: relative;
    min-width: 40%;
}
.song-preview-key-selector {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    box-sizing: border-box;
    background-color: #ffffff;
    border: 0.5px solid #D7DCE0;
    border-radius: 8px;
    padding: 10px 14px;
    height: 40px;
    font-size: 14px;
    font-weight: 400;
    color: #1E2225;
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
}
.song-preview-key-selector:hover { border-color: #1C7CB5; }
.song-preview-key-selector span { flex: 1; text-align: center; }
.song-preview-key-selector svg { flex-shrink: 0; }
.song-preview-key-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 300;
    background-color: #f9f9f9;
    border-radius: 8px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.15);
    min-width: 100%;
    max-height: 236px;
    overflow-y: auto;
    padding: 0;
}
.song-preview-key-dropdown.open { display: block; }
.sp-key-option {
    color: #1E2225;
    padding: 8px 16px;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 14px;
    cursor: pointer;
}
.sp-key-option:first-child { border-radius: 8px 8px 0 0; }
.sp-key-option:last-child  { border-radius: 0 0 8px 8px; }
.sp-key-option:hover { color: #1C7CB5; background: #F3F5F6; }
.sp-key-option--current { font-weight: 700; }
.sp-key-option--loading { color: #888; font-style: italic; padding: 8px 16px; }

/* Play controls — immersive design */
.sp-toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}
.song-preview-play-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}
/* Play/Pause pill — exact PDP layout (position:absolute icon+text) */
.preview-play-pill {
    position: relative;
    background: transparent;
    border: none;
    padding: 0;
    margin: 0;
    min-width: 96px;
    width: 96px;
    height: 40px;
    max-height: 40px;
    cursor: pointer;
    flex-shrink: 0;
    -webkit-appearance: none;
    appearance: none;
}
.preview-play-pill:focus  { outline: none; }
.preview-play-pill:active { background: transparent; }
.preview-play-pill:disabled { cursor: default; opacity: 0.5; }
.preview-pill-content {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}
.preview-pill-play,
.preview-pill-pause {
    display: flex;
    align-items: center;
    gap: 8px;
}
.preview-pill-pause { display: none; }
.song-preview-play-controls.is-playing .preview-pill-play  { display: none; }
.song-preview-play-controls.is-playing .preview-pill-pause { display: flex; }
.preview-pill-icon { display: flex; align-items: center; flex-shrink: 0; }
.preview-pill-play  .preview-pill-icon svg { width: 11px; height: 12px; display: block; }
.preview-pill-pause .preview-pill-icon svg { width: 12px; height: 12px; display: block; }
.preview-pill-text {
    color: #fff;
    font-size: 16px;
    font-weight: bold;
    white-space: nowrap;
}

/* Close button: transparent wrapper, SVG does the styling (matches restart btn) */
.song-preview-close-btn {
    background: transparent;
    border: none;
    padding: 0;
    margin: 0;
    height: 40px;
    width: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}
.song-preview-close-btn:hover svg circle, .song-preview-close-btn:hover svg path:first-child { opacity: 0.85; }

/* ── Sheet music image — same padding-top trick as grid cards (10:13 ratio) ── */
.song-preview-image-wrap {
    position: relative;
    width: 100%;
    padding-top: 130%;   /* 10:13 portrait ratio, identical to .browse-card-image */
    flex: 0 0 auto;
}
.song-preview-image-wrap img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    object-fit: contain;
    background: #fff;
    border: 1px solid #e2e5e8;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.10);
}

.song-preview-image-wrap img.img--lowres {
    padding: 8%;
}

/* ── Info body — pinned to the bottom of the panel ── */
.song-preview-body {
    padding: 0;
    padding-top: 12px;
    margin-top: auto;   /* pushes body to bottom; absorbs any space above */
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
/* Title + scoring badge on the same row */
.sp-title-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}
.song-preview-title {
    font-size: 16px;
    font-weight: 700;
    line-height: 1.3;
    margin: 0;
    position: relative;
    top: 3px;
    color: #2C3235;
    flex: 1;
    min-width: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
/* Two-column info rows: text on left, badge on right */
.sp-info-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 22px;
}
.song-preview-artist {
    font-size: 14px;
    color: #2C3235;
    margin: 0;
    margin-top: -1px;
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Rating row */
.song-preview-rating-row {
    display: flex;
    align-items: center;
    gap: 5px;
    flex: 1;
}
.song-preview-rating-row.rating-hidden {
    display: none !important;
    height: 0 !important;
    overflow: hidden !important;
}
#song-preview-rating-stars .rating-stars ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
}
#song-preview-rating-stars .rating-stars ul > li.star {
    display: inline-block;
}
#song-preview-rating-stars .rating-stars ul > li.star > button.fa {
    padding: 0 !important;
    background: none !important;
    border: 0 !important;
    font-size: 1.6rem;
    color: #ccc;
    cursor: default;
    pointer-events: none;
}
#song-preview-rating-stars .rating-stars ul > li.star.selected > button.fa {
    color: #FF912C;
}

/* Synthetic Ratings: numeric average + count beside the preview stars. */
#song-preview-rating-stars .stars-row--rated {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
}

/* Average + count wrapper: baseline-align so the count sits on the average's text
   baseline, while the group as a whole stays centred with the stars. */
#song-preview-rating-stars .stars-row--rated .rating-label-group {
    display: flex;
    align-items: baseline;
    gap: 4px;
}

/* Brand star artwork (treatment only) — empty / full / half per li state. Sized in
   em off the treatment star font-size (24px, matching the home-browse spec). Control
   rows keep the FontAwesome glyph at the original 1.6rem. */
#song-preview-rating-stars .stars-row--rated .rating-stars ul > li.star > button.fa {
    display: inline-block;
    width: .84em !important;
    height: 1em !important;
    font-size: 24px;
    color: transparent !important;
    background-color: transparent !important;
    background-repeat: no-repeat !important;
    background-position: center !important;
    background-size: contain !important;
    background-image: url('/images/icons/rating-star-empty.svg') !important;
}
#song-preview-rating-stars .stars-row--rated .rating-stars ul > li.star.selected > button.fa {
    background-image: url('/images/icons/rating-star-full.svg') !important;
}
#song-preview-rating-stars .stars-row--rated .rating-stars ul > li.star.selected.half > button.fa {
    background-image: url('/images/icons/rating-star-half.svg') !important;
}
#song-preview-rating-stars .rating-label {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.5;
    color: #2C3235;
}
#song-preview-rating-stars .rating-count-label {
    font-size: 12px;
    font-weight: 400;
    line-height: 1.5;
    color: #666666;
}

.sp-tag {
    display: inline-block;
    font-size: 12px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 20px;
    line-height: 1.4;
    flex-shrink: 1;
    white-space: nowrap;
    margin-left: auto;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    background: #E2DFDF;
    border: 1px solid rgba(90,90,84,0.20);
    color: #1F1F1C;
}
.sp-tag--icon    { background: #f5c8e8; color: #8b1560; }

/* Grid card scoring badge — colour only (position handled by .browse-card-badges) */
.browse-card-tag { background: #E2DFDF; border: 1px solid rgba(90,90,84,0.20); color: #1F1F1C; }

/* Difficulty badge colour variants for browse-song grid. */
.browse-card-tag--difficulty-easy         { background: #B6EABE; border: 1px solid #4B6E5033; color: #2A3D2C; }
.browse-card-tag--difficulty-intermediate { background: #FFE299; border: 1px solid #7D6A0033; color: #473C00; }
.browse-card-tag--difficulty-advanced     { background: #FBCEB4; border: 1px solid #8D4E4933; color: #5D322E; }

/* Difficulty dot indicator in the filter panel. */
.browse-filter-item { text-decoration: none; display: flex; align-items: center; }
.browse-difficulty-dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    margin: 1px 4px 0 2px;
}
.browse-difficulty-dot--easy         { background: #7FC98F; }
.browse-difficulty-dot--intermediate { background: #E0BE55; }
.browse-difficulty-dot--advanced     { background: #E8906A; }

/* Difficulty badge in the song preview panel info row. */
.sp-difficulty-tag {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    line-height: 1.4;
}
.sp-difficulty-tag--easy         { background: #B6EABE; border: 1px solid #4B6E5033; color: #2A3D2C; }
.sp-difficulty-tag--intermediate { background: #FFE299; border: 1px solid #7D6A0033; color: #473C00; }
.sp-difficulty-tag--advanced     { background: #FBCEB4; border: 1px solid #8D4E4933; color: #5D322E; }

/* CTA buttons — side by side, matching MVSP popup design */
.song-preview-cta {
    display: flex;
    flex-direction: row;
    gap: 8px;
    margin-top: 10px;
    margin-bottom: 8px;
}
.btn-preview-cart,
.btn-preview-goto {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 16px;
    font-weight: 700;
    border-radius: 1000px;
    padding: 8px 12px;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.2s, box-shadow 0.2s, color 0.2s, border-color 0.2s;
}
/* Add to Cart — mvsp-add-to-cart-btn style */
.btn-preview-cart {
    background: #09283A;
    color: #fff;
    border: 3px solid transparent;
}
.btn-preview-cart:hover,
.btn-preview-cart:focus {
    background: #0D3A54;
    color: #fff;
    box-shadow: 0 4px 12px rgba(0,0,0,0.18);
}
.btn-preview-cart:active { box-shadow: inset 0 2px 6px rgba(0,0,0,0.2); }
/* View Sheet Music — mvsp-buy-now-btn style */
.btn-preview-goto {
    background: #fff;
    color: #09283A;
    border: 3px solid #09283A;
}
.btn-preview-goto span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.btn-preview-goto:hover,
.btn-preview-goto:focus {
    border-color: #176492;
    color: #176492;
    box-shadow: 0 4px 12px rgba(0,0,0,0.18);
}
.btn-preview-goto:active { box-shadow: inset 0 2px 6px rgba(0,0,0,0.2); }
