/* audio-player.css — مشغّل الكتب الصوتية (audio-player.js) — مكتبتي / صفحة الاستماع / صفحة الكتاب
   شريط صغير تحت (زي تطبيقات الموسيقى) ← بيفتح المشغّل الكامل. المشغّل الكامل دايمًا غامق.
   التايم لاين وأزرار التشغيل من الشمال لليمين زي كل مشغّلات الصوت (يوتيوب/سبوتيفاي)، والكلام عربي. */
.hap { --hap-acc: #a78bfa; --hap-acc2: #c4b5fd; --hap-card: #1e1b2b; --hap-bg: #14121c; --hap-txt: #f4f2fb; --hap-txt2: #b3adca;
  --hap-line: rgba(255,255,255,.1); --hap-grad: linear-gradient(150deg, #8b5cf6, #7c3aed 55%, #6d28d9);
  font-family: 'Cairo', 'Tajawal', sans-serif; }
.hap *, .hap *::before, .hap *::after { box-sizing: border-box; }
.hap [hidden] { display: none !important; }
.hap button { font-family: inherit; -webkit-tap-highlight-color: transparent; }
.hap svg { display: block; }

/* ── الشريط الصغير ── */
.hap-mini { position: fixed; z-index: 900; inset-inline: max(10px, env(safe-area-inset-left)); bottom: calc(var(--hap-offset, 0px) + 10px + env(safe-area-inset-bottom));
  max-width: 720px; margin-inline: auto; display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 8px; border-radius: 16px;
  background: rgba(30,27,43,.94); -webkit-backdrop-filter: blur(16px) saturate(1.3); backdrop-filter: blur(16px) saturate(1.3);
  color: var(--hap-txt); box-shadow: 0 14px 34px -10px rgba(10,6,30,.55), 0 0 0 1px rgba(255,255,255,.06) inset; overflow: hidden;
  animation: hapUp .28s cubic-bezier(.2,.8,.2,1); }
@keyframes hapUp { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.hap-mini__prog { position: absolute; inset-inline: 10px; bottom: 0; height: 3px; border-radius: 3px; background: rgba(255,255,255,.12); direction: ltr; }
.hap-mini__prog i { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--hap-acc); }
.hap-mini__open { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; background: none; border: 0; color: inherit; cursor: pointer; text-align: start; padding: 0; }
.hap-mini__open img, .hap-mini__ph { width: 46px; height: 46px; border-radius: 10px; object-fit: cover; flex: 0 0 auto; background: #2a2540; }
.hap-mini__t { min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.hap-mini__t b { font-size: 14px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hap-mini__t small { font-size: 12px; color: var(--hap-txt2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hap-ib { width: 42px; height: 42px; border-radius: 50%; border: 0; background: none; color: var(--hap-txt); display: grid; place-items: center; cursor: pointer; flex: 0 0 auto; position: relative; }
.hap-ib:hover { background: rgba(255,255,255,.07); }
.hap-ib svg { width: 24px; height: 24px; }
.hap-ib.pp { background: #fff; color: #1e1b2b; }
.hap-ib.pp:hover { background: #f1eefe; }
.hap-ib.pp svg { width: 22px; height: 22px; }
.hap-ib .n { position: absolute; font-size: 9.5px; font-weight: 900; top: 50%; left: 50%; transform: translate(-50%, -36%); }
.hap-ib.sm svg { width: 20px; height: 20px; }
.hap-spin { width: 20px; height: 20px; border-radius: 50%; border: 2.5px solid rgba(30,27,43,.25); border-top-color: #1e1b2b; animation: hapSpin .8s linear infinite; }
@keyframes hapSpin { to { transform: rotate(360deg); } }

/* ── المشغّل الكامل ── */
.hap-full { position: fixed; inset: 0; z-index: 9000; color: var(--hap-txt); background: var(--hap-bg); display: flex; flex-direction: column; overflow: hidden auto;
  transform: translateY(100%); transition: transform .34s cubic-bezier(.2,.8,.2,1); visibility: hidden; overscroll-behavior: contain; }
.hap-full.on { transform: none; visibility: visible; }
.hap[data-mode="page"] .hap-full { position: relative; min-height: 100vh; min-height: 100dvh; transform: none; visibility: visible; transition: none; }
.hap-full__bg { position: fixed; inset: -40px; z-index: 0; background: center / cover no-repeat; filter: blur(50px) brightness(.42) saturate(1.3); transform: scale(1.15); opacity: .95; pointer-events: none; }
.hap-full__bg::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(20,18,28,.15), rgba(20,18,28,.75) 70%, var(--hap-bg)); }
.hap-full__in { position: relative; z-index: 1; width: 100%; max-width: 480px; margin: 0 auto; padding: max(10px, env(safe-area-inset-top)) 22px max(22px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; flex: 1; }
.hap-top { display: flex; align-items: center; gap: 8px; min-height: 52px; }
.hap-top .hap-ib { background: rgba(255,255,255,.08); }
.hap-top__t { flex: 1; min-width: 0; text-align: center; line-height: 1.3; }
.hap-top__t small { display: block; font-size: 11px; font-weight: 700; color: var(--hap-txt2); letter-spacing: .2px; }
.hap-top__t b { display: block; font-size: 13.5px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hap-cover { width: min(78vw, 340px, 42vh); aspect-ratio: 1; margin: 18px auto 20px; border-radius: 16px; overflow: hidden; background: #2a2540 center / cover;
  box-shadow: 0 30px 60px -18px rgba(0,0,0,.75); transition: transform .35s ease; }
.hap-cover img { width: 100%; height: 100%; object-fit: contain; display: block; -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px); }
.hap-full.paused .hap-cover { transform: scale(.94); }
.hap-meta { display: flex; align-items: flex-end; gap: 12px; }
.hap-meta__t { flex: 1; min-width: 0; }
.hap-meta h2 { margin: 0; font-size: 21px; font-weight: 900; line-height: 1.4; }
.hap-meta a, .hap-meta .au { display: inline-block; margin-top: 2px; font-size: 13.5px; font-weight: 700; color: var(--hap-txt2); text-decoration: none; }
.hap-meta a:hover { color: #fff; }
.hap-chline { margin-top: 10px; display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 800; color: var(--hap-acc2); background: rgba(167,139,250,.12);
  border: 1px solid rgba(167,139,250,.22); border-radius: 12px; padding: 8px 12px; cursor: pointer; width: 100%; text-align: start; color: var(--hap-acc2); }
.hap-chline span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hap-chline small { font-size: 11.5px; color: var(--hap-txt2); font-weight: 700; flex: 0 0 auto; }

/* التايم لاين */
.hap-seek { margin-top: 18px; direction: ltr; }
.hap-range { position: relative; height: 26px; display: flex; align-items: center; }
.hap-range__buf, .hap-range__track { position: absolute; left: 0; right: 0; height: 5px; border-radius: 5px; }
.hap-range__track { background: rgba(255,255,255,.14); }
.hap-range__buf { right: auto; width: 0; background: rgba(255,255,255,.26); }
.hap-range input { position: relative; z-index: 1; width: 100%; height: 26px; margin: 0; background: transparent; -webkit-appearance: none; appearance: none; cursor: pointer; --p: 0%; }
.hap-range input::-webkit-slider-runnable-track { height: 5px; border-radius: 5px; background: linear-gradient(90deg, #fff var(--p), transparent var(--p)); }
.hap-range input::-moz-range-track { height: 5px; border-radius: 5px; background: transparent; }
.hap-range input::-moz-range-progress { height: 5px; border-radius: 5px; background: #fff; }
.hap-range input::-webkit-slider-thumb { -webkit-appearance: none; width: 15px; height: 15px; margin-top: -5px; border-radius: 50%; background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.4); transition: transform .15s; }
.hap-range input::-moz-range-thumb { width: 15px; height: 15px; border: 0; border-radius: 50%; background: #fff; }
.hap-range input:active::-webkit-slider-thumb { transform: scale(1.3); }
.hap-times { display: flex; justify-content: space-between; font-size: 12px; font-weight: 700; color: var(--hap-txt2); margin-top: 2px; font-variant-numeric: tabular-nums; }
.hap-times .tip { color: var(--hap-acc2); }

/* أزرار التشغيل */
.hap-ctl { direction: ltr; display: flex; align-items: center; justify-content: space-between; margin: 14px auto 0; width: 100%; max-width: 360px; }
.hap-ctl .hap-ib { width: 54px; height: 54px; }
.hap-ctl .hap-ib svg { width: 30px; height: 30px; }
.hap-ctl .hap-ib.ch svg { width: 26px; height: 26px; }
.hap-ctl .hap-ib .n { font-size: 10.5px; }
.hap-ctl .hap-ib.pp { width: 76px; height: 76px; background: #fff; color: #1e1b2b; box-shadow: 0 16px 34px -12px rgba(124,58,237,.7); }
.hap-ctl .hap-ib.pp svg { width: 32px; height: 32px; }
.hap-ctl .hap-ib.pp .hap-spin { width: 28px; height: 28px; border-width: 3px; }
.hap-ctl .hap-ib:disabled { opacity: .35; cursor: default; }

.hap-row { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin-top: 22px; }
.hap-chip { border: 1px solid var(--hap-line); background: rgba(255,255,255,.06); color: var(--hap-txt); font: 800 13px 'Cairo', sans-serif; padding: 9px 15px; border-radius: 999px;
  cursor: pointer; display: inline-flex; gap: 7px; align-items: center; }
.hap-chip svg { width: 17px; height: 17px; }
.hap-chip.on { border-color: var(--hap-acc); color: var(--hap-acc2); background: rgba(167,139,250,.12); }
.hap-left { text-align: center; font-size: 12px; font-weight: 700; color: var(--hap-txt2); margin-top: 16px; }

/* رسالة (تسجيل دخول / مش في مكتبتك / خطأ) جوه المشغّل */
.hap-msg { margin: 18px 0 0; padding: 16px; border-radius: 16px; background: rgba(255,255,255,.07); border: 1px solid var(--hap-line); text-align: center; }
.hap-msg b { display: block; font-size: 16px; font-weight: 900; margin-bottom: 4px; }
.hap-msg p { margin: 0 0 12px; font-size: 13.5px; color: var(--hap-txt2); line-height: 1.8; }
.hap-msg a, .hap-msg button { display: inline-flex; align-items: center; gap: 6px; border: 0; cursor: pointer; text-decoration: none; background: var(--hap-grad); color: #fff;
  font: 800 14px 'Cairo', sans-serif; padding: 10px 20px; border-radius: 12px; }

/* الشيتات (الفصول / السرعة / المؤقت) */
.hap-scrim { position: fixed; inset: 0; z-index: 9100; background: rgba(0,0,0,.5); opacity: 0; pointer-events: none; transition: opacity .2s; }
.hap-scrim.on { opacity: 1; pointer-events: auto; }
.hap-sheet { position: fixed; z-index: 9101; left: 0; right: 0; bottom: 0; max-width: 560px; margin: 0 auto; max-height: 78vh; overflow: auto; overscroll-behavior: contain;
  background: var(--hap-card); color: var(--hap-txt); border-radius: 22px 22px 0 0; padding: 8px 14px max(18px, env(safe-area-inset-bottom));
  transform: translateY(105%); transition: transform .28s cubic-bezier(.2,.8,.2,1); box-shadow: 0 -20px 50px rgba(0,0,0,.4); }
.hap-sheet.on { transform: none; }
.hap-sheet__grab { width: 40px; height: 4px; border-radius: 4px; background: rgba(255,255,255,.2); margin: 4px auto 10px; }
.hap-sheet h3 { margin: 0 6px 10px; font-size: 16px; font-weight: 900; display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.hap-sheet h3 small { font-size: 12px; font-weight: 700; color: var(--hap-txt2); }
.hap-chs { list-style: none; margin: 0; padding: 0; }
.hap-chs li { display: flex; align-items: center; gap: 11px; padding: 11px 10px; border-radius: 12px; cursor: pointer; font-size: 14px; font-weight: 700; }
.hap-chs li:hover { background: rgba(255,255,255,.05); }
.hap-chs li.on { background: rgba(167,139,250,.14); color: var(--hap-acc2); }
.hap-chs li.lock { cursor: default; color: var(--hap-txt2); }
.hap-chs .n { width: 28px; height: 28px; flex: 0 0 auto; border-radius: 8px; display: grid; place-items: center; font-size: 12px; font-weight: 900; background: rgba(255,255,255,.07); }
.hap-chs .t { flex: 1; min-width: 0; line-height: 1.5; }
.hap-chs .t small { display: block; font-size: 11.5px; color: var(--hap-txt2); font-weight: 700; }
.hap-chs .t .bar { display: block; height: 3px; border-radius: 3px; background: rgba(255,255,255,.12); margin-top: 5px; direction: ltr; overflow: hidden; }
.hap-chs .t .bar i { display: block; height: 100%; background: var(--hap-acc); }
.hap-chs .d { font-size: 12px; color: var(--hap-txt2); font-variant-numeric: tabular-nums; direction: ltr; flex: 0 0 auto; }
.hap-chs .ok { color: #4ade80; font-size: 14px; flex: 0 0 auto; }
.hap-chs .lk svg { width: 16px; height: 16px; color: var(--hap-txt2); }
.hap-eq { display: inline-flex; gap: 2px; align-items: flex-end; height: 14px; }
.hap-eq i { width: 3px; background: var(--hap-acc); border-radius: 2px; animation: hapEq 1s ease-in-out infinite; }
.hap-eq i:nth-child(2) { animation-delay: -.4s; } .hap-eq i:nth-child(3) { animation-delay: -.7s; }
.hap-full.paused .hap-eq i, .hap-sheet.paused .hap-eq i { animation-play-state: paused; }
@keyframes hapEq { 0%, 100% { height: 4px; } 50% { height: 14px; } }
.hap-opts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.hap-opts button { border: 1px solid var(--hap-line); background: rgba(255,255,255,.05); color: var(--hap-txt); font: 800 15px 'Cairo', sans-serif; padding: 13px 6px; border-radius: 12px; cursor: pointer; }
.hap-opts button.on { border-color: var(--hap-acc); color: var(--hap-acc2); background: rgba(167,139,250,.14); }
.hap-opts button small { display: block; font-size: 11px; color: var(--hap-txt2); font-weight: 700; }
.hap-sheet__note { font-size: 12px; color: var(--hap-txt2); margin: 12px 6px 0; line-height: 1.7; }
.hap-toast { position: fixed; z-index: 9200; top: max(16px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); background: rgba(0,0,0,.82); color: #fff;
  font: 700 13px 'Cairo', sans-serif; padding: 9px 16px; border-radius: 12px; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: 90vw; text-align: center; }
.hap-toast.on { opacity: 1; }
body.hap-lock { overflow: hidden; }

@media (min-width: 900px) {
  .hap-full__in { max-width: 520px; }
  .hap-cover { width: min(340px, 40vh); }
}
@media (max-height: 640px) {
  .hap-cover { width: min(60vw, 30vh); margin: 8px auto 12px; }
  .hap-row { margin-top: 12px; }
}
