/* ==========================================================================
   Tasks: list, workspace (card modal / page), tags, stage stepper. Module stylesheet: tokens only, shared parts live in components.css.
   ========================================================================== */

/* ---- Tasks -------------------------------------------------------------------------------------------------- */
.tk-check { width: 24px; height: 24px; flex: none; border-radius: 50%; border: 1.5px solid var(--border-strong); background: var(--surface); color: transparent; display: inline-flex; align-items: center; justify-content: center; padding: 0; cursor: pointer; font-size: .8rem; transition: background var(--t-fast, .12s), border-color var(--t-fast, .12s), color var(--t-fast, .12s); }
.tk-check:hover { border-color: var(--accent); color: var(--accent); }
.tk-check:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tk-check.is-done { background: var(--success, #16a34a); border-color: var(--success, #16a34a); color: #fff; }
.tk-row-done .tk-title { text-decoration: line-through; color: var(--text-muted); }
.tk-row-done { opacity: .8; }
.tk-title { overflow-wrap: anywhere; }
.col-check { width: 36px; padding-inline-end: 0 !important; }

.tk-quick { display: flex; align-items: center; gap: var(--sp-2); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: 4px 6px 4px 12px; margin-block-end: var(--sp-3); }
.tk-quick:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft, transparent); }
.tk-quick__input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--text); height: 32px; outline: none; font: inherit; }
.tk-quick--flat { border-radius: 0; border-width: 0 0 1px; margin: 0; }
.tk-quick--inline { margin: var(--sp-2) 0 0; }

/* ---- Card workspace (the centred card modal and the stand-alone task page share it) ---------------------------------- */
.tk-ws { position: relative; min-width: 0; }
.tk-ws__cover { height: 112px; margin: calc(var(--sp-5) * -1) calc(var(--sp-5) * -1) var(--sp-3); background-size: cover; background-position: center; background-color: var(--surface-2); }
.tk-ws__cover--color { height: 56px; background: var(--c); }
.tk-ws__head { display: flex; align-items: flex-start; gap: var(--sp-2); margin-block-end: var(--sp-2); }
.tk-ws__head > .tk-check, .tk-ws__head > span > form { margin-block-start: 4px; }
.tk-ws__titles { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 0; }
.tk-ws__crumb { font-size: var(--fs-xs); line-height: 1.4; }
.tk-ws__crumb a { display: inline-flex; align-items: center; min-height: 24px; }   /* a link on its own line is a 24px target */
.tk-ws__actions { margin-inline-start: auto; display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: var(--sp-1) var(--sp-2); }
/* the title is the heading: a quiet field that shows its border on hover / focus; the label stays for screen readers */
.tk-ws__titlefield { gap: 0; }
.tk-ws__titlefield .m-field__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.tk-ws__titlefield .m-field__error:empty { display: none; }
.tk-ws__title.m-input { height: 36px; margin-inline-start: -7px; width: calc(100% + 7px); border-color: transparent; background: transparent; font-size: var(--fs-xl); font-weight: var(--fw-semibold); letter-spacing: var(--ls-title); text-overflow: ellipsis; }
.tk-ws__title.m-input:hover:not(:disabled):not(:focus) { border-color: var(--border-strong); }
.tk-ws__title.m-input:focus { background: var(--surface); }
.tk-ws__cols { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--sp-3); align-items: start; }
.tk-ws__side { display: flex; flex-direction: column; gap: var(--sp-2); min-width: 0; order: -1; }   /* phones: the actions first, in compact scrolling strips */
.tk-ws__main { min-width: 0; }
.tk-ws__core { margin-block-end: var(--sp-2); }
.tk-ws__details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-2) var(--sp-3); padding: var(--sp-2) 0; }
.tk-ws__details .span-2 { grid-column: 1 / -1; }
.tk-ws__details .m-field__opt { display: none; }   /* "(optional)" is noise in a facts panel */
.tk-ws__pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-2) var(--sp-3); }
.tk-time { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; justify-content: space-between; padding: var(--sp-2) var(--sp-3); border: 1px solid var(--border); border-radius: var(--r-lg); }
.tk-time form, .tk-time p { margin: 0 !important; }
@media (min-width: 768px) {
  .tk-ws__cols { grid-template-columns: minmax(0, 7fr) minmax(190px, 3fr); gap: var(--sp-5); }   /* Trello: main ≈ 70 %, actions ≈ 30 % */
  .tk-ws__side { order: 0; }
}
.tk-ws__sec { margin-block-start: var(--sp-2); }
.tk-ws__title { font-weight: var(--fw-medium); }

/* Section headings, Trello style: an icon in the margin, no panel around the content */
.tk-sec { margin-block-end: var(--sp-5); min-width: 0; }
.tk-sec[hidden] { display: none; }
.tk-sec__h { display: flex; align-items: center; gap: var(--sp-2); margin: 0 0 var(--sp-2); font-size: var(--fs-lg); font-weight: var(--fw-semibold); }
.tk-sec__h .bi { color: var(--text-muted); font-size: 1.05rem; }
.tk-sec__n { font-size: var(--fs-xs); font-weight: var(--fw-medium); color: var(--text-muted); background: var(--neutral-soft); border-radius: var(--r-pill); padding: 0 7px; }
.tk-ws .m-details { border: 0; }
.tk-ws .tk-sec .m-details { margin-block-start: var(--sp-2); }

/* Attachments: a compact row per file with a small thumbnail */
.tk-files { list-style: none; margin: 0 0 var(--sp-2); padding: 0; display: grid; gap: 2px; }
.tk-file { display: flex; align-items: center; gap: var(--sp-2); padding: 4px 0; min-width: 0; }
.tk-file__thumb { flex: none; width: 56px; height: 40px; border-radius: var(--r-md); background: var(--neutral-soft); color: var(--text-muted); display: grid; place-items: center; overflow: hidden; }
.tk-file__thumb > span { width: 100%; height: 100%; background-size: cover; background-position: center; }
.tk-file__main { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.tk-file__main small { color: var(--text-muted); font-size: var(--fs-xs); }
.tk-upload { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); }
.tk-upload.is-uploading label { opacity: .6; pointer-events: none; }
.tk-upload .m-field__error:empty { display: none; }
.tk-upload .m-field__error { flex: 1 1 100%; }

/* Comments & activity: one flat timeline, light dividers, no card around every entry */
.tk-ws__comments .tk-timeline { gap: 0; }
.tk-ws__comments .tk-timeline > li { border: 0; border-radius: 0; background: transparent; box-shadow: none; padding-inline: 0; border-block-start: 1px solid var(--border); }
.tk-ws__comments .tk-timeline > li:first-child { border-block-start: 0; }

/* The card modal ----------------------------------------------------------------------------------------------- */
.tk-modal { --tk-vh: 100dvh; --tk-vt: 0px; }
.tk-modal .modal-dialog { --bs-modal-width: 860px; max-width: min(var(--bs-modal-width), calc(100vw - 1.5rem)); width: 100%; margin-inline: auto; }
.tk-modal__content { display: flex; flex-direction: column; max-height: min(90vh, 90dvh); overflow: hidden; position: relative; }
.tk-modal__body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: var(--sp-5); scroll-behavior: auto; }
.tk-modal__x { flex: none; }
.tk-modal__bar { display: none; }
.tk-modal__loading { display: flex; align-items: center; justify-content: center; gap: var(--sp-2); min-height: 220px; color: var(--text-muted); }
@keyframes tk-load { from { background-position: -40% 0; } to { background-position: 140% 0; } }
.tk-modal .tk-ws__cover { margin-block-start: calc(var(--sp-5) * -1); }
.tk-modal .dropdown-menu { z-index: calc(var(--z-modal) + 5); }
/* phones: a full-screen sheet that follows the visual viewport (the on-screen keyboard never covers the field being typed in) */
@media (max-width: 767.98px) {
  .tk-modal.modal { top: var(--tk-vt, 0); height: var(--tk-vh, 100dvh); overflow: hidden; }
  .tk-modal .modal-dialog { max-width: none; width: 100%; height: 100%; margin: 0; min-height: 0; align-items: stretch; }
  .tk-modal__content { max-height: none; height: 100%; width: 100%; border: 0; border-radius: 0; }
  .tk-modal__bar { display: flex; align-items: center; flex: none; min-height: 48px; padding: 0 var(--sp-2); border-block-end: 1px solid var(--border); background: var(--surface); position: relative; z-index: 6; }
  .tk-modal__x { display: none; }   /* phones have the Back bar */
  .tk-modal__body { padding: var(--sp-3) var(--sp-3) calc(var(--sp-6) + env(safe-area-inset-bottom, 0px)); }
  .tk-ws__cover { margin: calc(var(--sp-3) * -1) calc(var(--sp-3) * -1) var(--sp-3); }
  /* the actions strip first, then the card, then the secondary panels (details, time) */
  .tk-ws__side { display: contents; }
  .tk-ws__side > .tk-act { order: -1; }
  .tk-ws__main { order: 1; }
  .tk-ws__side > :not(.tk-act) { order: 2; }
}
.tk-sub .m-list__item { gap: var(--sp-2); }

.tk-cal__bar { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2) var(--sp-3); border-block-end: 1px solid var(--border); flex-wrap: wrap; }
.tk-cal__title { font-size: var(--fs-md, 1rem); margin: 0; min-width: 9rem; text-align: center; }
.tk-cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.tk-cal__dow { padding: 6px; font-size: var(--fs-xs); color: var(--text-muted); text-align: center; border-block-end: 1px solid var(--border); background: var(--surface-2); }
.tk-cal__cell { min-height: 104px; border-inline-end: 1px solid var(--border); border-block-end: 1px solid var(--border); padding: 4px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tk-cal__row { display: contents; }
.tk-cal__row > .tk-cal__cell:last-child { border-inline-end: 0; }
.tk-cal__cell.is-out { background: var(--surface-2); }
.tk-cal__cell.is-out .tk-cal__day { color: var(--text-faint); }
.tk-cal__cell.is-today .tk-cal__day .num { background: var(--accent); color: var(--accent-contrast, #fff); border-radius: var(--r-pill); padding: 0 6px; }
.tk-cal__day { display: flex; justify-content: space-between; align-items: center; font-size: var(--fs-xs); color: var(--text-muted); }
.tk-cal__add { opacity: 0; color: var(--text-muted); padding: 0 4px; border-radius: var(--r-sm); }
.tk-cal__cell:hover .tk-cal__add, .tk-cal__add:focus-visible { opacity: 1; }
.tk-chip { display: flex; align-items: center; gap: 5px; min-height: 24px; font-size: var(--fs-xs); padding: 1px 6px; border-radius: var(--r-sm); background: var(--neutral-soft); color: var(--text); min-width: 0; text-decoration: none; }
.tk-chip:hover { background: var(--surface-hover); text-decoration: none; color: var(--accent-text); }
.tk-chip.is-done { text-decoration: line-through; color: var(--text-muted); }
.tk-chip.is-overdue { background: var(--danger-soft); color: var(--danger-text, var(--danger)); }
.tk-chip--more { justify-content: center; color: var(--text-muted); background: transparent; }
@media (max-width: 767.98px) {
  .tk-cal { display: block; }
  .tk-cal__dow { display: none; }
  .tk-cal__cell { min-height: 0; flex-direction: row; flex-wrap: wrap; align-items: center; border-inline-end: 0; padding: 6px var(--sp-3); }
  .tk-cal__cell:not(:has(.tk-chip)):not(.is-today) { display: none; }
  .tk-cal__day { flex: 0 0 100%; }
  .tk-cal__add { opacity: 1; }
}

/* ---- Task stage stepper (drawer / task page): chevron steps, scrolls sideways instead of wrapping ---------------------- */
.tk-stepper { margin-block-end: var(--sp-2); overflow-x: auto; scrollbar-width: thin; -webkit-overflow-scrolling: touch; padding-block-end: 2px; }
.tk-stepper__list { display: flex; list-style: none; margin: 0; padding: 0; gap: 0; min-width: min-content; }
.tk-step { flex: 1 1 0; min-width: max-content; display: flex; }
.tk-step form { display: flex; flex: 1; }
.tk-step__btn { flex: 1; display: flex; align-items: center; justify-content: center; text-align: center; white-space: nowrap; height: 28px; padding-inline: 20px 16px; border: 0; margin-inline-end: -10px; position: relative; font: inherit; font-size: var(--fs-sm); font-weight: 500; color: var(--text-muted); background: var(--surface-2); cursor: pointer; clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 50%, calc(100% - 12px) 100%, 0 100%, 12px 50%); transition: background-color var(--t-fast), color var(--t-fast); }
[dir="rtl"] .tk-step__btn { clip-path: polygon(12px 0, 100% 0, calc(100% - 12px) 50%, 100% 100%, 12px 100%, 0 50%); }
.tk-step:first-child .tk-step__btn { border-start-start-radius: var(--r-md); border-end-start-radius: var(--r-md); clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 50%, calc(100% - 12px) 100%, 0 100%); }
[dir="rtl"] .tk-step:first-child .tk-step__btn { clip-path: polygon(12px 0, 100% 0, 100% 100%, 12px 100%, 0 50%); }
.tk-step:last-child .tk-step__btn { margin-inline-end: 0; }
button.tk-step__btn:hover { background: var(--surface-3, var(--border)); color: var(--text); }
button.tk-step__btn:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.tk-step.is-past .tk-step__btn { background: color-mix(in srgb, var(--c) 18%, var(--surface-2)); color: var(--text); }
.tk-step.is-current .tk-step__btn { background: var(--c); color: #fff; font-weight: 600; cursor: default; }
.tk-step.is-pending .tk-step__btn { opacity: .6; }
.tk-step.is-pending.is-todo .tk-step__btn, .tk-step.is-pending.is-past .tk-step__btn { background: var(--c); color: #fff; }
@media (max-width: 767.98px) { .tk-step__btn { height: 34px; padding-inline: 20px 14px; } }

/* Task tags */

/* Tag chips input + coloured tag chips */
.tg-input { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; min-height: 34px; padding: 3px 6px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-md); cursor: text; }
.tg-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus-ring); }
.tg-input.is-disabled { background: var(--surface-2); cursor: default; }
.tg-input__chips { display: contents; }
.tg-chip { display: inline-flex; align-items: center; gap: 2px; max-width: 100%; padding: 0 2px 0 8px; font-size: var(--fs-xs); line-height: 22px; color: var(--accent-text); background: var(--accent-soft); border-radius: var(--r-pill); }
.tg-chip > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tg-chip__x { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; padding: 0; border: 0; border-radius: 50%; background: none; color: inherit; cursor: pointer; }
.tg-chip__x:hover { background: var(--accent-soft-strong); }
.tg-input__text { flex: 1 1 90px; min-width: 90px; padding: 2px 4px; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; }

.tk-ws__saved { margin-inline-start: var(--sp-2); font-size: var(--fs-xs); color: var(--text-faint); }
.tk-ws__saved[data-state="saved"] { color: var(--success); }
.tk-ws__saved[data-state="failed"] { color: var(--danger); }

/* Task workspace header: the main timer control */
.tk-ws__timer { display: inline-flex; align-items: center; gap: var(--sp-2); padding: 2px 4px 2px 10px; background: var(--danger-soft); border-radius: var(--r-pill); color: var(--danger); }
.tk-ws__timer .num { font-size: var(--fs-sm); }
.tk-ws__timer .m-btn { border-radius: var(--r-pill); }

/* ‹ › step buttons */
.tk-ws__step .icon-btn.is-disabled { opacity: .3; pointer-events: none; }

.tk-cal__bar a:not(.icon-btn):not(.m-btn) { font-weight: var(--fw-medium); }
/* the section heading above the description editor is its label: the field's own label stays for screen readers only */
.tk-ws__core .m-field > .m-field__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* A task opened from the project window is a second dialog on top of it: it (and its backdrop) sit above the project window */
.modal-backdrop ~ .modal-backdrop { --bs-backdrop-zindex: calc(var(--z-modal, 1055) + 8); }
.tk-modal.is-over { z-index: calc(var(--z-modal, 1055) + 10); }
/* …and a little smaller, with a stronger shadow, so the project window is seen underneath it */
.tk-modal.is-over .modal-dialog { max-width: min(800px, calc(100vw - 4rem)); }
.tk-modal.is-over .tk-modal__content { max-height: min(84vh, 84dvh); box-shadow: 0 24px 64px rgb(0 0 0 / .45); }
@media (max-width: 767.98px) { .tk-modal.is-over .modal-dialog { max-width: none; } .tk-modal.is-over .tk-modal__content { max-height: none; } }

/* Tick boxes (subtasks, project tasks, checklists) show the hand cursor, like every other clickable control */
.tk-check-item .form-check-input:not(:disabled), .tk-modal .form-check-input[type="checkbox"]:not(:disabled), .tk-check:not(:disabled) { cursor: pointer; }

/* Comments & activity: system lines stay hidden until "Show activity" is ticked */
.tk-chatter:not(.is-show-activity) .ct-activity.is-system { display: none; }

/* The round tick sits on the title's centre line (title field is 36px tall, the tick 24px) */
.tk-ws__head > span[data-ws-swap="check"] { margin-block-start: 6px; display: inline-flex; }
