/* Tasks: what every tasks screen shares (state and due badges). Loaded on back-office and
   working pages alike, so it uses only colours both define, with fallbacks, and its own amber
   (due today, the Tasks panel's hints), lighter on a dark page so it stays readable. */
:root { --task-amber: #8a5a00; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --task-amber: #e0a640; }
}
:root[data-theme="dark"] { --task-amber: #e0a640; }
.task-state {
  display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; line-height: 1.6;
  font-weight: 600; white-space: nowrap; background: #e8eceb; color: #33413d;
}
.task-state-ready { background: #e3effa; color: #1d4f7c; }
.task-state-in_progress { background: #dff3e8; color: #1f6a43; }
.task-state-blocked { background: #fde8e6; color: #9b2c22; }
.task-state-on_hold { background: #fbf1d9; color: #7a5a12; }
.task-state-for_review { background: #efe7fb; color: #5b3a92; }
.task-state-complete { background: #e2f1ea; color: #2f5d50; }
.task-state-cancelled { background: #eeeeee; color: #6b6b6b; text-decoration: line-through; }
.task-due { font-size: 12px; white-space: nowrap; color: var(--body-quiet-color, var(--muted, #666)); }
.task-due-today { color: var(--task-amber); font-weight: 600; }
.task-due-overdue { color: var(--error-fg, #b3261e); font-weight: 600; }
/* The count on the header's Tasks link (task_badge.py): shaped like the Messages badge, which it
   can't share a class with (chat.js takes the first .chat-badge for its unread count). Red when
   something of yours is overdue. */
.tasks-badge {
  display: inline-block; min-width: 16px; padding: 0 5px; margin-left: 4px; border-radius: 999px;
  background: rgba(255, 255, 255, .28); color: #fff; font-size: 11px; font-weight: 600; line-height: 16px;
  text-align: center;
}
.tasks-badge.overdue { background: #d64545; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .task-state { filter: brightness(.85) saturate(1.1); }
}
:root[data-theme="dark"] .task-state { filter: brightness(.85) saturate(1.1); }

/* A map of tasks and their links (tasks/_map.html, apps/tasks/maps.py): Tasks' Map view and a
   task's Waits for panel. Boxes coloured by status down their left edge; the task whose page it
   is outlined; faded, those outside the tab and filters. Wider than the screen, it scrolls. */
.task-map-scroll { overflow: auto; max-width: 100%; -webkit-overflow-scrolling: touch; }
/* Tasks' Map view takes the window's width: a plan runs wide. */
body > main:has(.task-results .task-map) { max-width: none; }
.task-map { display: block; font-family: inherit; }
/* Zoom and pan (static/tasks/map.js): a swipe pans, a pinch is the map's own, not the page's.
   A mouse drags it about. On Tasks' Map view it's a view of its own, filling the window from where
   it starts (--map-top) however big the map is, so it doesn't change size mid-pinch, down to its
   key (--map-below; a phone's tab bar under that): the page has nothing to scroll, so its header,
   tabs and filters stay where they are. On a phone the round + sits over the map. */
.task-map-scroll { touch-action: pan-x pan-y; }
.task-map { -webkit-user-select: none; user-select: none; }
.task-map-scroll.pannable { cursor: grab; }
.task-map-scroll.dragging { cursor: grabbing; }
#task-results .task-map-scroll {
  height: max(160px, calc(100vh - var(--map-top, 240px) - var(--tabbar-space, 0px) - var(--map-below, 44px)));
  height: max(160px, calc(100dvh - var(--map-top, 240px) - var(--tabbar-space, 0px) - var(--map-below, 44px)));
}
@media (max-width: 720px), (orientation: landscape) and (max-height: 500px) and (pointer: coarse) {
  /* Nothing under the map for the round + to clear: it sits over the map. */
  body:has(#task-results .task-map-scroll) { padding-bottom: var(--tabbar-space, 0px); }
  body:has(#task-results .task-map-scroll) > main { padding-bottom: 8px; }
  body:has(#task-results .task-map-scroll) :is(a, label, button).fab.fab { bottom: calc(var(--tabbar-space, 0px) + var(--map-below, 0px) + 6px); }
}
/* Over the map (map.js puts them there): Fit in its top right corner; bottom left, once part of
   the map is out of view, a small map with a frame round the part that shows. */
.task-map-frame { position: relative; }
.task-map-fit { display: none; position: absolute; top: 8px; right: 14px; z-index: 2; align-items: center; gap: 5px;
  margin: 0; padding: 5px 10px 5px 8px; font: inherit; font-size: 13px; font-weight: 600; line-height: 18px; cursor: pointer;
  color: var(--body-fg, var(--text, #1d1d1b)); background: var(--body-bg, var(--surface, #fff));
  border: 1px solid var(--hairline-color, var(--border, #d9dcd7)); border-radius: 8px; box-shadow: 0 1px 4px rgba(0, 0, 0, .14); }
.task-map-fit svg { width: 15px; height: 15px; }
.task-map-fit:hover, .task-map-fit:focus-visible { border-color: var(--primary, var(--accent, #2f5d50)); }
#task-results .task-map-fit, .task-map-frame:has(> .task-map-scroll:is(.pannable, [data-zoomed])) > .task-map-fit { display: inline-flex; }
.task-minimap { position: absolute; left: 8px; bottom: 14px; z-index: 2; padding: 4px; line-height: 0; cursor: pointer;
  touch-action: none; background: var(--body-bg, var(--surface, #fff)); border: 1px solid var(--hairline-color, var(--border, #d9dcd7));
  border-radius: 8px; box-shadow: 0 1px 6px rgba(0, 0, 0, .18); }
.task-minimap[hidden] { display: none; }
.task-minimap svg { display: block; overflow: visible; }
.task-minimap .line { fill: none; stroke: #8fa79e; stroke-width: 1; vector-effect: non-scaling-stroke; opacity: .7; }
.task-minimap .block { fill: #9aa3ab; }
.task-minimap .block.plain { fill: none; stroke: var(--body-quiet-color, var(--muted, #8a8a85)); stroke-width: 1; vector-effect: non-scaling-stroke; }
.task-minimap .block.faded { opacity: .45; }
.task-minimap .view { fill: rgba(47, 93, 80, .14); stroke: var(--primary, var(--accent, #2f5d50)); stroke-width: 2; vector-effect: non-scaling-stroke; }
@media print { .task-map-fit, .task-minimap { display: none !important; } }
.task-map-line { fill: none; stroke: #8fa79e; stroke-width: 1.6; }
.task-map-line.faded { opacity: .5; }
.task-map marker path, .task-map-key marker path { fill: #8fa79e; }
#task-map-arrow path { fill: #8fa79e; }
.task-map-box .box { fill: var(--body-bg, var(--surface, #fff)); stroke: var(--hairline-color, var(--border, #d9dcd7)); stroke-width: 1; }
.task-map-box:hover .box, .task-map-box:focus .box { stroke: var(--primary, #2f5d50); stroke-width: 1.5; }
.task-map-box.focus .box { stroke: var(--primary, #2f5d50); stroke-width: 2.5; }
.task-map-box.faded { opacity: .55; }
.task-map-box text { fill: var(--body-fg, var(--text, #1d1d1b)); font-size: 13px; }
.task-map-box .num { font-size: 12px; font-weight: 500; font-family: ui-monospace, Menlo, monospace; fill: var(--body-quiet-color, var(--muted, #6b6b66)); }
.task-map-box .state { font-size: 11.5px; font-weight: 600; }
.task-map-box .meta { font-size: 11.5px; fill: var(--body-quiet-color, var(--muted, #6b6b66)); }
.task-map-box.overdue .meta { fill: #b3261e; font-weight: 600; }
.task-map-box .stripe { fill: #9aa3ab; }
.task-map-box.st-ready .stripe, .task-map-box.st-ready .state { fill: #2a6aa3; }
.task-map-box.st-in_progress .stripe, .task-map-box.st-in_progress .state { fill: #23875a; }
.task-map-box.st-blocked .stripe, .task-map-box.st-blocked .state { fill: #c0392b; }
.task-map-box.st-on_hold .stripe, .task-map-box.st-on_hold .state { fill: #b07d12; }
.task-map-box.st-for_review .stripe, .task-map-box.st-for_review .state { fill: #7a4fc0; }
.task-map-box.st-complete .stripe, .task-map-box.st-complete .state { fill: #2f5d50; }
.task-map-box.st-cancelled .stripe, .task-map-box.st-cancelled .state { fill: #8a8a8a; }
.task-map-box.st-cancelled .title { text-decoration: line-through; }
/* A record a task waits for: dashed, green once it's done. */
.task-map-record .box { stroke-dasharray: 6 4; stroke: var(--body-quiet-color, var(--muted, #8a8a85)); }
.task-map-record .state { fill: var(--body-quiet-color, var(--muted, #6b6b66)); font-weight: 600; }
.task-map-record.done .box { stroke: #2f8a5b; }
.task-map-record.done .meta { fill: #2f8a5b; font-weight: 600; }
.task-row-done a { text-decoration: line-through; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .task-map-box :is(.stripe, .state) { filter: brightness(1.35); } }
:root[data-theme="dark"] .task-map-box :is(.stripe, .state) { filter: brightness(1.35); }
.task-map-key { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 8px 0 0; font-size: 12.5px;
                color: var(--body-quiet-color, var(--muted, #6b6b66)); }
.task-map-key span { display: inline-flex; align-items: center; gap: 6px; }
.task-map-key .task-map-how { color: var(--body-quiet-color, var(--muted, #6b6b66)); }
.task-map-key .how-touch { display: none; }
@media (pointer: coarse) { .task-map-key .how-touch { display: inline-flex; } .task-map-key .how-mouse { display: none; } }
.task-map-note { margin: 8px 0 0; font-size: 13px; }
.task-map-empty { margin: 24px 0; }
/* On a task's page, folded away until asked for. */
.task-map-details { margin-top: 12px; }
.task-map-details > summary { cursor: pointer; color: var(--link-fg, var(--accent, #2f5d50)); font-size: 13px; font-weight: 600; }
.task-map-details[open] > summary { margin-bottom: 8px; }
.task-held { margin: 2px 0 10px; padding: 8px 10px; border-radius: 8px; background: #fde8e6; color: #9b2c22; font-size: 13px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .task-held { background: #43201d; color: #ff8a80; } }
:root[data-theme="dark"] .task-held { background: #43201d; color: #ff8a80; }

/* What a task waits for, under its title (Tasks' list and board, a task's Waits for panel):
   each one links to it; done ones are ticked and quieter. */
.task-waits { flex-basis: 100%; margin-top: 3px; font-size: 12.5px; line-height: 1.4;
              color: var(--body-quiet-color, var(--muted, #6b6b66)); }
.task-waits a.task-wait { font-weight: 600; color: #a5372c; text-decoration: none; }
.task-waits a.task-wait:hover { text-decoration: underline; }
.task-waits a.task-wait.done { font-weight: 400; color: #2f8a5b; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .task-waits a.task-wait { color: #ff8a80; }
  :root:not([data-theme="light"]) .task-waits a.task-wait.done { color: #6fcf97; } }
:root[data-theme="dark"] .task-waits a.task-wait { color: #ff8a80; }
:root[data-theme="dark"] .task-waits a.task-wait.done { color: #6fcf97; }
.task-project-links { margin: 6px 0 4px; font-size: 13px; }
.task-project-links .task-quiet { margin-left: 4px; }
