/* =============================================================================
   ui/tasks.css — استایل و انیمیشن‌های بخش تسک‌ها
   برگردان مستقیم TasksScreen.kt + FireworkCheck/SliceText/PriorityRadio
   (ui/components/UiverseFx.kt · UiverseKit.kt)

   اعداد دقیقاً همان‌هایی است که در کاتلین نوشته شده:
     کادر چک‌باکس ۲۶dp · تیک tween(400, FastOutSlowIn) · ترقه tween(500, delay 90)
     لرزش ۲۶۰ms · SliceText 400ms + جابه‌جایی ۶px با تأخیر ۱۰۰
     رینگ درصد ۵۲dp/استروک ۵ · tween(700) · FadeSlideIn ۴۰ms × index
   ========================================================================== */

.tk { display: flex; flex-direction: column; gap: 4px; }

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

.tk-head {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 4px;
}
.tk-h1 { margin: 0; font-size: 1.35rem; font-weight: 900; line-height: 1.3; }
.tk-sub {
  margin-top: 2px; font-size: .78rem; color: var(--muted);
  transition: color var(--t-med) var(--e-decel);
}

/* رینگ درصد — Canvas(52.dp) با استروک ۵dp و سرهای گرد */
.tk-ring { position: relative; width: 52px; height: 52px; flex: none; }
.tk-ring svg { width: 52px; height: 52px; transform: rotate(-90deg); }
.tk-ring circle { fill: none; stroke-width: 5; stroke-linecap: round; }
.tk-ring .trk { stroke: color-mix(in srgb, var(--fg, #111) 7%, transparent); }
.tk-ring .val {
  stroke: var(--primary);
  transition: stroke-dashoffset 700ms cubic-bezier(.4, 0, .2, 1);
}
.tk-ring b {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: .68rem; font-weight: 800; color: var(--primary);
}

.tk-seg { padding: 0 2px 4px; }
.tk-list { display: flex; flex-direction: column; gap: 10px; padding: 12px 2px 96px; }

/* ------------------------------ ردیف تسک ------------------------------ */
/* Surface(shapes.large) + border 1dp outlineVariant .6 — تیک‌خورده: primary .07/.28 */

.tk-row {
  display: flex; align-items: center; gap: 4px;
  padding: 14px 15px;
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
  transition: background var(--t-med) var(--e-decel), border-color var(--t-med) var(--e-decel);
  /* FadeSlideIn: ۴۰ms × min(index, 6) — فقط رنگ و جابه‌جایی، بدون دست‌کاری در ارتفاع */
  animation: tkIn 320ms cubic-bezier(.16, 1, .3, 1) both;
  animation-delay: calc(var(--i, 0) * 40ms);
}
.tk-row.done {
  background: color-mix(in srgb, var(--primary) 7%, var(--surface));
  border-color: color-mix(in srgb, var(--primary) 28%, transparent);
}
@keyframes tkIn {
  from { opacity: 0; transform: translateY(10px) scale(.985); }
  to   { opacity: 1; transform: none; }
}

/* ---------------------------- FireworkCheck ---------------------------- */

.tk-check {
  position: relative; width: 46px; height: 46px; flex: none;
  display: grid; place-items: center;
  border-radius: 50%; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.tk-check .box { width: 46px; height: 46px; overflow: visible; }
.tk-check .frame {
  fill: none; stroke: var(--muted); stroke-width: 2;
  transition: stroke 300ms var(--e-decel);
}
.tk-check .fill {
  fill: var(--primary); opacity: 0;
  transition: opacity 400ms cubic-bezier(.4, 0, .2, 1);
}
.tk-check .tick {
  fill: none; stroke: var(--primary); stroke-width: 2.5;
  stroke-linecap: round; stroke-linejoin: round;
  /* دو خط تیک: کوتاه تا ۰٫۴۵ و بلند تا ۱ — کشیدن با dashoffset */
  stroke-dasharray: 22;
  stroke-dashoffset: 22;
  transition: stroke-dashoffset 400ms cubic-bezier(.4, 0, .2, 1);
}
.tk-check.high .frame,
.tk-check.high .tick { stroke: var(--danger, #FB7185); }
.tk-check.high .fill { fill: var(--danger, #FB7185); }

.tk-check.on .frame { stroke: var(--primary); }
.tk-check.on.high .frame { stroke: var(--danger, #FB7185); }
.tk-check.on .fill { opacity: .16; }
.tk-check.on .tick { stroke-dashoffset: 0; }
.tk-check.on.just .box { animation: tkShake 260ms linear; }

@keyframes tkShake {
  0%   { transform: translateX(0); }
  15%  { transform: translateX(2.2px); }
  33%  { transform: translateX(-2.2px); }
  50%  { transform: translateX(1.55px); }
  67%  { transform: translateX(-1.1px); }
  83%  { transform: translateX(.55px); }
  100% { transform: translateX(0); }
}

/* ترقه: شش نقطه که از ۰٫۵۵×box تا ۱٫۳×box بیرون می‌پاشند و محو می‌شوند */
.tk-check .sp {
  position: absolute; width: 4.8px; height: 4.8px; border-radius: 50%;
  background: var(--primary); opacity: 0; pointer-events: none;
}
.tk-check.high .sp { background: var(--danger, #FB7185); }
.tk-check.on.just .sp { animation: tkBurst 500ms 90ms linear; }
.tk-check .s0 { --ang: -90deg; }
.tk-check .s1 { --ang: -30deg; }
.tk-check .s2 { --ang: 30deg; }
.tk-check .s3 { --ang: 90deg; }
.tk-check .s4 { --ang: 150deg; }
.tk-check .s5 { --ang: 210deg; }

@keyframes tkBurst {
  0%   { opacity: 1; transform: rotate(var(--ang)) translateX(14.3px) scale(1); }
  100% { opacity: 0; transform: rotate(var(--ang)) translateX(33.8px) scale(.4); }
}

.tk-check.busy { cursor: default; }
.tk-spin {
  width: 16px; height: 16px; display: inline-block; flex: none;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, currentColor 25%, transparent);
  border-top-color: currentColor;
  animation: tkSpin 700ms linear infinite;
  margin-inline-end: 8px;
}
@keyframes tkSpin { to { transform: rotate(360deg); } }

/* ------------------------------- SliceText ------------------------------- */
/* خط خط‌خوردگی در RTL از راست به چپ کشیده می‌شود (tween 400)
   و متن معادل @keyframes move ۶px جابه‌جا می‌شود (tween 300 delay 100) */

.tk-slice { position: relative; display: inline-block; max-width: 100%; }
.tk-slice > span {
  display: inline-block;
  font-size: .95rem; line-height: 1.6;
  color: var(--fg, inherit);
  transition: color 400ms cubic-bezier(.4, 0, .2, 1),
              transform 300ms 100ms cubic-bezier(.4, 0, .2, 1);
}
.tk-slice > i {
  position: absolute; top: 50%; inset-inline-end: 0;
  height: 2px; width: 0;
  border-radius: 2px;
  background: var(--muted);
  transition: width 400ms cubic-bezier(.4, 0, .2, 1);
}
.tk-slice.on > span { color: var(--muted); transform: translateX(-6px); }
.tk-slice.on > i { width: 100%; }

.tk-meta { display: flex; align-items: center; gap: 8px; margin-top: 2px; flex-wrap: wrap; }

/* PriorityPill — CircleShape با پس‌زمینهٔ ۱۱٪ رنگ */
.tk-pill {
  padding: 2px 9px; border-radius: 999px; font-size: .66rem; font-weight: 700;
}
.tk-pill.high {
  color: var(--danger, #FB7185);
  background: color-mix(in srgb, var(--danger, #FB7185) 11%, transparent);
}
.tk-pill.low {
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 11%, transparent);
}
.tk-date { font-size: .66rem; color: var(--muted); }

.tk-del {
  width: 40px; height: 40px; flex: none;
  display: grid; place-items: center;
  border: 0; background: transparent; border-radius: 50%;
  color: color-mix(in srgb, var(--danger, #FB7185) 80%, transparent);
  cursor: pointer;
  transition: background var(--t-fast) var(--e-decel), transform var(--t-fast) var(--e-decel);
}
.tk-del:hover { background: color-mix(in srgb, var(--danger, #FB7185) 10%, transparent); }
.tk-del:active { transform: scale(.9); }
.tk-del[disabled] { opacity: .3; cursor: default; }

/* --------------------------------- FAB --------------------------------- */
/* Surface(60.dp, brandGradient, shadowElevation 12.dp) — مانند v17 روی body */

.tk-fab {
  position: fixed; z-index: 44;
  inset-inline-end: 20px;
  bottom: calc(var(--nav-h) + var(--safe-b) + 22px);
  width: 60px; height: 60px;
  display: grid; place-items: center;
  border: 0; border-radius: 20px;
  color: #fff; cursor: pointer;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  box-shadow: 0 12px 26px -8px color-mix(in srgb, var(--primary) 65%, transparent);
  transition: transform 140ms var(--e-decel), box-shadow 200ms var(--e-decel);
}
.tk-fab:active { transform: scale(.94); }

/* ------------------------------ شیت افزودن ------------------------------ */

.tk-lbl { margin: 14px 0 6px; font-size: .8rem; font-weight: 800; }

/* PriorityRadio — سه ستون مساوی، حلقهٔ نئونی، فنر dampingRatio .45 */
.tk-prio { display: flex; gap: 10px; }
.tk-prio button {
  flex: 1 1 0; display: flex; align-items: center; gap: 8px;
  padding: 10px; border: 0; border-radius: 13px; cursor: pointer;
  font-size: .78rem; font-weight: 700; color: var(--muted);
  background: color-mix(in srgb, var(--pc, var(--primary)) 6%, transparent);
  transition: background 260ms var(--e-decel), color 260ms var(--e-decel);
}
.tk-prio button i {
  width: 22px; height: 22px; flex: none; border-radius: 50%;
  border: 2.5px solid var(--pc, var(--primary));
  position: relative;
  transition: box-shadow 300ms cubic-bezier(.2, 1.4, .4, 1);
}
.tk-prio button i::after {
  content: ''; position: absolute; inset: 2px; border-radius: 50%;
  background: var(--pc, var(--primary));
  transform: scale(0);
  transition: transform 300ms cubic-bezier(.2, 1.7, .4, 1);
}
.tk-prio button[data-p="high"]   { --pc: #EF4444; }
.tk-prio button[data-p="normal"] { --pc: var(--primary); }
.tk-prio button[data-p="low"]    { --pc: #22C55E; }
.tk-prio button.on {
  color: var(--pc);
  background: color-mix(in srgb, var(--pc) 16%, transparent);
}
.tk-prio button.on i {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--pc) 26%, transparent);
}
.tk-prio button.on i::after { transform: scale(1); }

/* LazyRow روزها — FilterChip */
.tk-days {
  display: flex; gap: 8px; overflow-x: auto;
  padding-bottom: 4px; scrollbar-width: none;
}
.tk-days::-webkit-scrollbar { display: none; }
.tk-days button {
  flex: none; padding: 7px 13px; border-radius: 999px; cursor: pointer;
  font-size: .74rem; white-space: nowrap;
  color: var(--fg, inherit);
  background: transparent;
  border: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
  transition: background 200ms var(--e-decel), border-color 200ms var(--e-decel),
              color 200ms var(--e-decel), transform 200ms var(--e-decel);
}
.tk-days button.on {
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 16%, transparent);
  border-color: color-mix(in srgb, var(--primary) 55%, transparent);
  transform: scale(1.04);
}

.tk-addbtn { height: 50px; display: flex; align-items: center; justify-content: center; }

/* ------------------------- اسنک‌بار بازگرداندن ------------------------- */
/* AppSnack.undoable — SnackbarDuration.Long (۱۰ ثانیه)؛ DELETE تا پایان این مدت صبر می‌کند */

.tk-snack {
  position: fixed; z-index: 92;
  inset-inline: 16px;
  bottom: calc(var(--nav-h) + var(--safe-b) + 16px);
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-radius: 16px;
  background: #1F2937; color: #fff;
  font-size: .82rem;
  box-shadow: 0 14px 34px -12px rgba(0, 0, 0, .6);
  opacity: 0; transform: translateY(14px);
  transition: opacity 240ms var(--e-decel), transform 240ms var(--e-decel);
}
.tk-snack.in { opacity: 1; transform: none; }
.tk-snack span { flex: 1 1 auto; }
.tk-snack button {
  flex: none; border: 0; background: transparent; cursor: pointer;
  color: #4ADE9F; font-weight: 800; font-size: .82rem;
  padding: 4px 6px; border-radius: 8px;
}
.tk-snack button:active { transform: scale(.94); }

@media (min-width: 900px) {
  .tk-snack { inset-inline: auto 24px; max-width: 420px; bottom: 24px; }
  .tk-fab { bottom: 26px; }
}

@media (prefers-reduced-motion: reduce) {
  .tk-row { animation: none; }
  .tk-check.on .box,
  .tk-check.on .sp { animation: none; }
  .tk-check.on .sp { opacity: 0; }
}

/* overflow guards */
.tk-row > *, .tk-main { min-width: 0; }
.tk-title, .tk-note { overflow-wrap: anywhere; word-break: break-word; }
