/* ==========================================================================
   Saraf Audio Player — استایل پلیر صوتی صراف
   ========================================================================== */

.sap-player,
.sap-player * { box-sizing: border-box; }

.sap-player {
  --sap-gold: #F7CA45;
  --sap-gold-2: #E5B027;
  --sap-ink: #1E262C;
  --sap-ink-2: #151C21;
  --sap-blue: #1E3B91;
  --sap-radius: 18px;
  --sap-font: inherit;

  position: relative;
  display: block;
  width: 100%;
  margin: 28px 0;
  padding: 16px 18px;
  border-radius: var(--sap-radius);
  font-family: var(--sap-font);
  direction: rtl;
  text-align: right;
  -webkit-font-smoothing: antialiased;
}
/* وقتی پنل سرعت باز است، این پلیر باید روی بقیهٔ محتوا بیاید */
.sap-player.sap-menu-open { z-index: 40; }

.sap-player[hidden] { display: none; }
.sap-player audio { display: none !important; }

/* ---------- ردیف عنوان ---------- */
.sap-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  min-height: 20px;
}
.sap-label {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -.2px;
  line-height: 1.6;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sap-eq { display: inline-flex; align-items: flex-end; gap: 2px; height: 13px; flex: none; }
.sap-eq i {
  display: block; width: 2.5px; height: 4px; border-radius: 2px;
  background: var(--sap-gold); opacity: .55;
}
.sap-player.is-playing .sap-eq i { animation: sap-eq 900ms ease-in-out infinite; opacity: 1; }
.sap-player.is-playing .sap-eq i:nth-child(2) { animation-delay: 150ms; }
.sap-player.is-playing .sap-eq i:nth-child(3) { animation-delay: 300ms; }
.sap-player.is-playing .sap-eq i:nth-child(4) { animation-delay: 450ms; }
@keyframes sap-eq { 0%,100% { height: 4px; } 50% { height: 13px; } }
@media (prefers-reduced-motion: reduce) {
  .sap-player.is-playing .sap-eq i { animation: none; height: 8px; }
}

/* ---------- ردیف اصلی ---------- */
.sap-main { display: flex; align-items: center; gap: 14px; }

/* دکمه پخش */
.sap-play {
  position: relative;
  flex: none;
  width: 52px; height: 52px;
  border: 0; padding: 0; margin: 0;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--sap-gold) 0%, var(--sap-gold-2) 100%);
  color: var(--sap-ink);
  cursor: pointer;
  display: grid; place-items: center;
  box-shadow: 0 6px 18px -6px rgba(247, 202, 69, .75);
  transition: transform .18s ease, box-shadow .18s ease;
}
.sap-play:hover { transform: scale(1.06); }
.sap-play:active { transform: scale(.96); }
.sap-play:focus-visible { outline: 3px solid var(--sap-gold); outline-offset: 3px; }
.sap-play svg:not(.sap-ring) { width: 20px; height: 20px; fill: currentColor; }
.sap-play .sap-i-pause { display: none; }
.sap-player.is-playing .sap-play .sap-i-play { display: none; }
.sap-player.is-playing .sap-play .sap-i-pause { display: block; }
.sap-play.is-loading::after {
  content: ""; position: absolute; inset: -5px;
  border-radius: 50%;
  border: 2px solid transparent;
  border-top-color: var(--sap-gold);
  animation: sap-spin .8s linear infinite;
}
@keyframes sap-spin { to { transform: rotate(360deg); } }

/* حلقه پیشرفت دور دکمه (اسکین تیره) */
.sap-ring { position: absolute; inset: -9px; width: auto; height: auto; pointer-events: none; display: none; }
.sap-ring circle { fill: none; stroke-width: 3; }
.sap-ring .sap-ring-bg { stroke: rgba(255,255,255,.16); }
.sap-ring .sap-ring-fg {
  stroke: var(--sap-gold); stroke-linecap: round;
  transform: rotate(-90deg); transform-origin: 50% 50%;
  transition: stroke-dashoffset .12s linear;
}

/* ناحیه موج / نوار */
.sap-body { flex: 1 1 auto; min-width: 0; }

/* نوار و موج همیشه چپ‌به‌راست پر می‌شوند، حتی در صفحهٔ راست‌به‌چپ */
.sap-track {
  position: relative;
  width: 100%;
  cursor: pointer;
  touch-action: none;
  outline: none;
  direction: ltr;
}
.sap-track:focus-visible { outline: 2px solid var(--sap-gold); outline-offset: 6px; border-radius: 6px; }

/* --- موج صوتی --- */
.sap-wave {
  display: flex; align-items: center; gap: 2px;
  height: 40px; width: 100%; overflow: hidden;
}
.sap-wave span {
  flex: 1 1 auto; min-width: 2px;
  border-radius: 3px;
  background: currentColor;
  opacity: .22;
  transition: opacity .12s linear, transform .12s ease;
}
.sap-wave span.on { opacity: 1; color: var(--sap-gold); }
.sap-track:hover .sap-wave span { transform: scaleY(1.04); }

/* --- نوار پیشرفت ساده --- */
.sap-bar {
  position: relative; height: 6px; border-radius: 99px;
  background: transparent;
  overflow: visible;
}
.sap-bar::before {
  content: ""; position: absolute; inset: 0;
  border-radius: 99px; background: currentColor; opacity: .12;
}
.sap-buffer {
  position: absolute; inset-block: 0; inset-inline-start: 0;
  border-radius: 99px; background: currentColor; opacity: .08; width: 0;
}
.sap-fill {
  position: absolute; inset-block: 0; inset-inline-start: 0;
  width: 0; border-radius: 99px;
  background: linear-gradient(90deg, var(--sap-gold-2), var(--sap-gold));
}
.sap-knob {
  position: absolute; top: 50%; inset-inline-start: 0;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--sap-gold);
  transform: translate(50%, -50%);
  box-shadow: 0 2px 8px rgba(0,0,0,.28);
  transition: transform .15s ease;
}
.sap-track:hover .sap-knob { transform: translate(50%, -50%) scale(1.25); }

/* راهنمای زمان هنگام هاور */
.sap-tip {
  position: absolute; bottom: calc(100% + 8px); left: 0;
  transform: translateX(-50%);
  background: var(--sap-ink); color: #fff;
  font-size: 11px; font-weight: 600;
  padding: 3px 7px; border-radius: 6px;
  pointer-events: none; opacity: 0; transition: opacity .12s;
  white-space: nowrap; z-index: 3;
}
.sap-track:hover .sap-tip { opacity: 1; }

/* ---------- ردیف ابزار ---------- */
.sap-meta {
  display: flex; align-items: center; gap: 10px;
  margin-top: 8px; font-size: 12px; font-weight: 600;
}
.sap-times { display: inline-flex; align-items: center; gap: 4px; direction: ltr; }
.sap-time { font-variant-numeric: tabular-nums; letter-spacing: .2px; opacity: .85; }
.sap-time-sep { opacity: .4; }
.sap-spacer { flex: 1 1 auto; }
/* دکمه‌های پرش هم‌جهت با خط زمان (چپ‌به‌راست): عقب سمت چپ، جلو سمت راست */
.sap-skips { display: inline-flex; align-items: center; gap: inherit; direction: ltr; }

.sap-btn {
  border: 0; background: transparent; padding: 5px; margin: 0;
  font-family: inherit;
  cursor: pointer; border-radius: 8px;
  display: inline-grid; place-items: center;
  color: inherit; opacity: .7;
  transition: opacity .15s ease, background-color .15s ease;
  position: relative;
}
.sap-btn:hover { opacity: 1; background: rgba(127,127,127,.14); }
.sap-btn:focus-visible { outline: 2px solid var(--sap-gold); outline-offset: 1px; opacity: 1; }
.sap-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.sap-btn.sap-rate {
  direction: ltr;
  font-size: 11.5px; font-weight: 800; min-width: 38px; padding: 4px 6px;
  font-variant-numeric: tabular-nums;
  border: 1px solid currentColor; opacity: .55;
}
.sap-btn.sap-rate:hover { opacity: 1; }

.sap-btn.sap-rate.is-changed { opacity: 1; color: var(--sap-gold); border-color: var(--sap-gold); }

/* ==========================================================================
   پنل انتخاب سرعت پخش
   ========================================================================== */
.sap-speed {
  position: absolute; z-index: 30;
  width: 268px; max-width: calc(100% - 16px);
  padding: 14px 14px 12px;
  border-radius: 16px;
  background: var(--sap-pop-bg, #FFFFFF);
  color: var(--sap-pop-fg, #1E262C);
  border: 1px solid var(--sap-pop-line, rgba(0,0,0,.09));
  box-shadow: 0 24px 48px -20px rgba(0,0,0,.45), 0 2px 8px rgba(0,0,0,.12);
  direction: rtl; text-align: right;
  opacity: 0; visibility: hidden;
  transform: translateY(6px) scale(.97);
  transform-origin: bottom center;
  /* visibility بدون تأخیر باز می‌شود تا بلافاصله قابل فوکوس باشد، و با تأخیر بسته می‌شود */
  transition: opacity .16s ease, transform .16s ease, visibility 0s linear .16s;
}
.sap-speed.below { transform-origin: top center; }
.sap-speed.open { opacity: 1; visibility: visible; transform: none;
  transition: opacity .16s ease, transform .16s ease, visibility 0s linear 0s; }
@media (prefers-reduced-motion: reduce) { .sap-speed { transition: none; } }

.sap-speed-head { display: flex; align-items: center; gap: 8px; margin-bottom: 2px; }
.sap-speed-title { font-size: 12.5px; font-weight: 700; opacity: .75; }
.sap-speed-x {
  margin-inline-start: auto; border: 0; background: transparent; cursor: pointer;
  color: inherit; opacity: .5; padding: 4px; margin: -4px -4px -4px 0;
  border-radius: 8px; display: grid; place-items: center;
}
.sap-speed-x:hover { opacity: 1; }
.sap-speed-x svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

.sap-speed-val {
  direction: ltr;
  font-size: 27px; font-weight: 800; line-height: 1.3; text-align: center;
  font-variant-numeric: tabular-nums; letter-spacing: -.5px;
  margin-bottom: 6px;
}

.sap-speed-row { direction: ltr; display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.sap-step {
  flex: none; width: 30px; height: 30px; border-radius: 50%;
  border: 0; cursor: pointer; display: grid; place-items: center;
  background: var(--sap-pop-soft, rgba(30,38,44,.08));
  color: inherit;
}
.sap-step:hover { background: var(--sap-pop-soft-2, rgba(30,38,44,.16)); }
.sap-step svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }

.sap-speed-range {
  -webkit-appearance: none; appearance: none;
  flex: 1 1 auto; height: 6px; margin: 0; padding: 0;
  background: transparent; cursor: pointer; direction: ltr;
}
.sap-speed-range::-webkit-slider-runnable-track {
  height: 6px; border-radius: 99px; background: var(--sap-pop-soft, rgba(30,38,44,.14));
}
.sap-speed-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 17px; height: 17px; border-radius: 50%; background: var(--sap-gold);
  margin-top: -5.5px; box-shadow: 0 1px 5px rgba(0,0,0,.3);
}
.sap-speed-range::-moz-range-track { height: 6px; border-radius: 99px; background: var(--sap-pop-soft, rgba(30,38,44,.14)); }
.sap-speed-range::-moz-range-thumb {
  width: 17px; height: 17px; border: 0; border-radius: 50%; background: var(--sap-gold);
  box-shadow: 0 1px 5px rgba(0,0,0,.3);
}
.sap-speed-range:focus-visible { outline: 2px solid var(--sap-gold); outline-offset: 4px; border-radius: 99px; }

.sap-speed-chips { direction: ltr; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.sap-chip {
  position: relative;
  border: 1px solid transparent; cursor: pointer;
  background: var(--sap-pop-soft, rgba(30,38,44,.07));
  color: inherit;
  border-radius: 10px; padding: 7px 2px 6px;
  font: inherit; font-size: 13px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  transition: background-color .14s ease, color .14s ease;
}
.sap-chip i { display: block; font-style: normal; font-size: 9px; font-weight: 600; opacity: .6; margin-top: 1px; }
.sap-chip:hover { background: var(--sap-pop-soft-2, rgba(30,38,44,.14)); }
.sap-chip:focus-visible { outline: 2px solid var(--sap-gold); outline-offset: 2px; }
.sap-chip.on {
  background: var(--sap-gold); color: #1E262C; border-color: var(--sap-gold);
}
.sap-chip.on i { opacity: .7; }

/* رنگ پنل روی اسکین‌های تیره */
.sap-skin-wave, .sap-skin-dark {
  --sap-pop-bg: #262F36;
  --sap-pop-fg: #FFFFFF;
  --sap-pop-line: rgba(255,255,255,.12);
  --sap-pop-soft: rgba(255,255,255,.10);
  --sap-pop-soft-2: rgba(255,255,255,.18);
}
@media (prefers-color-scheme: dark) {
  .sap-skin-light.sap-auto-dark {
    --sap-pop-bg: #262F36;
    --sap-pop-fg: #FFFFFF;
    --sap-pop-line: rgba(255,255,255,.12);
    --sap-pop-soft: rgba(255,255,255,.10);
    --sap-pop-soft-2: rgba(255,255,255,.18);
  }
}

/* حجم صدا */
.sap-vol { display: flex; align-items: center; gap: 4px; }
.sap-vol input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 0; opacity: 0; height: 4px; margin: 0;
  background: transparent; cursor: pointer;
  transition: width .2s ease, opacity .2s ease;
}
.sap-vol:hover input[type="range"],
.sap-vol input[type="range"]:focus-visible { width: 62px; opacity: 1; }
.sap-vol input[type="range"]::-webkit-slider-runnable-track {
  height: 4px; border-radius: 99px; background: rgba(127,127,127,.35);
}
.sap-vol input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 11px; height: 11px; border-radius: 50%; background: var(--sap-gold);
  margin-top: -3.5px;
}
.sap-vol input[type="range"]::-moz-range-track { height: 4px; border-radius: 99px; background: rgba(127,127,127,.35); }
.sap-vol input[type="range"]::-moz-range-thumb { width: 11px; height: 11px; border: 0; border-radius: 50%; background: var(--sap-gold); }

/* ==========================================================================
   اسکین ۱ — موج طلایی روی پس‌زمینه تیره (sap-skin-wave)
   ========================================================================== */
.sap-skin-wave {
  background:
    radial-gradient(150px 150px at 100% 0%, rgba(247,202,69,.15), transparent 70%),
    linear-gradient(160deg, #232D34 0%, var(--sap-ink) 55%, var(--sap-ink-2) 100%);
  color: #fff;
  padding: 18px 20px 14px;
  box-shadow: 0 18px 40px -28px rgba(0,0,0,.85);
  border: 1px solid rgba(255,255,255,.07);
}
.sap-skin-wave .sap-label { color: #fff; }
.sap-skin-wave .sap-wave { color: #fff; }
.sap-skin-wave .sap-bar { display: none; }
.sap-skin-wave .sap-meta { color: #C9D3DB; }

/* ==========================================================================
   اسکین ۲ — کارت روشن مینیمال (sap-skin-light)
   ========================================================================== */
.sap-skin-light {
  background: #FFFFFF;
  color: var(--sap-ink);
  border: 1px solid #E4EBF5;
  box-shadow: 0 10px 26px -22px rgba(30,59,145,.55);
  padding: 16px 18px 12px;
}
.sap-skin-light .sap-label { color: var(--sap-blue); }
.sap-skin-light .sap-wave { display: none; }
.sap-skin-light .sap-bar { color: var(--sap-ink); }
.sap-skin-light .sap-tip { background: var(--sap-blue); }
.sap-skin-light .sap-meta { color: #5A6675; }
.sap-skin-light .sap-play { color: var(--sap-ink); }

@media (prefers-color-scheme: dark) {
  .sap-skin-light.sap-auto-dark {
    background: #1B2228; color: #EAF0F5; border-color: rgba(255,255,255,.08);
  }
  .sap-skin-light.sap-auto-dark .sap-label { color: var(--sap-gold); }
  .sap-skin-light.sap-auto-dark .sap-meta { color: #9FADB9; }
}

/* ==========================================================================
   اسکین ۳ — کارت تیره پریمیوم با حلقه پیشرفت (sap-skin-dark)
   ========================================================================== */
.sap-skin-dark {
  background:
    radial-gradient(120% 140% at 100% 0%, rgba(247,202,69,.12) 0%, transparent 55%),
    var(--sap-ink);
  color: #fff;
  border: 1px solid rgba(247,202,69,.22);
  padding: 18px 20px 14px;
  box-shadow: 0 18px 40px -30px rgba(0,0,0,.9);
}
.sap-skin-dark .sap-wave { display: none; }
.sap-skin-dark .sap-bar { color: #fff; }
.sap-skin-dark .sap-ring { display: block; }
.sap-skin-dark .sap-play { box-shadow: none; width: 48px; height: 48px; }
.sap-skin-dark .sap-label { color: var(--sap-gold); }
.sap-skin-dark .sap-meta { color: #B9C4CE; }

/* ==========================================================================
   پلیر شناور پایین صفحه
   ظرف بیرونی هیچ رویداد موشی/لمسی نمی‌گیرد تا با المان‌های ثابت دیگر
   (چت آنلاین، اعلان کوکی، دکمهٔ بازگشت به بالا) تداخل نکند.
   ========================================================================== */
.sap-sticky {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: var(--sap-sticky-z, 99990);
  padding: 0 12px calc(12px + env(safe-area-inset-bottom, 0px) + var(--sap-sticky-lift, 0px));
  pointer-events: none;
  transform: translateY(140%);
  transition: transform .3s cubic-bezier(.2,.85,.25,1);
  direction: rtl;
}
.sap-sticky.show { transform: none; }
@media (prefers-reduced-motion: reduce) { .sap-sticky { transition: none; } }
@media print { .sap-sticky { display: none !important; } }

.sap-sticky-in {
  pointer-events: auto;
  position: relative;
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 14px;
  background: linear-gradient(160deg, #262F36 0%, #1A2228 100%);
  color: #fff;
  border: 1px solid rgba(255,255,255,.09);
  box-shadow: 0 18px 44px -16px rgba(0,0,0,.6);
  font-family: var(--sap-font, inherit);
  overflow: hidden;
}

/* نوار پیشرفت روی لبهٔ بالایی */
.sap-sticky-track {
  position: absolute; top: 0; inset-inline: 0;
  height: 7px; cursor: pointer; direction: ltr;
  background: rgba(255,255,255,.10);
  touch-action: none;
}
.sap-sticky-track:focus-visible { outline: 2px solid var(--sap-gold, #F7CA45); outline-offset: -2px; }
.sap-sticky-fill {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, #E5B027, #F7CA45);
}

.sap-sticky-play {
  flex: none; width: 40px; height: 40px; margin-top: 3px;
  border: 0; border-radius: 50%; cursor: pointer;
  background: linear-gradient(145deg, #F7CA45, #E5B027);
  color: #1E262C; display: grid; place-items: center;
  transition: transform .16s ease;
}
.sap-sticky-play:hover { transform: scale(1.06); }
.sap-sticky-play:focus-visible { outline: 3px solid #F7CA45; outline-offset: 2px; }
.sap-sticky-play svg { width: 17px; height: 17px; fill: currentColor; }
.sap-sticky .sap-i-pause { display: none; }
.sap-sticky.is-playing .sap-i-play { display: none; }
.sap-sticky.is-playing .sap-i-pause { display: block; }

.sap-sticky-info {
  flex: 1 1 auto; min-width: 0; margin-top: 3px;
  background: transparent; border: 0; cursor: pointer;
  color: inherit; text-align: right; padding: 0 2px;
  display: grid; gap: 1px;
}
.sap-sticky-info:hover .sap-sticky-title { color: var(--sap-gold, #F7CA45); }
.sap-sticky-info:focus-visible { outline: 2px solid #F7CA45; outline-offset: 3px; border-radius: 6px; }
.sap-sticky-title {
  font-size: 13px; font-weight: 700; line-height: 1.6;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: color .15s ease;
}
.sap-sticky-time {
  font-size: 11px; font-weight: 600; color: #A9B6C1;
  font-variant-numeric: tabular-nums; text-align: right;
}
.sap-sticky .sap-btn { margin-top: 3px; color: #fff; }
.sap-sticky .sap-sticky-x { opacity: .5; }

@media (max-width: 560px) {
  .sap-sticky { padding: 0 8px calc(8px + env(safe-area-inset-bottom, 0px) + var(--sap-sticky-lift, 0px)); }
  .sap-sticky-in { gap: 8px; padding: 8px 10px; border-radius: 13px; }
  .sap-sticky-play { width: 42px; height: 42px; }
  .sap-sticky .sap-btn { padding: 7px; min-width: 38px; min-height: 38px; }
  .sap-sticky .sap-skips { display: none; }  /* روی موبایل جا باز می‌کنیم */
  .sap-sticky-title { font-size: 12.5px; }
}

/* ==========================================================================
   واکنش‌گرا
   ========================================================================== */

/* روی دستگاه‌های لمسی راهنمای هاور معنا ندارد */
@media (hover: none) {
  .sap-tip { display: none; }
  .sap-btn:hover { background: transparent; }
  .sap-track:hover .sap-wave span { transform: none; }
}

@media (max-width: 560px) {
  .sap-player { padding: 14px 13px 11px; margin: 22px 0; border-radius: 16px; }
  .sap-main { gap: 11px; }
  .sap-play { width: 48px; height: 48px; }
  .sap-skin-dark .sap-play { width: 46px; height: 46px; }
  .sap-wave { height: 34px; gap: 1.5px; }
  .sap-head { margin-bottom: 10px; }
  .sap-label { font-size: 12.5px; }
  .sap-meta { gap: 2px; font-size: 11.5px; margin-top: 10px; }
  /* هدف لمسی استاندارد ۴۰ پیکسل */
  .sap-btn { padding: 8px; min-width: 40px; min-height: 40px; }
  .sap-btn svg { width: 18px; height: 18px; }
  .sap-btn.sap-rate { min-width: 42px; min-height: 36px; padding: 5px 8px; }
  .sap-vol { display: none; }             /* روی موبایل با دکمه‌های خود گوشی تنظیم می‌شود */
}

/* گوشی‌های باریک: دکمهٔ دانلود هم می‌رود تا ردیف نشکند */
@media (max-width: 380px) {
  .sap-player { padding: 12px 11px 10px; }
  .sap-main { gap: 9px; }
  .sap-play { width: 44px; height: 44px; }
  .sap-wave { height: 30px; }
  .sap-dl { display: none; }
  .sap-meta { gap: 0; font-size: 11px; }
  .sap-btn { padding: 7px; min-width: 38px; min-height: 38px; }
}

/* LTR */
.sap-player.sap-ltr { direction: ltr; text-align: left; }
