/* ============================================================
   Gradivity audio — WhatsApp voice-note style player
   Renders inside .gr-audio-player blocks ([data-gr-audio]).
   No-JS fallback: native <audio> + track list stay visible.
   With JS: the note player is injected and native/list toggled.
   ============================================================ */

.gr-audio-player {
  --gr-accent: #25D366;
  --gr-track: #d7dbdf;
  --gr-text: #344054;
  --gr-muted: #667085;
  --gr-bubble: #F2FBF5;
  --gr-border: #D8F0E1;
  margin: 14px 0;
  background: var(--gr-bubble);
  border: 1px solid var(--gr-border);
  border-radius: 18px;
  padding: 10px 12px;
  max-width: 560px;
  box-shadow: 0 1px 3px rgba(20, 35, 20, .06);
  color: var(--gr-text);
}

/* ===== WhatsApp note ===== */
.gr-a-note {
  display: flex;
  align-items: center;
  gap: 12px;
}
.gr-a-play {
  flex: none;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 0;
  background: var(--gr-accent);
  color: #fff;
  font-size: 18px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(37, 211, 102, .35);
  transition: transform .12s ease, box-shadow .12s ease;
}
.gr-a-play:hover { transform: scale(1.06); box-shadow: 0 6px 14px rgba(37, 211, 102, .42); }
.gr-a-play:active { transform: scale(.94); }
.gr-a-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

/* ===== Progress bar (seek) ===== */
.gr-a-bar { display: flex; align-items: center; }
.gr-a-seek {
  width: 100%;
  height: 26px;
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
  background: var(--gr-track);
  border-radius: 999px;
  cursor: pointer;
  outline: none;
}
.gr-a-seek::-webkit-slider-runnable-track { height: 6px; border-radius: 999px; background: transparent; }
.gr-a-seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--gr-accent);
  margin-top: -4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
}
.gr-a-seek::-moz-range-track { height: 6px; border-radius: 999px; background: transparent; }
.gr-a-seek::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--gr-accent);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
}
.gr-a-seek:focus-visible { outline: 2px solid rgba(37, 211, 102, .45); outline-offset: 2px; }

/* ===== Meta row: time + name + tools ===== */
.gr-a-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--gr-muted);
}
.gr-a-time {
  flex: none;
  font-variant-numeric: tabular-nums;
  font-size: 11.5px;
  min-width: 34px;
}
.gr-a-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 800;
  color: var(--gr-text);
}
.gr-a-tools { display: flex; align-items: center; gap: 6px; flex: none; }
.gr-a-speed, .gr-a-list-btn {
  border: 1px solid #CFE8D8;
  background: #fff;
  color: #2F6B45;
  font-family: inherit;
  font-size: 11px;
  font-weight: 900;
  border-radius: 999px;
  padding: 3px 10px;
  cursor: pointer;
  transition: background .12s ease, color .12s ease;
}
.gr-a-speed:hover, .gr-a-list-btn:hover { background: #E2F7EA; }

/* ===== Playlist ===== */
.gr-track-list {
  margin: 10px 0 0;
  border-top: 1px dashed var(--gr-border);
  padding-top: 8px;
  max-height: 240px;
  overflow: auto;
}
.gr-audio-player[data-gr-bound] .gr-track-list { display: none; }
.gr-audio-player[data-gr-bound].gr-list-open .gr-track-list { display: block; }
.gr-track-line {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-radius: 10px;
  cursor: pointer;
  color: var(--gr-text);
  font-size: 13px;
  font-weight: 800;
}
.gr-track-line:hover { background: #E2F7EA; }
.gr-track-line.active { background: #DCF8E6; color: #1F5B38; }
.gr-track-num {
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #E7F7EE;
  color: #2F6B45;
  font-size: 11px;
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.gr-track-line.active .gr-track-num { background: var(--gr-accent); color: #fff; }
.gr-track-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== Native audio fallback ===== */
.gr-a-native { display: block; width: 100%; }
.gr-audio-player[data-gr-bound] .gr-a-native { display: none; }
.gr-a-empty { display: none; }

/* ===== Error note (inline diagnostic) ===== */
.gr-a-err {
  display: none;
  margin: 8px 0 0;
  padding: 7px 10px;
  border-radius: 10px;
  background: #FEEAEA;
  border: 1px solid #F5C6C6;
  color: #B42318;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.5;
}
.gr-a-err.show { display: block; }

/* ===== Floating bottom mini-player (all lesson audios) ===== */
.gr-mini {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  background: #fff;
  border-top: 1px solid var(--gr-border);
  box-shadow: 0 -6px 24px rgba(20, 35, 20, .16);
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  max-width: 640px;
  margin: 0 auto;
  border-radius: 16px 16px 0 0;
  font-family: inherit;
  color: var(--gr-text);
}
.gr-mini[hidden] { display: none !important; }
.gr-mini-prog { display: flex; align-items: center; margin-bottom: 6px; }
.gr-mini-seek {
  width: 100%;
  height: 22px;
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
  background: var(--gr-track);
  border-radius: 999px;
  cursor: pointer;
  outline: none;
}
.gr-mini-seek::-webkit-slider-runnable-track { height: 5px; border-radius: 999px; background: transparent; }
.gr-mini-seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--gr-accent);
  margin-top: -4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
}
.gr-mini-seek::-moz-range-track { height: 5px; border-radius: 999px; background: transparent; }
.gr-mini-seek::-moz-range-thumb {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--gr-accent);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
}
.gr-mini-main {
  display: flex;
  align-items: center;
  gap: 8px;
}
.gr-mini-btn {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 0;
  background: #E7F7EE;
  color: #2F6B45;
  font-size: 15px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .12s ease, transform .12s ease;
}
.gr-mini-btn:hover { background: #DCF8E6; }
.gr-mini-btn:active { transform: scale(.94); }
.gr-mini-btn.gr-mini-play {
  width: 42px;
  height: 42px;
  background: var(--gr-accent);
  color: #fff;
  box-shadow: 0 4px 10px rgba(37, 211, 102, .35);
}
.gr-mini-btn.gr-mini-play:hover { background: #1FBF5F; }
.gr-mini-close {
  background: transparent;
  color: var(--gr-muted);
}
.gr-mini-close:hover { background: #F2F4F7; }
.gr-mini-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 0 4px;
}
.gr-mini-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 800;
  color: var(--gr-text);
}
.gr-mini-sub {
  font-size: 11px;
  font-weight: 800;
  color: var(--gr-muted);
}
.gr-mini-time {
  flex: none;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--gr-muted);
  padding-left: 4px;
}

/* ===== Print: keep the track list as a plain text sheet ===== */
@media print {
  .gr-mini { display: none !important; }
  .gr-audio-player[data-gr-bound] .gr-track-list { display: block; }
  .gr-audio-player[data-gr-bound] .gr-track-line.active { background: none; }
  .gr-track-list { max-height: none; overflow: visible; }
}
