:root {
    --bg-dark: #0a0a0a;
    --bg-card: #141414;
    --bg-card-hover: #1a1a1a;
    --text-primary: #f5f5f5;
    --text-secondary: #888;
    --accent: #ff3d00;
    --accent-glow: rgba(255, 61, 0, 0.3);
    --border: #2a2a2a;
    --success: #00c853;
    --font-mono: 'JetBrains Mono', monospace;
    --font-serif: 'Instrument Serif', serif;
    --focus-ring: 0 0 0 3px rgba(255, 61, 0, 0.5);
}

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

/* ===== Accessibility Utilities ===== */

/* Screen reader only - visually hidden but accessible */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Skip link - visible on focus for keyboard users */
.skip-link {
    position: absolute;
    top: -100px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    padding: 12px 24px;
    background: var(--accent);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    border-radius: 0 0 8px 8px;
    transition: top 0.2s ease;
}

.skip-link:focus {
    top: 0;
    outline: none;
    box-shadow: var(--focus-ring);
}

/* Focus styles for all interactive elements */
:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

body {
    font-family: var(--font-mono);
    background: var(--bg-dark);
    color: var(--text-primary);
    overflow: hidden;
    touch-action: pan-x pan-y;
}

/* ===== Top Navigation Bar ===== */

#top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 20px;
    padding: 12px 20px;
    background: linear-gradient(180deg, rgba(10, 10, 10, 0.95) 0%, rgba(10, 10, 10, 0.85) 100%);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}

#top-bar .site-title {
    font-family: var(--font-serif);
    font-size: 22px;
    font-weight: 400;
    font-style: italic;
    color: var(--text-primary);
    margin: 0;
    letter-spacing: 0.02em;
    display: flex;
    align-items: center;
    gap: 10px;
}

#top-bar .site-logo {
    width: 28px;
    height: 28px;
    object-fit: contain;
    border-radius: 4px;
}

.top-bar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

#random-radio-btn,
.submit-radio-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 9px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

#random-radio-btn:hover,
.submit-radio-link:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(255, 61, 0, 0.08);
}

#random-radio-btn:focus-visible,
.submit-radio-link:focus-visible {
    border-color: var(--accent);
    box-shadow: var(--focus-ring);
}

#random-radio-btn svg,
.submit-radio-link svg {
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

#random-radio-btn:hover svg,
.submit-radio-link:hover svg {
    opacity: 1;
}

/* Pulsing animation for random button when clicked */
#random-radio-btn.selecting {
    animation: randomPulse 0.6s ease-out;
}

@keyframes randomPulse {
    0% { transform: scale(1); }
    50% { transform: scale(0.97); }
    100% { transform: scale(1); }
}

#map {
    width: 100vw;
    height: 100vh;
    padding-top: 56px; /* Account for fixed top bar */
}

/* Custom map tiles styling */
.leaflet-container {
    background: var(--bg-dark);
    font-family: var(--font-mono);
}

.leaflet-tile-pane {
    filter: grayscale(100%) invert(100%) contrast(90%) brightness(70%);
}

/* Custom marker styling */
.radio-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    cursor: pointer;
    transition: transform 0.15s ease;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

.radio-marker:hover {
    transform: scale(1.2);
}

.radio-marker.playing {
    animation: pulse 1.5s ease-in-out infinite;
}

/* Leaflet marker wrapper - keyboard focus styles */
.leaflet-marker-icon {
    outline: none;
    border-radius: 50%;
}

.leaflet-marker-icon:focus-visible .radio-marker {
    transform: scale(1.2);
    filter: drop-shadow(0 0 8px var(--accent));
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

/* Grouped marker with count badge */
.radio-marker-group {
    position: relative;
}

.radio-marker-group .count-badge {
    position: absolute;
    top: -8px;
    right: -12px;
    background: var(--accent);
    color: var(--text-primary);
    font-size: 11px;
    font-weight: 600;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    box-shadow: 0 2px 6px var(--accent-glow);
}

/* Radio selection list (for grouped markers) */
.radio-selection-list {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 0;
    min-width: 200px;
    max-height: 300px;
    overflow-y: auto;
}

.radio-selection-item {
    color: var(--text-primary);
    padding: 10px 16px;
    cursor: pointer;
    transition: background 0.15s ease;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 10px;
    outline: none;
}

.radio-selection-item:hover,
.radio-selection-item:focus-visible {
    background: var(--bg-card-hover);
}

.radio-selection-item:focus-visible {
    box-shadow: inset 0 0 0 2px var(--accent);
}

.radio-selection-item .favicon {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    object-fit: cover;
}

/* Popup styling */
.leaflet-popup-content-wrapper {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    padding: 0;
}

.leaflet-popup-content {
    margin: 0;
    min-width: 280px;
    max-width: 320px;
}

.leaflet-popup-tip {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-top: none;
    border-right: none;
}

.leaflet-popup-close-button {
    color: var(--text-secondary) !important;
    font-size: 20px !important;
    width: 32px !important;
    height: 32px !important;
    top: 8px !important;
    right: 8px !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.15s ease;
}

.leaflet-popup-close-button:hover {
    color: var(--text-primary) !important;
    background: var(--bg-dark);
}

/* Radio popup card */
.radio-popup {
    padding: 20px;
}

.radio-popup-header {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 16px;
}

.radio-popup-header .favicon {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    object-fit: cover;
    background: var(--bg-dark);
    flex-shrink: 0;
}

.radio-popup-header .info {
    flex: 1;
    min-width: 0;
}

.radio-popup-header .name,
.radio-popup-header h2.name {
    color: var(--text-primary);
    font-family: var(--font-serif);
    font-size: 20px;
    font-weight: 400;
    font-style: italic;
    margin-bottom: 4px;
    line-height: 1.2;
}

.radio-popup-header .location {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.radio-popup-description {
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-secondary);
    margin-bottom: 16px;
    max-height: 120px;
    overflow-y: auto;
}

.radio-popup-genre {
    display: inline-block;
    font-size: 11px;
    color: var(--accent);
    background: rgba(255, 61, 0, 0.1);
    padding: 4px 10px;
    border-radius: 12px;
    margin-bottom: 16px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Play button */
.play-button {
    width: 100%;
    padding: 14px;
    background: var(--accent);
    border: none;
    border-radius: 8px;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 16px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.play-button:hover {
    background: #ff5722;
    box-shadow: 0 4px 16px var(--accent-glow);
}

.play-button:disabled {
    background: var(--border);
    cursor: not-allowed;
    box-shadow: none;
}

.play-button.playing {
    background: var(--success);
}

.play-button svg {
    width: 16px;
    height: 16px;
}

/* Social links */
.radio-popup-links {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.radio-popup-links a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s ease;
    font-size: 14px;
}

.radio-popup-links a:hover {
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

/* Social icons using CSS masks for color inheritance */
.radio-popup-links .icon {
    display: block;
    width: 18px;
    height: 18px;
    background-color: currentColor;
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
}

.icon-website {
    -webkit-mask-image: url('/static/svg/website.svg');
    mask-image: url('/static/svg/website.svg');
}

.icon-instagram {
    -webkit-mask-image: url('/static/svg/instagram.svg');
    mask-image: url('/static/svg/instagram.svg');
}

.icon-soundcloud {
    -webkit-mask-image: url('/static/svg/soundcloud.svg');
    mask-image: url('/static/svg/soundcloud.svg');
}

.icon-youtube {
    -webkit-mask-image: url('/static/svg/youtube.svg');
    mask-image: url('/static/svg/youtube.svg');
}

/* Now playing bar */
#now-playing {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    padding: 12px 20px;
    z-index: 1000;
    transition: transform 0.3s ease;
}

#now-playing.hidden {
    transform: translateY(100%);
}

.now-playing-content {
    max-width: 600px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 14px;
}

#now-playing .favicon {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    object-fit: cover;
}

.now-playing-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

#now-playing-name {
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#now-playing-location {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.now-playing-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.control-btn {
    width: 40px;
    height: 40px;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.control-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* Volume control */
.volume-control {
    position: relative;
    display: flex;
    align-items: center;
}

.volume-icon.hidden {
    display: none;
}

#volume-btn.muted {
    color: var(--text-secondary);
}

/* Volume popup - SoundCloud style */
.volume-popup {
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%);
    background: #3a3a3a;
    border-radius: 3px;
    padding: 16px 10px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, visibility 0.15s ease;
    pointer-events: none;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

/* Arrow pointing down */
.volume-popup::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid #3a3a3a;
}

.volume-control:hover .volume-popup,
.volume-popup:hover {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.volume-slider-wrapper {
    width: 28px;
    height: 110px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

/* Vertical range slider - using writing-mode for proper vertical slider */
#volume-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 28px;
    height: 100%;
    background: transparent;
    outline: none;
    writing-mode: vertical-lr;
    direction: rtl;
    cursor: pointer;
}

/* Track - webkit (thin visual track in center with larger clickable area) */
#volume-slider::-webkit-slider-runnable-track {
    width: 28px;
    height: 100%;
    background: linear-gradient(to right, transparent calc(50% - 2px), #666 calc(50% - 2px), #666 calc(50% + 2px), transparent calc(50% + 2px));
    border-radius: 2px;
}

/* Thumb - webkit */
#volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: #fff;
    border: 2px solid #fff;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.2);
    margin-left: 6px;
}

/* Firefox */
#volume-slider::-moz-range-track {
    width: 28px;
    height: 100%;
    background: linear-gradient(to right, transparent calc(50% - 2px), #666 calc(50% - 2px), #666 calc(50% + 2px), transparent calc(50% + 2px));
    border-radius: 2px;
}

#volume-slider::-moz-range-progress {
    background: linear-gradient(to right, transparent calc(50% - 2px), #fff calc(50% - 2px), #fff calc(50% + 2px), transparent calc(50% + 2px));
    border-radius: 2px;
}

#volume-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: #fff;
    border: 2px solid #fff;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Loading state */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.loading::after {
    content: '';
    width: 24px;
    height: 24px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Attribution */
.leaflet-control-attribution {
    background: rgba(10, 10, 10, 0.8) !important;
    color: var(--text-secondary) !important;
    font-size: 10px !important;
}

.leaflet-control-attribution a {
    color: var(--text-secondary) !important;
}

/* Zoom controls */
.leaflet-control-zoom {
    border: 1px solid var(--border) !important;
    border-radius: 8px !important;
    overflow: hidden;
    margin-top: 66px !important; /* Account for fixed top bar */
}

.leaflet-control-zoom a {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border-bottom: 1px solid var(--border) !important;
}

.leaflet-control-zoom a:last-child {
    border-bottom: none !important;
}

.leaflet-control-zoom a:hover {
    background: var(--bg-card-hover) !important;
}

