/* Ledger A - tasks: task blocks on the grid (with the lock, the late flag, the "(2/3)" piece
   label and the Done circle), the Done tick and notes in the task form, the Tasks page list and
   the "Time to do" box. Loaded LAST, after events.css and travel.css: task blocks are also
   .event-block, and these rules must come later to win. */

/* ---------- tasks placed on the grid ---------- */
/* Same shape as an event block (each task block is also an .event-block, with its title and
   time as .event-block__title and .event-block__time). A light cream body (a touch deeper than
   the stage so it shows), a very thin border on the top, right and bottom, and a thick bar down
   the left side in the commitment's colour (--event-colour is set by js/ui/tasks/task-block.js).
   A circle in the top-right corner completes the task. */
.task-block {
  padding: var(--space-2) var(--space-20) var(--space-2) var(--space-5); /* room on the right for the circle */
  border: var(--border-thin) solid var(--colour-line-strong);
  border-left: var(--border-stripe) solid var(--event-colour);
  background: var(--colour-surface-frame);
  color: var(--colour-text);
}
/* A manual task (locked in place) has a mini lock in its top-left corner, after the colour bar.
   The block keeps the same shade as an auto task. */
.task-block--manual {
  padding-left: var(--space-15);
}
/* A block planned on or after its task's deadline day gets a small warning triangle, just left of
   the complete circle (SPEC C.f). */
.task-block--late {
  padding-right: var(--space-34);
}
.late-icon {
  position: absolute;
  top: 3px;
  right: 18px;
  width: var(--size-13);
  height: var(--size-13);
  pointer-events: none;
}
/* The same triangle sitting in a line of text: before a late task's name in the task list, and in
   the task form's note under Deadline. */
.late-icon--inline {
  position: static;
  flex: none;
  width: var(--size-14);
  height: var(--size-14);
  margin-right: var(--space-5);
  vertical-align: calc(var(--space-2) * -1);
}
.task-row__late,
.late-note,
.stretch-note {
  color: var(--colour-late);
  font-size: var(--font-size-sm);
}
.late-note,
.stretch-note {
  display: flex;
  align-items: flex-start;
  margin: calc(var(--space-4) * -1) 0 var(--space-10);
}
.late-note[hidden],
.stretch-note[hidden] {
  display: none;
}
/* The "Override normal rules" tick under a late note is in the same red, so it stands out. */
.check-label--late {
  color: var(--colour-late);
}
.late-icon__triangle {
  fill: var(--colour-late);
}
.late-icon__mark {
  fill: var(--colour-on-done);
}
/* A block whose task's schedule windows were stretched by 90 minutes or more gets a small clock
   (SPEC C.f.i.1.a), where the triangle sits; beside the triangle (to its left) if it has one. */
.task-block--stretched {
  padding-right: var(--space-34);
}
.task-block--late.task-block--stretched {
  padding-right: calc(var(--space-34) + var(--size-13));
}
.stretch-icon {
  position: absolute;
  top: 3px;
  right: 18px;
  width: var(--size-13);
  height: var(--size-13);
  pointer-events: none;
}
.stretch-icon--second {
  right: 34px;
}
/* The same clock in a line of text: the task list and the note in the task form. */
.stretch-icon--inline {
  position: static;
  flex: none;
  width: var(--size-14);
  height: var(--size-14);
  margin-right: var(--space-5);
  vertical-align: calc(var(--space-2) * -1);
}
.stretch-icon__face {
  fill: var(--colour-late);
}
.stretch-icon__hands {
  fill: var(--colour-on-done);
}
/* "(2/3)" after the title of a piece of a split task. The name gives way first. */
.event-block__title--piece {
  display: flex;
  gap: var(--space-3);
}
.task-block__piece-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.task-block__piece-label {
  flex: none;
  font-weight: var(--font-weight-normal);
  opacity: var(--opacity-65);
}
.task-block__lock {
  position: absolute;
  top: 3px;
  left: 2px;
  width: var(--size-10);
  height: var(--size-10);
  fill: var(--colour-text-muted);
  pointer-events: none;
}
.task-block:hover {
  background: var(--colour-surface-control);
  filter: none;
}
/* The button that opens the task lies over the whole block, see-through: the block's own title and
   time stay where they were (which keeps the look exactly as before). It sits under the resize
   strips and the Done circle, which come after it. */
.task-block__open {
  position: absolute;
  inset: 0;
  padding: 0;
  border: 0;
  border-radius: inherit;
  background: none;
  cursor: inherit;
}
.task-block__complete {
  position: absolute;
  top: 3px;
  right: 3px;
  width: var(--size-12);
  height: var(--size-12);
  padding: 0;
  background: transparent;
  border: var(--border-check) solid var(--colour-text-muted);
  border-radius: var(--radius-round);
  cursor: pointer;
}
.task-block__complete:hover {
  border-color: var(--colour-text);
  background: var(--colour-surface-strong);
}

/* A finished task keeps its block, dimmed (the text and the block, but not the circle, which
   stays a bright green with a white tick). The same circle is the Done tick in the task form.
   A finished block keeps its dimmed look when hovered (hence the :hover in the list). */
.task-block--done,
.task-block--done:hover {
  cursor: pointer; /* a finished task can't be dragged */
  border-color: color-mix(in srgb, var(--colour-line-strong) 50%, transparent);
  border-left-color: color-mix(in srgb, var(--event-colour) 50%, transparent);
  background: color-mix(in srgb, var(--colour-surface-frame) 50%, transparent);
}
.task-block--done .event-block__title,
.task-block--done .event-block__time {
  opacity: var(--opacity-50);
}
.done-check {
  width: var(--size-16);
  height: var(--size-16);
  margin: 0;
  border: var(--border-check) solid var(--colour-text-muted);
  border-radius: var(--radius-round);
  appearance: none;
  cursor: pointer;
}
.task-block--done .task-block__complete,
.done-check:checked {
  border-color: var(--colour-done);
  background: var(--colour-done) var(--done-tick) center / 80% no-repeat;
}
/* After :checked on purpose: hovering a ticked box still darkens its edge. */
.done-check:hover {
  border-color: var(--colour-text);
}

/* ---------- the task form's note under "Time to do" ---------- */
/* "1 h done so far" under a part-finished task's "Time to do" box */
.done-note {
  margin: calc(var(--space-4) * -1) 0 var(--space-10);
  color: var(--colour-text-muted);
  font-size: var(--font-size-relative-small);
}
.done-note[hidden] {
  display: none;
}

/* ---------- tasks: the list page ---------- */
.task-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}
.task-row {
  display: flex;
  align-items: stretch;
  gap: 0;
  width: 100%;
  padding: 0;
  overflow: hidden;
  border: var(--border-thin) solid var(--colour-line-strong);
  border-radius: var(--radius-8);
  background: var(
    --colour-surface-control
  ); /* mostly grey-ish body; the colour is only a tag (SPEC B.b.i.ii) */
  color: var(--colour-text);
  text-align: left;
}
.task-row:hover {
  background: var(--colour-surface-strong);
}
/* A finished task in the task list. */
.task-row--done {
  opacity: var(--opacity-55);
}
.task-row__tag {
  flex: none;
  width: var(--size-8);
}
.task-row__text {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
  padding: var(--space-8) var(--space-12);
}
.task-row__title {
  font-weight: var(--font-weight-bold);
}
.task-row__detail {
  color: var(--colour-text-muted);
  font-size: var(--font-size-sm);
}
.task-row__commitment {
  flex: none;
  align-self: center;
  padding: 0 var(--space-12);
  color: var(--colour-text-muted);
  font-size: var(--font-size-sm);
}

/* ---------- the scissors (hold X) ---------- */
/* While X is held the whole calendar shows scissors, and a dashed line on the hovered task block
   shows where a click would cut it (js/ui/tasks/task-cut.js). */
.calendar--cutting,
.calendar--cutting .task-block,
.calendar--cutting .task-block__open,
.calendar--cutting .event-block__resize {
  cursor: var(--cursor-scissors);
}
.task-block__cut-line {
  position: absolute;
  left: 0;
  right: 0;
  /* "top" is measured inside the block's 1px border, and the line is 2px thick: pull it up so
     its middle sits exactly on the cut minute, level with the scissors' joint. */
  margin-top: calc((var(--border-thin) + var(--size-2) / 2) * -1);
  border-top: var(--size-2) dashed var(--colour-text); /* as thick as the now line */
  pointer-events: none;
}
