/* ==============================================================
   QURAN AUDIO PLAYER — Views/Quran/Audio.cshtml
   The qap- blocks themselves live in style.css (they come from the
   design); this file only covers what the database-driven page adds.
   ============================================================== */

/* artwork uploaded in the portal fills the cover card */
.qap-track-art .qap-track-img,
.qap-player-art .qap-track-img,
.qap-queue-art .qap-track-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}
.qap-player-art,
.qap-queue-art { position: relative; overflow: hidden; }

/* categories an administrator adds beyond Quran / Naath / Hamd */
.qap-badge-default { background: #3a3f52; }
.qap-badge-dua { background: #0e7490; }

/* a track whose audio file has not been added yet */
.qap-track-card.qap-unavailable { cursor: not-allowed; }
.qap-track-card.qap-unavailable .qap-track-art { filter: grayscale(1); }
.qap-track-card.qap-unavailable:hover { transform: none; box-shadow: none; border-color: #e9ecef; }
.qap-soon { font-size: 11px; font-weight: 600; color: #b45309; }
body.dark .qap-soon { color: #f0ad5b; }

.qap-track-card:focus-visible { outline: 2px solid var(--ip-area-fill); outline-offset: 2px; }
.qap-track-card[hidden] { display: none; }

/* pill counters sit at the right edge */
.qap-cat-pill .ms-auto { font-weight: 500; }

/* list view keeps the title and the reciter on one line each */
.qap-track-card.list-card .qap-track-body { flex-wrap: wrap; row-gap: 0; }
.qap-track-card.list-card .qap-track-name,
.qap-track-card.list-card .qap-track-reciter { flex: 1 1 45%; min-width: 0; }

/* loop-one marker on the repeat button */
.qap-ctrl-btn { position: relative; }
.qap-ctrl-btn .qap-loop-one {
  position: absolute; top: 2px; inset-inline-end: 0; font-size: 9px; font-weight: 700; line-height: 1;
  background: var(--ip-area-fill); color: #fff; border-radius: 50%; width: 13px; height: 13px;
  display: inline-flex; align-items: center; justify-content: center;
}

.qap-queue-item { width: 100%; border: none; background: transparent; text-align: start; }

@media (max-width: 991.98px) {
  .qap-sidebar-backdrop {
    position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 1099;
  }
}

/* ==============================================================
   Favourites and playlists (signed-in listeners)
   ============================================================== */

/* the sidebar scrolls as a whole, so neither list may squeeze the other */
#qaPlaylistList,
#qaReciterList { flex: 0 0 auto; }

/* a playlist in the sidebar: one button that opens it, plus edit / delete beside it */
div.qap-pl-item { padding-block: 0 0; padding-inline: 0 6px; cursor: default; }
.qap-pl-item-main {
  display: flex; align-items: center; gap: 10px; flex: 1 1 auto; min-width: 0;
  padding-block: 9px 9px; padding-inline: 10px 4px; border: none; background: transparent; text-align: start;
  border-radius: 10px; cursor: pointer; color: inherit;
}
.qap-pl-item-main .qap-pl-item-name { max-width: 118px; }
.qap-pl-item:focus-within .qap-pl-item-actions { opacity: 1; }
.qap-pl-item-main:focus-visible,
.qap-pl-action-btn:focus-visible,
.qap-cat-pill:focus-visible,
.qap-create-playlist-btn:focus-visible,
.qap-track-action-btn:focus-visible,
.qap-heart-btn:focus-visible,
.qap-pl-move-btn:focus-visible,
.qap-pl-remove-btn:focus-visible,
.qap-pl-track-main:focus-visible,
.qap-atp-item:focus-visible,
.qap-color-dot:focus-visible { outline: 2px solid var(--ip-area-fill); outline-offset: 2px; }

/* hearts: the same red everywhere, and a favourite card keeps its heart on show */
.qap-track-action-btn.qap-fav-btn.active { color: #dc2626; }
.qap-track-card.is-fav .qap-track-actions,
.qap-track-card:focus-within .qap-track-actions { opacity: 1; }
button.qap-play-overlay { width: auto; border: 0; padding: 0; cursor: pointer; }
.qap-track-card:focus-within .qap-play-overlay { opacity: 1; }
button.qap-play-overlay:focus-visible { outline: 3px solid var(--ip-focus); outline-offset: -3px; }
/* The heart and "add to playlist" are full 24px targets (WCAG 2.2). */
.qap-track-action-btn { display: inline-grid; place-items: center; min-width: 28px; min-height: 28px; }
.qap-heart-btn:disabled { opacity: .4; cursor: default; }
.qap-heart-btn:disabled:hover { color: var(--ip-muted); }
.qap-track-card.list-card .qap-track-footer { gap: 10px; }

/* no hover on touch screens: the row actions are always there */
@media (hover: none) {
  .qap-track-actions,
  .qap-pl-item-actions { opacity: 1; }
}

/* playlist detail rows */
.qap-pl-track-row.dragging { opacity: .4; }
.qap-pl-track-row[draggable="true"] .qap-drag-handle { cursor: grab; }
.qap-pl-track-row[draggable="false"] .qap-drag-handle { visibility: hidden; }
.qap-pl-track-main {
  display: flex; align-items: center; gap: 12px; flex: 1 1 auto; min-width: 0;
  border: none; background: transparent; padding: 0; text-align: start; color: inherit; cursor: pointer;
  border-radius: 8px;
}
.qap-pl-track-text { flex: 1 1 auto; min-width: 0; }
.qap-pl-track-art { position: relative; overflow: hidden; }
.qap-pl-track-art .qap-track-img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: inherit;
}
.qap-pl-row-actions { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.qap-pl-row-actions .qap-pl-remove-btn { margin-inline-start: 0; opacity: 1; }
.qap-pl-move-btn {
  background: none; border: none; padding: 5px 7px; border-radius: 8px; line-height: 1;
  font-size: 15px; color: var(--ip-muted); cursor: pointer; transition: all .15s;
}
.qap-pl-move-btn:hover:not(:disabled) { background: rgba(0,0,0,.06); color: #1c1c1c; }
.qap-pl-move-btn:disabled { opacity: .3; cursor: default; }

/* add-to-playlist entries are real buttons */
button.qap-atp-item { width: 100%; background: transparent; text-align: start; color: inherit; }
button.qap-atp-item:disabled { opacity: .45; cursor: not-allowed; }

@media (max-width: 575.98px) {
  .qap-pl-track-row { flex-wrap: wrap; row-gap: 6px; }
  .qap-pl-track-row .qap-track-dur { display: none; }
  .qap-pl-row-actions { margin-inline-start: auto; }
  .qap-playlist-cover-lg { width: 96px; height: 96px; font-size: 2.2rem; }
}

body.dark .qap-pl-item-main { color: #e5e7eb; }
body.dark .qap-pl-move-btn { color: var(--ip-muted); }
body.dark .qap-pl-move-btn:hover:not(:disabled) { background: rgba(255,255,255,.08); color: #fff; }
body.dark .qap-track-action-btn:hover { background: rgba(255,255,255,.08); color: #fff; }
body.dark .qap-track-action-btn.qap-fav-btn.active { color: #f87171; }
body.dark .qap-heart-btn.active { color: #f87171; }
body.dark .qap-color-dot.active { border-color: #fff; }

/* ==============================================================
   Wave 2: the listening room. Deep-green hero with a "now playing" card whose equaliser moves while a
   recitation plays, covers that carry the surah's Arabic name over the house lattice, and house colours.
   ============================================================== */
.qap-shell { margin-top: 1.25rem; }
.qa-now__row { display: flex; align-items: center; gap: .9rem; }
.qa-now__text { min-width: 0; }
.qa-now__text .qx-glass__title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qa-now__art {
  position: relative;
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  flex-shrink: 0;
  border-radius: 18px;
  background: linear-gradient(135deg, #0d3b29, #1f7a63);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18), 0 14px 28px -16px rgba(0, 0, 0, .7);
  overflow: hidden;
}
.qa-now__art::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--ip-pattern-light);
  background-size: 60px 60px;
  opacity: .9;
}
.qa-eq { position: relative; z-index: 1; display: flex; align-items: flex-end; gap: 3px; height: 30px; }
.qa-eq span {
  display: block;
  width: 5px;
  height: 100%;
  border-radius: 3px;
  background: #f1d59a;
  transform-origin: bottom;
  transform: scaleY(.25);
}
@media (prefers-reduced-motion: no-preference) {
  .qa-now.is-playing .qa-eq span { animation: qa-eq 1s ease-in-out infinite; }
  .qa-now.is-playing .qa-eq span:nth-child(2) { animation-delay: -.6s; animation-duration: .8s; }
  .qa-now.is-playing .qa-eq span:nth-child(3) { animation-delay: -.3s; animation-duration: 1.2s; }
  .qa-now.is-playing .qa-eq span:nth-child(4) { animation-delay: -.9s; animation-duration: .9s; }
  .qa-now.is-playing .qa-eq span:nth-child(5) { animation-delay: -.45s; animation-duration: 1.1s; }
}
.qa-now.is-playing .qa-eq span { transform: scaleY(.7); }
@keyframes qa-eq {
  0%, 100% { transform: scaleY(.25); }
  50% { transform: scaleY(1); }
}
.qa-now .qx-actions { margin-top: .85rem; }
.qa-now #qaResume { max-width: 100%; overflow: hidden; }
.qa-now #qaResumeLabel { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Covers: the Arabic title over the eight-point lattice */
.qap-track-art::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--ip-pattern-light);
  background-size: 70px 70px;
  pointer-events: none;
}
.qap-track-art:has(.qap-track-img)::after { display: none; }
.qap-track-ar {
  position: relative;
  z-index: 1;
  padding: 0 .6rem;
  font-family: var(--ip-font-quran);
  font-size: clamp(1.5rem, 1.1rem + 1vw, 2.1rem);
  line-height: 1.5;
  color: #fff;
  text-align: center;
  text-shadow: 0 2px 12px rgba(0, 0, 0, .25);
}
.qap-track-art .qap-play-overlay,
.qap-track-art .qap-track-badge { z-index: 2; }
.qap-track-card { border-radius: 18px; transition: transform .25s var(--ip-ease), box-shadow .25s var(--ip-ease), border-color .25s var(--ip-ease); }
.qap-track-card:not(.qap-unavailable):hover { transform: translateY(-3px); box-shadow: var(--ip-shadow-md); }
.qap-track-card.list-card .qap-track-ar { font-size: 1rem; }
.qap-track-card.list-card .qap-track-art::after { background-size: 30px 30px; }
@media (max-width: 575.98px) {
  .qa-now__art { width: 56px; height: 56px; border-radius: 14px; }
}
/* The Arabic title always fits its cover, whatever the column width. */
.qap-track-art { container-type: inline-size; }
.qap-track-ar { font-size: clamp(.95rem, 14cqi, 2rem); white-space: nowrap; max-width: 100%; overflow: hidden; }
@media (max-width: 575.98px) {
  /* On a phone the playing track gets a full row, with the controls beneath it. */
  .qap-player-bar { flex-wrap: wrap; row-gap: .35rem; }
  .qap-player-bar .qap-player-track { flex: 1 1 100%; min-width: 0; }
  .qap-player-bar .qap-player-controls { flex: 1 1 100%; }
  .qap-page { padding-bottom: 150px; }
}
@media (max-width: 575.98px) {
  .qap-player-bar { height: auto; padding-block: .5rem .45rem; }
  .qap-player-bar .qap-player-track { max-width: none; }
  .qap-player-bar .qap-player-controls .mb-2 { margin-bottom: .2rem !important; }
}
