/* ==========================================================================
   Online Bangla Radio — mobile app shell
   Dark by default (people listen to these at night), with a light theme for
   anyone whose phone asks for one, plus a manual toggle.
   ========================================================================== */

:root {
  /* Dark is the default identity, so it lives on bare :root. */
  --bg: #14110E;
  --surface: #221D18;
  --surface-2: #2C251E;
  --fg: #F4EFE7;
  --fg-2: #D6CBBC;
  --muted: #9C8F80;
  --line: #383027;
  --accent: #F0A04B;
  --accent-ink: #1A1206;
  --accent-soft: #3A2A17;
  --shadow: 0 8px 28px rgba(0, 0, 0, .45);

  /* One family, three weights. A second display face cost 42KB of Bengali
     glyphs for a difference nobody reads at 17px. */
  --display: 'Hind Siliguri', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --body: 'Hind Siliguri', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

  /* Heights of whatever Google docks to the viewport, measured at runtime so our
     own furniture sits clear of it instead of fighting it. Both stay 0 until an
     anchor ad actually appears. */
  /* Width of the content column. The site is built for phones, but on a wide
     screen everything lines up in one centred column instead of the bar
     stretching edge to edge while the content sits in the middle. */
  --col: 680px;

  --anchor-h: 0px;       /* bottom anchor — the mini player sits above it */
  --anchor-top-h: 0px;   /* top anchor — the app bar sits below it */
  --dock-h: 0px;

  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #F7F3EC;
    --surface: #FFFFFF;
    --surface-2: #F0EAE0;
    --fg: #1B1612;
    --fg-2: #4A4038;
    --muted: #7A6E63;
    --line: #E2D9CC;
    --accent: #B4530A;
    --accent-ink: #FFFFFF;
    --accent-soft: #FBEAD8;
    --shadow: 0 8px 28px rgba(60, 40, 20, .14);
    color-scheme: light;
  }
}

:root[data-theme="light"] {
  --bg: #F7F3EC;
  --surface: #FFFFFF;
  --surface-2: #F0EAE0;
  --fg: #1B1612;
  --fg-2: #4A4038;
  --muted: #7A6E63;
  --line: #E2D9CC;
  --accent: #B4530A;
  --accent-ink: #FFFFFF;
  --accent-soft: #FBEAD8;
  --shadow: 0 8px 28px rgba(60, 40, 20, .14);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

h1, h2, h3, h4 { font-family: var(--display); font-weight: 700; margin: 0; letter-spacing: -.01em; text-wrap: balance; }

/* Give every tap target room to be tapped. */
a, button { -webkit-tap-highlight-color: rgba(240, 160, 75, .18); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* ------------------------------------------------------------- app bar --- */

.topbar {
  position: sticky;
  /* Below Google's top anchor ad if there is one, so the two never overlap. */
  top: var(--anchor-top-h, 0px);
  z-index: 40;
  transition: transform .25s ease;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top, 0px);
}

@supports not (backdrop-filter: blur(1px)) { .topbar { background: var(--bg); } }

/* The bar's background still spans the window; its contents line up with the
   page column so the logo, search and chips sit over the content below them. */
.topbar__inner { max-width: var(--col); margin: 0 auto; }

/*
 * Two guards on the app bar, both about Auto Ads.
 *
 * Auto Ads injects its own containers between the block children of anything it
 * reads as a content area, and it did exactly that inside this header: a 390px
 * ad landed in a sticky element and glued itself to 60% of the screen. The
 * children are now wrapped in a single inner element, and app.js watches the
 * measured height — if anything still lands in here the bar simply stops being
 * sticky and scrolls away with the page.
 *
 * Note it un-sticks rather than hiding or clipping. An ad that is hidden or cut
 * off is an AdSense policy problem; one that scrolls normally is not.
 */
.topbar.is-unstuck { position: static; transform: none !important; }

/* Slides out of the way while reading, comes back the moment you scroll up. */
.topbar.is-hidden { transform: translateY(-100%); }

.topbar__row {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 14px 0;
}

.brand { display: flex; align-items: center; gap: 8px; min-width: 0; margin-right: auto; }
.brand img { height: 26px; width: auto; max-width: 160px; object-fit: contain; object-position: left center; }
.brand__name { font-family: var(--display); font-weight: 700; font-size: 16px; white-space: nowrap; }
.brand__name span { color: var(--accent); }

.icon-btn {
  width: 32px; height: 32px; flex: 0 0 auto;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--fg-2);
  display: grid; place-items: center;
}
.icon-btn svg { width: 17px; height: 17px; fill: currentColor; }
.icon-btn:active { background: var(--accent-soft); color: var(--accent); }

/* Horizontally scrolling nav. Replaces the hamburger: every destination is one
   tap away and visible, and it costs no vertical space that a feed ad could use. */
.chips {
  display: flex; gap: 8px;
  overflow-x: auto;
  padding: 8px 14px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13px; font-weight: 600;
  white-space: nowrap;
}
.chip--on { background: var(--accent); color: var(--accent-ink); }

/* --------------------------------------------------------------- shell --- */

.page {
  padding: 16px 14px;
  /* Leave room for whatever is docked at the bottom so the last row is reachable. */
  padding-bottom: calc(28px + var(--dock-h) + var(--anchor-h) + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; gap: 22px;
  max-width: var(--col); margin: 0 auto;
}

.section { display: flex; flex-direction: column; gap: 12px; min-width: 0; }

.section__head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.section__head h2 { font-size: 17px; font-weight: 600; }
.section__head a { font-size: 12px; font-weight: 600; color: var(--accent); flex: 0 0 auto; }

.page__title { font-size: 22px; line-height: 1.2; }
.page__sub { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* ---------------------------------------------------------------- rows --- */

.list { display: flex; flex-direction: column; gap: 10px; }

.row {
  display: flex; align-items: center; gap: 12px;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 9px 11px 9px 9px;
}
.row:active { background: var(--surface-2); }

.art {
  width: 54px; height: 54px; flex: 0 0 auto;
  border-radius: 10px;
  object-fit: cover;
  background: var(--surface-2);
  display: grid; place-items: center;
  overflow: hidden;
}
.art--fallback { font-family: var(--display); font-size: 20px; font-weight: 700; color: rgba(255,255,255,.82); }

/* Station logos are drawn for a white background and carry their own margins.
   Cropping them to fill the square cuts the wordmark in half, so they sit on
   white and are scaled to fit instead. */
.art--logo { object-fit: contain; background: #FFFFFF; padding: 5px; border: 1px solid var(--line); }

.row__meta { min-width: 0; flex: 1; }
.row__title {
  font-size: 14px; font-weight: 600; line-height: 1.35;
  /* -webkit-box is what makes line-clamp work; it also blockifies the span. */
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.row__sub {
  display: block;
  font-size: 11.5px; color: var(--muted); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.row__play {
  width: 32px; height: 32px; flex: 0 0 auto;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  color: var(--accent);
  display: grid; place-items: center;
}
.row__play svg { width: 12px; height: 12px; fill: currentColor; }

/* Station rows read as a shelf rather than a list — there are only a dozen. */
.shelf {
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(98px, 1fr));
}
.tile { min-width: 0; }
.tile .art { width: 100%; height: auto; aspect-ratio: 1; border-radius: 12px; }
.tile__title {
  font-size: 12px; font-weight: 600; margin-top: 6px; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.tile__sub { display: block; font-size: 10.5px; color: var(--muted); }

.live-dot {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: #E5484D; margin-right: 5px; vertical-align: 1px;
}

/* ----------------------------------------------------------- term pills --- */

.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; padding: 7px 14px;
  font-size: 13px; font-weight: 600;
}
.pill span { color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }
.pill:active { border-color: var(--accent); color: var(--accent); }

/* ---------------------------------------------------------------- ads ---- */

/* Reserved space. The height is set inline per position so the box occupies its
   final size before the ad arrives and nothing below it moves. */
.ad { margin: 2px 0; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.ad--auto { min-height: 0; }

/* Edge-to-edge positions. The page and the footer both carry 14px of side
   padding; this cancels it so the unit gets the full screen width, which is
   what a responsive AdSense unit wants in order to offer the largest sizes. */
.ad--full {
  margin-left: -14px;
  margin-right: -14px;
  width: calc(100% + 28px);
  max-width: none;
  border-radius: 0;
}
.ad--full > ins { width: 100%; }
.ad--placeholder {
  flex-direction: column; gap: 2px;
  border: 1.5px dashed color-mix(in srgb, var(--accent) 55%, transparent);
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  text-align: center;
}
.ad__label { font-size: 9px; letter-spacing: .14em; text-transform: uppercase; font-weight: 700; }
.ad__name { font-size: 12px; font-weight: 600; }
.ad__dim { font-size: 11px; opacity: .8; font-variant-numeric: tabular-nums; }

/* -------------------------------------------------------------- player --- */

.player { display: flex; flex-direction: column; gap: 14px; align-items: center; }

.player__cover {
  width: min(62vw, 230px); aspect-ratio: 1;
  border-radius: 18px; overflow: hidden;
  box-shadow: var(--shadow);
  display: grid; place-items: center;
  font-family: var(--display); font-size: 54px; font-weight: 700; color: rgba(255,255,255,.82);
}
.player__cover img { width: 100%; height: 100%; object-fit: cover; }

.player__title { font-size: 18px; text-align: center; line-height: 1.3; }
.player__meta { font-size: 12.5px; color: var(--muted); text-align: center; }
.player__meta a { color: var(--accent); font-weight: 600; }

.player__bar { width: 100%; }
.seek {
  height: 4px; border-radius: 3px; background: var(--line);
  position: relative; cursor: pointer; touch-action: none;
}
/* Invisible padding so the 4px bar is still an easy target with a thumb. */
.seek::before { content: ''; position: absolute; inset: -12px 0; }
.seek__fill { height: 100%; width: 0; border-radius: 3px; background: var(--accent); position: relative; }
.seek__fill::after {
  content: ''; position: absolute; right: -5px; top: 50%; transform: translateY(-50%);
  width: 11px; height: 11px; border-radius: 50%; background: var(--accent);
}
.seek__buffer { position: absolute; inset: 0 auto 0 0; height: 100%; width: 0; border-radius: 3px; background: var(--muted); opacity: .35; }
.times { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 7px; font-variant-numeric: tabular-nums; }

.controls { display: flex; align-items: center; justify-content: center; gap: 22px; }
.controls button { color: var(--fg-2); display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; }
.controls button:disabled { opacity: .3; }
.controls svg { width: 22px; height: 22px; fill: currentColor; }
.controls .play-big {
  width: 60px; height: 60px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink);
}
.controls .play-big svg { width: 25px; height: 25px; }
.controls .small svg { width: 17px; height: 17px; }

.player__hint { font-size: 12px; color: var(--muted); text-align: center; max-width: 34ch; }

/* Secondary controls — speed and the sleep timer. Pills rather than bare text,
   so they read as things you can press and keep a stable width as the label
   changes from "1x" to "1.75x" or "Sleep off" to "Sleep 45m". */
.controls--secondary { gap: 10px; }
.controls--secondary button {
  width: auto; height: 34px; padding: 0 16px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--fg-2);
  font-size: 12.5px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  min-width: 70px;
}
.controls--secondary button.is-on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.speed-btn { font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- dock --- */

/* The mini player is fixed above whatever Google docks at the very bottom.
   --anchor-h is measured at runtime; if no anchor ad shows it stays 0 and the
   mini player sits flush with the bottom edge. */
.dock {
  position: fixed;
  left: 0; right: 0;
  bottom: calc(var(--anchor-h) + env(safe-area-inset-bottom, 0px));
  z-index: 35;
  background: var(--surface);
  border-top: 1px solid var(--line);
  box-shadow: 0 -6px 22px rgba(0, 0, 0, .25);
  transform: translateY(110%);
  transition: transform .22s ease;
}
.dock.is-open { transform: translateY(0); }

.dock__inner { display: flex; align-items: center; gap: 10px; padding: 8px 12px; max-width: var(--col); margin: 0 auto; }
.dock .art { width: 38px; height: 38px; border-radius: 8px; font-size: 15px; }
.dock__meta { min-width: 0; flex: 1; display: block; overflow: hidden; }
/* display:block matters here: these are spans, and text-overflow is ignored on
   an inline box, so without it a long title runs out under the play button. */
.dock__title { display: block; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dock__sub { display: block; font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dock__btn { width: 38px; height: 38px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; flex: 0 0 auto; }
.dock__btn svg { width: 15px; height: 15px; fill: currentColor; }
.dock__close { color: var(--muted); width: 28px; height: 28px; flex: 0 0 auto; display: grid; place-items: center; }
.dock__close svg { width: 13px; height: 13px; fill: currentColor; }
.dock__progress { height: 2px; background: var(--line); }
.dock__progress i { display: block; height: 100%; width: 0; background: var(--accent); }

/* ------------------------------------------------------------ playlist --- */

.queue { display: flex; flex-direction: column; gap: 2px; }
.queue__item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 9px; min-width: 0;
  text-align: left; width: 100%;
}
.queue__item.is-playing { background: var(--accent-soft); }
.queue__item.is-playing .queue__num { color: var(--accent); }
.queue__num { font-size: 11px; color: var(--muted); width: 18px; flex: 0 0 auto; font-variant-numeric: tabular-nums; }
.queue__title { font-size: 13px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }

/* ---------------------------------------------------------- pagination --- */

.pagination { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; align-items: center; }
.pagination a, .pagination span {
  min-width: 36px; height: 36px; padding: 0 10px;
  display: grid; place-items: center;
  border-radius: 9px; font-size: 13px; font-weight: 600;
  background: var(--surface); border: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.pagination .is-current { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.pagination .gap { background: none; border: none; color: var(--muted); min-width: 16px; }

/* -------------------------------------------------------------- search --- */

.search { display: flex; gap: 8px; }
.search input {
  flex: 1; min-width: 0;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 11px 13px;
  color: var(--fg); font-size: 15px;
}
.search input::placeholder { color: var(--muted); }
.search input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.search button { background: var(--accent); color: var(--accent-ink); border-radius: 10px; padding: 0 16px; font-weight: 700; font-size: 14px; }

/* -------------------------------------------------------------- footer --- */

.site-footer {
  max-width: var(--col); margin: 0 auto;
  border-top: 1px solid var(--line);
  padding: 22px 14px calc(26px + var(--dock-h) + var(--anchor-h) + env(safe-area-inset-bottom, 0px));
  text-align: center;
  display: flex; flex-direction: column; gap: 14px; align-items: center;
}
.app-banner img { width: min(280px, 80%); height: auto; margin: 0 auto; }
.footer-nav { display: flex; flex-wrap: wrap; gap: 6px 16px; justify-content: center; font-size: 13px; color: var(--fg-2); }
.copyright { font-size: 12px; color: var(--muted); }

.empty { color: var(--muted); font-size: 14px; text-align: center; padding: 28px 0; }

.back-link { font-size: 13px; color: var(--accent); font-weight: 600; }

/* Staging-only banner, so nobody mistakes the preview for the live site. */
.staging-flag {
  background: var(--accent); color: var(--accent-ink);
  font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  text-align: center; padding: 5px;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
