/* Podcast player. Theme by overriding the variables, e.g.
   .podcastplayer { --pp-accent: #e4572e; --pp-bg: #111; } */

.podcastplayer {
  --pp-h: 80px;                         /* bar height */
  --pp-bg: #333;                        /* bar colour without artwork */
  --pp-tint: #3e4458;                   /* tint under blurred artwork */
  --pp-fg: #fff;
  --pp-dim: rgba(255, 255, 255, .6);
  --pp-accent: #2a0f09;                 /* played bar, handles, pressed icons */
  --pp-track: rgba(155, 155, 155, .35);
  --pp-buf: rgba(255, 255, 255, .5);
  --pp-z: 1200;
  --pp-p: 0; --pp-b: 0; --pp-v: 1;      /* set by JS: played, buffered, volume (0–1) */

  position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--pp-z);
  display: flex; align-items: center; gap: 4px;
  height: var(--pp-h);
  padding: 0 12px env(safe-area-inset-bottom, 0);
  background: var(--pp-bg); color: var(--pp-fg);
  font-size: 14px; font-weight: 600; line-height: 1.3;
  text-align: left; text-transform: none; letter-spacing: normal;
  animation: pp-in .25s ease-out;
}
.podcastplayer[hidden] { display: none; }
.podcastplayer * { box-sizing: border-box; }
html.podcastplayer-open body { padding-bottom: 80px; }   /* keep content clear of the bar */

@keyframes pp-in { from { transform: translateY(100%); } }
@keyframes pp-spin { to { transform: rotate(360deg); } }

/* Blurred artwork */
.pp-art { position: absolute; inset: 0; z-index: -1; overflow: hidden; background: var(--pp-tint); pointer-events: none; }
.pp-art::before { content: ""; position: absolute; inset: -30px; background: var(--pp-art) center / cover; filter: blur(10px); opacity: .5; }
.podcastplayer:not(.has-art) .pp-art { display: none; }

/* Buttons */
/* :where() keeps these base rules low-specificity so .pp-* classes override them */
:where(.podcastplayer) button {
  position: relative; display: grid; place-items: center; flex: none;
  width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%;
  background: none; color: inherit; cursor: pointer;
  transition: opacity .1s, color .1s; -webkit-tap-highlight-color: transparent;
}
:where(.podcastplayer) button:hover { opacity: .8; }
:where(.podcastplayer) button:active { color: var(--pp-accent); }
.podcastplayer :focus { outline: 0; }
.podcastplayer :focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
:where(.podcastplayer) svg { width: 26px; height: 26px; pointer-events: none; transition: opacity .1s; }

/* Play / pause / loading spinner */
.pp-play { width: 52px; height: 52px; }
.pp-play svg { width: 48px; height: 48px; }
.pp-q, .is-playing .pp-p { display: none; }
.is-playing .pp-q { display: inline; }
.is-loading .pp-play svg { opacity: 0; }
.pp-play::before, .pp-play::after {
  content: ""; position: absolute; inset: 0; margin: auto; opacity: 0; transition: opacity .15s;
  border: 5px solid rgba(255, 255, 255, .5); border-top-color: #fff; border-left-color: #fff; border-radius: 50%;
}
.pp-play::before { width: 14px; height: 14px; animation: pp-spin .8s linear infinite; }
.pp-play::after { width: 34px; height: 34px; animation: pp-spin 1.2s cubic-bezier(.68, -.55, .265, 1.55) infinite; }
.is-loading .pp-play::before, .is-loading .pp-play::after { opacity: 1; }

/* Mute + close */
.pp-mute svg { grid-area: 1 / 1; }
.pp-mute svg + svg, .is-muted .pp-mute svg:first-child { opacity: 0; }
.is-muted .pp-mute svg + svg { opacity: 1; }
.pp-close { width: 36px; height: 36px; opacity: .6; }
.pp-close:hover { opacity: 1; }
.pp-close svg { width: 20px; height: 20px; }

/* Title + time */
.pp-info { flex: 1; min-width: 0; margin: 0 8px; }
.pp-title { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-weight: 700; }
.pp-title a { color: inherit; text-decoration: none; }
.pp-title a:hover { text-decoration: underline; }
.has-error .pp-title { opacity: .6; }
.pp-row { display: flex; align-items: center; gap: 12px; }
.pp-time { font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--pp-dim); }
.pp-time span:first-child { color: var(--pp-fg); }

/* Seek bar: one element. Layers = played, buffered, track; ::after = handle */
.pp-seek {
  position: relative; flex: 1; height: 22px; cursor: pointer; touch-action: none;
  background:
    linear-gradient(var(--pp-accent) 0 0) 0 50% / calc(var(--pp-p) * 100%) 4px no-repeat,
    linear-gradient(var(--pp-buf) 0 0) 0 50% / calc(var(--pp-b) * 100%) 4px no-repeat,
    linear-gradient(var(--pp-track) 0 0) 0 50% / 100% 4px no-repeat;
}
.podcastplayer:not(.is-loaded) .pp-seek { cursor: default; }
.pp-seek::after {
  content: ""; position: absolute; top: 50%; left: calc(var(--pp-p) * 100%);
  width: 16px; height: 16px; margin: -8px; border-radius: 50%;
  background: var(--pp-accent); box-shadow: 0 0 0 2px #fff;
  transform: scale(0); transition: transform .15s;
}
.is-loaded .pp-seek:hover::after, .is-loaded .pp-seek:focus-visible::after, .is-scrubbing .pp-seek::after { transform: none; }
@media (hover: none) { .is-loaded .pp-seek::after { transform: none; } }

/* Volume: one element, slides open from the mute button. 10px inset each side */
.pp-vol {
  position: relative; flex: none; width: 0; height: 44px; overflow: hidden; cursor: pointer; touch-action: none;
  transition: width .3s cubic-bezier(.4, .4, .265, .99);
  background:
    linear-gradient(var(--pp-fg) 0 0) 10px 50% / calc((100% - 20px) * var(--pp-v)) 3px no-repeat,
    linear-gradient(rgba(255, 255, 255, .25) 0 0) 10px 50% / calc(100% - 20px) 3px no-repeat;
}
.pp-vol::after {
  content: ""; position: absolute; top: 50%; left: calc(10px + (100% - 20px) * var(--pp-v));
  width: 14px; height: 14px; margin: -7px; border-radius: 50%;
  background: var(--pp-accent); box-shadow: 0 0 0 2px var(--pp-fg);
}
.pp-vol:hover, .pp-vol:focus, .pp-vol:has(+ .pp-mute:hover, + .pp-mute:focus-visible) {
  width: 90px; transition-timing-function: cubic-bezier(.4, .4, .265, 1.55);
}

/* Screen-reader announcements */
.pp-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* Phones: seek bar along the top edge, no volume (iOS ignores it) */
@media (max-width: 800px) {
  .podcastplayer { --pp-h: 72px; gap: 0; padding: 0 6px env(safe-area-inset-bottom, 0) 4px; }
  html.podcastplayer-open body { padding-bottom: 72px; }
  :where(.podcastplayer) svg { width: 24px; height: 24px; }
  .pp-rw, .pp-ff { width: 40px; }
  .pp-seek { position: absolute; left: 0; right: 0; top: -11px; }
  .pp-row { display: block; }
  .pp-vol, .pp-mute { display: none; }
}

@media (min-width: 801px) {
  .podcastplayer { gap: 10px; padding: 0 20px env(safe-area-inset-bottom, 0) 16px; }
  .pp-play { width: 58px; height: 58px; }
  .pp-play svg { width: 54px; height: 54px; }
  .pp-rw svg, .pp-ff svg { width: 30px; height: 30px; }
  .pp-info { margin: 0 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .podcastplayer, .podcastplayer *, .podcastplayer ::after { animation-duration: 2s; transition: none !important; }
  .podcastplayer { animation: none; }
}
