/* Overlay audio player: hiện ở đầu màn hình khi một audio trong sách được phát */
#aoPlayer {
  position: fixed;
  top: calc(8px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translate(-50%, -150%);
  z-index: 9999998;
  width: min(600px, calc(100% - 110px));
  box-sizing: border-box;
  padding: 6px 8px;
  background: rgba(20, 24, 33, 0.62);
  color: #fff;
  color-scheme: dark;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  transition: transform 0.25s ease, opacity 0.25s ease, background 0.2s ease;
  opacity: 0;
  pointer-events: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
#aoPlayer.ao-show {
  transform: translate(-50%, 0);
  opacity: 1;
  pointer-events: auto;
}
#aoPlayer.ao-show:hover,
#aoPlayer.ao-show:focus-within { background: rgba(20, 24, 33, 0.8); }
#aoPlayer [hidden] { display: none !important; }

#aoPlayer .ao-top {
  display: flex;
  align-items: center;
  gap: 6px;
}
#aoPlayer .ao-mid {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
#aoPlayer .ao-title {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 12px;
  font-weight: 600;
  opacity: 0.85;
  padding: 0 4px;
  line-height: 1.2;
}

#aoPlayer button {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
#aoPlayer button:active { background: rgba(255, 255, 255, 0.28); }
#aoPlayer button svg { width: 20px; height: 20px; fill: currentColor; display: block; }
#aoPlayer .ao-play { width: 44px; height: 44px; background: rgba(47, 128, 237, 0.9); }
#aoPlayer .ao-play:active { background: #1c64c8; }
#aoPlayer .ao-play svg { width: 24px; height: 24px; }
#aoPlayer .ao-rate,
#aoPlayer .ao-cc { width: auto; min-width: 40px; padding: 0 8px; border-radius: 20px; }
#aoPlayer .ao-cc { opacity: 0.65; }
#aoPlayer .ao-cc.ao-on { opacity: 1; background: rgba(47, 128, 237, 0.5); }
#aoPlayer .ao-close { width: 34px; height: 34px; background: transparent; }
#aoPlayer .ao-close svg { width: 18px; height: 18px; }

#aoPlayer .ao-seekrow {
  display: flex;
  align-items: center;
  gap: 6px;
}
#aoPlayer .ao-time {
  flex: none;
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  opacity: 0.85;
}
#aoPlayer .ao-seek {
  flex: 1;
  min-width: 0;
  height: 26px;
  margin: 0;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  --ao-pct: 0%;
}
#aoPlayer .ao-seek::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(to right, #2f80ed var(--ao-pct), rgba(255, 255, 255, 0.3) var(--ao-pct));
}
#aoPlayer .ao-seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  margin-top: -8px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}
#aoPlayer .ao-seek::-moz-range-track { height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.3); }
#aoPlayer .ao-seek::-moz-range-progress { height: 6px; border-radius: 3px; background: #2f80ed; }
#aoPlayer .ao-seek::-moz-range-thumb { width: 22px; height: 22px; border: 0; border-radius: 50%; background: #fff; }

#aoPlayer .ao-transcript {
  margin-top: 6px;
  max-height: min(24vh, 200px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding-top: 4px;
  font-size: 15px;
  line-height: 1.4;
}
#aoPlayer .ao-line {
  padding: 4px 8px;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.65);
  cursor: pointer;
}
#aoPlayer .ao-line:active { background: rgba(255, 255, 255, 0.1); }
#aoPlayer .ao-line.ao-active { color: #fff; background: rgba(47, 128, 237, 0.35); }

@media (max-width: 560px) {
  #aoPlayer { width: calc(100% - 60px); left: calc(50% - 22px); }
  #aoPlayer .ao-skip, #aoPlayer .ao-rate, #aoPlayer .ao-title { display: none; }
}

/* Player nhỏ trong sách (bị thu nhỏ theo trang): nới vùng chạm của nút play
   để dễ bấm trên tablet. Đơn vị tính theo kích thước gốc 350x63 trước khi scale. */
.audio-player .audio-play::after {
  content: "";
  position: absolute;
  top: -30px;
  bottom: -30px;
  left: -24px;
  right: -6px;
}
