/* TraPay blog audio player — "listen to this article".
 * Two-row card: [label + time] over [progress bar] over [speed · transport].
 * Brand-blue, soft depth, scoped under #tp-audio. RTL-correct.
 * Accessible: 44px targets, visible focus, reduced-motion aware. */

#tp-audio {
  direction: rtl;
  max-width: 44rem;
  margin: 1.5rem auto 0;
  padding: 10px 14px;
  border: 1px solid color-mix(in srgb, var(--brand) 14%, transparent);
  border-radius: 14px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--brand) 5%, #fff), var(--brand-50));
  box-shadow: 0 1px 2px rgba(13,62,126,.04), 0 4px 14px rgba(13,62,126,.05);
}

#tp-audio .tpa-row { display: flex; align-items: center; }

/* ---- Row 1: label (right) + time (left) ---- */
#tp-audio .tpa-top { justify-content: space-between; margin-bottom: 7px; gap: 10px; }
#tp-audio .tpa-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: .82rem;
  font-weight: 600;
  color: var(--brand);
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#tp-audio .tpa-time {
  direction: ltr;
  unicode-bidi: isolate;
  font-variant-numeric: tabular-nums;
  font-size: .8rem;
  color: var(--muted);
  white-space: nowrap;
}

/* equalizer bars (animate only while playing) */
#tp-audio .tpa-eq { display: inline-flex; gap: 2px; height: 14px; align-items: flex-end; opacity: .35; }
#tp-audio.is-playing .tpa-eq { opacity: 1; }
#tp-audio .tpa-eq span {
  width: 3px; height: 40%;
  background: var(--brand); border-radius: 2px;
}
#tp-audio.is-playing .tpa-eq span { animation: tpa-eq .9s ease-in-out infinite; }
#tp-audio.is-playing .tpa-eq span:nth-child(2) { animation-delay: .15s; }
#tp-audio.is-playing .tpa-eq span:nth-child(3) { animation-delay: .3s; }
@keyframes tpa-eq { 0%,100% { height: 30%; } 50% { height: 100%; } }

/* ---- Progress track (full width, seekable) ---- */
#tp-audio .tpa-track {
  position: relative;
  height: 18px;              /* hit area */
  display: flex;
  align-items: center;
  cursor: pointer;
  touch-action: none;
  outline: none;
  margin-bottom: 8px;
}
#tp-audio .tpa-track::before {  /* rail */
  content: "";
  position: absolute;
  inset-inline: 0;
  height: 5px;
  border-radius: 5px;
  background: color-mix(in srgb, var(--brand) 16%, transparent);
}
#tp-audio .tpa-fill {
  position: absolute;
  inset-inline-start: 0;      /* RTL: grows from the right */
  height: 5px;
  width: 0;
  border-radius: 5px;
  background: var(--brand);
}
#tp-audio .tpa-knob {
  position: absolute;
  inset-inline-start: 0;
  width: 13px; height: 13px;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 3px #fff, 0 1px 4px rgba(13,62,126,.3);
  transform: translateX(50%);
  transition: transform .1s ease;
}
#tp-audio .tpa-track:hover .tpa-knob,
#tp-audio .tpa-track:focus-visible .tpa-knob { transform: translateX(50%) scale(1.25); }
#tp-audio .tpa-track:focus-visible::before { box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 32%, transparent); }

/* ---- Row 2: speed | transport | spacer (transport stays centered) ---- */
#tp-audio .tpa-controls { justify-content: space-between; }
#tp-audio .tpa-speed, #tp-audio .tpa-spacer { flex: 0 0 46px; }
#tp-audio .tpa-spacer { visibility: hidden; }

#tp-audio .tpa-transport {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

/* play/pause — the focal control */
#tp-audio .tpa-btn {
  flex: 0 0 auto;
  width: 40px; height: 40px;
  border: 0; border-radius: 50%;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  display: grid; place-items: center;
  box-shadow: 0 3px 9px rgba(13,62,126,.24);
  transition: transform .15s ease, filter .15s ease;
}
#tp-audio .tpa-btn:hover { filter: brightness(1.08); }
#tp-audio .tpa-btn:active { transform: scale(.95); }
#tp-audio .tpa-btn:focus-visible { outline: 3px solid var(--brand); outline-offset: 3px; }
#tp-audio .tpa-btn svg { width: 20px; height: 20px; display: block; }
#tp-audio .tpa-btn .tpa-pause { display: none; }
#tp-audio.is-playing .tpa-btn .tpa-play { display: none; }
#tp-audio.is-playing .tpa-btn .tpa-pause { display: block; }

/* ±10s skip (44px hit area, smaller glyph) */
#tp-audio .tpa-skip {
  flex: 0 0 auto;
  position: relative;
  width: 40px; height: 40px;
  border: 0; background: transparent;
  color: var(--brand);
  cursor: pointer;
  display: grid; place-items: center;
  border-radius: 10px;
  transition: background .15s ease, transform .1s ease;
}
#tp-audio .tpa-skip:hover { background: color-mix(in srgb, var(--brand) 10%, transparent); }
#tp-audio .tpa-skip:active { transform: scale(.92); }
#tp-audio .tpa-skip:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
#tp-audio .tpa-skip svg { width: 22px; height: 22px; }
/* ۱۰ centered INSIDE the circular rewind/forward glyph */
#tp-audio .tpa-skip-n {
  position: absolute;
  top: 53%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: .5rem;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

/* speed toggle pill */
#tp-audio .tpa-speed {
  height: 30px;
  padding: 0 10px;
  border: 1px solid color-mix(in srgb, var(--brand) 28%, transparent);
  border-radius: 999px;
  background: #fff;
  color: var(--brand);
  font-size: .76rem; font-weight: 700;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background .15s ease;
  white-space: nowrap;
}
#tp-audio .tpa-speed:hover { background: var(--brand-50); }
#tp-audio .tpa-speed:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }

@media (max-width: 400px) {
  #tp-audio { padding: 9px 11px; }
  #tp-audio .tpa-transport { gap: 8px; }
  #tp-audio .tpa-speed, #tp-audio .tpa-spacer { flex-basis: 40px; }
  #tp-audio .tpa-speed { padding: 0 7px; font-size: .72rem; }
  #tp-audio .tpa-label { font-size: .78rem; }
  #tp-audio .tpa-time { font-size: .72rem; }
}

@media (prefers-reduced-motion: reduce) {
  #tp-audio .tpa-eq span { animation: none !important; height: 60%; }
  #tp-audio .tpa-btn, #tp-audio .tpa-knob, #tp-audio .tpa-skip, #tp-audio .tpa-speed { transition: none; }
}
