/* ─────────────────────────────────────────────────────────────────────────
   TO-DO LIST — Home › Today and a place's Activity (METIS-pub#810, #817).

   Markup: crm/partials/_todo_list.html (a section) and _todo_row.html (a row);
   data: core.todos.todo_list. The page around it is the welcome page
   (web/app/templates/sites/welcome.html); module spacing and headings are
   sites.css's .welcome-module.

     .todo-page               the page: the to-do grid, then what follows it
     .todo-list               a section; .disclosure, folded by disclosure.js
     .todo-list__count        the count beside the heading, quiet
     .todo-row                one row: who or what · kind · where … due
     .todo-row__mark          an action's bolt, a camp's flag, in the face slot
     .todo-row__kind          the kind's chip (.chip--typed), word and mark
     .todo-kind--<key>        a kind's colour pair (--todo-kind-* tokens) for
                              .chip--typed and the mark: action, outreach, camp,
                              conversation
     .todo-toolbar            the kind filter: the list toolbar's segmented
                              control (sites/_todo_kinds.html)
     .todo-page__list         the list, beside the shared side panel
                              (.todo-side__feed, side-panel.css)
     .todo-row__step          a journey step: a dot in --todo-step-color + name
     .todo-row__due--overdue  red; --edit: the date as a button that opens
                              .todo-row__editor (crm/js/cell_editor.js)
     .todo-list__places       an empty Home's "See <place>'s Activity →" links
     .record-overview         a record's Overview: its rows, then the sections

   In the wide main column a row is one line; in the side column and on a
   phone its kind and where wrap under the name, past the face.
   ───────────────────────────────────────────────────────────────────────── */

@layer components {
  .todo-page {
    padding-top: var(--space-6);
  }

  .todo-page__list {
    container: todo-list / inline-size;
    max-inline-size: 64rem;
  }

  .todo-list__title {
    display: flex;
    align-items: baseline;
    gap: var(--space-2);
  }

  .todo-list__count {
    color: var(--color-text-muted);
    font-weight: 400;
  }

  .todo-list__note {
    font-size: var(--text-sm);
  }

  .todo-list__rows {
    list-style: none;
    margin: var(--space-2) 0 0;
    padding: 0;
    border-top: 1px solid var(--color-border-light);
  }

  .todo-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    column-gap: var(--space-3);
    row-gap: var(--space-1);
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--color-border-light);
  }

  /* Folded until "Show all": the attribute is the server's, the open state
     disclosure.js's. */
  .todo-list:not([data-open]) .todo-row[data-more] {
    display: none;
  }

  .todo-row__main {
    min-width: 0;
    color: var(--color-text-strong);
    font-weight: 500;
    text-decoration: none;
  }

  .todo-row__main:hover .person-face__name,
  .todo-row__main:hover .todo-row__title {
    text-decoration: underline;
  }

  .todo-row__lead {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    min-width: 0;
    max-width: 100%;
  }

  /* The face's slot and size (person-face.css's --sm), so names line up. */
  .todo-row__mark {
    flex: none;
    display: inline-grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border-radius: var(--radius-full);
    background: var(--chip-accent-bg, var(--color-surface-2));
    color: var(--chip-accent-fg, var(--color-text-muted));
  }

  .todo-row__title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* The second line sits under the name, past the face and its gap. */
  .todo-row__meta {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: var(--space-2);
    min-width: 0;
    padding-left: calc(24px + var(--space-2));
    color: var(--color-text-muted);
    font-size: var(--text-sm);
  }

  .todo-row__kind {
    flex: none;
  }

  /* Each kind's colour pair, read by .chip--typed and by the row's mark. */
  .todo-kind--action {
    --chip-accent-bg: var(--todo-kind-action-bg);
    --chip-accent-fg: var(--todo-kind-action-text);
  }

  .todo-kind--outreach {
    --chip-accent-bg: var(--todo-kind-outreach-bg);
    --chip-accent-fg: var(--todo-kind-outreach-text);
  }

  .todo-kind--camp {
    --chip-accent-bg: var(--todo-kind-camp-bg);
    --chip-accent-fg: var(--todo-kind-camp-text);
  }

  .todo-kind--conversation {
    --chip-accent-bg: var(--todo-kind-conversation-bg);
    --chip-accent-fg: var(--todo-kind-conversation-text);
  }

  .todo-kind__icon {
    flex: none;
  }

  /* The row open in the side panel. */
  .todo-row:has(> .todo-row__main[aria-current]) {
    background: color-mix(in oklab, var(--color-accent) 8%, transparent);
    border-left: var(--space-1) solid var(--color-accent);
    padding-left: var(--space-2);
  }

  .todo-row__where,
  .todo-row__step {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* The calm step chip: a dot in the journey's colour, the step's name. */
  .todo-row__step {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 0 var(--space-2);
    border-radius: var(--radius-full);
    background: var(--color-surface-2);
    color: var(--color-text);
  }

  .todo-row__step::before {
    content: "";
    flex: none;
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
    background: var(--todo-step-color, var(--color-accent));
  }

  .todo-row__due {
    grid-column: 2;
    grid-row: 1;
    font-size: var(--text-sm);
    white-space: nowrap;
    color: var(--color-text-muted);
    font-variant-numeric: tabular-nums;
  }

  .todo-row__due--overdue {
    color: var(--color-danger);
    font-weight: 500;
  }

  /* The date as a control (an action the reader may edit): quiet until
     pointed at, then the same dashed underline as the quest row's cells. */
  .todo-row__due--edit {
    justify-self: end;
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    font-size: var(--text-sm);
    cursor: pointer;
    text-decoration: underline dashed transparent;
    text-underline-offset: 3px;
    transition: text-decoration-color var(--transition-fast);
  }

  .todo-row__due--edit:hover,
  .todo-row__due--edit:focus-visible {
    text-decoration-color: currentColor;
  }

  /* The date's autosave field, under the row, as wide as it. */
  .todo-row__editor {
    grid-column: 1 / -1;
    padding: var(--space-3);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
  }

  .todo-row__editor:empty {
    display: none;
  }

  .todo-sections__note {
    margin: 0 0 var(--space-3);
    color: var(--color-text-muted);
    font-size: var(--text-sm);
  }

  .todo-list__places {
    list-style: none;
    margin: var(--space-2) 0 0;
    padding: 0;
    display: grid;
    gap: var(--space-1);
  }

  .todo-list__all {
    margin-top: var(--space-2);
    padding-inline: 0;
  }

  .todo-list[data-open] .todo-list__open,
  .todo-list:not([data-open]) .todo-list__shut {
    display: none;
  }

  .todo-list__empty {
    margin: var(--space-2) 0 0;
    color: var(--color-text-muted);
  }

  /* The kind filter, over the list. */
  .todo-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    padding-block: 0 var(--space-4);
  }

  .todo-toolbar__count {
    color: var(--color-text-muted);
    font-variant-numeric: tabular-nums;
  }

  /* The list's side panel (side-panel.css). Whose Home it is is the band's
     header (place-header.css). */
  .todo-side__body {
    padding: 0 var(--space-4) var(--space-4);
  }

  /* Its Updates reel stays the shared sideways scroller (video-card.css,
     METIS-pub#810): one card the panel's width at a time, snapping, the next
     one's edge showing that there is more. */
  .todo-side__feed .video-reel > .video-card--wide,
  .todo-side__feed .video-reel > .video-card-slot--wide {
    flex-basis: 88%;
  }

  /* A phone: the Updates come under the list, as a section of the page
     (the panel's default in the page's flow, side-panel.css). */
  @media (max-width: 768px) {
    .side-panel:not([data-sheet]) .todo-side__body {
      padding-inline: 0;
    }
  }

  /* A record's Overview (crm/record_overview.html): its rows (Responsible,
     Due, Links) or its journeys come first, then the to-do sections, set
     apart as one module is from the next (sites.css's .welcome-module +
     .welcome-module), so "Overdue" does not sit on the Links row. */
  .record-overview > :not(.welcome-module) + .welcome-module {
    margin-top: var(--space-8);
    padding-top: var(--space-6);
    border-top: 1px solid var(--color-border);
  }

  /* A place's own blocks around the to-do grid: its lead (a gathering's
     banner) first, above the grid; the rest under it. */
  .todo-page > :is(.welcome-module, section):not(:first-child) {
    margin-top: var(--space-8);
  }

  .todo-page > :is(.welcome-module, section):first-child {
    margin-bottom: var(--space-8);
  }

  /* Wide main column: one line per row (who · kind · where … due). */
  @container todo-list (min-width: 36rem) {
    .todo-page__list .todo-row {
      grid-template-columns: minmax(0, calc(var(--space-16) * 4)) minmax(0, 1fr) auto;
    }

    .todo-page__list .todo-row__meta {
      grid-column: 2;
      grid-row: 1;
      padding-left: 0;
    }

    .todo-page__list .todo-row__due {
      grid-column: 3;
    }
  }
}
