/* Listen player for Insights articles. Markup comes from
   scripts/generate_post_pages.py (audio_player_html); behaviour from article-audio.js. */
.ac-listen {
  --ls-red: var(--accent, #E31B23);
  display: flex; align-items: center; gap: 16px;
  margin: 30px 0 0; padding: 12px 16px 12px 12px;
  max-width: 560px;
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(255,255,255,0.045), rgba(255,255,255,0.015));
  backdrop-filter: blur(6px);
  position: relative;
  transition: border-color .2s, box-shadow .3s;
}
.ac-listen:hover { border-color: rgba(255,255,255,0.18); }
.ac-listen.is-on { border-color: rgba(227,27,35,0.45); box-shadow: 0 18px 50px -24px rgba(227,27,35,0.55); }

.ac-listen__play {
  flex-shrink: 0; width: 52px; height: 52px; border-radius: 50%;
  border: 0; cursor: pointer; display: grid; place-items: center;
  background: var(--ls-red); color: #fff;
  box-shadow: 0 8px 26px -8px rgba(227,27,35,0.7);
  transition: transform .15s, background .15s;
  position: relative;
}
.ac-listen__play:hover { transform: scale(1.06); background: var(--accent-hover, #FF2A33); }
.ac-listen__play:focus-visible { outline: 3px solid rgba(227,27,35,0.55); outline-offset: 3px; }
.ac-listen__play svg { width: 20px; height: 20px; fill: currentColor; }
.ac-listen__play .i-pause, .ac-listen.is-playing .ac-listen__play .i-play { display: none; }
.ac-listen.is-playing .ac-listen__play .i-pause { display: block; }
.ac-listen.is-loading .ac-listen__play::after {
  content: ""; position: absolute; inset: -4px; border-radius: 50%;
  border: 2px solid transparent; border-top-color: #fff; animation: ac-ls-rot .8s linear infinite;
}
@keyframes ac-ls-rot { to { transform: rotate(360deg); } }

.ac-listen__body { flex: 1; min-width: 0; }
.ac-listen__row { display: flex; align-items: center; gap: 10px; }
.ac-listen__label {
  font: 600 11px/1 var(--font-mono, 'JetBrains Mono', monospace);
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--fg1, #fff);
}
.ac-listen__time {
  margin-left: auto; font: 500 11.5px/1 var(--font-mono, monospace);
  color: var(--fg2, #A8B0BA); font-variant-numeric: tabular-nums; white-space: nowrap;
}
.ac-listen__sub {
  margin-top: 7px; font-size: 12.5px; line-height: 1.35; color: var(--fg3, #7A828C);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ac-listen__sub b { color: var(--fg2, #A8B0BA); font-weight: 600; }

.ac-listen__eq { display: inline-flex; gap: 2px; align-items: flex-end; height: 12px; }
.ac-listen__eq i { width: 2px; height: 30%; border-radius: 2px; background: var(--ls-red); opacity: .55; }
.ac-listen.is-playing .ac-listen__eq i { opacity: 1; animation: ac-ls-eq .9s ease-in-out infinite; }
.ac-listen__eq i:nth-child(2) { animation-delay: -.35s !important; }
.ac-listen__eq i:nth-child(3) { animation-delay: -.7s !important; }
.ac-listen__eq i:nth-child(4) { animation-delay: -.2s !important; }
.ac-listen__eq i:nth-child(5) { animation-delay: -.55s !important; }
@keyframes ac-ls-eq { 0%, 100% { height: 25%; } 50% { height: 100%; } }

.ac-listen__seek {
  -webkit-appearance: none; appearance: none; display: none;
  width: 100%; height: 4px; margin: 10px 0 2px; border-radius: 4px; cursor: pointer; outline: none;
  background: linear-gradient(90deg, var(--ls-red) var(--ls-p, 0%), rgba(255,255,255,0.12) var(--ls-p, 0%));
}
.ac-listen.is-on .ac-listen__seek { display: block; }
.ac-listen__seek::-webkit-slider-thumb { -webkit-appearance: none; width: 13px; height: 13px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 3px rgba(227,27,35,0.35); }
.ac-listen__seek::-moz-range-thumb { width: 13px; height: 13px; border: 0; border-radius: 50%; background: #fff; }
.ac-listen__seek:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px rgba(227,27,35,0.7); }

.ac-listen__ctrl { display: none; gap: 6px; flex-shrink: 0; }
.ac-listen.is-on .ac-listen__ctrl { display: flex; }
.ac-listen__btn {
  height: 30px; min-width: 40px; padding: 0 9px; border-radius: 8px; cursor: pointer;
  border: 1px solid rgba(255,255,255,0.12); background: rgba(255,255,255,0.03); color: var(--fg2, #A8B0BA);
  font: 600 11px/1 var(--font-mono, monospace); font-variant-numeric: tabular-nums;
}
.ac-listen__btn:hover { color: #fff; border-color: rgba(255,255,255,0.25); }
.ac-listen__btn:focus-visible { outline: 2px solid rgba(227,27,35,0.6); outline-offset: 2px; }

/* ---- sticky mini player ---- */
.ac-listen-mini {
  position: fixed; left: 50%; bottom: 18px; z-index: 900;
  width: min(640px, calc(100vw - 24px));
  transform: translate(-50%, calc(100% + 30px)); opacity: 0; pointer-events: none;
  display: flex; align-items: center; gap: 12px; padding: 10px 14px 10px 10px;
  border-radius: 16px; border: 1px solid rgba(255,255,255,0.12);
  background: rgba(14,16,20,0.92); backdrop-filter: blur(14px);
  box-shadow: 0 24px 60px -16px rgba(0,0,0,0.85);
  transition: transform .35s cubic-bezier(.2,.8,.2,1), opacity .25s;
  overflow: hidden;
}
.ac-listen-mini.is-shown { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; }
.ac-listen-mini .ac-listen__play { width: 42px; height: 42px; }
.ac-listen-mini .ac-listen__play svg { width: 16px; height: 16px; }
.ac-listen-mini__txt { flex: 1; min-width: 0; }
.ac-listen-mini__t { font-weight: 700; font-size: 13.5px; color: var(--fg1, #fff); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ac-listen-mini__c { font: 500 11px/1.4 var(--font-mono, monospace); color: var(--fg3, #7A828C); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.ac-listen-mini__bar { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: rgba(255,255,255,0.06); }
.ac-listen-mini__bar i { display: block; height: 100%; width: 0; background: var(--ls-red); box-shadow: 0 0 10px rgba(227,27,35,0.8); }
.ac-listen-mini__x { background: none; border: 0; color: var(--fg3, #7A828C); cursor: pointer; font-size: 16px; padding: 6px; line-height: 1; }
.ac-listen-mini__x:hover { color: #fff; }

@media (max-width: 600px) {
  .ac-listen { gap: 12px; padding: 10px 12px 10px 10px; }
  .ac-listen__play { width: 46px; height: 46px; }
  .ac-listen__label { letter-spacing: 0.08em; font-size: 10.5px; white-space: nowrap; }
  .ac-listen__eq { display: none; }
  .ac-listen.is-playing .ac-listen__eq { display: inline-flex; }
  .ac-listen.is-on .ac-listen__label { display: none; }
  .ac-listen.is-on .ac-listen__time { margin-left: 0; }
  .ac-listen.is-on { flex-wrap: wrap; }
  .ac-listen.is-on .ac-listen__ctrl { width: 100%; justify-content: flex-end; }
  .ac-listen-mini .ac-listen__btn { display: none; }
  /* leave the bottom-right corner to the Future voice-agent avatar */
  .ac-listen-mini { left: 12px; right: 118px; width: auto; transform: translateY(calc(100% + 30px)); }
  .ac-listen-mini.is-shown { transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .ac-listen.is-playing .ac-listen__eq i { animation: none; height: 70%; }
  .ac-listen-mini { transition: none; }
}

/* ---- chapters ---- */
.ac-listen__track { position: relative; }
.ac-listen__tick {
  position: absolute; top: 10px; width: 2px; height: 4px; margin-left: -1px; pointer-events: none;
  background: rgba(11,13,16,0.9); border-radius: 1px;
}
.ac-listen__chap {
  display: inline-flex; align-items: center; gap: 4px; max-width: 100%;
  margin: 0; padding: 0; border: 0; background: none; cursor: pointer;
  font: inherit; color: var(--fg3, #7A828C); text-align: left;
}
.ac-listen__chap b { color: var(--fg2, #A8B0BA); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ac-listen__chap:hover b, .ac-listen__chap[aria-expanded="true"] b { color: #fff; }
.ac-listen__caret { color: var(--ls-red, #E31B23); font-size: 11px; transition: transform .2s; }
.ac-listen__chap[aria-expanded="true"] .ac-listen__caret { transform: rotate(180deg); }
.ac-listen__chap:focus-visible { outline: 2px solid rgba(227,27,35,0.6); outline-offset: 3px; border-radius: 4px; }

.ac-listen-menu {
  position: fixed; z-index: 2147483000; max-height: min(60vh, 440px); overflow: auto;
  border: 1px solid rgba(255,255,255,0.12); border-radius: 16px;
  background: rgba(14,16,20,0.97); backdrop-filter: blur(14px);
  box-shadow: 0 24px 60px -16px rgba(0,0,0,0.9);
  animation: ac-ls-in .18s ease;
}
.ac-listen-menu[hidden] { display: none; }
@keyframes ac-ls-in { from { opacity: 0; transform: translateY(-4px); } }
.ac-listen-menu__head {
  position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px 10px 18px; background: rgba(14,16,20,0.97);
  font: 600 10.5px/1 var(--font-mono, monospace); letter-spacing: 0.18em; text-transform: uppercase; color: var(--fg3, #7A828C);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.ac-listen-menu__x { background: none; border: 0; color: var(--fg3, #7A828C); cursor: pointer; font-size: 15px; padding: 4px 6px; }
.ac-listen-menu__x:hover { color: #fff; }
.ac-listen-menu ol { list-style: none; margin: 0; padding: 6px; }
.ac-listen-menu li { margin: 0; }
.ac-listen-menu [data-ch] {
  display: flex; align-items: baseline; gap: 14px; width: 100%; padding: 10px 12px; border: 0; border-radius: 10px;
  background: none; cursor: pointer; text-align: left; font: 500 14px/1.4 var(--font-sans, inherit); color: var(--fg2, #A8B0BA);
}
.ac-listen-menu [data-ch]:hover, .ac-listen-menu [data-ch]:focus-visible { background: rgba(255,255,255,0.05); color: #fff; outline: none; }
.ac-listen-menu__t { flex-shrink: 0; min-width: 44px; font: 500 12px var(--font-mono, monospace); color: var(--fg3, #7A828C); font-variant-numeric: tabular-nums; }
.ac-listen-menu .is-now { color: #fff; background: rgba(227,27,35,0.10); }
.ac-listen-menu .is-now .ac-listen-menu__t { color: var(--ls-red, #E31B23); }

/* bottom sheet (phones, and when opened from the mini player) */
.ac-listen-menu.is-sheet {
  left: 50%; bottom: 92px; top: auto; width: min(560px, calc(100vw - 24px)); transform: translateX(-50%);
  animation: ac-ls-up .22s ease;
}
@keyframes ac-ls-up { from { opacity: 0; transform: translate(-50%, 10px); } }
.ac-listen-mini__c.is-link { cursor: pointer; }
.ac-listen-mini__c.is-link:hover { color: #fff; }
@media (max-width: 600px) {
  .ac-listen-menu.is-sheet { left: 12px; right: 12px; width: auto; transform: none; bottom: 12px; max-height: 70vh; border-radius: 18px; }
  @keyframes ac-ls-up { from { opacity: 0; transform: translateY(10px); } }
  .ac-listen-sheet-open .ac-listen-mini { opacity: 0; pointer-events: none; }
  .ac-listen-menu [data-ch] { padding: 13px 12px; }
}
@media (prefers-reduced-motion: reduce) { .ac-listen-menu, .ac-listen-menu.is-sheet { animation: none; } }
