/* Nomios web UI: tasks (the task board). Design system: docs/design/DESIGN_SYSTEM.md.
   The stylesheets are linked in this order: tokens, base, shell, components, tasks, pages. */

@layer tasks {
  /* The hero: date, greeting, a quiet line, and the progress card. */
  .hero {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-4) var(--space-6);
    margin-bottom: var(--space-5);
  }

  .hero-text {
    flex: 1 1 18rem;
    min-width: 0;
  }

  .eyebrow {
    margin: 0;
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: var(--tracking-eyebrow);
    color: var(--color-text-muted);
  }

  .hero h1 {
    margin: var(--space-1) 0;
    font-size: var(--text-3xl);
    font-weight: 650;
  }

  .progress-card {
    flex: 0 1 15rem;
    padding: var(--space-3) var(--space-4);
    background: var(--glass-raised-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: inset 0 1px 0 var(--glass-highlight);
  }

  .progress-title {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin: 0;
    font-size: var(--text-sm);
    font-weight: 600;
  }

  .progress-count {
    font-size: var(--text-lg);
    font-variant-numeric: tabular-nums;
  }

  .spark {
    display: block;
    width: 100%;
    height: 2rem;
    margin: var(--space-2) 0 var(--space-1);
  }

  .spark polyline {
    fill: none;
    stroke: var(--color-accent);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .progress-card .note {
    margin: 0;
    font-size: var(--text-xs);
  }

  .board-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: var(--space-3);
  }

  .board-toolbar .btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    text-decoration: none;
  }

  .board-toolbar .btn[aria-current="true"] {
    border-color: var(--color-accent);
  }

  .trail-pill {
    display: inline-flex;
    gap: var(--space-2);
    margin: 0;
    padding: var(--space-2) var(--space-4);
    font-size: var(--text-sm);
    background: var(--glass-raised-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-pill);
  }

  .trail-pill span {
    color: var(--color-text-muted);
  }

  .filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: var(--space-3) var(--space-4);
    margin-bottom: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--color-column);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
  }

  .filter-bar label {
    display: grid;
    gap: var(--space-1);
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: var(--tracking-eyebrow);
    text-transform: uppercase;
    color: var(--color-text-muted);
  }

  .filter-bar select {
    min-width: 11rem;
    font-size: var(--text-sm);
    letter-spacing: 0;
    text-transform: none;
  }

  /* Project chips: a legend of the project colours that also filters the board. */
  .chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
  }

  .chip {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    min-width: 0;
    overflow-wrap: anywhere; /* a project name without a space must not widen the page */
    gap: var(--space-2);
    padding: var(--space-1) var(--space-3);
    font-size: var(--text-sm);
    color: var(--color-text);
    text-decoration: none;
    background: var(--glass-raised-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-pill);
    transition:
      transform var(--dur-fast) var(--ease-spring),
      border-color var(--dur-fast) var(--ease-standard);
  }

  .chip:hover {
    transform: translateY(var(--lift));
    border-color: var(--color-border-strong);
  }

  .chip.is-active {
    border-color: var(--color-accent);
    font-weight: 600;
  }

  .dot {
    flex: none;
    width: 0.6rem;
    height: 0.6rem;
    background: var(--project, var(--status-neutral));
    border-radius: 50%;
  }

  /* Do today: the one task to look at first. */
  .do-today {
    display: grid;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
    padding: var(--space-3) var(--space-4);
    background: var(--glass-raised-bg);
    border: 1px solid var(--color-border);
    border-inline-start: 4px solid var(--project, var(--color-accent));
    border-radius: var(--radius-lg);
  }

  .do-today-title {
    margin: 0;
    font-size: var(--text-xs);
    font-weight: 700;
    letter-spacing: var(--tracking-eyebrow);
    text-transform: uppercase;
    color: var(--color-text-muted);
  }

  .do-today-body {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2) var(--space-4);
  }

  .do-today-task {
    display: flex;
    flex: 1 1 14rem;
    align-items: center;
    gap: var(--space-2);
    margin: 0;
    font-size: var(--text-lg);
  }

  .do-today .btn {
    text-decoration: none;
  }

  /* The board: four columns of task cards. */
  .task-columns {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr));
    gap: var(--space-4);
    align-items: start;
  }

  .task-columns-single {
    grid-template-columns: minmax(0, 1fr);
  }

  .task-column {
    min-width: 0;
    padding: var(--space-3);
    background: var(--color-column);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
  }

  .task-column > h2 {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin: var(--space-1) var(--space-2) var(--space-3);
    font-size: var(--text-base);
  }

  .column-add {
    display: inline-grid;
    place-items: center;
    width: 1.75rem;
    height: 1.75rem;
    margin-inline-start: auto;
    color: var(--color-text-muted);
    border-radius: var(--radius-pill);
    text-decoration: none;
  }

  .column-add:hover {
    color: var(--color-text);
    background: var(--color-hover);
  }

  .column-add .icon {
    width: 1rem;
    height: 1rem;
  }

  /* The floating "+": a new task from anywhere on the board. */
  .fab {
    position: fixed;
    inset-block-end: var(--space-6);
    inset-inline-end: var(--space-6);
    z-index: var(--z-sticky);
    display: grid;
    place-items: center;
    width: var(--fab-size);
    height: var(--fab-size);
    color: var(--color-accent-contrast);
    background: var(--color-accent);
    border-radius: 50%;
    box-shadow: var(--shadow-2);
    transition: transform var(--dur-fast) var(--ease-spring);
  }

  .fab:hover {
    transform: translateY(var(--lift)) scale(1.05);
  }

  .fab:active {
    transform: scale(var(--press-scale));
  }

  .fab .icon {
    width: 1.5rem;
    height: 1.5rem;
  }

  .task-cards {
    display: grid;
    gap: var(--space-3);
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .task {
    min-width: 0;
    padding: var(--space-3);
    background: var(--glass-raised-bg);
    border: 1px solid var(--color-border);
    border-inline-start: 4px solid var(--project, var(--color-border-strong));
    border-radius: var(--radius-md);
    box-shadow: inset 0 1px 0 var(--glass-highlight);
    transition:
      transform var(--dur-fast) var(--ease-spring),
      border-color var(--dur-fast) var(--ease-standard);
  }

  .task:hover {
    transform: translateY(var(--lift));
    border-color: var(--color-border-strong);
    border-inline-start-color: var(--project, var(--color-border-strong));
  }

  .task-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-2);
  }

  .task-title {
    flex: 1 1 0; /* fills the row, so the flag stays at the right and the grip at the left */
    min-width: 0;
    margin: 0;
    font-size: var(--text-base);
    overflow-wrap: anywhere;
    hyphens: auto; /* German compounds break at a syllable, with a hyphen (html lang follows the catalog) */
  }

  .task-title a {
    color: var(--color-text);
    text-decoration: none;
  }

  .task-title a:hover {
    text-decoration: underline;
  }

  .task-flag {
    flex: none;
    color: var(--status-awaiting);
  }

  .task-flag .icon {
    width: 1rem;
    height: 1rem;
  }

  .task-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-1) var(--space-3);
    margin: var(--space-2) 0 0;
    font-size: var(--text-xs);
  }

  .due {
    font-weight: 600;
    color: var(--color-text-muted);
  }

  .due-today {
    color: var(--status-awaiting);
  }

  .due-overdue {
    color: var(--status-failed);
  }

  .project-tag {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    min-width: 0;
    overflow-wrap: anywhere;
    gap: var(--space-1);
    color: var(--color-text-muted);
  }

  .signals {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-1) var(--space-3);
    margin: var(--space-2) 0 0;
    padding: 0;
    list-style: none;
    font-size: var(--text-xs);
    color: var(--color-text-muted);
  }

  .signal {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
  }

  .signal .icon {
    width: 0.9rem;
    height: 0.9rem;
  }

  .signal-waiting {
    color: var(--status-awaiting);
  }

  .solve-confirm {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
    margin-top: var(--space-2);
    padding-top: var(--space-2);
    border-top: 1px solid var(--color-border);
  }

  .solve-confirm .note {
    flex: 1 1 100%;
    margin: 0;
  }

  .signal-proposal {
    color: var(--status-awaiting);
  }

  .signal-working {
    color: var(--color-accent);
  }

  .signal-working .working-mark {
    margin-top: 0;
  }

  /* Effort: three bars, one to three of them filled. */
  .bars {
    display: inline-flex;
    align-items: flex-end;
    gap: 2px;
    height: 0.9rem;
  }

  .bars i {
    width: 3px;
    background: currentcolor;
    opacity: 0.3;
  }

  .bars i:nth-child(1) {
    height: 40%;
  }

  .bars i:nth-child(2) {
    height: 70%;
  }

  .bars i:nth-child(3) {
    height: 100%;
  }

  .effort-1 .bars i:nth-child(-n + 1),
  .effort-2 .bars i:nth-child(-n + 2),
  .effort-3 .bars i {
    opacity: 1;
  }

  /* Drag and drop: the grip is added by board.js, so a page without it shows none. */
  .grip {
    flex: none;
    align-self: flex-start;
    width: 0.75rem;
    height: 1.25rem;
    margin-inline-end: var(--space-1);
    color: var(--color-text-muted);
    cursor: grab;
    touch-action: none;
    background: radial-gradient(currentcolor 1.2px, transparent 1.5px) 0 0 / 6px 6px;
    opacity: 0.55;
  }

  .grip:hover {
    opacity: 1;
  }

  .task.is-dragging {
    position: relative;
    z-index: var(--z-overlay);
    cursor: grabbing;
    box-shadow: var(--shadow-2);
    opacity: 0.92;
    transition: none;
  }

  .task.is-dragging .grip {
    cursor: grabbing;
  }

  .task-column.drop-target {
    outline: 2px dashed var(--color-accent);
    outline-offset: 2px;
  }

  .task-column.drop-refused {
    outline: 2px dashed var(--status-failed);
    outline-offset: 2px;
  }

  .task.drop-before {
    box-shadow: 0 -4px 0 -1px var(--color-accent);
  }

  .task-column.drop-end .task-cards {
    padding-bottom: var(--space-2);
    box-shadow: 0 4px 0 -1px var(--color-accent);
  }

  @media (prefers-reduced-motion: no-preference) {
    .task.just-dropped {
      animation: settle var(--dur-slow) var(--ease-spring);
    }
  }

  @keyframes settle {
    from {
      transform: scale(1.03);
    }
  }

  .task-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1);
    margin-top: var(--space-2);
    padding-top: var(--space-2);
    border-top: 1px solid var(--color-border);
  }

  .task-actions form {
    display: contents;
  }

  .icon-button {
    display: inline-grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    color: var(--color-text-muted);
    background: transparent;
    border-color: transparent;
    box-shadow: none;
    border-radius: var(--radius-sm);
  }

  .icon-button:hover {
    color: var(--color-text);
    background: var(--color-hover);
  }

  .icon-button[aria-pressed="true"] {
    color: var(--status-awaiting);
  }

  .icon-button:disabled {
    opacity: 0.45;
  }

  .icon-button .icon {
    width: 1rem;
    height: 1rem;
  }

  /* The feedback on a result (U64b): a history that is only ever added to, and one field. */
  .followups {
    display: grid;
    gap: var(--space-3);
    padding: var(--space-4);
    background: var(--color-sunken);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
  }

  .followup-list {
    display: grid;
    gap: var(--space-3);
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .followup {
    padding-inline-start: var(--space-3);
    border-inline-start: 2px solid var(--color-border);
  }

  .followup time {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
  }

  .followup p {
    margin: var(--space-1) 0 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
  }

  /* A primary button that waits (no words yet, unsaved changes) stays readable: a quiet look. */
  .followups .btn:disabled,
  .modal-foot [data-send-off]:disabled {
    color: var(--color-text-muted);
    background: var(--glass-raised-bg);
    border-color: var(--color-border-strong);
    opacity: 1;
  }

  .followup-count {
    text-align: end;
    font-variant-numeric: tabular-nums;
  }
}
