/* pages/tasks.css — /tasks/ (SPEC §5.6).
 *
 * The board: a fixed top of LIST NAMES (K49) on the card's own colour, the
 * lists scrolling below it, a card per task on the M3 state-layer mechanism, S standard icon
 * buttons for edit and complete, and filled text fields for add and edit.
 *
 * A card's delete is HELD by the undo bar (views.delete): the card leaves at
 * once, the Google DELETE goes when the bar ends without Undo.
 *
 * PAGE-SCOPE RULE (§1.1, test_design check 9): every selector starts with a
 * class this file owns — `.board`, `.column*`, `.card*` (the task card), `.board__status` —
 * or with [data-page="tasks"]. All eleven page files load on every page.
 */

/* ------------------------------------------------------- the fixed top -- */

/* NO BAND (2026-10-02, "seamless"). The pane used to paint a washed band down
   to the list names' lower edge, with the lip's two notches under it (DM
   L7121-7129: the board is a masked sideways scroller, so the band could not
   be its own). The tops took the card's colour, so the band went with them:
   the heads stand on the plain card, and they scroll sideways with their own
   columns, so a head and its column can never drift. */
[data-page="tasks"].pane { padding: 0; }

/* The write status is a notice UNDER the board: a fixed top holds what the
   page IS, and whether a change reaches Google is not that (and its height
   would otherwise be part of the fixed top, which CSS cannot measure). It hugs its
   text and keeps clear of the FAB's corner (K6) when this pane has it. */
[data-page="tasks"] .notices {
  order: 1;
  justify-items: start;
  margin: 8px calc(var(--app-viewpad) + var(--fabreach)) var(--app-viewpad) var(--app-viewpad);
}

/* --------------------------------------------------------------- board -- */

/* ⚠️ `stretch`, NOT `flex-start`. THE COLUMNS MUST BE EQUALLY TALL, because a
   column's height IS its drop target.

   Under `flex-start` every column ended at its own last card, and
   `.column__cards` — the element Sortable actually accepts a drop on — ended
   with it. So dropping a card into the empty space below another column's
   cards was a drop OUTSIDE any zone: Sortable put the card back, and the
   client then posted the SOURCE list with the card's unchanged neighbour. A
   perfect 200, a correct repaint, and nothing moved. The emptiest column was
   the smallest target — Done, the one you most want to hit.

   The board fills the pane body (app.css makes it the filler), and every
   column is 100% of it: no `100vh` arithmetic, so the page never scrolls (K24)
   and a split pane is right too. The top padding is the card padding: the
   heads sit at y 16-64. A SIDEWAYS fade scroller (app.css lists `.board`). */
.board {
  flex: 1;
  min-height: 0;
  display: flex;
  gap: 16px;
  align-items: stretch;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 16px 16px 0;
}
.board[hidden] { display: none; }

/* No fill (DM: "remove the background of the individual lists!"). The radius
   stays 28 for the drop outline, which is not drawn. ⚠️ A FIXED height (100%
   of the board), never sized to the contents: lifting a card out of the
   tallest column would shrink every column mid-drag, and the zone you aimed
   at would slide out from under the pointer.
   312 SHRINKS to 288: four 312s, three gaps and the padding are 1328, and his
   1440 desktop's pane is 1320 — a rigid 312 left the board 8px of sideways
   scroll with its end fade armed while every column was in view. */
.column {
  flex: 0 1 312px;
  min-width: 288px;
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  border-radius: var(--md-sys-shape-corner-extra-large);
}
.column[hidden] { display: none; }
/* The guide between two columns starts under the list names (56 below the
   column's top at y 16 = y 72), a hairline on the card. */
.column + .column::before {
  content: "";
  position: absolute;
  left: -8px;
  top: 56px;
  bottom: 0;
  width: 1px;
  background: var(--app-color-hairline);
  pointer-events: none;
}

.column__head {
  height: 48px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;              /* the name lines up with the card titles */
  min-width: 0;
}
.column__head h2 {
  margin: 0;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--md-sys-color-on-surface);
  font-family: var(--md-ref-typeface-plain);
  font-size: var(--md-sys-typescale-title-small-size);
  line-height: var(--md-sys-typescale-title-small-line-height);
  font-weight: var(--md-sys-typescale-title-small-weight);
  letter-spacing: 0;
}
/* The count is an .m3-badge (the template adds the class): a count, not an
   alert (D9). */
.column__count { font-variant-numeric: tabular-nums; }

/* THE DROP ZONE. ⚠️ It fills the column, so its height is how big a target
   the column is; without this it shrink-wraps its cards and the rest of the
   column looks droppable while refusing every drop. `min-height` keeps an
   empty column catchable on its own. A VERTICAL fade scroller (app.css lists
   it). The first card sits 12px under the list names. */
.column__cards {
  flex: 1;
  min-height: 200px;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 0 16px;
}
.column__cards[hidden] { display: none; }
.column:last-child .column__cards { padding-bottom: calc(16px + var(--fabreach)); }
.column__empty { margin: 0; }

/* ----------------------------------------------------------------- add -- */

/* Backlog's add field: a label-less FILLED text field (§3.7's look) with a
   leading `add`. Its placeholder is its only label, so unlike .m3-textfield
   it never hides it. No focus ring: the accent indicator is the mark (§2.14). */
/* The -8px cancels the column's gap: the zone above keeps 16px of its own
   bottom padding as the space, and Backlog's drop zone stays within 56px of
   the other columns' (smoke.mjs: an empty zone is as tall as a full one, ±60). */
.column__add {
  position: relative;
  flex: none;
  margin: -8px 0 0;
}
.column__add[hidden] { display: none; }
.column__add::before {
  content: "add";
  position: absolute;
  left: 16px;
  top: 16px;
  font-family: var(--app-typeface-icon);
  font-size: var(--app-icon-size-large);
  line-height: 1;
  font-weight: normal;
  font-feature-settings: "liga";
  font-variation-settings: "FILL" 0, "opsz" 24;
  color: var(--md-sys-color-on-surface-variant);
  pointer-events: none;
}
.column__add input {
  --_container: var(--md-sys-color-surface-container-highest);
  --_state-color: var(--md-sys-color-on-surface);
  --_ind-w: 1px;
  --_ind-c: var(--md-sys-color-on-surface-variant);
  box-sizing: border-box;
  display: block;
  width: 100%;
  height: var(--app-field-h);
  margin: 0;
  padding: 0 16px 0 52px;
  border: 0;
  border-start-start-radius: var(--md-sys-shape-corner-extra-small);
  border-start-end-radius: var(--md-sys-shape-corner-extra-small);
  border-end-start-radius: var(--md-sys-shape-corner-none);
  border-end-end-radius: var(--md-sys-shape-corner-none);
  background-color: color-mix(in srgb, var(--_state-color) var(--_state), var(--_container));
  box-shadow: inset 0 calc(-1 * var(--_ind-w)) 0 var(--_ind-c);
  color: var(--md-sys-color-on-surface);
  caret-color: var(--app-color-accent);
  font-family: var(--md-ref-typeface-plain);
  font-size: var(--md-sys-typescale-body-large-size);
  line-height: var(--md-sys-typescale-body-large-line-height);
  font-weight: var(--md-sys-typescale-body-large-weight);
  letter-spacing: 0;
}
.column__add input::placeholder { color: var(--md-sys-color-on-surface-variant); opacity: 1; }
@media (hover: hover) {
  .column__add input:hover {
    --_state: var(--md-sys-state-hover-state-layer-opacity);
    --_ind-c: var(--md-sys-color-on-surface);
  }
}
.column__add input:focus {
  --_state: 0%;
  --_ind-w: 2px;
  --_ind-c: var(--app-color-accent);
  outline: none;                         /* the indicator is the mark, never the ring */
}
@media (prefers-reduced-motion: no-preference) {
  .column__add input {
    transition: background-color var(--md-sys-motion-spring-fast-effects-duration) var(--md-sys-motion-spring-fast-effects),
                box-shadow var(--md-sys-motion-spring-fast-spatial-duration) var(--md-sys-motion-spring-fast-spatial);
  }
}

/* ---------------------------------------------------------------- card -- */

/* The task card (`.card` is pinned by board.js and by `closest .card`). A
   grid, so the two icon buttons sit in COLUMNS of their own and a long title
   never runs under them. Container #282A2C with the one state layer (§2.5).
   The padding makes a one-line card exactly 56 (M3's one-line height) with
   the 40px buttons centred on the title's first line: 8 + 40 + 8. The whole
   card is the drag handle. */
.card {
  --_container: var(--md-sys-color-surface-container-high);
  --_state-color: var(--md-sys-color-on-surface);
  --_fill: 0;
  box-sizing: border-box;
  flex: none;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  column-gap: 4px;
  align-items: start;
  min-height: 56px;
  margin: 0;
  padding: 8px 8px 8px 16px;
  border-radius: var(--md-sys-shape-corner-medium);
  background-color: color-mix(in srgb, var(--_state-color) var(--_state), var(--_container));
  color: var(--md-sys-color-on-surface);
  cursor: grab;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.card[hidden] { display: none; }
@media (hover: hover) {
  .card:not(.card--editing):hover { --_state: var(--md-sys-state-hover-state-layer-opacity); }
}
/* Sortable's dragClass: the dragged state layer, lifted. */
.card--dragging {
  --_state: var(--md-sys-state-dragged-state-layer-opacity);
  box-shadow: var(--md-sys-elevation-level3);
  cursor: grabbing;
}
/* Sortable's ghostClass, the placeholder where the card will land: the
   grabbed thing stays put and dims. No colour. */
.card--ghost { opacity: .4; }
@media (prefers-reduced-motion: no-preference) {
  .card {
    transition: background-color var(--md-sys-motion-spring-fast-effects-duration) var(--md-sys-motion-spring-fast-effects),
                box-shadow var(--md-sys-motion-spring-fast-effects-duration) var(--md-sys-motion-spring-fast-effects);
  }
}

.card__title {
  grid-column: 1;
  grid-row: 1;
  margin: 0;
  padding-top: 8px;                      /* the first line centred on the 40px buttons */
  min-width: 0;
  overflow-wrap: anywhere;
  font-family: var(--md-ref-typeface-plain);
  font-size: var(--md-sys-typescale-body-large-size);
  line-height: var(--md-sys-typescale-body-large-line-height);
  font-weight: var(--md-sys-typescale-body-large-weight);
  letter-spacing: 0;
  color: var(--md-sys-color-on-surface);
}
.card__meta {
  grid-column: 1;
  grid-row: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 4px 0;
  min-width: 0;
}
.card__meta[hidden] { display: none; }
/* The date is a TEXT mark; overdue is red TEXT only, never an outline (K32). */
.card__due {
  font-family: var(--md-ref-typeface-plain);
  font-size: var(--md-sys-typescale-label-medium-size);
  line-height: var(--md-sys-typescale-label-medium-line-height);
  font-weight: var(--md-sys-typescale-label-medium-weight);
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
  color: var(--md-sys-color-on-surface-variant);
}
.card--overdue .card__due { color: var(--md-sys-color-error); }
/* The flag is a label chip (.m3-chip--label from the template). On the
   #282A2C card it steps up to #333537, or it would vanish into its ground. */
.card__flag.m3-chip { --_container: var(--md-sys-color-surface-container-highest); max-width: 100%; }

/* Edit, delete and complete: S standard icon buttons (.m3-icon-btn from the
   template; 40 visible in a 48 box). The box's 4px inset is cancelled
   vertically too, so the buttons cost the row 40, not 48. Revealed on hover
   or focus; always shown on touch (K16). Delete sits between the two, so
   complete keeps the trailing edge it always had. */
.card__edit, .card__del, .card__done {
  grid-row: 1;
  margin-block: -4px;
  opacity: 0;
}
.card__edit { grid-column: 2; }
.card__del { grid-column: 3; }
.card__done { grid-column: 4; }
.card:is(:hover, :focus-within) :is(.card__edit, .card__del, .card__done) { opacity: 1; }
@media (hover: none), (pointer: coarse) {
  .card :is(.card__edit, .card__del, .card__done) { opacity: 1; }
}
/* A refusal in a column (views.delete / commit_delete): the banner, set in
   from the column's edges like its cards. */
.column__err { flex: none; margin: 0; }
@media (prefers-reduced-motion: no-preference) {
  .card :is(.card__edit, .card__del, .card__done) {
    transition-property: opacity, border-radius, background-color, color, box-shadow;
    transition-duration:
      var(--md-sys-motion-spring-fast-effects-duration), var(--md-sys-motion-spring-default-effects-duration),
      var(--md-sys-motion-spring-fast-effects-duration), var(--md-sys-motion-spring-fast-effects-duration),
      var(--md-sys-motion-spring-fast-effects-duration);
    transition-timing-function:
      var(--md-sys-motion-spring-fast-effects), var(--md-sys-motion-spring-default-effects),
      var(--md-sys-motion-spring-fast-effects), var(--md-sys-motion-spring-fast-effects),
      var(--md-sys-motion-spring-fast-effects);
  }
}

/* ---- a card, as a form ------------------------------------------------- */

/* The same container, in edit mode. Labelled filled fields (.m3-textfield
   from the template), the due/flag pair side by side, Save (filled ink) and
   Cancel (text) at the end. Not a drag handle while it is a form. */
.card--editing {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  padding: 12px;
  cursor: default;
  user-select: auto;
}
.card__fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
}
.card__fields[hidden] { display: none; }
.card__editactions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
  margin-top: 8px;
}
.card__editactions[hidden] { display: none; }

/* --------------------------------------------------------------- phone -- */

/* A carousel of columns (DM L2440): each one a window wide less a peek of the
   next, snapped at the board's padding. The height stays 100%. The add field
   keeps clear of the FAB's corner, which the snapped Backlog column reaches
   on a phone (K6; the §5.6 hand-off): it ends where the notice under it ends,
   --app-fabclear short of the pane's edge (the column already stops 16 short).
   There is no split here (<=839px), so this pane always has the corner. */
@media (max-width: 720px) {
  .board {
    scroll-snap-type: x mandatory;
    scroll-padding-inline: 16px;
  }
  /* While a card is dragged (board.js): Sortable's autoscroll nudges the board
     10px at a time, and a mandatory snap put every nudge back. */
  .board.board--dragging { scroll-snap-type: none; }
  .column {
    flex: 0 0 calc(100vw - 64px);       /* never shrunk: a carousel page each */
    min-width: 0;
    scroll-snap-align: start;
  }
  [data-page="tasks"] .column__add { margin-inline-end: calc(var(--app-fabclear) - 16px); }
}
