/* ============================================================
   Listen — Qur'an audiobook page
   Uses the site's existing tokens, so light/dark come free.
   ============================================================ */

.listen-page { padding-top: 72px; }
.listen-page.player-open { padding-bottom: 120px; }

/* ---------- Hero ---------- */
.listen-hero {
  position: relative;
  text-align: center;
  padding-block: clamp(2.5rem, 7vw, 5rem) clamp(2rem, 5vw, 3.5rem);
  overflow: hidden;
  isolation: isolate;
}
.listen-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(ellipse 70% 60% at 50% 0%, color-mix(in srgb, var(--green) 26%, transparent), transparent 70%),
    var(--bg);
}
.listen-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image: url("../assets/img/BooksSectionBackground.jpg");
  background-size: cover;
  background-position: center;
  opacity: 0.08;
}
html[data-theme="light"] .listen-hero::after { opacity: 0.05; }

.bismillah {
  font-family: "Amiri", "Cormorant Garamond", serif;
  font-size: clamp(1.5rem, 3.6vw, 2.1rem);
  color: var(--gold);
  margin-bottom: 1rem;
  line-height: 1.6;
}
.listen-title {
  font-size: clamp(2.4rem, 6.4vw, 4.2rem);
  line-height: 1.08;
  margin-top: 0.7rem;
  color: var(--ink);
}
.listen-title br { display: block; }
.listen-subtitle {
  font-family: var(--font-display);
  font-style: italic;
  font-size: clamp(1.15rem, 2.6vw, 1.6rem);
  color: var(--gold-bright);
  margin-top: 0.7rem;
}
.listen-byline { color: var(--ink-muted); font-size: 0.95rem; margin-top: 0.35rem; }
.listen-hero .rule { margin-top: 1.4rem; }
.listen-lede {
  max-width: 60ch;
  margin: 1.2rem auto 0;
  color: var(--ink-soft);
  font-size: 1.02rem;
  line-height: 1.7;
}

/* ---------- Toolbar ---------- */
.listen-toolbar {
  position: sticky;
  top: 72px;
  z-index: 40;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-block: 1px solid var(--border-soft);
  padding-block: 0.85rem;
  scroll-margin-top: 72px;
}
.toolrow {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  flex-wrap: wrap;
}
.listen-search {
  flex: 1;
  min-width: 240px;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.7rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  color: var(--ink-muted);
  transition: border-color 0.2s var(--ease);
}
.listen-search:focus-within { border-color: var(--gold); }
.listen-search svg { flex: none; }
.listen-search input {
  flex: 1;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  outline: none;
  min-width: 0;
}
.listen-search input::placeholder { color: var(--ink-muted); }
.listen-count { color: var(--ink-muted); font-size: 0.88rem; white-space: nowrap; }
.listen-count b { color: var(--gold); font-weight: 600; }
.dot { opacity: 0.5; margin-inline: 0.25rem; }

/* ---------- Chapter grid ---------- */
.surah-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1rem;
  padding-block: clamp(1.5rem, 4vw, 2.5rem);
}
.surah-card {
  position: relative;
  display: flex;
  gap: 1rem;
  align-items: stretch;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  transition: transform 0.25s var(--ease), border-color 0.25s var(--ease), box-shadow 0.25s var(--ease);
}
.surah-card.is-available { border-color: var(--border); cursor: pointer; }
.surah-card.is-available:hover {
  transform: translateY(-4px);
  border-color: var(--gold);
  box-shadow: var(--shadow);
}
.surah-card:not(.is-available) { opacity: 0.62; }
.surah-card.is-loaded { border-color: var(--gold); }
.surah-card.is-playing {
  border-color: var(--gold);
  box-shadow: 0 0 0 1px var(--gold), var(--shadow);
}
.surah-badge {
  position: absolute;
  top: 0.85rem;
  right: 1rem;
  font-size: 0.6rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--green);
  font-weight: 600;
}
html[data-theme="dark"] .surah-badge { color: #6fd3a0; }
.surah-num {
  flex: none;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: linear-gradient(140deg, var(--green), var(--green-deep));
  color: #f2ecd9;
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
}
.surah-card:not(.is-available) .surah-num {
  background: color-mix(in srgb, var(--surface-2) 90%, transparent);
  color: var(--ink-muted);
  border: 1px solid var(--border-soft);
}
/* Column layout + `margin-top:auto` on the actions keeps the Listen/Download
   buttons on one line across a row, even when a longer meta line ("The Family
   of Imran · 200 verses · 1:03:26") wraps onto two. */
.surah-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.surah-line1 {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.8rem;
}
.surah-card.is-available .surah-line1 { padding-right: 5.6rem; }
.surah-name {
  font-family: var(--font-display);
  font-size: 1.28rem;
  font-weight: 600;
  color: var(--ink);
  margin: 0;
  line-height: 1.2;
}
.surah-ar {
  font-family: "Amiri", serif;
  font-size: 1.1rem;
  color: var(--gold);
  white-space: nowrap;
}
.surah-meta { color: var(--ink-muted); font-size: 0.85rem; margin-top: 0.25rem; }
.surah-actions { display: flex; gap: 0.55rem; margin-top: auto; padding-top: 0.9rem; flex-wrap: wrap; }
.surah-actions .btn { min-height: 38px; padding: 0.45rem 0.95rem; font-size: 0.85rem; }
.surah-soon {
  margin-top: 0.7rem;
  font-size: 0.8rem;
  color: var(--ink-muted);
  font-style: italic;
}
.surah-share.is-copied { border-color: var(--gold); color: var(--gold-bright); }
/* Three buttons will not fit one line inside the card body on a phone, so lay
   them out deliberately — Listen | Download, then Share across the full width —
   instead of letting Share orphan itself at half width. */
@media (max-width: 560px) {
  .surah-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .surah-actions > * { justify-content: center; }
  .surah-share { grid-column: 1 / -1; }
}
/* Brief highlight so an arriving share link shows which card it meant. */
.surah-card.is-linked { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold), var(--shadow); }
.no-results { text-align: center; color: var(--ink-muted); padding-block: 2rem; }

/* Confirmation for the icon-only player Share button, which has no room for a
   label swap. Sits above the fixed player bar. */
.listen-toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  transform: translate(-50%, 12px);
  z-index: 90;
  padding: 0.6rem 1.1rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
  color: var(--ink);
  font-size: 0.86rem;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.22s var(--ease), transform 0.22s var(--ease), visibility 0.22s;
}
.listen-toast.is-on { opacity: 1; visibility: visible; transform: translate(-50%, 0); }
@media (prefers-reduced-motion: reduce) { .listen-toast { transition: opacity 0.15s; } }

/* ---------- Pagination ---------- */
.pager {
  display: flex;
  justify-content: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  padding-bottom: clamp(2.5rem, 6vw, 4rem);
}
.pg-btn {
  min-width: 42px;
  height: 42px;
  padding: 0 0.7rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--ink-soft);
  font-size: 0.92rem;
  transition: color 0.2s, border-color 0.2s, background-color 0.2s;
}
.pg-btn:hover:not(:disabled) { color: var(--gold-bright); border-color: var(--gold); }
.pg-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.pg-btn.is-current {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-ink);
  border-color: transparent;
  font-weight: 600;
}

/* ---------- Fixed player bar ---------- */
.qplayer {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 70;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--border);
  box-shadow: 0 -14px 40px rgba(0, 0, 0, 0.35);
  padding-block: 0.7rem calc(0.7rem + env(safe-area-inset-bottom, 0px));
  animation: qpUp 0.35s var(--ease);
}
@keyframes qpUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.qplayer-inner {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) auto minmax(200px, 2fr) auto;
  align-items: center;
  gap: clamp(0.7rem, 2vw, 1.4rem);
}

.qp-meta { display: flex; align-items: center; gap: 0.7rem; min-width: 0; }
.qp-num {
  flex: none;
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 9px;
  background: linear-gradient(140deg, var(--green), var(--green-deep));
  color: #f2ecd9;
  font-family: var(--font-display);
  font-weight: 600;
}
.qp-titles { display: flex; flex-direction: column; min-width: 0; }
.qp-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.qp-sub {
  font-size: 0.76rem;
  color: var(--ink-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.qp-controls { display: flex; align-items: center; gap: 0.45rem; }
.qp-btn {
  position: relative;
  width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--ink-soft);
  transition: color 0.2s, border-color 0.2s, transform 0.15s;
}
.qp-btn:hover { color: var(--gold-bright); border-color: var(--gold); }
.qp-btn:active { transform: scale(0.94); }
.qp-skip-num {
  position: absolute;
  font-size: 0.5rem;
  font-weight: 600;
  bottom: 9px;
  letter-spacing: -0.02em;
}
.qp-play {
  width: 50px; height: 50px;
  border-radius: 50%;
  border: none;
  background: var(--btn-primary-bg);
  color: var(--btn-primary-ink);
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.3);
  transition: transform 0.18s var(--ease), background-color 0.2s;
}
.qp-play:hover { transform: scale(1.06); }
.qp-play .ic-pause, .qp-play .ic-spinner { display: none; }
.qplayer.is-playing .ic-play { display: none; }
.qplayer.is-playing .ic-pause { display: block; }
.qplayer.is-loading .ic-play, .qplayer.is-loading .ic-pause { display: none; }
.qplayer.is-loading .ic-spinner { display: block; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.qp-seekwrap { display: flex; align-items: center; gap: 0.7rem; min-width: 0; }
.qp-time {
  font-size: 0.76rem;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
  flex: none;
  min-width: 38px;
  text-align: center;
}
.qp-seek, .qp-vol {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--gold) var(--p, 0%), var(--border) var(--p, 0%));
  cursor: pointer;
}
.qp-seek { flex: 1; min-width: 0; }
.qp-vol { width: 74px; }
.qp-seek::-webkit-slider-thumb, .qp-vol::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--gold);
  border: 2px solid var(--bg);
  cursor: grab;
}
.qp-seek::-moz-range-thumb, .qp-vol::-moz-range-thumb {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--gold);
  border: 2px solid var(--bg);
  cursor: grab;
}

.qp-extras { display: flex; align-items: center; gap: 0.45rem; }
.qp-speed { position: relative; }
.qp-chip {
  height: 34px;
  min-width: 52px;
  padding: 0 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--ink-soft);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  transition: color 0.2s, border-color 0.2s;
}
.qp-chip:hover { color: var(--gold-bright); border-color: var(--gold); }
.qp-speed-menu {
  position: absolute;
  bottom: calc(100% + 0.6rem);
  right: 0;
  list-style: none;
  margin: 0;
  padding: 0.35rem;
  min-width: 132px;
  background: color-mix(in srgb, var(--surface) 97%, transparent);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 5;
}
.qp-speed-menu button {
  width: 100%;
  text-align: left;
  padding: 0.5rem 0.7rem;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--ink-soft);
  font-size: 0.86rem;
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
}
.qp-speed-menu button span { color: var(--ink-muted); font-size: 0.76rem; }
.qp-speed-menu button:hover { background: var(--gold-soft); color: var(--ink); }
.qp-speed-menu button[aria-checked="true"] { color: var(--gold-bright); font-weight: 600; }

.qp-volume { display: flex; align-items: center; gap: 0.4rem; }
.qp-volume .ic-muted { display: none; }
.qplayer.is-muted .ic-vol { display: none; }
.qplayer.is-muted .ic-muted { display: block; }

/* ---------- Responsive player ---------- */
@media (max-width: 1080px) {
  .qplayer-inner { grid-template-columns: minmax(120px, 1fr) auto minmax(160px, 1.6fr) auto; }
  .qp-volume { display: none; }
}
@media (max-width: 820px) {
  .qplayer-inner {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "meta extras"
      "seek seek"
      "controls controls";
    gap: 0.55rem 0.8rem;
  }
  .qp-meta { grid-area: meta; }
  .qp-extras { grid-area: extras; }
  .qp-seekwrap { grid-area: seek; }
  .qp-controls { grid-area: controls; justify-content: center; }
  .listen-page.player-open { padding-bottom: 190px; }
}
@media (max-width: 520px) {
  .surah-grid { grid-template-columns: 1fr; }
  .surah-line1 { padding-right: 4rem; }
  .listen-toolbar { top: 64px; }
}
