/* Modern look for De Stemm Radio */

/* Reset and base */
* { box-sizing: border-box; }
:root {
  --accent: #C66528; /* brand orange */
  --bg: #0f172a; /* slate-900 */
  --surface: rgba(255,255,255,0.08);
  --border: rgba(255,255,255,0.18);
  --text: #e5e7eb;
  --text-strong: #f9fafb;
  --danger: #ef4444; /* live red */
  --muted: #9ca3af; /* gray for muted/paused */
  --stale: #3b82f6; /* blue when paused >10s */
}

html, body { height: 100%; overscroll-behavior: none; }
body {
  margin: 0;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(900px 900px at 0% 0%, rgba(198,101,40,0.18), transparent),
    radial-gradient(900px 900px at 100% 100%, rgba(70,130,180,0.12), transparent);
  min-height: 100svh;
  height: 100dvh;
  overflow: hidden;
}
@supports (-webkit-touch-callout: none) {
  body { min-height: -webkit-fill-available; }
}

/* Player card */
#radio-player {
  width: min(440px, 92vw);
  background: linear-gradient(180deg, rgba(255,255,255,0.14), rgba(255,255,255,0.08));
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 24px 22px;
  box-shadow: 0 14px 36px rgba(0,0,0,0.35);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: calc(100dvh - 32px);
  padding-top: calc(22px + env(safe-area-inset-top));
  padding-bottom: calc(22px + env(safe-area-inset-bottom));
}
@supports (backdrop-filter: blur(12px)) {
  #radio-player { background: var(--surface); backdrop-filter: blur(12px); }
}

#radio-logo {
  max-width: 140px;
  margin: 4px auto 6px;
  display: block;
  filter: drop-shadow(0 8px 20px rgba(0,0,0,0.35));
  transition: transform 0.2s;
}
#radio-logo:active { transform: scale(0.95); }

/* Header / status */
.app-header { margin-top: 6px; }
.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background-color: rgba(239,68,68,0.15);
  border: 1px solid rgba(239,68,68,0.35);
  color: #fecaca;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.78rem;
}
.live-pill .dot { width: 8px; height: 8px; border-radius: 50%; background-color: var(--danger); box-shadow: 0 0 0 4px rgba(239,68,68,0.22); position: relative; }
.live-pill.is-live .dot { background-color: var(--danger); box-shadow: 0 0 0 4px rgba(239,68,68,0.22); }
 .live-pill.is-muted .dot { background-color: var(--muted); box-shadow: 0 0 0 4px rgba(156,163,175,0.22); }
 .live-pill.is-stale .dot { background-color: var(--stale); box-shadow: 0 0 0 4px rgba(59,130,246,0.22); }

 /* Dot motion ring for live/stale states */
 .live-pill.is-live .dot::after {
   content: "";
   position: absolute;
   left: 50%;
   top: 50%;
   width: 8px;
   height: 8px;
   transform: translate(-50%, -50%) scale(1);
   border-radius: 50%;
   border: 2px solid rgba(239,68,68,0.5);
   opacity: 0.7;
   pointer-events: none;
   animation: livePulse 1.6s ease-out infinite;
 }
 .live-pill.is-stale .dot::after {
   content: "";
   position: absolute;
   left: 50%;
   top: 50%;
   width: 8px;
   height: 8px;
   transform: translate(-50%, -50%) scale(1);
   border-radius: 50%;
   border: 2px solid rgba(59,130,246,0.45);
   opacity: 0.65;
   pointer-events: none;
   animation: stalePing 2.2s ease-out infinite;
 }

 @keyframes livePulse {
   0%   { transform: translate(-50%, -50%) scale(1);   opacity: 0.7; }
   70%  { transform: translate(-50%, -50%) scale(2.2); opacity: 0.1; }
   100% { transform: translate(-50%, -50%) scale(2.4); opacity: 0;   }
 }
 @keyframes stalePing {
   0%   { transform: translate(-50%, -50%) scale(1);   opacity: 0.65; }
   60%  { transform: translate(-50%, -50%) scale(2.0); opacity: 0.12; }
   100% { transform: translate(-50%, -50%) scale(2.2); opacity: 0;   }
 }

 @media (prefers-reduced-motion: reduce) {
   .live-pill .dot::after { animation: none !important; }
 }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background-color: rgba(255,255,255,0.08);
  border: 1px solid var(--border);
  color: var(--text-strong);
  font-weight: 600;
  font-size: 0.78rem;
}

.now-playing {
  margin: 12px 0 8px;
  font-size: clamp(0.95rem, 2.3vw, 1.15rem);
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-strong);
  text-align: center;
}

audio { display: none; }

.controls { display: flex; flex-direction: column; align-items: center; gap: 16px; margin-top: 8px; }
#radio-player .controls:last-of-type { margin-top: auto; }
.button-row { display: flex; align-items: center; justify-content: center; gap: 18px; margin: 6px 0 4px; }

/* Icon buttons */
.play-pause-button,
.mute-button,
.live-button,
.share-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(255,255,255,0.08);
  border: 1px solid var(--border);
  border-radius: 50%;
  background-repeat: no-repeat;
  background-position: center;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease, filter 180ms ease;
}

.play-pause-button { width: 84px; height: 84px; background-size: 84px 84px; box-shadow: 0 12px 28px rgba(0,0,0,0.28); }
.mute-button, .live-button, .share-button { width: 48px; height: 48px; background-size: 42px 42px; }

.play-pause-button:hover,
.mute-button:hover,
.live-button:hover,
.share-button:hover { transform: translateY(-1px); box-shadow: 0 8px 18px rgba(0,0,0,0.28); border-color: rgba(255,255,255,0.28); filter: brightness(1.06); }

/* Volume */
.volume-slider,
#volume-slider { width: 100%; accent-color: var(--accent); }
.volume-label { margin-top: 6px; text-align: center; color: var(--text); font-size: 0.78rem; opacity: 0.8; }

.audio-visualizer { width: 100%; height: 56px; margin: 10px 0 2px; background: transparent; display: block; }

/* Listener label (badge style already applied) */
#listener_label { font-weight: 600; letter-spacing: 0.02em; }

/* Social */
.social-row { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 4px; }
.social-button { display: inline-flex; align-items: center; justify-content: center; width: 50px; height: 50px; border-radius: 14px; background-color: rgba(255,255,255,0.08); border: 1px solid var(--border); cursor: pointer; transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease, filter 180ms ease; }
.social-button.wide { width: 110px; }
.social-button:hover { transform: translateY(-1px); box-shadow: 0 8px 18px rgba(0,0,0,0.28); border-color: rgba(255,255,255,0.28); filter: brightness(1.06); }
.social-button div { width: 100%; height: 100%; background-repeat: no-repeat; background-position: center; background-size: 100% 100%; border-radius: 12px; }
.listener-stats-button { margin-left: 8px; padding: 4px 10px; font-size: 0.7rem; border-radius: 999px; border: 1px solid var(--border); background-color: rgba(255,255,255,0.08); color: var(--text-strong); cursor: pointer; box-shadow: 0 6px 14px rgba(0,0,0,0.25); transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease, filter 180ms ease; }
.listener-stats-button:hover { transform: translateY(-1px); box-shadow: 0 8px 18px rgba(0,0,0,0.28); border-color: rgba(255,255,255,0.28); filter: brightness(1.06); }

.tagline { margin-top: 2px; color: var(--text); text-align: center; }
.app-meta { margin-top: 0; color: var(--text); text-align: center; font-size: 0.74rem; opacity: 0.7; }
.install-inline { display: inline-block; margin: 6px auto 0; padding: 6px 10px; font-size: 0.78rem; color: var(--text-strong); background: rgba(255,255,255,0.08); border: 1px solid var(--border); border-radius: 12px; cursor: pointer; box-shadow: 0 6px 14px rgba(0,0,0,0.25); }
.install-inline:hover { filter: brightness(1.06); }
.install-status { margin-top: 4px; text-align: center; color: var(--text); font-size: 0.72rem; opacity: 0.66; }

/* Install modal */
.install-modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: none; align-items: center; justify-content: center; z-index: 1000; padding: env(safe-area-inset-top) 16px env(safe-area-inset-bottom); }
.install-modal-overlay:not([hidden]) { display: flex; }
.install-modal-overlay[hidden] { display: none; }
.install-modal { background: rgba(255,255,255,0.1); backdrop-filter: blur(10px); border: 1px solid var(--border); border-radius: 16px; padding: 16px 14px; width: min(420px, 92vw); color: var(--text-strong); box-shadow: 0 12px 28px rgba(0,0,0,0.35); }
.install-modal h3 { margin: 0 0 8px; font-size: 1rem; }
.install-modal p { margin: 0 0 12px; font-size: 0.95rem; color: var(--text); }
.install-actions { display: flex; gap: 10px; justify-content: flex-end; }
.install-btn-primary, .install-btn-secondary { padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border); cursor: pointer; }
.install-btn-primary { background: var(--accent); color: #fff; box-shadow: 0 8px 18px rgba(198,101,40,0.35); }
.install-btn-secondary { background: rgba(255,255,255,0.08); color: var(--text-strong); }
.install-btn-primary:hover, .install-btn-secondary:hover { filter: brightness(1.06); }
.stats-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: none; align-items: center; justify-content: center; z-index: 1100; padding: env(safe-area-inset-top) 16px env(safe-area-inset-bottom); }
.stats-overlay:not([hidden]) { display: flex; }
.stats-overlay[hidden] { display: none; }
.stats-modal { background: rgba(15,23,42,0.96); border: 1px solid var(--accent); border-radius: 16px; padding: 16px 14px; width: min(440px, 94vw); color: var(--text-strong); box-shadow: 0 18px 40px rgba(198,101,40,0.25); max-height: min(520px, 90vh); display: flex; flex-direction: column; }
.stats-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; gap: 8px; }
.stats-header h3 { margin: 0; font-size: 1rem; color: var(--accent); }
.stats-close { border: none; background: transparent; color: var(--text-strong); font-size: 1.4rem; cursor: pointer; padding: 4px 8px; border-radius: 999px; }
.stats-close:hover { background-color: rgba(255,255,255,0.08); }
.stats-summary { margin: 0 0 10px; font-size: 0.86rem; color: var(--text); }
.stats-graph { display: flex; align-items: flex-end; gap: 4px; width: 100%; padding-top: 6px; border-top: 1px solid rgba(255,255,255,0.08); overflow-x: auto; padding-bottom: 4px; }
.stats-bar { flex: 0 0 20px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 2px; }
.stats-bar-inner { width: 100%; border-radius: 8px 8px 0 0; background: linear-gradient(180deg, #fabb90, #C66528); height: 0; }
.stats-bar-value { font-size: 0.7rem; color: var(--text); opacity: 0.9; }
.stats-bar-hour { font-size: 0.68rem; color: var(--muted); }

.schedule-list { display: flex; flex-direction: column; gap: 12px; overflow-y: auto; padding-right: 4px; margin-top: 10px; }
.schedule-item { background: rgba(255,255,255,0.05); padding: 12px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.1); }
.schedule-item.active { border-color: var(--accent); background: rgba(198,101,40,0.1); }
.schedule-time { font-size: 0.8rem; color: var(--accent); margin-bottom: 2px; font-weight: 600; }
.schedule-name { font-size: 0.95rem; font-weight: 500; }

/* Separators subtle tweak */
.separator-thin { background-color: rgba(198,101,40,0.8); width: 100%; height: 1px; margin-top: 24px; }
.separator-space { background-color: transparent; width: 100%; height: 10px; }

@media (max-width: 380px) {
  .play-pause-button { width: 76px; height: 76px; background-size: 76px 76px; }
  .mute-button, .live-button, .share-button { width: 44px; height: 44px; background-size: 38px 38px; }
  #radio-logo { max-width: 100px; }
}

@media (max-height: 580px) {
  .play-pause-button { width: 72px; height: 72px; background-size: 72px 72px; }
  .mute-button, .live-button, .share-button { width: 44px; height: 44px; background-size: 38px 38px; }
  #radio-logo { max-width: 100px; }
  .button-row { gap: 12px; }
  .controls { gap: 10px; }
  .now-playing { font-size: clamp(0.9rem, 2.2vw, 1.05rem); }
  .install-banner { padding: 8px 10px; margin-top: 10px; font-size: 0.95rem; }
}

@media (max-height: 480px) {
  .play-pause-button { width: 64px; height: 64px; background-size: 64px 64px; }
  .mute-button, .live-button, .share-button { width: 40px; height: 40px; background-size: 36px 36px; }
  #radio-logo { max-width: 90px; }
  .button-row { gap: 10px; }
  .controls { gap: 8px; }
  .now-playing { font-size: clamp(0.86rem, 2vw, 1rem); }
  .tagline { margin-top: 6px; }
  .install-banner { padding: 7px 9px; margin-top: 8px; font-size: 0.9rem; }
}
