/* Radio Player — popup styles */

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}

.rp-body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: #fff;
    background: #1a1f2e;
    user-select: none;
    -webkit-user-select: none;
}

.rp-stage {
    position: relative;
    height: 100vh;
    height: 100dvh; /* mobile: excludes URL bar */
    width: 100vw;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.rp-bg {
    position: absolute;
    inset: 0;
    background: var(--rp-bg);
    background-size: cover;
    background-position: center;
    z-index: 0;
}

.rp-overlay {
    position: absolute;
    inset: 0;
    /* Falls back to a subtle darkening gradient when no overlay is configured in settings */
    background: var(--rp-overlay, linear-gradient(180deg, rgba(0,0,0,0.15) 0%, rgba(0,0,0,0.45) 100%));
    z-index: 1;
}

.rp-main {
    position: relative;
    z-index: 2;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 24px;
    min-height: 0;
}

.rp-logo-wrap {
    width: var(--rp-logo-width, 200px);
    height: var(--rp-logo-width, 200px);
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rp-logo {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 4px 16px rgba(0,0,0,0.35));
}

.rp-logo[src=""] { display: none; }

.rp-station-name {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 8px;
    letter-spacing: -0.01em;
    color: var(--rp-title-color, #ffffff);
}

.rp-track-info {
    font-size: 15px;
    color: var(--rp-track-color, #d9d9d9);
    font-weight: 400;
    max-width: 90%;
    line-height: 1.4;
}

.rp-track-info .rp-artist {
    color: #fff;
    font-weight: 600;
}

/* Ads */
.rp-ads {
    position: relative;
    z-index: 2;
    display: flex;
    justify-content: center;
    padding: 8px;
    background: rgba(0,0,0,0.2);
}

.rp-ad-desktop { display: block; }
.rp-ad-mobile  { display: none; }

@media (max-width: 600px) {
    .rp-ad-desktop { display: none; }
    .rp-ad-mobile  { display: block; }
}

/* Equaliser */
.rp-eq {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 3px;
    height: 32px;
    padding: 0 20px 12px;
}

.rp-eq span {
    display: block;
    width: 4px;
    height: 4px;
    background: var(--rp-accent);
    border-radius: 2px;
    opacity: 0.55;
    transition: height 0.18s ease, opacity 0.3s ease;
}

.rp-eq.is-playing span {
    animation: rp-eq-bar 1.1s ease-in-out infinite;
    opacity: 0.9;
}

/* Stagger each bar so they don't move in unison */
.rp-eq.is-playing span:nth-child(1)  { animation-delay: -0.85s; animation-duration: 1.05s; }
.rp-eq.is-playing span:nth-child(2)  { animation-delay: -0.40s; animation-duration: 0.95s; }
.rp-eq.is-playing span:nth-child(3)  { animation-delay: -0.65s; animation-duration: 1.20s; }
.rp-eq.is-playing span:nth-child(4)  { animation-delay: -0.20s; animation-duration: 0.85s; }
.rp-eq.is-playing span:nth-child(5)  { animation-delay: -0.95s; animation-duration: 1.15s; }
.rp-eq.is-playing span:nth-child(6)  { animation-delay: -0.55s; animation-duration: 0.90s; }
.rp-eq.is-playing span:nth-child(7)  { animation-delay: -0.30s; animation-duration: 1.25s; }
.rp-eq.is-playing span:nth-child(8)  { animation-delay: -0.75s; animation-duration: 1.00s; }
.rp-eq.is-playing span:nth-child(9)  { animation-delay: -0.10s; animation-duration: 1.10s; }
.rp-eq.is-playing span:nth-child(10) { animation-delay: -0.50s; animation-duration: 0.95s; }
.rp-eq.is-playing span:nth-child(11) { animation-delay: -0.80s; animation-duration: 1.20s; }
.rp-eq.is-playing span:nth-child(12) { animation-delay: -0.25s; animation-duration: 0.90s; }
.rp-eq.is-playing span:nth-child(13) { animation-delay: -0.60s; animation-duration: 1.15s; }
.rp-eq.is-playing span:nth-child(14) { animation-delay: -0.05s; animation-duration: 1.00s; }
.rp-eq.is-playing span:nth-child(15) { animation-delay: -0.90s; animation-duration: 0.95s; }
.rp-eq.is-playing span:nth-child(16) { animation-delay: -0.35s; animation-duration: 1.25s; }
.rp-eq.is-playing span:nth-child(17) { animation-delay: -0.70s; animation-duration: 1.05s; }
.rp-eq.is-playing span:nth-child(18) { animation-delay: -0.15s; animation-duration: 1.10s; }
.rp-eq.is-playing span:nth-child(19) { animation-delay: -0.45s; animation-duration: 0.90s; }
.rp-eq.is-playing span:nth-child(20) { animation-delay: -0.00s; animation-duration: 1.20s; }

@keyframes rp-eq-bar {
    0%, 100% { height: 4px; }
    20%      { height: 22px; }
    40%      { height: 10px; }
    60%      { height: 28px; }
    80%      { height: 14px; }
}

@media (prefers-reduced-motion: reduce) {
    .rp-eq.is-playing span { animation: none; height: 12px; }
}

/* Controls bar */
.rp-controls {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(180deg, transparent 0%, rgba(0,0,0,0.4) 100%);
    border-top: 1px solid rgba(255,255,255,0.08);
    min-height: 80px;
}

/* Channels button anchors left, volume anchors right; play sits dead-centre */
.rp-btn-channels {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
}

.rp-volume-wrap {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
}

.rp-btn {
    background: transparent;
    border: none;
    color: rgba(255,255,255,0.85);
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease, transform 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.rp-btn:hover { color: #fff; }
.rp-btn:active { opacity: 0.7; }

.rp-btn svg {
    width: 24px;
    height: 24px;
}

.rp-btn-play {
    background: var(--rp-accent);
    color: #fff;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

.rp-btn-play svg {
    width: 28px;
    height: 28px;
}

.rp-btn-play:hover { color: #fff; }

.rp-icon-loading {
    animation: rp-spin 0.9s linear infinite;
}

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

/* Volume */
.rp-volume-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.rp-volume {
    width: 80px;
    height: 4px;
    background: rgba(255,255,255,0.25);
    border-radius: 2px;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}

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

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

@media (max-width: 480px) {
    .rp-volume { width: 60px; }
    .rp-controls { padding: 16px; }
    .rp-btn-channels { left: 12px; }
    .rp-volume-wrap { right: 12px; }
}

/* Mobile: shrink logo and tighten spacing so controls stay on screen */
@media (max-height: 700px) {
    .rp-logo-wrap { width: var(--rp-logo-width-md, 150px); height: var(--rp-logo-width-md, 150px); margin-bottom: 16px; }
    .rp-station-name { font-size: 20px; }
    .rp-track-info { font-size: 14px; }
    .rp-main { padding: 16px; }
    .rp-eq { height: 24px; padding: 0 16px 8px; }
}

@media (max-height: 560px) {
    .rp-logo-wrap { width: var(--rp-logo-width-sm, 110px); height: var(--rp-logo-width-sm, 110px); margin-bottom: 10px; }
    .rp-station-name { font-size: 17px; margin-bottom: 4px; }
    .rp-track-info { font-size: 13px; }
    .rp-eq { height: 18px; padding: 0 12px 6px; }
    .rp-controls { padding: 12px; min-height: 64px; }
    .rp-btn-play { width: 48px; height: 48px; }
    .rp-btn-play svg { width: 24px; height: 24px; }
}

/* Channel panel */
.rp-channel-panel {
    position: absolute;
    inset: 0;
    z-index: 10;
    background: rgba(15, 18, 28, 0.96);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    animation: rp-fade 0.2s ease;
}

.rp-channel-panel[hidden] {
    display: none;
}

@keyframes rp-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.rp-channel-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.rp-channel-panel-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.rp-channel-close {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 32px;
    line-height: 1;
    cursor: pointer;
    padding: 0 8px;
}

.rp-channel-list {
    list-style: none;
    overflow-y: auto;
    flex: 1;
    padding: 8px 0;
}

.rp-channel-list li {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 24px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.rp-channel-list li:hover {
    background: rgba(255,255,255,0.06);
}

.rp-channel-list li.active {
    background: rgba(255,255,255,0.08);
    border-left: 3px solid var(--rp-accent);
    padding-left: 21px;
}

.rp-channel-list img {
    width: 44px;
    height: 44px;
    border-radius: 6px;
    object-fit: contain;
    background: rgba(255,255,255,0.05);
    flex-shrink: 0;
}

.rp-channel-list img[src=""] { visibility: hidden; }

.rp-channel-list .rp-channel-list-name {
    font-size: 15px;
    font-weight: 500;
}
