/*
 * The Tasks window (tasks.js), on the page's tokens (style.css), so it follows light and dark mode. Narrow windows
 * show the actions as icons alone; touch screens get bigger targets; reduced motion stills the bars.
 *
 * Colours, always beside words: blue for work going on, amber for waiting for the person, red for blocked or failed,
 * green for done, violet for the next action item. A task's colour (--tone) edges its row and fills its bar.
 */

.tasks {
    container: tasks / inline-size;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Adding: a field and a round button. */
.tasks-add {
    display: flex;
    flex: none;
    gap: 6px;
}

.tasks-input {
    flex: 1;
    min-width: 0;
    padding: 7px 14px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    font-size: 0.875rem;
}

.tasks-input::placeholder {
    color: var(--muted);
}

.tasks-input:focus-visible {
    outline-offset: 0;
}

.tasks-add-button {
    flex: none;
    width: 36px;
    height: 36px;
    padding: 0;
}

.tasks-error {
    margin: 0;
    padding: 6px 10px;
    border-radius: 8px;
    background: var(--warn-bg);
    color: var(--warn-text);
    font-size: 0.8125rem;
}

.tasks-empty {
    margin: 4px 2px;
    color: var(--muted);
    font-size: 0.875rem;
}

.tasks-groups {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* A group's heading, with its count. */
.tasks-group-title {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0 0 6px;
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.tasks-group-name {
    margin: 0;
    font: inherit;
}

.tasks-group-count {
    min-width: 18px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--text);
    font-size: 0.6875rem;
    line-height: 18px;
    letter-spacing: 0;
    text-align: center;
}

/* Start my day and Wrap up, under the field. */
.tasks-day {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: -4px;
}

/* Each group folds, with a chevron that turns; Done is folded at first. */
.tasks-group > summary {
    width: fit-content;
    cursor: pointer;
    list-style: none;
}

.tasks-group > summary::-webkit-details-marker {
    display: none;
}

.tasks-group:not([open]) > summary {
    margin-bottom: 0;
}

.tasks-group > summary::before {
    content: '';
    width: 6px;
    height: 6px;
    margin: 0 3px 0 2px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(-45deg);
    transition: transform 120ms ease;
}

.tasks-group[open] > summary::before {
    transform: rotate(45deg);
}

.tasks-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}

/* One task, edged in its colour. */
.task {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px;
    border: 1px solid var(--line);
    border-left: 3px solid var(--tone, var(--line));
    border-radius: 10px;
    background: var(--surface);
}

:is(.task, .ticket):is([data-status='working'], [data-live]) {
    --tone: var(--progress);
}

:is(.task, .ticket)[data-status='waiting'] {
    --tone: var(--warning);
}

:is(.task, .ticket):is([data-status='blocked'], [data-status='failed']) {
    --tone: var(--danger);
}

:is(.task, .ticket)[data-status='done'] {
    --tone: var(--good);
}

/* Folded: the title, status and bar alone. */
.task[data-folded] {
    padding-block: 7px;
}

.task-toggle {
    flex: none;
    width: 28px;
    height: 28px;
    margin: -3px -4px 0 0;
    padding: 0;
    color: var(--muted);
}

.task-toggle .icon {
    transition: transform 120ms ease;
}

.task-toggle[aria-expanded='true'] .icon {
    transform: rotate(180deg);
}

/* A row just added glows, then fades to how it looks (tasks.js, ADDED_MS: 4 s). */
.task.task-added {
    animation: task-added 4s ease-out both;
}

@keyframes task-added {
    0%,
    45% {
        border-color: var(--accent);
        background: color-mix(in srgb, var(--accent) 22%, var(--surface));
        box-shadow: 0 0 0 2px var(--accent);
    }
}

.task[data-status='waiting'] {
    border-color: color-mix(in srgb, var(--warning) 60%, var(--line));
    border-left-color: var(--warning);
}

.task-top {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.task-check {
    flex: none;
    width: 18px;
    height: 18px;
    margin: 2px 0 0;
    accent-color: var(--accent);
    cursor: pointer;
}

.task-main {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.task-title {
    margin: 0;
    font-size: 0.9375rem;
    font-weight: 600;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.task[data-status='done'] .task-title {
    color: var(--muted);
    text-decoration: line-through;
}

.task[data-status='failed'] .task-title,
.task[data-status='cancelled'] .task-title {
    color: var(--muted);
}

.task-title-input {
    width: 100%;
    padding: 3px 8px;
    border: 1px solid var(--accent);
    border-radius: 6px;
    background: var(--surface);
    font-size: 0.9375rem;
    font-weight: 600;
}

.task-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 10px;
    color: var(--muted);
    font-size: 0.75rem;
}

/* The status: a dot beside its words, never colour alone. */
.task-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 1px 8px 1px 6px;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--text);
    font-weight: 500;
}

.task-dot {
    flex: none;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--muted);
}

.task-chip[data-tone='accent'] .task-dot,
.task-chip[data-tone='pending'] .task-dot {
    background: var(--accent);
}

.task-chip:is([data-tone='live'], [data-tone='progress']) .task-dot {
    background: var(--progress);
}

.task-chip[data-tone='live'] .task-dot {
    animation: task-pulse 1.6s ease-in-out infinite;
}

.task-chip[data-tone='pending'] .task-dot {
    animation: task-pulse 0.9s ease-in-out infinite;
}

.task-chip[data-tone='warning'] {
    background: var(--warn-bg);
    color: var(--warn-text);
}

.task-chip[data-tone='warning'] .task-dot {
    background: var(--warning);
}

.task-chip[data-tone='good'] .task-dot {
    background: var(--good);
}

.task-chip[data-tone='danger'] {
    color: var(--danger);
}

.task-chip[data-tone='danger'] .task-dot {
    background: var(--danger);
}

.task-chip[data-tone='muted'] .task-dot {
    border: 1.5px solid var(--muted);
    background: transparent;
}

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

/* How far along: filled from the steps or a percent; a sheen while NowPaw works on it, a slide when it can't say. */
.task-progress {
    position: relative;
    height: 6px;
    overflow: hidden;
    border-radius: 999px;
    background: var(--surface-2);
}

.task-progress-fill {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background-color: var(--tone, var(--progress));
    transition: width 300ms ease;
}

.task-progress.live .task-progress-fill {
    background-image: linear-gradient(90deg, transparent 0, rgb(255 255 255 / 40%) 50%, transparent 100%);
    background-size: 200% 100%;
    animation: task-sheen 1.6s linear infinite;
}

.task-progress.indeterminate .task-progress-fill {
    width: 35%;
    animation: task-slide 1.4s ease-in-out infinite;
}

.task-needs {
    margin: 0;
    padding: 6px 8px;
    border-radius: 8px;
    background: var(--warn-bg);
    color: var(--warn-text);
    font-size: 0.8125rem;
    overflow-wrap: anywhere;
}

.task-needs.blocked {
    background: color-mix(in srgb, var(--danger) 12%, var(--surface));
    color: var(--danger);
}

/* A note keeps its lines; the row shows two, the ticket all (its first two, the rest under Show more). */
.task-note {
    display: -webkit-box;
    margin: 0;
    overflow: hidden;
    color: var(--muted);
    font-size: 0.8125rem;
    white-space: pre-line;
    overflow-wrap: anywhere;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
}

/* A watch's state: "Sam: no reply yet", "Sunny, 55°F · 10% rain". */
.task-line {
    margin: 0;
    font-size: 0.8125rem;
    overflow-wrap: anywhere;
}

.task-watch[data-status='declined'] {
    border-color: color-mix(in srgb, var(--warning) 60%, var(--line));
}

.task-watch:is([data-status='ended'], [data-status='cancelled'], [data-status='stopped'], [data-status='failed']) :is(.task-title, .task-line) {
    color: var(--muted);
}

/* A schedule's last result: "Last run 2 hr. ago: The build is green." */
.task-result-time {
    color: var(--muted);
}

.task-result.failed {
    color: var(--danger);
}

.task-schedule:is([data-status='paused'], [data-status='ended']) .task-title {
    color: var(--muted);
}

.task-instructions {
    margin-top: 4px;
    white-space: pre-line;
}

.task-steps > summary {
    width: fit-content;
    color: var(--muted);
    font-size: 0.75rem;
    cursor: pointer;
}

.task-step-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 4px 0 0;
    padding: 0;
    list-style: none;
}

.task-step label {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    font-size: 0.8125rem;
    cursor: pointer;
}

.task-step input {
    flex: none;
    margin: 3px 0 0;
    accent-color: var(--good);
}

/* The next action item to do. */
.task-step.next span {
    color: var(--action);
    font-weight: 600;
}

.task-step input:checked + span {
    color: var(--muted);
    text-decoration: line-through;
}

.task-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.task-action {
    gap: 4px;
    padding: 3px 9px;
}

/* The actions less often wanted, as icons alone (tasks.js, #actions). */
.task-action.icon-only {
    padding: 3px 7px;
}

.task-action.icon-only .task-action-label {
    display: none;
}

.task-action.confirming {
    border-color: var(--danger);
    color: var(--danger);
}

/* The count in the window's title bar, marked when a task waits for the person. */
.tasks-badge {
    flex: none;
    min-width: 18px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--text);
    font-size: 0.6875rem;
    font-weight: 600;
    line-height: 18px;
    text-align: center;
}

.tasks-badge.has-waiting {
    background: var(--warn-bg);
    color: var(--warn-text);
}

.tasks-badge.has-waiting::after {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    margin-left: 4px;
    border-radius: 50%;
    background: var(--warning);
    vertical-align: 1px;
}

/*
 * A task as a ticket on the dashboard (tasks.js, #showTicket): one column, centred, that scrolls in the stage; the same
 * colours, a summary that keeps its lines, and the actions at the end.
 */
.ticket {
    display: flex;
    flex-direction: column;
    gap: 10px;
    height: 100%;
    overflow: auto;
    padding: 18px max(18px, calc((100% - 680px) / 2));
    border-top: 3px solid var(--tone, var(--line));
}

.ticket-label {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.ticket-note {
    margin: 0;
    font-size: 0.9375rem;
    line-height: 1.55;
    white-space: pre-line;
    overflow-wrap: anywhere;
}

.ticket-more > summary {
    width: fit-content;
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.8125rem;
    cursor: pointer;
}

.ticket-more > .ticket-note {
    margin-top: 6px;
}

.ticket-empty {
    margin: 8px 0;
    color: var(--muted);
    font-size: 0.875rem;
    text-align: center;
}

.ticket .task-progress {
    flex: none;
    height: 8px;
}

.ticket .task-step label {
    font-size: 0.9375rem;
}

.ticket .task-actions {
    margin-top: 6px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
}

/*
 * A ticket's test desk, with ITSM-Box on (tasks.js, #computerSection): the checker's verdict in a box, then a line for
 * each step NowPaw took there, unfolding to what it looked at, the actions done and by whom, and the setup after. All
 * of it text: no code, no files.
 */
.ticket-computer {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.computer-aside {
    margin-left: 8px;
    font-weight: 400;
    letter-spacing: 0;
    text-transform: none;
}

.computer-verdict {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 9px 12px;
    border: 2px solid var(--line);
    border-radius: 10px;
    font-size: 0.9375rem;
    overflow-wrap: anywhere;
}

.computer-verdict.good {
    border-color: var(--accent);
}

.computer-verdict.bad {
    border-color: var(--danger);
}

.computer-verdict.warn {
    border-color: var(--warning);
}

.computer-mark,
.computer-status {
    display: grid;
    flex: none;
    place-items: center;
    border-radius: 50%;
    background: var(--danger);
    color: #fff;
}

.computer-mark {
    width: 20px;
    height: 20px;
    margin-top: 1px;
}

.computer-verdict.good .computer-mark,
.computer-step.ok .computer-status {
    background: var(--good);
}

.computer-verdict.warn .computer-mark {
    background: var(--warning);
}

.computer-mark .icon,
.computer-status .icon {
    width: 12px;
    height: 12px;
    stroke-width: 3;
}

.computer-words {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.computer-by {
    color: var(--muted);
    font-size: 0.78125rem;
}

.computer-label {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 0.75rem;
}

/* What NowPaw did on the desk, folded under the verdict (tasks.js, #computerSection). */
.computer-fold {
    display: flex;
    align-items: center;
    gap: 4px;
    width: fit-content;
    padding: 2px 4px 2px 0;
    border: 0;
    background: none;
    font: inherit;
    font-size: 0.8125rem;
    cursor: pointer;
}

.computer-fold:hover {
    color: var(--text);
}

.computer-fold > .icon {
    width: 14px;
    height: 14px;
}

.computer-steps {
    margin: 0;
    padding: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 10px;
    list-style: none;
}

.computer-step + .computer-step {
    border-top: 1px solid var(--line);
}

.computer-toggle {
    display: grid;
    grid-template-columns: 14px 18px 52px minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 6px 10px;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    font-size: 0.84375rem;
    text-align: left;
    cursor: pointer;
}

.computer-toggle:hover,
.computer-toggle[aria-expanded='true'] {
    background: var(--surface-2);
}

.computer-toggle > .icon {
    width: 14px;
    height: 14px;
    color: var(--muted);
}

.computer-status {
    width: 18px;
    height: 18px;
}

.computer-kind {
    padding: 0 4px;
    border: 1px solid var(--line);
    border-radius: 5px;
    color: var(--muted);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-align: center;
}

.computer-step[data-kind='check'] .computer-kind {
    border-color: var(--accent);
    color: var(--accent);
}

.computer-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.computer-result,
.computer-tag {
    font-size: 0.78125rem;
    font-weight: 500;
    white-space: nowrap;
}

.computer-result.good,
.computer-tag.good {
    color: var(--good);
}

.computer-result.bad,
.computer-tag.bad {
    color: var(--danger);
}

.computer-result.warn,
.computer-tag.warn {
    color: var(--warn-text);
}

.computer-result.plain,
.computer-tag.plain {
    color: var(--muted);
}

.computer-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px 12px 10px 36px;
    background: var(--surface-2);
}

.computer-caption {
    margin: 2px 0 0;
    color: var(--muted);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.computer-read,
.computer-acts,
.computer-facts {
    display: flex;
    margin: 0;
    padding: 0;
    list-style: none;
}

.computer-read,
.computer-acts {
    flex-direction: column;
    gap: 4px;
    font-size: 0.84375rem;
}

.computer-act {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.computer-who {
    flex: none;
    padding: 0 7px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--muted);
    font-size: 0.71875rem;
    font-weight: 600;
}

.computer-what {
    min-width: 0;
    overflow-wrap: anywhere;
}

.computer-tag {
    margin-left: auto;
    padding-left: 8px;
}

.computer-facts {
    flex-wrap: wrap;
    gap: 6px;
}

.computer-fact {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 9px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    font-size: 0.78125rem;
}

.computer-fact::before {
    content: '';
    flex: none;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--muted);
}

.computer-fact.good::before {
    background: var(--good);
}

.computer-fact.bad::before {
    background: var(--danger);
}

.computer-fact.warn::before {
    background: var(--warning);
}

.computer-plain {
    margin: 2px 0 0;
    color: var(--muted);
    font-size: 0.8125rem;
}

@keyframes task-slide {
    from {
        transform: translateX(-100%);
    }
    to {
        transform: translateX(290%);
    }
}

@keyframes task-sheen {
    from {
        background-position: 100% 0;
    }
    to {
        background-position: -100% 0;
    }
}

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

/* A narrow window: the actions as icons, which keep their names for screen readers and tooltips. */
@container tasks (max-width: 300px) {
    .task {
        padding: 8px;
    }

    .task-action {
        padding: 4px 7px;
    }

    .task-action-label {
        display: none;
    }
}

@media (pointer: coarse) {
    .tasks-input {
        min-height: 40px;
    }

    .tasks-add-button {
        width: 40px;
        height: 40px;
    }

    .task-check {
        width: 22px;
        height: 22px;
    }

    .task-action {
        min-width: 36px;
        min-height: 36px;
    }

    .task-step label {
        align-items: center;
        min-height: 32px;
    }

    .tasks-group > summary,
    .task-steps > summary {
        padding: 6px 0;
    }

    .task-toggle {
        width: 36px;
        height: 36px;
    }
}

/* Still: stripes for a bar that can't say how far, no sheen, no pulse. */
@media (prefers-reduced-motion: reduce) {
    .task-progress-fill,
    .tasks-group > summary::before,
    .task-toggle .icon {
        transition: none;
    }

    .task-progress.live .task-progress-fill {
        background-image: none;
        animation: none;
    }

    .task.task-added {
        animation-timing-function: steps(1, end);
    }

    .task-progress.indeterminate .task-progress-fill {
        width: 100%;
        background: repeating-linear-gradient(135deg, var(--tone, var(--progress)) 0 6px, color-mix(in srgb, var(--tone, var(--progress)) 40%, transparent) 6px 12px);
        animation: none;
    }

    .task-chip .task-dot {
        animation: none;
    }
}
