@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600&display=swap');

:root {
  --ink: #f7f5ef;
  --paper: #f1efe7;
  --drawer-ink: #26322a;
  --drawer-line: #d5d9d0;
  --drawer-width: min(370px, 35vw);
  --accent: #e8ca91;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; }
body { margin: 0; overflow: hidden; background: #111820; color: var(--ink); font-family: 'DM Sans', sans-serif; }
button, input, select { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.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;
}

.city-section, .city-stage { position: relative; width: 100%; height: 100svh; min-height: 440px; overflow: hidden; background: #111820; }
.city-stage { transition: transform .4s ease, filter .4s ease; }
.city-image {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  object-position: var(--scene-focal-desktop, 50% 50%); opacity: 0;
  transform: scale(1.002); transition: opacity .9s ease; will-change: opacity;
}
.city-image.is-active { opacity: 1; }
.city-shade {
  position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(180deg, #07111b0a 36%, #07111b38 62%, #07111bd9 100%),
    linear-gradient(90deg, #07111b4d 0%, transparent 48%);
}

.scene-meta {
  position: absolute; z-index: 2; left: clamp(24px, 5vw, 78px); bottom: clamp(34px, 7vh, 76px);
  width: min(760px, 58vw); text-shadow: 0 2px 24px #000a;
  transition: opacity .3s ease, transform .3s ease;
}
.scene-country-time { margin: 0 0 8px; font-size: clamp(11px, .9vw, 14px); font-weight: 500; letter-spacing: .14em; text-transform: uppercase; }
.scene-meta h1 { margin: 0 0 12px; font-size: clamp(30px, 3.6vw, 60px); font-weight: 500; line-height: 1.08; letter-spacing: -.04em; text-wrap: balance; }
.station-line { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; font-size: clamp(13px, 1.15vw, 17px); }
#sceneStation { overflow-wrap: anywhere; font-weight: 500; }
.scene-city { margin: 0 0 20px; font-size: 16px; font-weight: 400; letter-spacing: .01em; color: #ffffffd9; }
#sceneFrequency { color: #ffffffb8; }
.broadcast-state {
  display: inline-flex; align-items: center; gap: 7px; min-height: 26px; padding: 5px 9px;
  border: 1px solid #ffffff3d; border-radius: 999px; background: #0c1418a8;
  color: #fff; font-size: 9px; font-weight: 600; letter-spacing: .13em; text-shadow: none;
  backdrop-filter: blur(9px);
}
#onAirDot { width: 6px; height: 6px; border-radius: 50%; background: #ef574f; opacity: .35; }
.is-on-air #onAirDot { animation: on-air-breathe 2.2s ease-in-out infinite; }
.scene-relation { margin: 8px 0 0; color: #ffffffb8; font-size: 11px; }

.player-controls {
  position: absolute; z-index: 3; right: clamp(22px, 4.2vw, 68px); bottom: clamp(32px, 7vh, 72px);
  min-height: 54px; display: flex; align-items: center; gap: 5px; padding: 5px 8px;
  border: 1px solid #ffffff30; border-radius: 999px; background: #0b1115a8;
  box-shadow: 0 12px 40px #0003; backdrop-filter: blur(15px);
}
.player-controls button {
  width: 44px; height: 44px; flex: 0 0 44px; display: grid; place-items: center; padding: 0;
  border: 0; border-radius: 50%; background: transparent; color: #f8f5eb; font-size: 21px;
  transition: background .18s ease, transform .18s ease, color .18s ease;
}
.player-controls button:hover { background: #ffffff17; transform: translateY(-1px); }
.player-controls .power-control { background: #f5f0e3; color: #141b1c; font-size: 13px; }
.player-controls .power-control[aria-pressed='true'] { background: var(--accent); }
.play-icon { transform: translateX(1px); }
.favorite-button[aria-pressed='true'] { color: #f0cb83; }
.favorite-button:disabled { opacity: .35; cursor: default; }
.volume-control { position: relative; width: clamp(74px, 9vw, 130px); height: 44px; display: flex; align-items: center; padding: 0 6px; }
.volume-control input { width: 100%; height: 18px; accent-color: var(--accent); cursor: pointer; opacity: .84; }
.volume-control output {
  position: absolute; left: 50%; bottom: calc(100% + 7px); padding: 4px 7px; border-radius: 4px;
  background: #0a1115df; color: #fff; font-size: 9px; opacity: 0; transform: translate(-50%, 4px);
  transition: opacity .18s ease, transform .18s ease;
}
.volume-control.is-adjusting output { opacity: 1; transform: translate(-50%, 0); }

.stations-toggle {
  position: fixed; z-index: 9; top: 22px; left: 22px; width: 44px; height: 44px; display: grid; place-items: center;
  border: 1px solid #ffffff35; border-radius: 50%; background: #0a12179c; color: #fff; font-size: 15px;
  box-shadow: 0 8px 25px #0002; backdrop-filter: blur(12px); transition: background .2s ease, transform .2s ease;
}
.stations-toggle:hover { background: #0a1217d9; transform: translateY(-1px); }
.drawer-open .stations-toggle { visibility: hidden; }
.drawer-backdrop { position: fixed; inset: 0; z-index: 10; border: 0; background: #07101755; backdrop-filter: blur(2px); }
.station-drawer {
  position: fixed; inset: 0 auto 0 0; z-index: 11; width: var(--drawer-width); display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto; padding: 20px 18px 14px; overflow: hidden;
  overscroll-behavior: contain; border-right: 1px solid #ffffff8c; background: #f1efe7f2;
  color: var(--drawer-ink); box-shadow: 8px 0 40px #07130b38; backdrop-filter: blur(22px);
  transform: translateX(-100%); visibility: hidden; transition: transform .35s ease, visibility .35s;
}
.drawer-open .station-drawer { transform: translateX(0); visibility: visible; }
.drawer-header { display: flex; align-items: center; justify-content: space-between; }
.drawer-header h2 { margin: 0; font-size: 24px; font-weight: 500; letter-spacing: -.04em; }
.close-drawer { width: 44px; height: 44px; border: 0; background: transparent; color: #59645c; font-size: 26px; }
.drawer-tools { padding-top: 20px; }
.country-box { position: relative; min-height: 42px; display: flex; align-items: center; margin-bottom: 7px; border: 1px solid #c8cec4; border-radius: 8px; background: #fff8; color: #637064; }
.country-box select { width: 100%; min-width: 0; height: 40px; padding: 0 34px 0 11px; appearance: none; border: 0; outline: 0; background: transparent; color: var(--drawer-ink); font-size: 11px; cursor: pointer; }
.country-box > span:last-child { position: absolute; right: 11px; pointer-events: none; }
.search-box { min-height: 40px; display: flex; align-items: center; gap: 9px; border-bottom: 1px solid #7c887e; color: #667268; }
.search-box input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--drawer-ink); font-size: 12px; }
.search-box input::placeholder { color: #8a948b; }
.saved-library {
  width: 100%; min-height: 42px; display: grid; grid-template-columns: 24px 1fr auto; align-items: center; gap: 8px;
  margin-top: 14px; padding: 7px 10px; border: 1px solid #c8cec4; border-radius: 8px; background: #ffffff69;
  color: #35443a; font-size: 11px; text-align: left; transition: background .18s ease, border-color .18s ease;
}
.saved-library:hover { border-color: #89958b; background: #fff9; }
.saved-library[aria-pressed='true'] { border-color: #35483a; background: #35483a; color: #fff; }
.saved-library-icon { font-size: 17px; text-align: center; }
.saved-count { min-width: 23px; padding: 3px 6px; border-radius: 999px; background: #d7ded4; color: #445247; font-size: 9px; text-align: center; }
.saved-library[aria-pressed='true'] .saved-count { background: #ffffff24; color: #fff; }
.browse-label { margin: 16px 0 7px; color: #78837a; font-size: 8px; font-weight: 650; letter-spacing: .12em; text-transform: uppercase; }
.filter-row { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.filter-row::-webkit-scrollbar { display: none; }
.primary-filters { padding: 0 0 9px; }
.genre-filters { margin: 0 -18px; padding: 0 18px 13px; border-top: 1px solid #d8ddd5; padding-top: 9px; }
.filter { padding: 6px 10px; border: 1px solid #cbd1c8; border-radius: 999px; background: transparent; color: #59675c; font-size: 10px; white-space: nowrap; }
.filter.active, .filter:hover { border-color: #2f4334; background: #2f4334; color: #fff; }
.station-list { min-height: 0; overflow-y: auto; overscroll-behavior: contain; border-top: 1px solid var(--drawer-line); }
.station-row { width: 100%; min-height: 60px; display: grid; grid-template-columns: minmax(0, 1fr) 36px; align-items: center; gap: 3px; padding: 3px 2px; border: 0; border-bottom: 1px solid var(--drawer-line); background: transparent; color: var(--drawer-ink); text-align: left; content-visibility: auto; contain-intrinsic-size: 60px; }
.station-main { min-width: 0; min-height: 54px; display: grid; grid-template-columns: 32px minmax(0, 1fr); align-items: center; gap: 10px; padding: 5px 0; border: 0; background: transparent; color: inherit; text-align: left; }
.station-row:hover, .station-row.is-current { border-radius: 5px; background: #dce3d9a3; }
.station-thumb { width: 32px; height: 32px; display: grid; place-items: center; overflow: hidden; border-radius: 50%; background: #7e8c7f; color: #fff; font-size: 9px; }
.station-thumb img { width: 100%; height: 100%; object-fit: cover; }
.station-name { overflow: hidden; font-size: 11px; font-weight: 600; white-space: nowrap; text-overflow: ellipsis; }
.station-location { display: block; margin-top: 3px; overflow: hidden; color: #768278; font-size: 8px; font-weight: 400; white-space: nowrap; text-overflow: ellipsis; }
.station-save { width: 36px; height: 36px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%; background: transparent; color: #647065; font-size: 17px; }
.station-save:hover { background: #ced8cc; }
.station-save[aria-pressed='true'] { color: #334f39; }
.loading-state, .empty-state { padding: 26px 4px; color: #758078; font-size: 12px; }
.list-footer { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; padding-top: 12px; color: #758078; font-size: 8px; }
.list-footer > button { border: 0; background: transparent; color: #304634; font-size: 9px; }
.photo-credits, .data-sources { grid-column: 1 / -1; }
.photo-credits summary, .data-sources summary { min-height: 24px; display: flex; align-items: center; cursor: pointer; list-style: none; }
.photo-credits[open] summary, .data-sources[open] summary { margin-bottom: 5px; }
.photo-credit-row { margin: 0 0 5px; line-height: 1.35; }
.photo-credits a, .data-sources a { margin-right: 10px; color: inherit; text-decoration: none; }
.photo-credits a:hover, .photo-credits a:focus-visible, .data-sources a:hover, .data-sources a:focus-visible { text-decoration: underline; }

@keyframes on-air-breathe {
  0%, 100% { opacity: .42; box-shadow: 0 0 0 0 #ef574f00; }
  50% { opacity: 1; box-shadow: 0 0 0 4px #ef574f22, 0 0 12px #ef574faa; }
}

@media (min-width: 721px) {
  .drawer-open .city-stage { transform: translateX(min(9vw, 120px)) scale(.985); filter: brightness(.82); }
}

@media (max-width: 900px) {
  .scene-meta { width: min(620px, 64vw); }
  .scene-meta h1 { font-size: clamp(30px, 4vw, 48px); }
  .player-controls { right: 22px; }
}

@media (max-width: 720px) {
  :root { --drawer-width: calc(100vw - 28px); }
  .city-image { object-position: var(--scene-focal-mobile, 50% 50%); }
  .city-shade { background: linear-gradient(180deg, #07111b08 28%, #07111b42 52%, #07111bf0 100%); }
  .stations-toggle { top: 16px; left: 16px; }
  .scene-meta { left: 20px; right: 20px; bottom: calc(106px + env(safe-area-inset-bottom)); width: auto; }
  .scene-country-time { margin-bottom: 7px; font-size: 10px; }
  .scene-meta h1 { margin-bottom: 9px; font-size: clamp(28px, 7vw, 42px); line-height: 1.08; }
  .scene-city { font-size: 14px; margin-bottom: 14px; }
  .station-line { gap: 6px 9px; font-size: 12px; }
  #sceneFrequency:not(:empty)::before { margin-right: 9px; }
  .broadcast-state { min-height: 24px; padding: 4px 8px; }
  .player-controls { left: 18px; right: auto; bottom: calc(20px + env(safe-area-inset-bottom)); width: calc(100% - 36px); justify-content: center; min-height: 56px; }
  .volume-control { flex: 1 1 auto; max-width: 130px; }
}

@media (max-width: 430px) {
  .scene-meta { bottom: calc(103px + env(safe-area-inset-bottom)); }
  .scene-meta h1 { font-size: clamp(26px, 7vw, 34px); }
  .player-controls { gap: 1px; padding-inline: 5px; }
  .player-controls button { width: 42px; height: 44px; flex-basis: 42px; }
  .volume-control { min-width: 62px; padding-inline: 3px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
  .city-image, .city-stage, .scene-meta { transition: none !important; }
  .is-on-air #onAirDot { animation: none; opacity: 1; box-shadow: 0 0 8px #ef574f88; }
}

.photo-credits[open] #photoCredits { max-height: 24vh; overflow-y: auto; }
