/* ===========================================
   ATC LIVE RADIO — UI
   Warm · Technical · Still
   =========================================== */

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ---- Design tokens ---- */
:root {
  /* Palette — OKLCH for perceptual uniformity */
  --c-bg:      oklch(94.5% 0.012 78);   /* warm beige body */
  --c-surface: oklch(99.2% 0.005 78);   /* warm white card */
  --c-ink:     oklch(17%   0.012 55);   /* near-black, slightly warm */
  --c-sub:     oklch(56%   0.010 68);   /* secondary text */
  --c-muted:   oklch(71%   0.007 70);   /* muted labels */
  --c-ghost:   oklch(80%   0.006 70);   /* inactive buttons */
  --c-rule:    oklch(90.5% 0.008 78);   /* dividers */
  --c-hover:   oklch(93%   0.013 78);   /* row hover / active bg */

  /* Easing */
  --ease:      cubic-bezier(0.25, 1, 0.5, 1);
  --ease-expo: cubic-bezier(0.16, 1, 0.3, 1);

  /* Durations */
  --t-fast: 110ms;
  --t-base: 220ms;
  --t-slow: 360ms;

  /* Radii */
  --r-card: 20px;
  --r-item: 8px;
}

/* ---- Body ---- */
body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--c-bg);
  font-family: 'Barlow', system-ui, -apple-system, sans-serif;
  overflow: hidden;
  position: relative;
}

/* ---- Background blobs — three warm tones ---- */
.bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.48;
}

.blob-1 {
  width: 460px;
  height: 460px;
  top: -130px;
  left: -100px;
  background: oklch(82% 0.030 75);
  animation: drift1 28s ease-in-out infinite;
}

.blob-2 {
  width: 320px;
  height: 320px;
  bottom: -80px;
  right: -80px;
  background: oklch(78% 0.022 88);
  animation: drift2 22s ease-in-out infinite;
}

.blob-3 {
  width: 240px;
  height: 240px;
  top: 50%;
  left: 58%;
  background: oklch(85% 0.018 60);
  animation: drift3 35s ease-in-out infinite;
}

@keyframes drift1 {
  0%, 100% { transform: translate(0, 0)    scale(1);    }
  33%       { transform: translate(40px, 30px)  scale(1.06); }
  66%       { transform: translate(-20px, 50px) scale(0.94); }
}
@keyframes drift2 {
  0%, 100% { transform: translate(0, 0)     scale(1);    }
  40%       { transform: translate(-30px, -40px) scale(1.08); }
  70%       { transform: translate(20px, -20px)  scale(0.96); }
}
@keyframes drift3 {
  0%, 100% { transform: translate(0, 0)      scale(1);    }
  50%       { transform: translate(-50px, 30px) scale(1.12); }
}

/* ---- Card ---- */
.card {
  position: relative;
  z-index: 1;
  background: var(--c-surface);
  border-radius: var(--r-card);
  box-shadow:
    0 1px  2px  oklch(17% 0.012 55 / 0.04),
    0 4px  14px oklch(17% 0.012 55 / 0.07),
    0 18px 44px oklch(17% 0.012 55 / 0.07);
  padding: 28px;
  width: 340px;
  animation: card-enter 0.55s var(--ease-expo) both;
}

@keyframes card-enter {
  from { opacity: 0; transform: translateY(24px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0)    scale(1);    }
}

/* Stagger children into view after card arrives */
.card > * {
  animation: fade-up 0.42s var(--ease-expo) both;
}
.card > *:nth-child(1) { animation-delay: 0.10s; }
.card > *:nth-child(2) { animation-delay: 0.16s; }
.card > *:nth-child(3) { animation-delay: 0.20s; }
.card > *:nth-child(4) { animation-delay: 0.24s; }
.card > *:nth-child(5) { animation-delay: 0.28s; }
.card > *:nth-child(6) { animation-delay: 0.32s; }
.card > *:nth-child(7) { animation-delay: 0.36s; }

@keyframes fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---- Local font ---- */
@font-face {
  font-family: 'Teko';
  src: url('assets/font/Teko-Regular.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}

/* ---- Card header ---- */
.live-badge {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 10px;
  letter-spacing: 0.17em;
  color: var(--c-muted);
  text-transform: uppercase;
  margin-bottom: 8px;
  font-weight: 500;
}

.live-dot {
  width: 7px;
  height: 7px;
  background: oklch(62% 0.18 145);
  border-radius: 50%;
  flex-shrink: 0;
  animation: blink 2.4s ease-in-out infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.15; }
}

.live-badge.is-error .live-dot {
  background: var(--c-rule);
  animation: none;
}
.live-badge.is-error .live-badge-text {
  color: var(--c-rule);
}

.station-item.is-offline {
  opacity: 0.35;
  pointer-events: none;
}
.station-item.is-offline .station-item-name::after {
  content: ' · offline';
}

/* Hero station code — anchor of the UI */
.station-code {
  font-family: 'Teko', sans-serif;
  font-size: 48px;
  color: var(--c-ink);
  line-height: 1;
  letter-spacing: 0.03em;
  transition:
    opacity   var(--t-fast) ease,
    transform var(--t-fast) var(--ease);
}

.station-name {
  font-size: 12px;
  color: var(--c-sub);
  margin-top: 3px;
  margin-bottom: 4px;
  font-weight: 400;
  transition:
    opacity   var(--t-fast) ease,
    transform var(--t-fast) var(--ease);
}

/* Fade + slide-up on station switch */
.station-code.fading,
.station-name.fading {
  opacity: 0;
  transform: translateY(-5px);
}

.metar-info {
  font-size: 10px;
  letter-spacing: 0.07em;
  color: var(--c-muted);
  margin-top: 2px;
  margin-bottom: 22px;
  min-height: 14px;
}

/* Animate METAR data appearing */
.metar-info.metar-in {
  animation: metar-appear 0.4s var(--ease-expo) both;
}
@keyframes metar-appear {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---- Play button ---- */
.play-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  background: var(--c-ink);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  margin: 0 auto 26px;
  color: var(--c-surface);
  position: relative;
  transition:
    transform    var(--t-base) var(--ease),
    background   var(--t-base) ease,
    box-shadow   var(--t-base) ease;
  box-shadow: 0 2px 12px oklch(17% 0.012 55 / 0.16);
}

.play-btn:hover {
  background: oklch(26% 0.010 55);
  transform: scale(1.06);
  box-shadow: 0 5px 20px oklch(17% 0.012 55 / 0.24);
}

.play-btn:active {
  transform: scale(0.93);
  box-shadow: 0 1px 5px oklch(17% 0.012 55 / 0.10);
  transition-duration: 80ms;
}

/* Slow breathing while playing */
.play-btn.is-playing {
  animation: breathe 5s ease-in-out infinite;
}
@keyframes breathe {
  0%, 100% { box-shadow: 0 2px 12px oklch(17% 0.012 55 / 0.16); transform: scale(1); }
  50%       { box-shadow: 0 8px 34px oklch(17% 0.012 55 / 0.26); transform: scale(1.07); }
}

/* Buffering — radiating ring */
.play-btn.is-buffering::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  animation: ping 1.4s ease-out infinite;
  pointer-events: none;
}
@keyframes ping {
  0%   { box-shadow: 0 0 0 0px oklch(17% 0.012 55 / 0.22); }
  80%  { box-shadow: 0 0 0 22px oklch(17% 0.012 55 / 0); }
  100% { box-shadow: 0 0 0 22px oklch(17% 0.012 55 / 0); }
}

/* Icon crossfade */
.play-btn svg {
  position: absolute;
  transition:
    opacity   var(--t-base) ease,
    transform var(--t-base) var(--ease);
}
.play-btn svg.icon-hidden {
  opacity: 0;
  transform: scale(0.68);
  pointer-events: none;
}

/* ---- Lo-Fi stream selector ---- */
.lofi-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.lofi-label {
  font-size: 10px;
  letter-spacing: 0.17em;
  color: var(--c-muted);
  text-transform: uppercase;
  min-width: 32px;
  font-weight: 500;
}

.lofi-options {
  display: flex;
  gap: 14px;
}

.lofi-option {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--c-ghost);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
  font-weight: 500;
  transition:
    color     var(--t-fast) ease,
    transform var(--t-fast) var(--ease);
}
.lofi-option:hover  { color: var(--c-sub); }
.lofi-option:active { transform: scale(0.88); transition-duration: 70ms; }
.lofi-option.active { color: var(--c-ink); }

/* ---- Station list ---- */
.station-list {
  list-style: none;
  margin-bottom: 20px;
  max-height: 200px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
}
.station-list::-webkit-scrollbar { display: none; }

.station-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px 9px 18px;
  border-radius: var(--r-item);
  cursor: pointer;
  position: relative;
  transition:
    background var(--t-base) ease,
    transform  var(--t-base) var(--ease),
    opacity    var(--t-base) ease;
}

/* Active indicator dot — scales in when station is selected */
.station-item::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 50%;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--c-ink);
  transform: translateY(-50%) scale(0);
  opacity: 0;
  transition:
    transform var(--t-base) var(--ease-expo),
    opacity   var(--t-base) ease;
}
.station-item.active::before {
  transform: translateY(-50%) scale(1);
  opacity: 1;
}

.station-item:hover {
  background: var(--c-hover);
  transform: translateX(2px);
}
.station-item:active {
  opacity: 0.6;
  transition-duration: 70ms;
}
.station-item.active {
  background: var(--c-hover);
  transform: translateX(2px);
}

.station-item-code {
  font-family: 'Teko', sans-serif;
  font-size: 17px;
  color: var(--c-ink);
  min-width: 46px;
  line-height: 1;
  transition: color var(--t-fast) ease;
}

.station-item-name {
  font-size: 12px;
  color: var(--c-muted);
  transition: color var(--t-fast) ease;
}
.station-item.active .station-item-name { color: var(--c-sub); }

/* ---- Volume sliders ---- */
.volumes {
  border-top: 1px solid var(--c-rule);
  padding-top: 16px;
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.volume-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.volume-label {
  font-size: 10px;
  letter-spacing: 0.17em;
  color: var(--c-muted);
  text-transform: uppercase;
  min-width: 32px;
  font-weight: 500;
}

.slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 2px;
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  background: linear-gradient(
    to right,
    var(--c-ink) 0%,
    var(--c-ink) calc(var(--val, 70) * 1%),
    var(--c-rule) calc(var(--val, 70) * 1%),
    var(--c-rule) 100%
  );
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 13px;
  height: 13px;
  background: var(--c-ink);
  border-radius: 50%;
  cursor: pointer;
  transition:
    transform   var(--t-fast) var(--ease),
    box-shadow  var(--t-fast) ease;
}
.slider:hover::-webkit-slider-thumb {
  transform: scale(1.45);
  box-shadow: 0 0 0 4px oklch(17% 0.012 55 / 0.10);
}
.slider:active::-webkit-slider-thumb { transform: scale(1.2); }

.slider::-moz-range-thumb {
  width: 13px;
  height: 13px;
  background: var(--c-ink);
  border-radius: 50%;
  border: none;
  cursor: pointer;
  transition: transform var(--t-fast) var(--ease);
}
.slider:hover::-moz-range-thumb { transform: scale(1.45); }

/* ---- Sleep timer ---- */
.sleep-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 6px;
  margin-bottom: 18px;
}

.sleep-label {
  font-size: 10px;
  letter-spacing: 0.17em;
  color: var(--c-muted);
  text-transform: uppercase;
  min-width: 32px;
  font-weight: 500;
}

.sleep-options {
  display: flex;
  gap: 14px;
}

.sleep-option {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--c-ghost);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
  font-weight: 500;
  transition:
    color     var(--t-fast) ease,
    transform var(--t-fast) var(--ease);
}
.sleep-option:hover  { color: var(--c-sub); }
.sleep-option:active { transform: scale(0.88); transition-duration: 70ms; }
.sleep-option.active { color: var(--c-ink); }

/* ---- Footer ---- */
.card-footer {
  display: flex;
  justify-content: center;
  border-top: 1px solid var(--c-rule);
  padding-top: 14px;
}

.card-footer a {
  color: var(--c-ghost);
  text-decoration: none;
  display: flex;
  align-items: center;
  transition: color var(--t-fast) ease;
}
.card-footer a svg {
  transition: transform var(--t-base) var(--ease);
}
.card-footer a:hover {
  color: var(--c-ink);
}
.card-footer a:hover svg {
  transform: rotate(15deg);
}

/* ---- Mobile touch targets ---- */
@media (pointer: coarse) {
  .lofi-option,
  .sleep-option {
    padding: 10px 6px;
    margin: -10px -6px;
  }

  .lofi-options,
  .sleep-options {
    gap: 20px;
  }
}

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
