/* Daily tasks (docs/TASKS.md §7): the student checklist (Home card and #/tasks), the Telegram connect card, and the
   teacher's Tasks page. Colours come from the app.css tokens only, so both themes work without dark rules.
   Prefixes: .tk-* the student checklist and Telegram card (public/js/tasks.js, pages/student/tasks.js, Home). */

/* `hidden` must win over the component display rules below. */
.tk [hidden], .tk-home [hidden], .tk-tg [hidden], .tk-tg-slim [hidden] { display: none !important; }

/* =========================================================================
   Checklist (public/js/tasks.js checklist())
   ========================================================================= */
.tk-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.tk-item {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; min-width: 0;
  padding: 8px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--card);
  transition: background .15s, border-color .15s;
}
/* A done row sinks toward the page (in both themes --bg is darker than a card). */
.tk-item.is-done { background: var(--bg); }
.tk-item.is-overdue:not(.is-done) { border-color: var(--warn-line); box-shadow: inset 4px 0 0 var(--warn); }

.tk-main { flex: 1 1 260px; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
/* The whole label (box + text) is the tap target: at least 44 px tall. */
.tk-check { display: flex; align-items: center; gap: 12px; min-height: 44px; min-width: 0; cursor: pointer; }
.tk-check.is-static { cursor: default; }
.tk-box { flex: none; width: 24px; height: 24px; margin: 0; accent-color: var(--ok); cursor: pointer; }
.tk-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.tk-kind {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; color: var(--muted);
}
.tk-kind .icon { flex: none; color: var(--brand-dark); }
.tk-title { font-weight: 700; font-size: 15px; color: var(--ink); overflow-wrap: anywhere; }
.tk-item.is-done .tk-title { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 1px; }
.tk-item.is-done .tk-kind .icon { color: var(--muted); }

/* Meta and details line up with the text, after the 24 px box and its 12 px gap. */
.tk-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; padding-left: 36px; font-size: 13px; color: var(--muted); }
.tk-dot { color: var(--faint); }
.tk-due { display: inline-flex; align-items: center; gap: 4px; }
.tk-due .icon { flex: none; }
.tk-due.is-overdue { color: var(--warn-text); font-weight: 700; }
.tk-due.is-progress { color: var(--warn-text); font-weight: 600; }
.tk-auto { font-style: italic; }
.tk-details { margin: 4px 0 2px; padding-left: 36px; font-size: 14px; color: var(--muted); white-space: pre-line; overflow-wrap: anywhere; }

.tk-actions { flex: 0 1 auto; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }
.tk-btn { min-height: 40px; }
.tk-file { max-width: 280px; min-width: 0; }
.tk-file-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tk-file-size { flex: none; font-weight: 500; color: var(--muted); }
.tk-file-off { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; font-size: 13px; color: var(--muted); }

/* Items the site ticks by itself (tests, practice): a round status mark in place of the box. */
.tk-mark {
  flex: none; width: 24px; height: 24px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  border: 2px solid var(--line-strong); color: var(--muted);
}
.tk-mark.is-progress { border-color: var(--warn); background: var(--warn-soft); color: var(--warn-text); }
.tk-mark.is-done { border-color: var(--ok); background: var(--ok); color: var(--on-status); }

.tk-practice-meta { gap: 6px 10px; }
.tk-progress { flex: 1 1 120px; max-width: 220px; height: 6px; }
.tk-practice.is-met .tk-progress > span { background: var(--ok); }

/* Home card: tighter rows, no details. */
.tk-list.is-compact { gap: 6px; }
.tk-list.is-compact .tk-item { padding: 4px 10px; }
.tk-list.is-compact .tk-title { font-size: 14.5px; }

@media (max-width: 560px) {
  /* The buttons move under the text (lined up with it) instead of squeezing it. */
  .tk-actions { flex-basis: 100%; padding-left: 36px; }
  .tk-actions .tk-file { flex: 0 1 auto; }
  .tk-list.is-compact .tk-item { padding-bottom: 8px; }
}

/* =========================================================================
   #/tasks page
   ========================================================================= */
.tk { display: flex; flex-direction: column; gap: 20px; }
.tk > .page-head { margin-bottom: 0; }
.tk .page-title:focus { outline: none; }
.tk-card { overflow: hidden; }
.tk-card-head {
  display: flex; flex-direction: column; gap: 8px; padding: 14px 18px; border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--brand-soft), var(--card));
}
.tk-sum { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.tk-sum-label { font-weight: 800; font-size: 16px; }
.tk-sum-text { font-weight: 700; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tk-sum-bar { height: 8px; }
.tk-card.is-complete .tk-sum-bar > span { background: var(--ok); }
.tk-card-body { padding: 14px; }
.tk-card-foot { display: flex; flex-direction: column; gap: 10px; padding: 0 18px 16px; }
.tk-card-foot:empty { display: none; }
.tk-alldone { display: flex; align-items: center; gap: 8px; margin: 0; }
.tk-alldone .icon { flex: none; }
.tk-hint { margin: 0; font-size: 13px; color: var(--muted); }
.tk-empty { text-align: center; padding: 32px 16px; color: var(--muted); }
.tk-empty p { margin: 0 0 4px; }
.tk-empty-title { font-weight: 700; font-size: 16px; color: var(--ink); }
.tk-empty-icon {
  display: inline-flex; align-items: center; justify-content: center; width: 52px; height: 52px; margin-bottom: 10px;
  border-radius: 50%; background: var(--brand-soft); color: var(--brand-dark);
}
@media (max-width: 480px) {
  .tk-card-head { padding-left: 14px; padding-right: 14px; }
  .tk-card-body { padding: 10px; }
  .tk-card-foot { padding: 0 14px 14px; }
}

/* =========================================================================
   Telegram card (telegramCard()) and the slim prompt on Home
   ========================================================================= */
.tk-tg-body { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; padding: 16px 18px; }
.tk-tg-icon {
  flex: none; width: 44px; height: 44px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: var(--info-soft); color: var(--info-text);
}
.tk-tg-icon.is-small { width: 32px; height: 32px; }
.tk-tg.is-connected .tk-tg-icon { background: var(--ok-soft); color: var(--ok-text); }
.tk-tg.is-blocked .tk-tg-icon { background: var(--warn-soft); color: var(--warn-text); }
.tk-tg-text { flex: 1 1 260px; min-width: 0; }
.tk-tg-title { font-size: 17px; font-weight: 800; margin: 0 0 2px; }
.tk-tg-sub { margin: 0; font-size: 14px; color: var(--muted); overflow-wrap: anywhere; }
.tk-tg-sub strong { color: var(--ink); }
.tk-tg-actions { flex: none; display: flex; flex-wrap: wrap; gap: 8px; }
.tk-tg-actions .btn { min-height: 40px; }
.tk-tg-foot { padding: 0 18px; }
.tk-tg-hint { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; margin: 0 0 16px; }
.tk-tg-hint .btn { min-height: 40px; }
.tk-tg-blocked { display: flex; align-items: flex-start; gap: 8px; margin: 0 0 16px; }
.tk-tg-blocked .icon { flex: none; margin-top: 2px; }
@media (max-width: 560px) {
  .tk-tg-body { padding: 14px; }
  .tk-tg-foot { padding: 0 14px; }
  .tk-tg-actions { flex-basis: 100%; }
  .tk-tg-actions .btn { flex: 1 1 auto; }
}

.tk-tg-slim { display: flex; flex-direction: column; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--line); background: var(--surface-2); }
.tk-tg-slim-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; }
.tk-tg-slim-text { flex: 1 1 200px; min-width: 0; font-size: 14px; color: var(--muted); }
.tk-tg-slim .tk-tg-connect { min-height: 40px; }
.tk-tg-slim .tk-tg-hint { margin: 0; }

/* =========================================================================
   Home: "Today's tasks" card (above the plan)
   ========================================================================= */
.tk-slot { margin: 0 0 24px; }
.tk-slot:empty { display: none; }
.tk-home { overflow: hidden; }
.tk-home-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; padding: 14px 16px 10px; }
.tk-home-head-text { min-width: 0; }
.tk-home-title { font-size: 18px; font-weight: 800; letter-spacing: -.01em; margin: 0; }
.tk-home-title:focus { outline: none; }
.tk-home-sub { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.tk-home.is-complete .tk-home-sub { color: var(--ok-text); font-weight: 600; }
.tk-home-all { flex: none; min-height: 40px; }
.tk-home-bar { height: 6px; margin: 0 16px 12px; }
.tk-home.is-complete .tk-home-bar > span { background: var(--ok); }
.tk-home-body { padding: 0 12px 12px; }
@media (max-width: 480px) {
  .tk-home-head { padding: 12px 14px 8px; }
  .tk-home-bar { margin: 0 14px 10px; }
  .tk-home-body { padding: 0 8px 10px; }
  .tk-tg-slim { padding: 12px 14px; }
}
