/* Completion belongs to the circular control, not to the whole habit or agenda. */
:root {
  --completion-surface: var(--green-soft);
  --completion-border: var(--green);
  --completion-ink: var(--green);
  --completion-control-surface: var(--green-soft);
}

.habits-v2 .habit-card.is-complete {
  background: var(--surface);
  border-color: var(--line);
}
.habits-v2 .is-complete .habit-body .habit-progress {
  color: var(--muted);
  font-weight: 550;
}
.habits-v2 .habit-card.is-complete .habit-body h3 {
  color: var(--text);
}
.agenda-event.is-complete .agenda-icon {
  background: var(--green-soft);
  color: var(--green);
  box-shadow: none;
}
.agenda-event.is-complete .agenda-title h3 {
  color: var(--text);
}
.agenda-event.is-complete .agenda-progress,
.agenda-completed-label {
  color: var(--muted);
}

/* Keep generous tap areas; the visible check and its circle stay compact. */
.habits-v2 .habit-card > .habit-action,
.agenda-event .agenda-action {
  position: relative;
  isolation: isolate;
  border-radius: 50%;
}
.habits-v2 .habit-card > .habit-action:has(.empty-circle) {
  background: transparent;
}
.habits-v2 .habit-card > .habit-action.done,
.agenda-event .agenda-action.done {
  color: var(--completion-ink);
  background: transparent;
  box-shadow: none;
}
.habits-v2 .habit-card > .habit-action.done::before,
.agenda-event .agenda-action.done::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 32px;
  height: 32px;
  transform: translate(-50%, -50%);
  border: 1.5px solid var(--completion-ink);
  border-radius: 50%;
  background: var(--completion-control-surface);
  pointer-events: none;
  z-index: -1;
}
.habits-v2 .habit-card > .habit-action.done > svg,
.agenda-event .agenda-action.done > svg {
  width: 21px;
  height: 21px;
  stroke-width: 2.5;
}

/* Tasks retain their list color, with the same green circular completion mark. */
.check-btn,
.subtask .check-btn {
  border-radius: 50%;
}
.task-card.is-complete .check-btn,
.check-btn.done,
.check-btn.checked {
  color: var(--completion-ink);
  background: var(--completion-control-surface);
  border-color: var(--completion-ink);
}
.task-card.is-complete .check-btn > svg,
.check-btn.done > svg,
.check-btn.checked > svg {
  stroke-width: 2.5;
}
.subtask input[type='checkbox'] {
  appearance: none;
  -webkit-appearance: none;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  min-width: 22px;
  padding: 0;
  border: 1.5px solid var(--muted);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}
.subtask input[type='checkbox']:checked {
  border-color: var(--completion-ink);
  background: var(--completion-control-surface);
}
.subtask input[type='checkbox']:checked::before {
  content: '';
  width: 5px;
  height: 9px;
  margin-top: -2px;
  transform: rotate(45deg);
  border: solid var(--completion-ink);
  border-width: 0 2px 2px 0;
}

/* Green still conveys results in statistics, rather than tinting the main cards. */
.history-calendar .stats-day.completed,
.history-calendar .history-day.completed {
  border-color: var(--completion-border);
  color: var(--green);
}
.history-legend i.completed {
  border-color: var(--green);
}
.history-calendar .stats-day.partial,
.history-calendar .history-day.partial,
.history-legend i.partial {
  border-color: var(--yellow);
}

@media (max-width: 560px) {
  .agenda-event.is-complete .agenda-icon {
    box-shadow: none;
  }
}
