/* Shared by every task-row context: task/domain/agenda lists, search
   results, and the add-to-agenda picker (all now variants of
   tasks/_task_row.html -- see GitHub issue #207). Previously lived as a
   <style> block re-included per page (_task_row_styles.html); promoted to a
   real stylesheet once search.html needed the same rules instead of its own
   near-duplicate copy. */

.task-list {
  list-style: none;
  /* Break out of .main-content's horizontal padding so the list reaches
     screen edge to screen edge; row-level padding keeps the checkbox and
     assignee from touching the edge directly. */
  margin: 0 calc(-1 * var(--space-4));
  padding: 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.responsibility-list {
  border-bottom: none;
}

@media (min-width: 768px) {
  .task-list {
    /* .main-content's horizontal padding widens to 2rem at this breakpoint. */
    margin: 0 calc(-1 * var(--space-7));
  }
}

.task-row {
  position: relative;
  min-height: 40px;
  /* Clips .task-row-actions-left/-right (the swipe-revealed action zones)
     until the foreground layer slides away from over them. */
  overflow: hidden;
}

.task-row + .task-row {
  border-top: 1px solid var(--border);
}

.task-row.is-dragging {
  position: relative;
  z-index: 2;
}

/* The visible, tappable/swipeable/draggable layer -- opaque so it fully
   hides .task-row-actions-left/-right until swiped, and the thing
   task-row-gestures.js actually transforms during a reorder drag or swipe. */
.task-row-foreground {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2);
  min-height: 40px;
  background: var(--bg);
  /* Let native vertical scroll proceed by default; task-row-gestures.js
     only takes over once it's classified a gesture as horizontal
     (swipe) or as an armed reorder-drag. */
  touch-action: pan-y;
}

.task-row-foreground:hover {
  background: var(--surface-sunken);
}

.task-row.is-dragging .task-row-foreground {
  background: var(--surface);
  box-shadow: var(--shadow-drag);
}

/* Once a horizontal swipe or reorder owns the pointer, stop browser
   overscroll/rubber-banding from competing with it. Vertical scrolling is
   still native while the gesture is pending and being classified. */
.task-row-gesture-lock {
  overscroll-behavior: none;
  touch-action: none;
  overflow: hidden;
}

.main-content.task-row-gesture-lock {
  overflow-y: hidden;
}

/* Read-only row variants (search results, the agenda picker) render the
   whole foreground as a link/static block instead of a draggable surface. */
a.task-row-foreground {
  text-decoration: none;
  color: inherit;
}

/* Swipe-revealed action zones, behind the foreground layer -- one on each
   edge, each holding 1+ .task-row-action buttons. Only rendered for rows
   that have real actions to reveal on that side (see task-row-gestures.js,
   which treats a missing zone as "nothing to swipe that direction," same
   as before this was generalized from one hardcoded zone to two, see
   GitHub issue #207). The layer spans the row so the edge action's color
   fills every exposed pixel, while task-row-gestures.js measures the
   visible buttons themselves for reveal detents and commit distance. */
.task-row-actions-left,
.task-row-actions-right {
  position: absolute;
  z-index: 0;
  top: 0;
  bottom: 0;
  display: flex;
  width: 100%;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1);
  background: var(--surface-sunken);
  /* Keep the buttons in the accessibility tree so keyboard focus can reveal
     the same actions as a swipe. Opacity hides the full-width color layer at
     rest. */
  opacity: 0;
  pointer-events: none;
}

.task-row-swipe-right > .task-row-actions-left,
.task-row-swipe-left > .task-row-actions-right {
  opacity: 1;
  pointer-events: auto;
}

.task-row-actions-left {
  left: 0;
  justify-content: flex-start;
}

.task-row-actions-right {
  right: 0;
  justify-content: flex-end;
}

.task-row-action {
  width: 80px;
  height: calc(100% - var(--space-1));
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: var(--surface-sunken);
  color: var(--text);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: var(--radius-pill);
  cursor: pointer;
}

.task-row-action--danger {
  background: var(--danger);
  color: var(--surface);
}

.task-row-action--duration {
  background: var(--blue);
  color: var(--surface);
}

.task-row-action--assignee {
  background: var(--purple);
  color: var(--surface);
}

.row-lead {
  align-self: flex-start;
  /* flex-start alone pins the circle to the very top of the row, above the
     title's own line-box center (title's line-height leaves room the
     circle doesn't have) -- nudge down to meet it, same fix already used
     for subtask rows' checkbox (_subtask_list.html). */
  margin-top: var(--space-1);
}

.task-title-link {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  text-decoration: none;
  /* Anchors are natively draggable by default, which otherwise steals the
     gesture from task-row-gestures.js (only the link "picks up", not the
     row). */
  -webkit-user-drag: none;
  user-drag: none;
  /* A half-step aligns the text glyphs with the completion circle without
     making the title's line box read low. */
  padding-top: 2px;
}

.task-title-link--task {
  padding-top: 1px;
}

.add-row .task-row-foreground {
  /* A little left of sibling titles: the leading '+' has optical width of
     its own, while an invisible circle spacer made these read indented. */
  padding-left: calc(var(--space-2) + 26px);
}

.add-row .add-row-input {
  padding-top: var(--space-1);
}

.task-title {
  display: block;
  font-family: var(--font-content);
  font-size: var(--fs-task-title-plain);
  color: var(--text);
}

.responsibility-list .task-row-foreground {
  min-height: 52px;
  padding-top: var(--space-3);
  padding-bottom: var(--space-3);
}

.responsibility-meta {
  overflow: hidden;
  color: var(--text-muted);
  font-family: var(--font-chrome);
  font-size: 0.78rem;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.responsibility-list .add-row .task-row-foreground {
  min-height: 48px;
  padding-top: var(--space-2);
  padding-bottom: var(--space-2);
}

.task-meta-line {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.task-duration-picker,
.duration-picker {
  flex-shrink: 0;
  position: relative;
}

.task-subtask-count {
  flex-shrink: 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.pill {
  flex-shrink: 0;
  font-size: 0.7rem;
  font-weight: 600;
  /* Deliberately below the 4px spacing floor -- a pill badge needs tighter
     vertical padding than the scale provides to read as compact rather
     than ballooning its line-height. */
  padding: 0.0625rem var(--space-2);
  border-radius: var(--radius-pill);
}

.pill-urgent {
  color: var(--danger);
  background: var(--danger-tint);
}

.pill-business-hours {
  color: var(--accent);
  background: var(--accent-tint);
}

/* Trailing chevron on read-only rows that navigate elsewhere (search
   results). Smaller/bolder/lighter than a typical nav chevron so it reads
   as a quiet affordance, not a focal point of the row. */
.task-row-chevron {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  color: var(--text-muted);
}

/* The add-to-agenda picker's inclusion toggle -- distinct from the leading
   .check-circle (which reflects the task's own done/active status): this
   one reflects membership on the agenda being built, and is the only
   clickable element on that row. */
.agenda-toggle-btn {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 2px solid var(--accent);
  border-radius: var(--radius-circle);
  background: none;
  color: var(--accent);
  cursor: pointer;
}

.agenda-toggle-btn.is-added {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--surface);
}

.agenda-toggle-icon {
  width: 12px;
  height: 12px;
}

.task-due-date {
  flex-shrink: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: right;
}

.task-row.due-soon .task-due-date {
  color: var(--warning);
  font-weight: 600;
}

.task-row.due-overdue .task-due-date {
  color: var(--danger);
  font-weight: 600;
}

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

/* Hide the add-row's assignee picker until a title's actually been typed. */
.add-row-input:placeholder-shown ~ .assignee-picker {
  display: none;
}

@media (pointer: coarse) {
  /* The whole row is a drag/swipe surface on touch (see
     task-row-gestures.js) -- suppress the iOS link-preview callout,
     text-selection handles, and tap-highlight that would otherwise fight
     a press-and-hold drag or a swipe on the title link. The tap-highlight
     in particular gets "stuck" at the touch start point, since a custom
     gesture never runs through the normal tap lifecycle that would clear
     it. */
  .task-list.orderable .task-row-foreground {
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
  }
}

/* Applied only after a row gesture is armed, classified, or actively
   dragging. Ordinary title taps and textarea editing retain native selection. */
.task-row-gesture-suppress-select,
.task-row-gesture-suppress-select * {
  -webkit-user-select: none;
  user-select: none;
}
