/* The personal day list (/today, today/index): a flat list of rows in
   the list view's card language — check, id, title with the project and
   archive underneath, labels, column dropdown, assignee, ⋮. Archive-
   independent page: no sidebar, no resource header. */
@layer components {
  .today-page {
    max-width: 62rem;
    margin: 0 auto;
    padding: 0.5rem 0 3rem;
  }

  .today-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem 1.5rem;
    margin-bottom: 1rem;
  }

  .today-title {
    margin: 0;
    font-size: 1.6rem;
    color: var(--ink);
  }

  .today-date {
    margin: 0.15rem 0 0;
    color: var(--muted);
  }

  /* "3 von 7 erledigt" with a gold bar — replaced with every row answer. */
  .today-progress {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--muted);
    font-size: 0.95rem;
    min-height: 1.5rem;
  }

  .today-progress-bar {
    display: block;
    width: 12rem;
    max-width: 40vw;
    height: 0.5rem;
    border-radius: 999px;
    background: var(--gold);
    overflow: hidden;
  }

  .today-progress-fill {
    display: block;
    height: 100%;
    background: var(--gold-bright);
    transition: width 0.3s ease;
  }

  /* Progress and the "Erledigte ausblenden" switch, right of the title. */
  .today-tools {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.25rem;
  }

  .today-hide-done {
    height: auto;
  }

  /* Progress and the red "+ Aufgabe" (the board's button) on one line,
     the switch underneath. The form itself waits in a dialog (today/new),
     so the list starts right under the header. */
  .today-tools-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
  }

  .today-add-button {
    flex-shrink: 0;
  }

  /* The dialog's form: title over project, both full width. */
  .today-add-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-width: min(28rem, 80vw);

    & input[type="text"],
    & select {
      width: 100%;
    }
  }

  .today-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
  }

  .today-row {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 2.2rem 0.6rem 0.75rem;
    border-radius: 12px;
    border: 1px solid var(--surface-border);
    background: var(--surface);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.08);
  }

  /* Important tasks wear the same gold as the board card and the list
     row (kanban.css / item_list.css), read from the same attribute the
     star flips (favorite_controller) — so the tint answers the click
     itself. A done row keeps it: the strike through the title says
     finished, the surface says important. */
  .today-row[data-favorite-favorite="true"] {
    background: #faf0d4;
  }

  /* Drag & drop (today_controller): the dragged row leaves a faint ghost
     in the list, the lifted copy (touch fallback) casts a shadow. */
  .today-row-ghost {
    opacity: 0.4;
  }

  .today-row-chosen {
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.16);
  }

  /* The handle: six dots at the row's start. A mouse may drag the whole
     row, so it is only a hint there; touch drags by it alone —
     touch-action: none keeps the page from scrolling under the finger. */
  .today-row-handle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 1.1rem;
    margin-left: -0.35rem;
    color: var(--muted-3);
    --icon-size: 1.1rem;
    cursor: grab;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
  }

  .today-row:hover .today-row-handle {
    color: var(--muted);
  }

  @media (pointer: coarse) {
    /* A finger needs more than the icon: the handle spans the row's height. */
    .today-row-handle {
      align-self: stretch;
      width: 1.5rem;
      color: var(--muted-2);
    }
  }

  /* "Erledigte ausblenden" — the controller's value hides the done rows;
     once nothing is left to see, the note below the list says so. */
  .today-page[data-today-hide-done-value="true"] .today-row.is-done {
    display: none;
  }

  .today-all-done {
    display: none;
    margin: 0;
    padding: 1.5rem 1rem;
    text-align: center;
    color: var(--muted);
    border: 1px dashed var(--surface-border);
    border-radius: 12px;
    background: var(--cream-soft);
  }

  .today-page[data-today-hide-done-value="true"] .today-list:has(.today-row):not(:has(.today-row:not(.is-done))) + .today-all-done {
    display: block;
  }

  /* Every entry waits: the list is empty, the note says why instead of
     an empty gap above the waiting section. */
  .today-all-waiting {
    display: none;
    margin: 0;
    padding: 1.5rem 1rem;
    text-align: center;
    color: var(--muted);
    border: 1px dashed var(--surface-border);
    border-radius: 12px;
    background: var(--cream-soft);
  }

  .today-list:not(:has(.today-row)) ~ .today-all-waiting {
    display: block;
  }

  /* During a drag (today_controller sets is-dragging on the page) an
     empty list — the list when every entry waits, the waiting section
     before its first entry, the source once its only row is lifted — is
     a dashed box with the hint, so there is something to drop onto; the
     "all waiting" note makes way for it. */
  .today-page.is-dragging .today-all-waiting {
    display: none;
  }

  .today-page.is-dragging .today-list:not(:has(.today-row)) {
    min-height: 3.2rem;
    align-items: center;
    justify-content: center;
    border: 1px dashed var(--muted-3);
    border-radius: 12px;
    color: var(--muted-2);
    font-size: 0.85rem;
  }

  .today-page.is-dragging .today-list:not(:has(.today-row))::before {
    content: attr(data-drop-hint);
  }

  /* ---- Waiting section (doc/wartezustand-spezifikation.html) ----
     The column's waiting area, flat: below the list, under a label like
     the column's, a dashed line between. Always in the DOM (stream
     target), collapsed by CSS while it has no row to show — none at all,
     or only done ones the switch hides — and open as a drop zone while
     a row is being dragged. :has(), not :empty — ERB leaves whitespace
     text nodes in the list. */
  .today-waiting {
    display: none;
    flex-direction: column;
    gap: 0.6rem;
    margin-top: 1.25rem;
    padding-top: 0.9rem;
    border-top: 1px dashed var(--muted-3);
  }

  .today-waiting:has(.today-row),
  .today-page.is-dragging .today-waiting {
    display: flex;
  }

  .today-page[data-today-hide-done-value="true"]:not(.is-dragging) .today-waiting:not(:has(.today-row:not(.is-done))) {
    display: none;
  }

  .today-waiting-label {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    margin: 0;
    padding: 0 0.25rem;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted-2);
  }

  /* A waiting row: damped and the title muted like the waiting card
     (kanban.css .kanban-card.is-waiting), the reason line under the
     crumb — one line, ellipsized; the tooltip carries the whole text. */
  .today-row.is-waiting {
    opacity: 0.78;
  }

  .today-row.is-waiting .today-row-title {
    color: var(--muted);
  }

  .today-row-waiting {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    min-width: 0;
    margin-top: 0.1rem;
    font-size: 0.78rem;
    color: var(--muted-2);
  }

  .today-row-waiting .icon {
    flex-shrink: 0;
  }

  .today-row-waiting span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .today-row-waiting-since {
    flex-shrink: 0;
    color: var(--muted-3);
  }

  /* The check: a square that fills green once the task sits in a done
     column. Follows the column, never a state of its own. */
  .today-check {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    flex-shrink: 0;
    border-radius: 7px;
    border: 1.5px solid var(--muted-3);
    color: transparent;
    background: var(--surface);
    --icon-size: 1rem;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  }

  .today-check:hover {
    border-color: var(--done-green);
    color: var(--done-green);
  }

  .today-row.is-done .today-check {
    background: var(--done-green);
    border-color: var(--done-green);
    color: #fff;
  }

  .today-row-id {
    flex-shrink: 0;
    min-width: 2.4rem;
  }

  .today-row-main {
    flex: 1 1 12rem;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
  }

  .today-row-title {
    color: var(--ink);
    font-weight: 500;
    text-decoration: none;
    overflow-wrap: anywhere;
  }

  .today-row-title:hover {
    color: var(--wine);
  }

  .today-row.is-done .today-row-title {
    text-decoration: line-through;
    color: var(--muted-2);
  }

  .today-row-crumb {
    font-size: 0.8rem;
    color: var(--muted);
  }

  .today-row-project {
    color: var(--muted);
    font-weight: 500;
    text-decoration: none;
  }

  .today-row-project:hover {
    color: var(--wine);
  }

  .today-row-since {
    color: var(--muted-3);
  }

  .today-row-chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.35rem;
    flex-shrink: 0;
  }

  .today-row .kanban-card-assignee {
    margin-left: 0;
  }

  /* The star: the list row's size (kanban.css .kanban-list-star), its
     color and glyph come from kanban.css off the row's attribute. */
  .today-row-favorite {
    --icon-size: 1.15rem;
  }

  .today-row-menu {
    position: absolute;
    right: 0.35rem;
    top: 50%;
    transform: translateY(-50%);
  }

  .today-hint {
    margin: 1.25rem 0 0;
    color: var(--muted-2);
    font-size: 0.85rem;
  }

  .today-empty {
    padding: 2.5rem 1rem;
    text-align: center;
    border: 1px dashed var(--surface-border);
    border-radius: 12px;
    background: var(--cream-soft);
  }

  .today-empty-title {
    margin: 0 0 0.4rem;
    font-weight: 600;
    color: var(--ink);
  }

  .today-empty-body {
    margin: 0 auto;
    max-width: 34rem;
    color: var(--muted);
  }

  @media (max-width: 640px) {
    .today-row {
      flex-wrap: wrap;
      row-gap: 0.4rem;
    }

    .today-row-id {
      display: none;
    }

    /* The phone folds the header to two lines: "Heute" with the progress
       right of it, then the date with the switch right of it. Both wrappers
       dissolve (display: contents) so the four pieces can take grid cells;
       the bar gives way so "9 von 22 erledigt" stays whole next to the
       title. */
    .today-header {
      display: grid;
      grid-template-columns: auto minmax(0, 1fr);
      grid-template-areas:
        "title progress"
        "date switch";
      align-items: center;
      row-gap: 0.15rem;
    }

    .today-heading,
    .today-tools {
      display: contents;
    }

    .today-title {
      grid-area: title;
    }

    .today-tools-row {
      grid-area: progress;
      justify-content: flex-end;
      min-width: 0;
      gap: 0.5rem;
    }

    .today-progress {
      justify-content: flex-end;
      min-width: 0;
    }

    /* The button shrinks to its plus — "9 von 22 erledigt" keeps the room. */
    .today-add-button-text {
      display: none;
    }

    .today-header .today-add-button.btn-small {
      padding-inline: 0.375rem;
    }

    .today-progress-bar {
      flex: 0 1 8rem;
      width: auto;
      max-width: none;
      min-width: 2.5rem;
    }

    .today-progress-text {
      white-space: nowrap;
    }

    .today-date {
      grid-area: date;
    }

    .today-hide-done {
      grid-area: switch;
      justify-self: end;
      min-width: 0;
    }

    /* Handle, check and title share the first line; the chips wrap under
       the title (indented past handle and check) as one group. */
    .today-row-chips {
      flex-basis: 100%;
      justify-content: flex-start;
      padding-left: 3.45rem;
    }

    @media (pointer: coarse) {
      .today-row-chips {
        padding-left: 3.85rem;
      }
    }
  }
}
