/* ==================================================================================================
   Domain components — owner: design-system agent (feature agents may extend in their page CSS)

   .task-card      board card (components/task_card.html). States: .is-done, .is-active (open in
                   the drawer), Sortable classes. Parts: __labels, __title, __type, __meta, __key,
                   __stats, __assignee
   .task-row       list row (components/task_row.html). Parts: __check, __main, __title, __key,
                   __labels, __project, __meta. States: .is-done, .is-active
   .task-key       "WEB-12" monospace-ish key
   .priority       signal bars (prio-* sprite symbols); data-priority="0..4" colors it
   .due            due-date chip: data-state="overdue|today|soon|later|done"
   .type-icon      task type glyph (bug/feature/…): color via data-color
   .user-chip      avatar + name · .project-chip (chip with icon tile) · .label-chip (chip)
   Drag & drop     .sortable-ghost / .sortable-chosen / .sortable-drag / .sortable-fallback
   ================================================================================================== */

/* -- Task key ------------------------------------------------------------------------------------ */
.task-key {
  color: var(--text-3);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

/* -- Priority (signal bars) ---------------------------------------------------------------------- */
.priority {
  display: inline-grid;
  flex-shrink: 0;
  place-items: center;
  color: var(--text-3);
}
.priority[data-priority="1"] { color: var(--text-2); }
.priority[data-priority="2"] { color: var(--c-yellow-ink); }
.priority[data-priority="3"] { color: var(--c-orange); }
.priority[data-priority="4"] { color: var(--c-red); }
.priority-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

/* -- Task type glyph ----------------------------------------------------------------------------- */
.type-icon {
  display: inline-grid;
  flex-shrink: 0;
  place-items: center;
  color: var(--tone-ink);
}

/* -- Due chip ------------------------------------------------------------------------------------ */
.due {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 7px 0 6px;
  border-radius: var(--radius-full);
  color: var(--text-2);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.due .icon {
  opacity: 0.85;
}
.due[data-state="overdue"] {
  background: color-mix(in srgb, var(--c-red) 13%, transparent);
  color: var(--c-red-ink);
}
.due[data-state="today"] {
  background: color-mix(in srgb, var(--c-orange) 15%, transparent);
  color: var(--c-orange-ink);
}
.due[data-state="soon"] {
  background: color-mix(in srgb, var(--c-blue) 12%, transparent);
  color: var(--c-blue-ink);
}
.due[data-state="later"] {
  background: var(--fill-1);
}
.due[data-state="done"] {
  color: var(--text-3);
  text-decoration: line-through;
  text-decoration-color: color-mix(in srgb, currentColor 50%, transparent);
}

/* -- Entity chips -------------------------------------------------------------------------------- */
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  max-width: 100%;
  font-size: var(--fs-md);
  vertical-align: middle;
}
.user-chip__name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-chip__sub {
  color: var(--text-2);
  font-size: var(--fs-xs);
}
a.user-chip:hover .user-chip__name {
  text-decoration: underline;
  text-underline-offset: 0.18em;
}
.user-chip--pill {
  height: 26px;
  padding: 0 10px 0 3px;
  border-radius: var(--radius-full);
  background: var(--fill-1);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
}
.project-chip {
  gap: 6px;
  padding-left: 3px;
  background: var(--fill-1);
  color: var(--text);
}
.project-chip .icon-tile {
  --size: 16px;
}
a.project-chip:hover {
  background: var(--fill-2);
}
.label-chip {
  font-weight: var(--fw-medium);
}

/* -- Task card (board) --------------------------------------------------------------------------- */
.task-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  padding: 12px 12px 10px;
  border-radius: 12px;
  background: var(--surface);
  box-shadow:
    0 0 0 1px var(--card-ring),
    var(--shadow-sm);
  color: var(--text);
  cursor: pointer;
  touch-action: manipulation;
  transition:
    transform var(--dur-2) var(--ease-out),
    box-shadow var(--dur-2) var(--ease-out),
    opacity var(--dur-2) ease;
  -webkit-touch-callout: none;
}
@media (hover: hover) {
  .task-card:hover {
    transform: translateY(-1px);
    box-shadow:
      0 0 0 1px var(--card-ring),
      var(--shadow-md);
  }
}
.task-card:active {
  transform: scale(0.985);
}
.task-card:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 2px var(--accent),
    0 0 0 5px var(--focus-ring);
}
.task-card.is-active {
  box-shadow:
    0 0 0 2px var(--accent),
    var(--shadow-md);
}
.task-card__labels {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-width: 0;
}
.task-card__labels .chip {
  max-width: 140px;
}
.task-card__title {
  display: -webkit-box;
  overflow: hidden;
  font-family: var(--font-sans);
  font-size: var(--fs-md);
  font-weight: var(--fw-medium);
  letter-spacing: -0.005em;
  line-height: 1.38;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow-wrap: anywhere;
}
.task-card__type {
  display: inline-block;
  margin-right: 4px;
  vertical-align: -2px;
  color: var(--tone-ink);
}
.task-card__done {
  display: inline-block;
  margin-right: 4px;
  vertical-align: -3px;
  color: var(--success);
}
.task-card__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  min-width: 0;
  min-height: 22px;
}
.task-card__stats {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.task-card__assignee {
  margin-left: auto;
}
.task-card.is-done {
  opacity: 0.62;
}
.task-card.is-done .task-card__title {
  color: var(--text-2);
}
.task-card.is-done:hover {
  opacity: 0.9;
}
.meta--done {
  color: var(--success-ink);
}
.meta--done .icon {
  color: var(--success);
}

/* -- Task row (list) ----------------------------------------------------------------------------- */
.task-row {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px 12px;
  min-height: 44px;
  padding: 8px 16px;
  background: var(--surface);
  transition: background-color var(--dur-1) ease;
}
.task-row + .task-row {
  box-shadow: inset 0 1px 0 var(--line);
}
.task-row:hover {
  background: var(--surface-2);
}
.task-row.is-active {
  background: var(--accent-softer);
}
.task-row__main {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.task-row__title {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-weight: var(--fw-medium);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.task-row__title::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
}
.task-row__title:focus-visible {
  outline: none;
}
.task-row:has(.task-row__title:focus-visible) {
  box-shadow: inset 0 0 0 2px var(--accent);
}
.task-row .check-circle,
.task-row__meta > :is(a, button),
.task-row__labels,
.task-row__project {
  position: relative;
  z-index: 1;
}
.task-row__labels {
  display: flex;
  flex-shrink: 1;
  gap: 4px;
  min-width: 0;
  overflow: hidden;
}
.task-row__meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}
.task-row__meta .due {
  min-width: 0;
}
.task-row.is-done .task-row__title {
  color: var(--text-3);
  text-decoration: line-through;
  text-decoration-color: color-mix(in srgb, currentColor 45%, transparent);
}
@media (max-width: 767px) {
  .task-row {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: start;
    padding: 12px 16px;
  }
  .task-row .check-circle {
    margin-top: 1px;
  }
  .task-row__main {
    flex-wrap: wrap;
    row-gap: 2px;
  }
  .task-row__title {
    flex: 1 1 100%;
    white-space: normal;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
  }
  .task-row__labels {
    display: none;
  }
  .task-row__meta {
    grid-column: 2;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 8px;
  }
  .task-row__meta .avatar {
    margin-left: auto;
  }
}

/* -- Favorite star (components/favorite_button.html) --------------------------------------------- */
.favorite-toggle.is-on,
.favorite-toggle.is-on:hover {
  background: transparent;
  color: var(--c-yellow);
}
@media (prefers-reduced-motion: no-preference) {
  .favorite-toggle.is-on .icon {
    animation: pop 380ms var(--ease-spring);
  }
}

/* -- Drag & drop (SortableJS) -------------------------------------------------------------------- */
.sortable-ghost {
  opacity: 0.35;
}
.task-card.sortable-ghost,
.task-row.sortable-ghost {
  opacity: 1;
  background: var(--accent-softer);
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--accent) 45%, transparent);
}
.task-card.sortable-ghost > *,
.task-row.sortable-ghost > * {
  visibility: hidden;
}
.sortable-chosen {
  cursor: grabbing;
}
.sortable-drag,
.sortable-fallback {
  opacity: 1 !important;
  transform: rotate(1.5deg) scale(1.02);
  box-shadow:
    0 0 0 1px var(--card-ring),
    var(--shadow-xl) !important;
  cursor: grabbing;
}
.drag-handle {
  color: var(--text-3);
  cursor: grab;
  touch-action: none;
}
.drag-handle:active {
  cursor: grabbing;
}
