/* ------------------------------------------------------------------
   ALC Pan-African Radio — design system
   Adapted from the Foreign Affairs editorial language: deep navy +
   cream/parchment, serif headlines, generous whitespace; threaded with
   ALC's brand cyan and orange as small chromatic accents.
   ------------------------------------------------------------------ */

:root {
  /* foreground / surface (Foreign Affairs cream + navy) */
  --bg: #F4EFE6;          /* parchment */
  --bg-elev: #FFFFFF;
  --bg-dark: #0F2A47;     /* deep navy */
  --ink: #15171A;
  --ink-mute: #56606E;
  --ink-faint: #8B95A3;
  --rule: #D9D2C5;

  /* ALC brand accents */
  --brand: #0F2A47;       /* primary, navy */
  --brand-2: #6EC1E4;     /* ALC cyan */
  --brand-warm: #EE4D0E;  /* ALC orange */
  --brand-leaf: #61CE70;  /* ALC green */
  --accent-rust: #A85A2A; /* editorial rust */

  /* states */
  --live: #D81F2A;
  --shadow-sm: 0 1px 2px rgba(15,42,71,.08);
  --shadow-md: 0 8px 28px rgba(15,42,71,.12);
  --shadow-lg: 0 18px 50px rgba(15,42,71,.18);

  /* typography */
  --font-serif: 'Source Serif 4', 'Georgia', 'Times New Roman', serif;
  --font-sans: 'Inter', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;

  /* spacing scale */
  --s-1: .25rem;
  --s-2: .5rem;
  --s-3: .75rem;
  --s-4: 1rem;
  --s-5: 1.5rem;
  --s-6: 2rem;
  --s-7: 3rem;
  --s-8: 4rem;

  /* layout */
  --topbar-h: 60px;
  --mini-h: 84px;
  --max-w: 1080px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  padding-bottom: calc(env(safe-area-inset-bottom) + var(--mini-h));
}
body.miniplayer-hidden { padding-bottom: env(safe-area-inset-bottom); }

img { max-width: 100%; display: block; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; cursor: pointer; border: 0; background: transparent; color: inherit; }
:focus-visible { outline: 3px solid var(--brand-2); outline-offset: 2px; border-radius: 4px; }

.skip-link {
  position: absolute; left: -1000px; top: 0;
  background: var(--brand); color: #fff; padding: .5rem 1rem; z-index: 200;
}
.skip-link:focus { left: 0; }

/* ------------------ TOPBAR ------------------ */

.topbar {
  position: sticky; top: 0; z-index: 50;
  height: var(--topbar-h);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--s-3);
  padding: 0 var(--s-4);
  padding-top: env(safe-area-inset-top);
  height: calc(var(--topbar-h) + env(safe-area-inset-top));
  background: var(--bg-dark);
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.topbar__menu {
  width: 40px; height: 40px; border-radius: 8px;
  display: inline-grid; place-items: center;
  color: #fff;
}
.topbar__menu:hover { background: rgba(255,255,255,.08); }
.topbar__brand {
  display: inline-flex; align-items: center; gap: .65rem;
  color: #fff; text-decoration: none;
}
.topbar__brand img { filter: brightness(0) invert(1); }
.topbar__brand-text { display: flex; flex-direction: column; line-height: 1; }
.topbar__brand-name { font-family: var(--font-serif); font-weight: 700; letter-spacing: .04em; font-size: 1.05rem; }
.topbar__brand-sub { font-size: .68rem; letter-spacing: .14em; text-transform: uppercase; color: rgba(255,255,255,.7); margin-top: 3px; }

.topbar__live {
  display: inline-flex; align-items: center; gap: .45rem;
  background: var(--live); color: #fff; font-weight: 600; font-size: .8rem;
  padding: .45rem .8rem; border-radius: 999px;
  letter-spacing: .04em;
}
.topbar__live:hover { filter: brightness(1.06); }
.live-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 0 rgba(255,255,255,.7);
  animation: pulse 1.6s ease-out infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(255,255,255,.6); }
  70%  { box-shadow: 0 0 0 8px rgba(255,255,255,0); }
  100% { box-shadow: 0 0 0 0 rgba(255,255,255,0); }
}

/* ------------------ SIDENAV ------------------ */

.sidenav {
  position: fixed; left: 0; top: 0; bottom: 0;
  width: 280px; max-width: 86vw;
  background: var(--bg-dark); color: #fff;
  padding: calc(var(--topbar-h) + env(safe-area-inset-top) + var(--s-4)) var(--s-4) var(--s-6);
  z-index: 60;
  transform: translateX(-100%);
  transition: transform .25s ease;
  overflow-y: auto;
}
.sidenav.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
.sidenav a {
  display: block;
  color: #fff;
  text-decoration: none;
  padding: .85rem .9rem;
  border-radius: 10px;
  font-weight: 500;
  font-size: .98rem;
}
.sidenav a:hover { background: rgba(255,255,255,.06); text-decoration: none; }
.sidenav a.active { background: rgba(110,193,228,.18); color: var(--brand-2); }

.sidenav__scrim {
  position: fixed; inset: 0;
  background: rgba(15,42,71,.55);
  z-index: 55;
}

/* ------------------ MAIN ------------------ */

.main { min-height: calc(100vh - var(--topbar-h)); }
.view {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: var(--s-5) var(--s-4) var(--s-7);
}
@media (min-width: 720px) {
  .view { padding: var(--s-6) var(--s-5) var(--s-8); }
}

/* ------------------ TYPOGRAPHY ------------------ */

.eyebrow {
  font-family: var(--font-sans);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--accent-rust);
}
.h-display {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: clamp(1.9rem, 4.6vw, 3rem);
  line-height: 1.05;
  letter-spacing: -.01em;
  margin: .25rem 0 .5rem;
}
.h-section {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1.55rem;
  letter-spacing: -.005em;
  margin: var(--s-7) 0 var(--s-3);
  display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3);
}
.h-section .more { font-family: var(--font-sans); font-size: .82rem; font-weight: 600; color: var(--brand); letter-spacing: .04em; text-transform: uppercase; }
.deck {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  line-height: 1.45;
  color: var(--ink-mute);
}
.byline {
  font-family: var(--font-sans);
  font-size: .82rem;
  color: var(--ink-mute);
  display: flex; flex-wrap: wrap; gap: .4rem var(--s-3); align-items: center;
}
.byline .dot { width: 3px; height: 3px; background: var(--ink-faint); border-radius: 50%; display: inline-block; }

/* ------------------ HERO ------------------ */

.hero {
  display: grid; gap: var(--s-5);
  border-bottom: 1px solid var(--rule);
  padding-bottom: var(--s-6);
}
@media (min-width: 880px) {
  .hero { grid-template-columns: 1.2fr .9fr; gap: var(--s-7); align-items: center; }
}
.hero__art {
  aspect-ratio: 4/3;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--brand), #1a3e69 60%, var(--accent-rust));
  display: grid; place-items: center;
  color: rgba(255,255,255,.92);
  position: relative; overflow: hidden;
  box-shadow: var(--shadow-md);
}
.hero__art svg { width: 60%; height: 60%; opacity: .85; }

.hero__listen {
  display: inline-flex; align-items: center; gap: .55rem;
  background: var(--brand); color: #fff;
  padding: .8rem 1.1rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: .92rem;
  letter-spacing: .02em;
  margin-top: var(--s-4);
  box-shadow: var(--shadow-sm);
}
.hero__listen:hover { background: #143257; text-decoration: none; }
.hero__listen svg { width: 18px; height: 18px; }

/* ------------------ CARDS ------------------ */

.cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s-5);
}
@media (min-width: 640px) { .cards { grid-template-columns: 1fr 1fr; } }
@media (min-width: 980px) { .cards.cards--3 { grid-template-columns: 1fr 1fr 1fr; } }

.card {
  background: var(--bg-elev);
  border-radius: 10px;
  overflow: hidden;
  display: flex; flex-direction: column;
  border: 1px solid var(--rule);
  transition: transform .15s ease, box-shadow .15s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.card__art {
  aspect-ratio: 16/10;
  background: var(--bg-dark);
  position: relative;
  overflow: hidden;
}
.card__art::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0) 60%, rgba(0,0,0,.25));
}
.card__art svg, .card__art img { width: 100%; height: 100%; object-fit: cover; }
.card__body { padding: var(--s-4); display: flex; flex-direction: column; gap: var(--s-2); flex: 1; }
.card__cat { font-size: .7rem; letter-spacing: .16em; text-transform: uppercase; color: var(--accent-rust); font-weight: 700; }
.card__title { font-family: var(--font-serif); font-weight: 700; font-size: 1.15rem; line-height: 1.25; color: var(--ink); margin: 0; }
.card__title a { color: inherit; }
.card__title a:hover { color: var(--brand); text-decoration: none; }
.card__excerpt { color: var(--ink-mute); font-size: .92rem; line-height: 1.5; margin: 0; }
.card__meta { margin-top: auto; display: flex; justify-content: space-between; align-items: center; gap: var(--s-3); font-size: .8rem; color: var(--ink-mute); }
.card__listen {
  display: inline-flex; align-items: center; gap: .35rem;
  font-weight: 600; color: var(--brand);
}
.card__listen svg { width: 16px; height: 16px; }

/* Compact list rows for episodes/articles */
.row {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: var(--s-3);
  padding: var(--s-3) 0;
  border-bottom: 1px solid var(--rule);
  align-items: center;
}
.row__art { width: 64px; height: 64px; border-radius: 6px; overflow: hidden; background: var(--bg-dark); }
.row__art svg, .row__art img { width: 100%; height: 100%; object-fit: cover; }
.row__title { font-family: var(--font-serif); font-weight: 600; font-size: 1.02rem; line-height: 1.25; }
.row__title a { color: var(--ink); }
.row__title a:hover { color: var(--brand); text-decoration: none; }
.row__sub { font-size: .82rem; color: var(--ink-mute); margin-top: 2px; }
.row__play { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--brand); color: #fff; }
.row__play:hover { background: #143257; }
.row__play svg { width: 18px; height: 18px; }

/* ------------------ CHIPS / FILTERS ------------------ */

.chips { display: flex; flex-wrap: wrap; gap: var(--s-2); margin: var(--s-3) 0 var(--s-5); }
.chip {
  display: inline-flex; align-items: center; gap: .35rem;
  background: var(--bg-elev); border: 1px solid var(--rule);
  border-radius: 999px;
  padding: .4rem .85rem;
  font-size: .85rem;
  color: var(--ink);
  text-decoration: none;
}
.chip:hover { border-color: var(--brand); text-decoration: none; }
.chip.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.chip__count { font-size: .72rem; opacity: .7; }

/* ------------------ ARTICLE READER ------------------ */

.article {
  max-width: 720px;
  margin: 0 auto;
}
.article__hero {
  margin-bottom: var(--s-5);
}
.article__hero .deck { margin-top: var(--s-3); }
.article__meta { margin-top: var(--s-4); display: flex; flex-wrap: wrap; gap: var(--s-3); align-items: center; }

.article__listen-bar {
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-left: 4px solid var(--brand-warm);
  border-radius: 8px;
  padding: var(--s-4);
  margin: var(--s-5) 0;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: var(--s-3);
  align-items: center;
}
.article__listen-bar .label { font-size: .75rem; color: var(--ink-mute); letter-spacing: .12em; text-transform: uppercase; font-weight: 700; }
.article__listen-bar .listen-status { font-family: var(--font-serif); font-size: .98rem; color: var(--ink); }
.article__listen-bar .play {
  width: 48px; height: 48px; border-radius: 50%; background: var(--brand); color: #fff;
  display: grid; place-items: center;
}
.article__listen-bar .play svg { width: 22px; height: 22px; }
.article__listen-bar .play:hover { background: #143257; }
.article__listen-bar .speed {
  background: transparent; border: 1px solid var(--rule);
  padding: .35rem .55rem; border-radius: 6px;
  font-size: .82rem; font-weight: 600; color: var(--ink);
}
.article__listen-bar .speed:hover { border-color: var(--brand); }
.article__listen-bar .controls { display: inline-flex; gap: .35rem; align-items: center; }

.article__body {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  line-height: 1.75;
  color: var(--ink);
}
.article__body p { margin: 0 0 1.2em; }
.article__body p[data-tts-active="true"] {
  background: linear-gradient(transparent 65%, rgba(110,193,228,.45) 65%);
  border-radius: 2px;
}

/* ------------------ SCHEDULE ------------------ */

.schedule { display: grid; gap: var(--s-5); }
.schedule__day {
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-radius: 10px;
  overflow: hidden;
}
.schedule__day h3 {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  margin: 0;
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--rule);
  background: linear-gradient(180deg, var(--bg-elev), var(--bg));
}
.schedule__slot {
  display: grid;
  grid-template-columns: 90px 1fr auto;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--rule);
  align-items: center;
}
.schedule__slot:last-child { border-bottom: 0; }
.schedule__slot.now { background: linear-gradient(90deg, rgba(216,31,42,.07), transparent 50%); }
.schedule__time { font-family: var(--font-sans); font-weight: 600; color: var(--brand); }
.schedule__time .end { display: block; color: var(--ink-faint); font-weight: 400; font-size: .82rem; }
.schedule__title { font-family: var(--font-serif); font-weight: 600; font-size: 1.02rem; }
.schedule__sub { font-size: .82rem; color: var(--ink-mute); margin-top: 2px; }
.schedule__badge { font-size: .68rem; color: var(--live); font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }

/* ------------------ MINI-PLAYER ------------------ */

.miniplayer {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 70;
  background: var(--bg-dark);
  color: #fff;
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: var(--s-3);
  align-items: center;
  padding: var(--s-2) var(--s-4);
  padding-bottom: calc(var(--s-2) + env(safe-area-inset-bottom));
  min-height: var(--mini-h);
  box-shadow: 0 -8px 30px rgba(0,0,0,.25);
}
.miniplayer__art {
  width: 48px; height: 48px; border-radius: 6px; overflow: hidden;
  background: rgba(255,255,255,.08);
}
.miniplayer__art img { width: 100%; height: 100%; object-fit: cover; }
.miniplayer__meta { min-width: 0; }
.miniplayer__title {
  font-family: var(--font-serif); font-weight: 600; font-size: .95rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.miniplayer__sub {
  font-size: .78rem; color: rgba(255,255,255,.7);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px;
}
.miniplayer__progress {
  margin-top: 6px;
  height: 3px; background: rgba(255,255,255,.16); border-radius: 2px; overflow: hidden;
}
.miniplayer__bar { height: 100%; width: 0%; background: var(--brand-2); transition: width .25s linear; }
.miniplayer__controls { display: inline-flex; gap: .15rem; align-items: center; }

.iconbtn {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  color: #fff;
}
.iconbtn:hover { background: rgba(255,255,255,.08); }
.iconbtn--primary {
  background: var(--brand-2); color: var(--bg-dark); width: 44px; height: 44px;
}
.iconbtn--primary:hover { background: #8acef0; }

/* ------------------ MISC ------------------ */

.spinner {
  width: 32px; height: 32px; border-radius: 50%;
  border: 3px solid var(--rule); border-top-color: var(--brand);
  animation: spin .9s linear infinite;
  margin: var(--s-7) auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty {
  text-align: center;
  padding: var(--s-7) var(--s-4);
  color: var(--ink-mute);
}
.empty .h-section { justify-content: center; }

.tag-list { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: var(--s-3); }
.tag { font-size: .72rem; padding: .25rem .55rem; border: 1px solid var(--rule); border-radius: 4px; color: var(--ink-mute); }

.btn-row { display: inline-flex; gap: var(--s-2); margin-top: var(--s-3); flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  background: var(--bg-elev); border: 1px solid var(--rule);
  padding: .55rem .9rem; border-radius: 8px;
  font-weight: 600; font-size: .88rem; color: var(--ink);
}
.btn:hover { border-color: var(--brand); text-decoration: none; }
.btn.btn--primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.btn--primary:hover { background: #143257; }
.btn.btn--ghost { background: transparent; }
.btn svg { width: 16px; height: 16px; }

.pillrow { display: flex; gap: var(--s-2); flex-wrap: wrap; }
.pill {
  display: inline-flex; align-items: center; gap: .35rem;
  background: rgba(15,42,71,.06);
  border-radius: 999px; padding: .25rem .6rem;
  font-size: .76rem; color: var(--ink-mute); font-weight: 600;
}

.live-banner {
  background: var(--bg-dark); color: #fff;
  border-radius: 12px;
  padding: var(--s-5);
  display: grid; gap: var(--s-3);
  position: relative; overflow: hidden;
}
.live-banner::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(900px 200px at 90% -10%, rgba(110,193,228,.35), transparent 60%);
  pointer-events: none;
}
.live-banner__head { display: inline-flex; align-items: center; gap: .55rem; font-size: .8rem; letter-spacing: .12em; text-transform: uppercase; opacity: .88; }
.live-banner__title { font-family: var(--font-serif); font-size: 1.4rem; font-weight: 700; }
.live-banner__next { font-size: .88rem; opacity: .8; }

.audio-fallback {
  background: var(--bg-elev);
  padding: var(--s-3);
  border-radius: 8px;
  border: 1px solid var(--rule);
}
.audio-fallback audio { width: 100%; }
.audio-fallback .hint { font-size: .8rem; color: var(--ink-mute); margin-top: .5rem; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--mini-h) + 16px); transform: translateX(-50%);
  background: var(--bg-dark); color: #fff;
  padding: .65rem 1rem; border-radius: 999px;
  font-size: .85rem;
  box-shadow: var(--shadow-lg);
  z-index: 80;
  opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, -6px); }

/* Side-nav stays open on wide screens */
@media (min-width: 980px) {
  .topbar__menu { display: none; }
  .sidenav { transform: translateX(0); width: 240px; box-shadow: none; border-right: 1px solid var(--rule); background: var(--bg); color: var(--ink); }
  .sidenav a { color: var(--ink); }
  .sidenav a:hover { background: rgba(15,42,71,.06); }
  .sidenav a.active { background: rgba(15,42,71,.1); color: var(--brand); }
  .sidenav__scrim { display: none !important; }
  .main { margin-left: 240px; }
  .topbar { padding-left: 240px; }
}
