.task-item {
  /* Height of a row's first line. The checkbox, the title's first line and
     the delete button are each centred within it, so a one-line task sits in
     the middle of its hover/focus box and a multi-line one stays top-aligned. */
  --task-line: 24px;
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: 6px var(--space-2);
  border-radius: var(--radius-md);
  position: relative;
}

.task-item:hover {
  background: var(--color-hover-row);
}

/* The list scrolls (overflow), which would clip a ring drawn outside the
   row; draw it inside the row's edge instead. */
.task-item:focus-visible {
  outline-offset: -2px;
}

.task-item.task-dragging {
  opacity: 0.4;
}

/* Two classes: must outweigh the base checkbox rule's `margin: 0`. */
.task-item .task-checkbox {
  margin-top: calc((var(--task-line) - 18px) / 2);
}

.task-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  /* Pads the title's line box (font size × the inherited 1.4 line height)
     out to --task-line. */
  padding-block: calc((var(--task-line) - var(--font-size-task) * 1.4) / 2);
}

/* Title with its due date right after it; a long title wraps and the date
   follows on the last line's row or drops below, never squeezed. */
.task-headline {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px var(--space-2);
}

.task-title {
  min-width: 0;
  font-size: var(--font-size-task);
  overflow-wrap: break-word;
}

.task-item-completed .task-title {
  text-decoration: line-through;
  color: var(--color-text-muted);
}

/* First line of the notes, on one line under the title. */
.task-notes-preview {
  overflow: hidden;
  color: var(--color-text-muted);
  font-size: 0.8rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}


.task-due-badge {
  flex: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0 var(--space-1);
  color: var(--color-text-muted);
  font-size: 0.78rem;
  white-space: nowrap;
}

.task-due-badge.task-due-overdue {
  background: var(--color-inverse-bg);
  border-color: var(--color-inverse-bg);
  color: var(--color-inverse-text);
  font-weight: 600;
}

.task-due-badge.task-due-today {
  border-color: var(--color-border-strong);
  color: var(--color-text);
  font-weight: 600;
}

.task-delete-button {
  flex-shrink: 0;
  width: var(--task-line);
  height: var(--task-line);
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--color-text-muted);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}

.task-delete-button:hover {
  background: var(--color-hover-row);
  color: var(--color-text);
}

/* A task that has just been moved (keyboard or drop) is tinted briefly so the
   eye can find where it landed. */
@keyframes task-moved {
  from {
    background: var(--color-moved);
  }
}

.task-item.task-moved {
  animation: task-moved 900ms ease-out;
}

/* Drag & drop insertion indicator (design D8): a thin bar drawn between rows.
   The element itself takes no space (zero height, and a negative margin that
   cancels the list gap it would add), so rows don't jump as the bar moves. */
.drop-insertion-line {
  position: relative;
  flex: none;
  height: 0;
  margin: -1px var(--space-2);
  pointer-events: none;
}

.drop-insertion-line::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: -1px;
  height: 2px;
  border-radius: 2px;
  background: var(--color-focus);
}

/* The quadrant a dragged task would land in: a translucent wash over
   whatever surface the card has, plus a stronger border. */
.quadrant-drag-over {
  border-color: var(--color-border-strong);
  box-shadow: inset 0 0 0 100vmax var(--color-hover-row);
}

.quadrant-do.quadrant-drag-over {
  box-shadow: inset 0 0 0 100vmax var(--color-hover-row), var(--shadow-raised);
}
