/* =====================================================================
   style.css — استایل Neumorphism (بخش ۶ پرامپت پروژه).

   قانون طلایی عملکردی که در این فایل رعایت شده:
   • هیچ‌جا box-shadow انیمیت نمی‌شود؛ سایه‌ها همیشه ثابت (static) هستند.
   • حالت "فشرده شدن" دکمه‌ها با دو لایه‌ی از‌پیش‌طراحی‌شده (raised/pressed)
     و جابه‌جایی opacity بین آن‌ها ساخته شده، نه بازمحاسبه‌ی shadow.
   • همه‌ی انیمیشن‌ها فقط روی transform و opacity هستند (GPU compositing).
   • progress بار خطی هم با transform: scaleX (نه width) پر می‌شود.
   • برای progress دایره‌ای دور کاور، از SVG با stroke-dashoffset استفاده شده.
   • content-visibility: auto روی ردیف‌های لیست آهنگ برای رندر سریع‌تر.
   ===================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap');

:root {
  /* --- پالت رنگ برگرفته از رفرنس ضمیمه‌شده --- */
  --bg-gradient-start: #dee6f7;
  --bg-gradient-end: #eef1fa;
  --surface: #edf1fa;
  --surface-alt: #e7ecf7;
  --shadow-light: rgba(255, 255, 255, 0.85);
  --shadow-dark: rgba(163, 177, 198, 0.55);
  --accent: #7b8ef4;
  --accent-strong: #6272e0;
  --accent-tint: #dde3fb;
  --text-primary: #454b60;
  --text-secondary: #9aa1b8;
  --text-on-accent: #ffffff;
  --danger: #e0748c;

  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --radius-round: 999px;

  --shadow-raised: 8px 8px 16px var(--shadow-dark), -8px -8px 16px var(--shadow-light);
  --shadow-raised-sm: 5px 5px 10px var(--shadow-dark), -5px -5px 10px var(--shadow-light);
  --shadow-pressed: inset 4px 4px 8px var(--shadow-dark), inset -4px -4px 8px var(--shadow-light);
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: 'Poppins', system-ui, sans-serif;
  color: var(--text-primary);
  background: linear-gradient(160deg, var(--bg-gradient-start), var(--bg-gradient-end));
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
  padding-bottom: 12px;
}

.view {
  display: none;
  padding: 20px 20px 100px;
  animation: view-fade-in 220ms ease-out;
}

.view.active {
  display: block;
}

/* انیمیشن ورود صفحه: فقط opacity + transform (بدون layout thrash) */
@keyframes view-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* --------------------------- عناصر پایه‌ی نئومورفیک --------------------------- */

.neu-surface {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-raised);
}

.neu-circle-btn {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-round);
  background: var(--surface);
  border: none;
  box-shadow: var(--shadow-raised-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  cursor: pointer;
  transform: translateZ(0);
  transition: transform 120ms ease;
}

/* لایه‌ی دوم (pressed) از پیش در DOM حاضر است؛ فقط opacity آن تغییر می‌کند. */
.neu-circle-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: var(--shadow-pressed);
  opacity: 0;
  transition: opacity 120ms ease;
  pointer-events: none;
}

.neu-circle-btn:active {
  transform: scale(0.94) translateZ(0);
}
.neu-circle-btn:active::after {
  opacity: 1;
}

.neu-circle-btn.accent {
  background: linear-gradient(145deg, var(--accent), var(--accent-strong));
  color: var(--text-on-accent);
  box-shadow: 6px 6px 14px rgba(98, 114, 224, 0.45), -4px -4px 10px rgba(255, 255, 255, 0.5);
}

.neu-circle-btn.large {
  width: 68px;
  height: 68px;
  font-size: 22px;
}

/* --------------------------- هدر مشترک صفحات --------------------------- */

.screen-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.screen-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
}

/* --------------------------- کتابخانه / فولدرها --------------------------- */

.library-heading {
  font-size: 24px;
  font-weight: 700;
  margin: 4px 0 20px;
}

.source-group {
  margin-bottom: 22px;
}

.source-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px 10px;
}

.source-group-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.source-group-count {
  font-size: 12px;
  color: var(--text-secondary);
}

.bulk-download-btn {
  font-size: 12px;
  font-weight: 500;
  color: var(--accent-strong);
  background: none;
  border: none;
  padding: 6px 10px;
  cursor: pointer;
}

.track-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.track-row {
  /* بخش ۶ پرامپت: در لیست‌های بلند، از content-visibility برای جلوگیری
     از رندر هم‌زمان همه‌ی آیتم‌ها استفاده شود. */
  content-visibility: auto;
  contain-intrinsic-size: 68px;

  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  cursor: pointer;
  transform: translateZ(0);
  transition: transform 120ms ease, background 150ms ease;
}

.track-row:active {
  transform: scale(0.98) translateZ(0);
}

.track-row.playing {
  background: var(--accent-tint);
}

.track-cover-sm {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #f3c9e0, #a9b6f2);
  flex-shrink: 0;
  object-fit: cover;
}

.track-info {
  flex: 1;
  min-width: 0;
}

.track-title {
  font-size: 14.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-artist {
  font-size: 12.5px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-action-btn {
  width: 36px;
  height: 36px;
  font-size: 14px;
  flex-shrink: 0;
}

.pin-badge {
  font-size: 11px;
  color: var(--accent-strong);
  margin-inline-start: 4px;
}

/* --------------------------- Now Playing --------------------------- */

.cover-ring-wrap {
  position: relative;
  width: 260px;
  height: 260px;
  margin: 8px auto 24px;
}

.cover-ring-svg {
  position: absolute;
  inset: 0;
  transform: rotate(-90deg);
}

.cover-ring-track {
  fill: none;
  stroke: var(--surface-alt);
  stroke-width: 4;
}

.cover-ring-progress {
  fill: none;
  stroke: url(#coverRingGradient);
  stroke-width: 4;
  stroke-linecap: round;
  /* فقط stroke-dashoffset تغییر می‌کند (طبق پرامپت، تکنیک مجاز برای
     progress دایره‌ای)، نه width/height/box-shadow. */
  transition: stroke-dashoffset 180ms linear;
}

.cover-art {
  position: absolute;
  inset: 14px;
  border-radius: 50%;
  overflow: hidden;
  box-shadow: var(--shadow-raised);
  background: linear-gradient(160deg, #f3c9e0, #a9b6f2);
}

.cover-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.now-playing-title {
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 4px;
}

.now-playing-artist {
  text-align: center;
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0 0 24px;
}

/* --- Progress bar خطی (مطابق رفرنس)، پر شدن با transform: scaleX --- */

.progress-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 28px;
}

.progress-track {
  position: relative;
  flex: 1;
  height: 4px;
  border-radius: var(--radius-round);
  background: var(--surface-alt);
  box-shadow: var(--shadow-pressed);
  overflow: visible;
}

.progress-fill {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-strong));
  transform-origin: left center;
  transform: scaleX(0); /* مقدار واقعی توسط JS ست می‌شود؛ فقط transform تغییر می‌کند */
  will-change: transform;
}

.progress-thumb {
  position: absolute;
  top: 50%;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent-strong);
  box-shadow: 0 2px 6px rgba(98, 114, 224, 0.5);
  transform: translate(-50%, -50%);
  left: 0%; /* توسط JS به‌روزرسانی می‌شود */
}

.transport-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 22px;
  margin-bottom: 20px;
}

.secondary-controls-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 30px;
  margin-bottom: 28px;
}

.secondary-controls-row .neu-circle-btn.active {
  color: var(--accent-strong);
  box-shadow: var(--shadow-pressed);
}

/* --------------------------- اکولایزر --------------------------- */

.eq-section {
  margin-bottom: 22px;
}

.eq-section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.04em;
  margin-bottom: 10px;
}

.eq-preset-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.eq-chip {
  flex-shrink: 0;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  border: none;
  border-radius: var(--radius-round);
  background: var(--surface);
  color: var(--text-secondary);
  box-shadow: var(--shadow-raised-sm);
  cursor: pointer;
  transform: translateZ(0);
  transition: transform 120ms ease;
}

.eq-chip:active {
  transform: scale(0.95) translateZ(0);
}

.eq-chip.selected {
  color: var(--text-on-accent);
  background: linear-gradient(145deg, var(--accent), var(--accent-strong));
  box-shadow: var(--shadow-pressed);
}

.clear-bass-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.clear-bass-value {
  width: 28px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-strong);
}

input[type='range'].neu-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: var(--radius-round);
  background: var(--surface-alt);
  box-shadow: var(--shadow-pressed);
  outline: none;
}

input[type='range'].neu-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--accent), var(--accent-strong));
  box-shadow: 0 2px 6px rgba(98, 114, 224, 0.5);
  cursor: pointer;
}

/* --------------------------- تنظیمات --------------------------- */

.settings-card {
  padding: 18px;
  margin-bottom: 16px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.settings-label {
  font-size: 13.5px;
  color: var(--text-primary);
}

.settings-value {
  font-size: 13px;
  color: var(--text-secondary);
}

.neu-pill-btn {
  padding: 10px 18px;
  border: none;
  border-radius: var(--radius-round);
  background: var(--surface);
  color: var(--text-primary);
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-raised-sm);
  cursor: pointer;
  transform: translateZ(0);
  transition: transform 120ms ease;
}

.neu-pill-btn:active {
  transform: scale(0.96) translateZ(0);
}

.neu-pill-btn.primary {
  color: var(--text-on-accent);
  background: linear-gradient(145deg, var(--accent), var(--accent-strong));
}

.neu-pill-btn.danger-outline {
  color: var(--danger);
}

/* --------------------------- Onboarding --------------------------- */

.onboarding-step {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 16px;
  margin-bottom: 14px;
}

.onboarding-step-number {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--accent-tint);
  color: var(--accent-strong);
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.onboarding-step-text {
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text-primary);
}

.onboarding-step-text strong {
  color: var(--accent-strong);
}

/* --------------------------- مودال تأیید دانلود دسته‌جمعی --------------------------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(69, 75, 96, 0.35);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-sheet {
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border-radius: 28px 28px 0 0;
  box-shadow: var(--shadow-raised);
  padding: 24px 20px 32px;
  transform: translateY(100%);
  transition: transform 220ms ease;
}

.modal-overlay.open .modal-sheet {
  transform: translateY(0);
}

.modal-title {
  font-size: 17px;
  font-weight: 700;
  margin: 0 0 8px;
}

.modal-body {
  font-size: 13.5px;
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  gap: 10px;
}

.modal-actions .neu-pill-btn {
  flex: 1;
  text-align: center;
}

.text-input-field {
  width: 100%;
  padding: 12px 16px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--surface);
  border: none;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-pressed);
  outline: none;
}

.text-input-field::placeholder {
  color: var(--text-secondary);
}

.playlist-picker-row {
  cursor: pointer;
}

/* --------------------------- ناوبری پایین --------------------------- */

.bottom-nav {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius-round);
  background: var(--surface);
  box-shadow: var(--shadow-raised);
  z-index: 20;
}

.bottom-nav button.active {
  box-shadow: var(--shadow-pressed);
  color: var(--accent-strong);
}

.hidden {
  display: none !important;
}

.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--text-primary);
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--radius-round);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease, transform 200ms ease;
  z-index: 60;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 360px) {
  .cover-ring-wrap { width: 220px; height: 220px; }
}
