/* =============================================================================
   ui/library.css — استایل بخش کتابخانه (موزیک + جزوه‌ها)
   برگردان دقیق ui/library/LibraryScreen.kt · Music.kt · Summaries.kt

   ثابت‌های اندروید:
     GlowSearchField → حلقهٔ conic که در ۵۲۰۰ms یک دور می‌چرخد، در فوکوس روشن‌تر
     TrackRow        → ورود پله‌ای ۴۰ms، کاور ۵۲ گوشه ۱۲
     HeartLike       → pop 1→1.28→1 و حلقهٔ جشن، رنگ #FF5B89
     SummaryCard     → کاور ۱۷۰، گوشه ۲۰
   ========================================================================== */

@property --a {
  syntax: '<angle>';
  inherits: false;
  initial-value: 0deg;
}

.lb { padding: 4px 0 22px; }

/* --------------------------------- هدر ----------------------------------- */

.lb-head {
  display: flex; align-items: center; gap: 12px;
  padding: 6px 2px 14px;
}
.lb-h1 {
  margin: 0; font-size: 24px; font-weight: 800; letter-spacing: -.3px;
  flex: 1 1 auto; min-width: 0;
}
.lb-cta {
  flex: none;
  display: inline-flex; align-items: center; gap: 6px;
  height: 40px; padding: 0 16px;
  border: 0; border-radius: 999px; cursor: pointer;
  color: #fff; font-size: 13.5px; font-weight: 700;
  background: linear-gradient(135deg, var(--primary), var(--secondary, var(--primary)));
  box-shadow: 0 6px 18px rgba(var(--primary-rgb, 234 88 12) / .28);
  transition: transform 140ms var(--e-decel), box-shadow 240ms var(--e-decel);
}
.lb-cta b { font-size: 17px; line-height: 1; font-weight: 800; }
.lb-cta:active { transform: scale(.96); }

.lb-seg { margin: 0 0 14px; }

/* --------------------------- تعویض تب: fade+slide ------------------------- */

.lb-pane { position: relative; }
.lb-anim { animation: lbIn 260ms var(--e-decel) both; }
@keyframes lbIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

/* ------------------------------ چیپ‌ها ----------------------------------- */

.lb-chips,
.lb-cats,
.lb-nhead {
  display: flex; align-items: center; gap: 8px;
  margin: 0 0 12px;
}
.lb-chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.lb-chips::-webkit-scrollbar { display: none; }
.lb-cats { flex-wrap: wrap; gap: 6px; }

.lb-chips > button,
.lb-cats > button,
.lb-catwrap > button {
  flex: none;
  height: 32px; padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 12px; font-weight: 600; white-space: nowrap; line-height: 1;
  cursor: pointer;
  transition: background 200ms var(--e-decel), color 200ms var(--e-decel),
              border-color 200ms var(--e-decel), transform 140ms var(--e-decel);
}
.lb-chips > button:active,
.lb-cats > button:active,
.lb-catwrap > button:active { transform: scale(.96); }

.lb-chips > button.on,
.lb-cats > button.on,
.lb-catwrap > button.on {
  background: rgba(var(--primary-rgb, 234 88 12) / .12);
  border-color: transparent;
  color: var(--primary);
  font-weight: 700;
}

.grow { flex: 1 1 auto; }
.min0 { min-width: 0; }
.start { text-align: start; }

/* دکمهٔ آیکنی (آپلود / بیشتر) */
.lb-icb {
  flex: none;
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border: 0; border-radius: 12px;
  background: transparent; color: var(--primary);
  cursor: pointer;
  transition: background 200ms var(--e-decel), transform 140ms var(--e-decel);
}
.lb-icb:hover { background: rgba(var(--primary-rgb, 234 88 12) / .10); }
.lb-icb:active { transform: scale(.92); }
.lb-icb.sm { width: 32px; height: 32px; color: var(--muted); }

/* --------------------------- GlowSearchField ------------------------------ */

.lb-glow {
  position: relative;
  margin: 0 0 14px;
  border-radius: 16px;
}
.lb-glow[hidden] { display: none; }
/* درخشش معادل GlowSearchField — بدون mask/conic تا در فایرفاکس هم درست باشد */
.lb-glow > .ring { display: none; }
.lb-glow > .in {
  position: relative;
  display: flex; align-items: center; gap: 8px;
  height: 50px; padding: 0 14px;
  border-radius: 16px;
  border: 1.6px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  transition: border-color 300ms var(--e-decel), box-shadow 300ms var(--e-decel);
}
.lb-glow.foc > .in {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(var(--primary-rgb) / .14);
}
.lb-glow > .in > input {
  flex: 1 1 auto; min-width: 0;
  border: 0; outline: none; background: transparent;
  color: inherit;
  font-size: 14px;
}
.lb-glow > .in > input::placeholder { color: var(--muted); }

/* ------------------------------ ردیف موزیک ------------------------------- */

.lb-body { min-height: 120px; }

.lb-tracks { display: flex; flex-direction: column; gap: 10px; }

.lb-track {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px 8px 8px;
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(0 0 0 / .04);
  animation: lbRow 300ms var(--e-decel) both;
  animation-delay: calc(var(--i, 0) * 40ms);
}
.lb-track.cur {
  background: rgba(var(--primary-rgb, 234 88 12) / .10);
  box-shadow: none;
}
.lb-track.slim { padding: 6px 10px; border-radius: 14px; }
@keyframes lbRow {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}

.lb-cov {
  flex: none; border-radius: 12px; object-fit: cover;
  background: rgba(0 0 0 / .05);
}
.lb-cov.ph {
  display: grid; place-items: center;
  font-size: 20px;
}

.lb-tt {
  font-size: 14.5px; font-weight: 700; line-height: 1.35;
  overflow-wrap:anywhere; white-space:normal;
}
.lb-ts {
  font-size: 12.5px; color: var(--muted); line-height: 1.5;
  overflow-wrap:anywhere; white-space:normal;
}
.lb-ts.pad { padding: 10px 2px; }

/* ------------------------------ HeartLike -------------------------------- */

.lb-heart {
  position: relative; flex: none;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: transparent; color: var(--muted);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 240ms var(--e-decel);
}
.lb-heart svg { fill: none; stroke: currentColor; stroke-width: 1.9; }
.lb-heart.on { color: #FF5B89; }
.lb-heart.on svg { fill: #FF5B89; stroke: #FF5B89; }
.lb-heart.pop svg { animation: lbPop 420ms cubic-bezier(.2, 1.7, .4, 1); }
@keyframes lbPop {
  0%   { transform: scale(1); }
  45%  { transform: scale(1.28); }
  100% { transform: scale(1); }
}
.lb-heart > .cel {
  position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid #FF5B89; opacity: 0; pointer-events: none;
}
.lb-heart.pop > .cel { animation: lbCel 500ms ease-out; }
@keyframes lbCel {
  0%   { opacity: .7; transform: scale(.5); }
  100% { opacity: 0; transform: scale(1.7); }
}

.lb-lk {
  flex: none; min-width: 14px;
  font-size: 12.5px; font-weight: 600; color: var(--muted);
  text-align: center;
}

/* ------------------------------ پلی‌لیست‌ها ------------------------------- */

.lb-pls { display: flex; flex-direction: column; gap: 10px; }
.lb-pl {
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 12px;
  border: 0; border-radius: 18px;
  background: var(--surface); color: inherit;
  cursor: pointer; text-align: start;
  box-shadow: 0 1px 2px rgba(0 0 0 / .04);
  animation: lbRow 300ms var(--e-decel) both;
  animation-delay: calc(var(--i, 0) * 40ms);
  transition: transform 140ms var(--e-decel);
}
.lb-pl:active { transform: scale(.99); }
.lb-pl.slim { padding: 10px 12px; border-radius: 14px; }
.lb-pl > .ic {
  flex: none; width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: rgba(var(--primary-rgb, 234 88 12) / .10);
  color: var(--primary);
}
.lb-pl b { display: block; font-size: 14.5px; font-weight: 700; }
.lb-plnew { width: 100%; margin: 0 0 12px; }

.lb-plt { margin: 2px 0 4px; font-size: 18px; font-weight: 800; }
.lb-play { width: 100%; margin: 12px 0 4px; }
.lb-prow { display: flex; gap: 8px; margin: 12px 0 4px; }
.lb-prow > .btn { flex: 1 1 0; }

/* ------------------------------ منوی ⋮ ---------------------------------- */

.lb-mh { display: flex; align-items: center; gap: 12px; padding: 2px 0 4px; }
.lb-div { height: 1px; background: var(--line); margin: 12px 0 6px; }
.lb-mi {
  display: flex; align-items: center; gap: 10px;
  width: 100%; height: 48px; padding: 0 6px;
  border: 0; border-radius: 14px;
  background: transparent; color: inherit;
  font-size: 14.5px; font-weight: 600;
  cursor: pointer; text-align: start;
  transition: background 180ms var(--e-decel);
}
.lb-mi:hover { background: rgba(0 0 0 / .04); }
.lb-mi.danger { color: var(--danger, #EF4444); }

/* ------------------------------ شیت آپلود -------------------------------- */

.lb-file { width: 100%; }
.lb-hint { font-size: 12px; color: var(--muted); line-height: 1.7; padding: 2px; }
.lb-cvbox {
  display: flex; align-items: center; gap: 10px;
  padding: 8px; border-radius: 14px;
  background: rgba(0 0 0 / .035);
}
.lb-upbtn:disabled { opacity: .5; cursor: default; }

.lb-prog {
  position: relative;
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--muted);
  padding: 8px 2px 2px;
}
.lb-prog > i {
  position: absolute; inset-inline-start: 2px; bottom: 0;
  height: 3px; width: 0; border-radius: 99px;
  background: var(--primary);
  transition: width 220ms linear;
}

.lb-sw {
  display: flex; align-items: center; gap: 10px;
  font-size: 14px; font-weight: 600;
  padding: 4px 2px;
}
.lb-sw input { width: 20px; height: 20px; accent-color: var(--primary); }

.lb-catwrap { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 4px; }

/* ------------------------------- جزوه‌ها --------------------------------- */

.lb-nhead { font-size: 15px; font-weight: 800; }

.lb-cards { display: flex; flex-direction: column; gap: 14px; }
@media (min-width: 900px) {
  .lb-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
}

.lb-card {
  border-radius: 20px; overflow: hidden;
  background: var(--surface);
  box-shadow: 0 2px 10px rgba(0 0 0 / .05);
  cursor: pointer;
  animation: lbRow 320ms var(--e-decel) both;
  animation-delay: calc(var(--i, 0) * 40ms);
  transition: transform 160ms var(--e-decel);
}
.lb-card:active { transform: scale(.99); }
.lb-card > .cv { width: 100%; height: 170px; object-fit: cover; display: block; }
.lb-card > .bd { padding: 12px 14px 14px; }
.lb-card .tt { display: flex; align-items: center; gap: 8px; }
.lb-card .tt b {
  font-size: 15px; font-weight: 800; line-height: 1.4;
  overflow-wrap:anywhere; white-space:normal;
}
.lb-card .mt {
  display: flex; align-items: center; gap: 10px;
  margin-top: 8px;
  font-size: 12.5px; color: var(--muted);
}
.lb-card .mt .h { color: #FF5B89; font-weight: 600; }
.lb-card .mt .c { display: inline-flex; align-items: center; gap: 4px; }

.lb-catpill {
  flex: none;
  padding: 4px 10px; border-radius: 999px;
  background: rgba(var(--primary-rgb, 234 88 12) / .12);
  color: var(--primary);
  font-size: 11.5px; font-weight: 700; white-space: nowrap;
}

/* --------------------------- جزئیات جزوه --------------------------------- */

.lb-pager { position: relative; margin: 0 0 12px; }
.lb-pager > .track {
  display: flex; gap: 8px;
  overflow-x: auto; scroll-snap-type: x mandatory;
  scrollbar-width: none;
  border-radius: 16px;
}
.lb-pager > .track::-webkit-scrollbar { display: none; }
.lb-pager > .track > img {
  flex: none; width: 100%; scroll-snap-align: center;
  border-radius: 16px; object-fit: contain;
  max-height: 58vh; background: rgba(0 0 0 / .04);
}
.lb-pager > .cnt {
  position: absolute; inset-block-start: 10px; inset-inline-end: 10px;
  padding: 3px 10px; border-radius: 999px;
  background: rgba(0 0 0 / .55); color: #fff;
  font-size: 11.5px; font-weight: 700;
  direction: ltr;
}

.lb-desc { margin: 4px 0 10px; font-size: 14px; line-height: 1.9; color: var(--muted); }
.lb-owner { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lb-owner b { font-size: 13.5px; font-weight: 700; }

.lb-cmh { margin: 16px 0 8px; font-size: 14.5px; font-weight: 800; }
.lb-cms { display: flex; flex-direction: column; gap: 10px; max-height: 40vh; overflow-y: auto; }
.lb-cm {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px; border-radius: 14px;
  background: rgba(0 0 0 / .035);
}
.lb-cm b { font-size: 13px; font-weight: 700; }
.lb-cm p { margin: 2px 0 0; font-size: 13.5px; line-height: 1.8; overflow-wrap: anywhere; }

.lb-cmbar { display: flex; align-items: center; gap: 8px; margin: 12px 0 0; }
.lb-cmbar > .input { flex: 1 1 auto; min-width: 0; }
.lb-cmbar > .btn:disabled { opacity: .5; cursor: default; }

/* ------------------------- کاهش حرکت (a11y) ------------------------------ */

@media (prefers-reduced-motion: reduce) {
  .lb-anim, .lb-track, .lb-pl, .lb-card { animation: none !important; }
  .lb-glow > .ring { animation: none; }
  .lb-heart.pop svg, .lb-heart.pop > .cel { animation: none; }
}

/* long titles must not widen library rows */
.grow { min-width: 0; }
.lb-nm, .lb-sub, .lb-title { overflow-wrap: anywhere; }
