/* ---------- Running timer ------------------------------------------------------
   A pill on every page while a timer runs: bottom right on wide screens, just
   above the tab bar on phones. Under the header, tab bar and sheets. */

.timer-pill {
  position: fixed;
  right: 20px;
  bottom: calc(20px + env(safe-area-inset-bottom));
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(420px, calc(100vw - 32px));
  padding: 8px 8px 8px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.timer-pill-dot {
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--danger);
  animation: timer-pulse 1.6s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .timer-pill-dot {
    animation: none;
  }
}

@keyframes timer-pulse {
  50% { opacity: 0.35; }
}

.timer-pill-task {
  display: flex;
  flex: 1;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
  color: var(--ink);
  text-decoration: none;
}

.timer-pill-title {
  overflow: hidden;
  font-size: 0.88rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timer-pill-elapsed {
  flex: none;
  color: var(--body);
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
}

.timer-pill-stop-form {
  display: inline-flex;
  flex: none;
  margin: 0;
}

.timer-pill-stop {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: var(--danger-wash);
  color: var(--danger-ink);
  font-size: 0.8rem;
  cursor: pointer;
}

.timer-pill-stop:hover,
.timer-pill-stop:focus-visible {
  background: var(--danger);
  color: var(--on-primary);
}

@media (max-width: 640px) {
  .timer-pill {
    right: 16px;
    left: 16px;
    bottom: calc(72px + env(safe-area-inset-bottom));
    max-width: none;
  }

  .timer-pill-stop {
    width: 44px;
    height: 44px;
  }

  /* Room for the pill, so it never covers the end of a page. */
  .has-tab-bar:has(.timer-pill) {
    padding-bottom: calc(128px + env(safe-area-inset-bottom));
  }
}

/* ---------- Start/stop on the timeline and Today ---------------------------- */

.timeline-block-start.is-running {
  color: var(--danger);
}

.timeline-block-tracked {
  display: block;
  color: var(--muted);
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
}

.today-item-body {
  flex: 1;
  min-width: 0;
}

.today-item-timer-form {
  display: inline-flex;
  flex: none;
  margin: 0;
}

.today-item-timer {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--surface);
  color: var(--body);
  font-size: 0.7rem;
  cursor: pointer;
}

.today-item-timer:hover,
.today-item-timer:focus-visible {
  border-color: var(--primary);
  color: var(--primary-ink);
}

.today-item-timer.is-running {
  border-color: var(--danger);
  background: var(--danger-wash);
  color: var(--danger-ink);
}

@media (pointer: coarse) {
  .today-item-timer {
    width: 44px;
    height: 44px;
  }
}

.board-card-tracked {
  font-variant-numeric: tabular-nums;
}

/* ---------- Time on the task page ------------------------------------------- */

.task-time {
  margin-top: 20px;
}

.task-time-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.task-time-header h2 {
  margin: 0 0 4px;
  font-size: 1.1rem;
}

.task-time-total {
  margin: 0;
  color: var(--body);
  font-size: 0.9rem;
}

.task-time-total strong,
.task-time-planned {
  white-space: nowrap;
}

.task-time-timer.is-running {
  background: var(--danger);
}

.task-time-entries {
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
}

.task-time-entry {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line-soft);
}

.task-time-entry-when {
  flex: 1;
  min-width: 0;
  color: var(--body);
  font-size: 0.88rem;
}

.task-time-entry-duration {
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.task-time-entry.is-running .task-time-entry-duration {
  color: var(--danger-ink);
}

.task-time-entry-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.task-time-empty {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

.task-time-add summary {
  color: var(--primary-ink);
  font-weight: 600;
  cursor: pointer;
}

.task-time-form {
  margin-top: 12px;
}
