/* ============================================================
   HADLAY KALAN — गाँव का रेडियो
   Home card + persistent mini player bar
   ============================================================ */

/* The YouTube iframe must stay in the layout — display:none makes some
   browsers suspend playback.

   Size matters for AUDIO, not just video: YouTube picks the stream from the
   player's rendered size, so a 1x1px player is served the lowest rung of the
   ladder and the music sounds thin. Keep it a real 640x360 player — hence the
   iframe rule below, which stays 640x360 while the wrapper clips it.

   The wrapper must stay ON-SCREEN and faintly visible. Desktop and mobile
   Chrome will happily decode an off-screen, opacity:0 video, but the Android
   WebView inside the app only allocates a video surface for content it
   actually composites. Parking this off-screen (left:-10000px), fully
   transparent (opacity:0) or behind the page (z-index:-1) made the app load
   the player, fire state changes, then sit in BUFFERING forever with no error
   code — while the website played fine. So: clipped to 2px in the corner,
   opacity 0.01 rather than 0, and a non-negative z-index. Invisible in
   practice, composited in principle.

   To verify playback in the app, run this in the console and watch the corner:
     document.getElementById('hkRadioHost').classList.add('hkr-debug') */
#hkRadioHost {
  position: fixed;
  right: 0;
  bottom: 0;
  width: 4px;
  height: 4px;
  overflow: hidden;   /* clips the 640x360 iframe down to a 4px square */
  opacity: 1;         /* fully opaque: near-zero opacity is a "skip this
                         layer" hint the WebView compositor may act on, and
                         at 4px the visitor cannot tell the difference */
  pointer-events: none;
  z-index: 0;         /* NOT negative — behind the page is not composited */
}
#hkRadioHost iframe { width: 640px; height: 360px; border: 0; }

/* While music is playing, show the player as a small now-playing tile.

   The Android WebView only reliably hands a video a decoder surface when it
   actually composites it — a hidden player is what left the radio buffering
   forever inside the app while the website played fine. A visible tile also
   sits better with YouTube's terms, which expect the player to be shown
   rather than hidden purely to take the audio.

   The iframe stays a true 640x360 and is scaled down visually, because
   YouTube chooses the audio stream from the player's *layout* size — shrinking
   the element itself would get us the thin-sounding bottom rung (see above).
   pointer-events stays off, so the radio's own controls remain authoritative. */
#hkRadioHost.hkr-host-live {
  width: 96px;
  height: 54px;
  right: 12px;
  /* clears the persistent mini bar, which sits at 80px + safe-area */
  bottom: calc(142px + env(safe-area-inset-bottom, 0px));
  border-radius: 10px;
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-lg);
  z-index: 998;            /* just under .hkr-bar at 999 */
}

#hkRadioHost.hkr-host-live iframe {
  width: 640px;            /* unchanged — drives the audio stream choice */
  height: 360px;
  transform: scale(0.15);  /* 640x360 -> 96x54 on screen */
  transform-origin: top left;
}

/* Diagnostic only: makes the player a real visible box so you can confirm
   whether the app is compositing it. Never enabled in normal use. */
#hkRadioHost.hkr-debug {
  width: 320px;
  height: 180px;
  bottom: 70px;
  opacity: 1;
  z-index: 99;
}
#hkRadioHost.hkr-debug iframe { width: 320px; height: 180px; }

/* ── Home card ──────────────────────────────────────── */
.hkr-now {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, rgba(22,163,74,0.10), rgba(245,158,11,0.10));
  border: 1px solid var(--glass-border-subtle);
}

.hkr-disc {
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 22px;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: 0 4px 14px rgba(22,163,74,0.28);
}

.hkr-now-text { flex: 1; min-width: 0; }

/* YouTube titles run long ("Tumko Dekha To Ye Khayal Aaya | Saath Saath | ...").
   Two clamped lines read far better than one truncated at a few characters. */
.hkr-title {
  font-weight: 700;
  font-size: 14.5px;
  line-height: 1.35;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.hkr-meta {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.hkr-time {
  font-size: 11px;
  color: var(--text-light);
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
}

.hkr-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 12px;
}

.hkr-btn {
  width: 38px;
  height: 38px;
  border: 1px solid var(--glass-border);
  background: var(--glass-strong);
  color: var(--text-secondary);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
}
.hkr-btn:active { transform: scale(0.9); }

.hkr-btn-main {
  width: 48px;
  height: 48px;
  font-size: 17px;
  color: #fff;
  border: none;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  box-shadow: 0 4px 14px rgba(22,163,74,0.32);
}

.hkr-status {
  display: none;
  font-size: 12px;
  color: var(--accent);
  margin-top: 10px;
  text-align: center;
}

/* ── Playlist dropdown ──────────────────────────────── */
.hkr-select-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  color: var(--text-light);
  font-size: 12px;
}

.hkr-select {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--glass-strong);
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  /* Long YouTube-sourced playlist names must not stretch the card. */
  text-overflow: ellipsis;
}
.hkr-select:focus { border-color: var(--primary); }

/* ── Volume ─────────────────────────────────────────── */
.hkr-volume-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  color: var(--text-light);
  font-size: 12px;
}
.hkr-volume-row input[type="range"] {
  flex: 1;
  accent-color: var(--primary);
  height: 4px;
  cursor: pointer;
}

/* ── Seek bar — jump to any minute of the song ───────── */
.hkr-seek-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}

.hkr-seek-time {
  font-size: 11px;
  color: var(--text-light);
  font-variant-numeric: tabular-nums;
  min-width: 34px;
  text-align: center;
  flex-shrink: 0;
}

.hkr-seek-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
  height: 24px;
  display: flex;
  align-items: center;
}

/* Painted track sits under a transparent range input, so the thumb stays a
   real native control (good touch target) while the fill matches the theme. */
.hkr-seek-track {
  position: absolute;
  left: 0; right: 0;
  height: 5px;
  border-radius: 3px;
  background: var(--border);
  overflow: hidden;
  pointer-events: none;
}
.hkr-seek-fill {
  height: 100%;
  width: 0%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
}

.hkr-seek {
  position: relative;
  width: 100%;
  margin: 0;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  height: 24px;
}
.hkr-seek::-webkit-slider-runnable-track { height: 5px; background: transparent; }
.hkr-seek::-moz-range-track { height: 5px; background: transparent; }
.hkr-seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 15px;
  height: 15px;
  margin-top: -5px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(22,101,52,0.35);
}
.hkr-seek::-moz-range-thumb {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(22,101,52,0.35);
}

/* The number belongs *inside* the circular-arrow glyph — that is what makes it
   read as "go back ten seconds" rather than an icon with a stray 10 next to it. */
.hkr-skip {
  position: relative;
  font-size: 20px;
  color: var(--text-secondary);
}
.hkr-skip b {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding-top: 2px;
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: -0.3px;
  pointer-events: none;
}



/* ── Track list ─────────────────────────────────────── */
.hkr-list {
  margin-top: 12px;
  /* Exactly four rows, the rest scrolls — a 98-song list should not push the
     whole page down. 52px row + 4px gap. */
  max-height: calc(4 * 52px + 3 * 4px);
  overflow-y: auto;
  overscroll-behavior: contain;   /* don't drag the page when the list ends */
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hkr-track {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 52px;
  flex-shrink: 0;
  box-sizing: border-box;
  padding: 9px 10px;
  border: none;
  background: transparent;
  border-radius: 12px;
  text-align: right;
  cursor: pointer;
  transition: var(--transition);
}
.hkr-track:active { transform: scale(0.99); }
.hkr-track.playing { background: var(--primary-light); }

.hkr-track-num {
  width: 20px;
  flex-shrink: 0;
  font-size: 11px;
  color: var(--text-light);
}
.hkr-track.playing .hkr-track-num { color: var(--primary); font-weight: 700; }

.hkr-track-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  text-align: left;
}
.hkr-track-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hkr-track-film {
  font-size: 11px;
  color: var(--text-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hkr-track-icon { font-size: 10px; color: var(--text-light); flex-shrink: 0; }
.hkr-track.playing .hkr-track-icon { color: var(--primary); }

.hkr-empty {
  text-align: center;
  font-size: 13px;
  color: var(--text-light);
  padding: 18px 0;
}

.hkr-credit {
  margin-top: 10px;
  font-size: 10.5px;
  line-height: 1.5;
  color: var(--text-light);
  text-align: center;
}

/* ── Persistent mini bar (sits above the bottom nav) ── */
/* Aligned to the floating nav pill: 12px insets, clearing its 62px height
   plus its own 10px + safe-area offset, with an 8px gap. */
.hkr-bar {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  z-index: 999;
  display: none;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 16px;
  background: rgba(255,255,255,0.92);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.hkr-bar.active { display: flex; }

.hkr-bar-disc {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 14px;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--accent));
}

.hkr-bar-text { flex: 1; min-width: 0; }
.hkr-bar-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hkr-bar-meta {
  font-size: 10.5px;
  color: var(--text-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hkr-bar-btn {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border: none;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary-dark);
  display: grid;
  place-items: center;
  font-size: 12px;
  cursor: pointer;
}
.hkr-bar-btn:active { transform: scale(0.9); }
.hkr-bar-btn.main { background: var(--primary); color: #fff; }

.hkr-bar-progress {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 0;
  height: 10px;              /* tappable strip … */
  padding-top: 8px;          /* … with a 2px line drawn at its base */
  box-sizing: border-box;
  cursor: pointer;
}
.hkr-bar-progress::before {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: 4px;
  height: 2px;
  border-radius: 2px;
  background: var(--border);
}
.hkr-bar-fill {
  position: absolute;
  left: 0;
  bottom: 4px;
  height: 2px;
  width: 0%;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width 0.9s linear;
}

/* Keep the last section clear of the bar when it's showing.
   Base is 90px + safe-area (home-fireside.css) — add the bar's height on top,
   don't replace it. */
body.hkr-bar-open .main-content {
  padding-bottom: calc(148px + env(safe-area-inset-bottom, 0px));
}

@media (max-width: 380px) {
  .hkr-bar-meta { display: none; }
}

/* ══════════════════════════════════════════════════════════
   RADIO TEASER — the strip under the status bar.
   Its job is discovery: most visitors never scroll far enough
   to find the player, so one tap here starts the music.
   ══════════════════════════════════════════════════════════ */
.hk-rt {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 12px 0;
  padding: 8px 10px 8px 8px;
  border-radius: 18px;
  background: linear-gradient(120deg, rgba(22,163,74,0.12), rgba(245,158,11,0.14));
  border: 1px solid var(--glass-border-subtle);
  box-shadow: var(--shadow-glass);
}

.hk-rt-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0;
  border: none;
  background: none;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}

.hk-rt-disc {
  position: relative;
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 17px;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: 0 3px 12px rgba(22,163,74,0.30);
}

/* Equaliser replaces the note while music is actually playing. */
.hk-rt-eq {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 2.5px;
}
.hk-rt-eq i {
  width: 3px;
  height: 8px;
  border-radius: 2px;
  background: #fff;
  animation: hkRtBounce 0.9s ease-in-out infinite;
}
.hk-rt-eq i:nth-child(2) { animation-delay: 0.18s; }
.hk-rt-eq i:nth-child(3) { animation-delay: 0.36s; }
@keyframes hkRtBounce {
  0%, 100% { height: 7px; }
  50%      { height: 17px; }
}
/* Playing: show the bars, hide the note. */
.hk-rt.playing .hk-rt-eq { display: flex; }
.hk-rt.playing .hk-rt-disc > i { visibility: hidden; }

@media (prefers-reduced-motion: reduce) {
  .hk-rt-eq i { animation: none; height: 12px; }
}
body.hk-perf-lite .hk-rt-eq i { animation: none; height: 12px; }

.hk-rt-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }

/* Chevron: the affordance that says the strip opens into something. */
.hk-rt-chev {
  flex-shrink: 0;
  font-size: 12px;
  color: var(--text-light);
  transition: transform 0.22s ease;
}
.hk-rt-chev.up { transform: rotate(180deg); }

/* When open, the strip and the player below it read as one unit. */
.hk-rt.open {
  border-bottom-left-radius: 6px;
  border-bottom-right-radius: 6px;
  margin-bottom: 0;
}

.hk-rt-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--primary-dark);
}

.hk-rt-badge {
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: 0.4px;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  text-transform: uppercase;
}
/* Once they have played something, the "new" flag has done its job. */
.hk-rt.playing .hk-rt-badge { display: none; }

.hk-rt-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hk-rt-play {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 15px;
  cursor: pointer;
  box-shadow: 0 3px 12px rgba(22,163,74,0.32);
  transition: var(--transition);
}
.hk-rt-play:active { transform: scale(0.9); }

@media (max-width: 340px) {
  .hk-rt-label { font-size: 11px; }
  .hk-rt-title { font-size: 11.5px; }
}

/* Desktop: the mini player is viewport-anchored like the bottom nav, so it
   needs the same treatment — centred on the app column instead of spanning
   the whole screen. See section 20 of home-fireside.css. */
@media (min-width: 768px) {
  .hkr-bar {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: 476px;
    max-width: calc(100vw - 24px);
  }
}

/* The player is folded away until the strip is tapped. `hidden` does the
   hiding; this just seats it against the strip and gives it an entrance. */
.hkr-card[hidden] { display: none; }
.hkr-card {
  margin-top: 6px;
  border-top-left-radius: 6px;
  border-top-right-radius: 6px;
  animation: hkrOpen 0.22s ease both;
}
@keyframes hkrOpen {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .hkr-card { animation: none; }
  .hk-rt-chev { transition: none; }
}
body.hk-perf-lite .hkr-card { animation: none; }
