/* Task fields (owner: fields agent) — the workspace's Type / Priority options.

   .field-badge   type / priority badge (components/task_type_badge.html, priority_badge.html):
                  the option's icon in its color (data-color → --tone-ink) + optional name
   .field-glyph   bare colored glyph of an option (pickers, filters, manager rows)
   .field-menu    option list of a picker (components/field_options_menu.html)
   .tf            the manager (tasks/fields/partials/manager.html): tabs, rows, add row, confirm
   .icon-pop      the large icon + color picker popover (components/icon_picker_popover.html)
   Tokens only; light + dark through the tone variables. */

/* -- Badges & glyphs ---------------------------------------------------------------------------- */
.field-badge {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.field-badge[data-color] {
  color: var(--tone-ink);
}
.field-badge > .icon {
  flex-shrink: 0;
}
.field-badge.field-badge--label {
  color: inherit;
}
.field-badge--label[data-color] > .icon {
  color: var(--tone-ink);
}
.field-badge--label[data-priority="0"] > .icon {
  color: var(--text-3);
}
.field-badge__text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.priority.field-badge[data-priority="0"] {
  color: var(--text-3);
}
.priority-label .field-badge,
.tp-field .field-badge--label {
  font-weight: var(--fw-regular);
}

.field-glyph {
  display: inline-grid;
  flex-shrink: 0;
  place-items: center;
  color: var(--tone-ink);
}
.field-glyph--none {
  color: var(--text-3);
}

/* -- Picker menus ------------------------------------------------------------------------------- */
.field-menu {
  min-width: 220px;
}
.field-menu__list {
  display: flex;
  flex-direction: column;
}
.field-menu[data-compact] .field-menu__search:not(.is-typing) {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.field-menu__show {
  display: inline-flex;
  flex: 1;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.field-menu__show .menu__text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.field-menu__item.is-match {
  background: var(--fill-1);
}
.field-menu__manage {
  color: var(--text-2);
}
.field-menu__manage > .icon:first-child {
  color: var(--text-3);
}
.tc-pill .field-menu__show {
  gap: 6px;
}

/* -- Manager ------------------------------------------------------------------------------------ */
.tf {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-width: 0;
}
.tf__tabs {
  align-self: stretch;
}
/* r4 · 12.14: on the settings page the manager sits on the grouped background (no card around
   the inset group); in the sheet the group is a quiet fill. */
.card.tf-card {
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
}
.tf-panel {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-width: 0;
}
.tf-panel[hidden] {
  display: none;
}
.tf-panel.is-saving .tf-list {
  opacity: 0.86;
}
.tf-panel__hint {
  margin: 0;
  color: var(--text-2);
  font-size: var(--fs-sm);
  line-height: var(--lh-normal, 1.45);
}
.tf {
  --tf-group: var(--surface);
  --tf-group-ring: 0 0 0 0.5px var(--card-ring), var(--shadow-xs), inset 0 0.5px 0 var(--card-highlight);
}
.tf-modal .tf {
  --tf-group: var(--fill-1);
  --tf-group-ring: none;
}
.tf-list {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  border-radius: var(--radius-card);
  background: var(--tf-group);
  box-shadow: var(--tf-group-ring);
  list-style: none;
}
/* One option: grip · colored squircle (icon + color picker) · name · Default / Milestone · count · ⋯ */
.tf-row {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  min-height: 50px;
  padding: 6px 8px 6px 6px;
  transition: background-color var(--dur-1) var(--ease-out);
}
.tf-row + .tf-row::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: 72px;
  height: 0.5px;
  background: var(--line);
  pointer-events: none;
}
.tf-row:hover {
  background: var(--fill-1);
}
.tf-row:first-child {
  border-top-left-radius: inherit;
  border-top-right-radius: inherit;
}
.tf-row:last-child {
  border-bottom-left-radius: inherit;
  border-bottom-right-radius: inherit;
}
.tf-row__handle {
  display: inline-grid;
  flex-shrink: 0;
  place-items: center;
  width: 20px;
  height: 32px;
  color: var(--text-3);
  cursor: grab;
  opacity: 0.55;
  transition: opacity var(--dur-1) var(--ease-out);
  touch-action: none;
}
.tf-row:hover .tf-row__handle,
.tf-row:focus-within .tf-row__handle {
  opacity: 1;
}
.tf-row__handle--off {
  cursor: default;
  opacity: 0;
}
.tf-glyph {
  display: inline-grid;
  flex-shrink: 0;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: var(--tone-gradient);
  box-shadow: inset 0 0.5px 0 rgb(255 255 255 / 0.28), 0 0.5px 1.5px rgb(0 0 0 / 0.14);
  color: var(--tone-on);
  cursor: default;
  transition:
    filter var(--dur-1) var(--ease-out),
    transform var(--dur-snappy) var(--spring-snappy);
}
.tf-glyph:hover:not(:disabled) {
  filter: brightness(1.06);
}
.tf-glyph:active:not(:disabled) {
  transform: scale(0.9);
}
.tf-glyph:focus-visible {
  outline: 2px solid var(--focus-outline);
  outline-offset: 2px;
}
.tf-glyph:disabled {
  cursor: default;
}
.tf-glyph--static {
  background: var(--fill-2);
  box-shadow: none;
  color: var(--text-3);
  cursor: default;
}
.tf-row__name {
  display: flex;
  flex: 1 1 0;
  min-width: 72px;
}
.tf-row__input {
  width: 100%;
  min-width: 0;
  height: 32px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: var(--fw-medium);
  text-overflow: ellipsis;
  transition:
    border-color var(--dur-1) var(--ease-out),
    background-color var(--dur-1) var(--ease-out);
}
.tf-row__input::placeholder {
  color: var(--text);
  opacity: 1;
}
.tf-row__input:hover:not([readonly]) {
  background: var(--fill-1);
}
.tf-row__input:focus {
  border-color: var(--accent);
  background: var(--input-bg, var(--surface));
  outline: none;
  box-shadow: 0 0 0 3px var(--focus-ring);
}
.tf-row__input:focus::placeholder {
  color: var(--text-3);
}
.tf-row__input[aria-invalid="true"] {
  border-color: var(--danger);
}
.tf-row__static-name {
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
  padding: 0 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-2);
  font-weight: var(--fw-medium);
}
.tf-row__note {
  flex-shrink: 0;
  white-space: nowrap;
  color: var(--text-3);
  font-size: var(--fs-xs);
}
.tf-tag {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 8px;
  border-radius: var(--radius-full);
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  white-space: nowrap;
}
.tf-tag--milestone {
  background: var(--fill-2);
  color: var(--text-2);
}
.tf-row__count {
  flex-shrink: 0;
  min-width: 24px;
  color: var(--text-3);
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.tf-row__menu {
  flex-shrink: 0;
}
.tf-row__error {
  flex-basis: 100%;
  margin: 0 0 2px 64px;
}
.tf-row--static:hover {
  background: none;
}
.tf-row.is-new {
  animation: none;
}
.tf-row.sortable-ghost {
  background: var(--accent-softer);
  opacity: 0.6;
}
.tf-row.sortable-chosen {
  background: var(--surface-elevated);
  box-shadow: var(--shadow-md);
}

/* Delete confirmation (in place of the row) */
.tf-row--confirm,
.tf-row--confirm:hover {
  padding: 12px;
  background: color-mix(in srgb, var(--danger) 6%, var(--surface));
}
.tf-confirm {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}
.tf-confirm__head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.tf-confirm__title {
  margin: 0;
  font-weight: var(--fw-semibold);
}
.tf-confirm__text {
  margin: 0;
  color: var(--text-2);
  font-size: var(--fs-sm);
}
.tf-confirm__select {
  width: 100%;
  max-width: 320px;
}
.tf-confirm__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

/* "⊕ Add option": the group's last row (Reminders' "New Reminder"); the Add button shows once there
   is a name (Enter adds too). */
.tf-panel:has(> .tf-add) > .tf-list {
  border-bottom-right-radius: 0;
  border-bottom-left-radius: 0;
}
.tf-add {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  min-height: 50px;
  margin-top: calc(-1 * var(--space-3));
  padding: 6px 8px 6px 34px;
  border-radius: 0 0 var(--radius-card) var(--radius-card);
  background: var(--tf-group);
  box-shadow: var(--tf-group-ring);
  clip-path: inset(0 -12px -12px -12px);
}
.tf-add::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: 72px;
  height: 0.5px;
  background: var(--line);
}
.tf-add::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 7px;
  width: 18px;
  height: 18px;
  margin-top: -9px;
  border-radius: 50%;
  background:
    linear-gradient(var(--text-on-accent), var(--text-on-accent)) center / 10px 2px no-repeat,
    linear-gradient(var(--text-on-accent), var(--text-on-accent)) center / 2px 10px no-repeat,
    var(--accent);
  pointer-events: none;
}
.tf-add__input.input {
  flex: 1 1 140px;
  min-width: 0;
  height: 32px;
  padding: 0 8px;
  border: 0;
  background: transparent;
  box-shadow: none;
  color: var(--text);
  font-weight: var(--fw-medium);
}
.tf-add__input.input::placeholder {
  color: var(--accent-ink);
  font-weight: var(--fw-regular);
}
.tf-add__input.input:focus {
  box-shadow: none;
}
.tf-add__input.input:focus::placeholder {
  color: var(--text-3);
}
.tf-add .tf-row__error {
  margin-left: 40px;
}
.tf-add__submit {
  flex-shrink: 0;
}
.tf-add:has(.tf-add__input:placeholder-shown) .tf-add__submit {
  display: none;
}
.is-shake {
  border-color: var(--danger);
}

.tf-modal .modal__footer {
  display: flex;
  align-items: center;
  gap: 8px;
}

@media (prefers-reduced-motion: no-preference) {
  .tf-row.is-new {
    animation: tf-row-in var(--dur-3) var(--ease-spring-soft, var(--ease-out));
  }
  .is-shake {
    animation: tf-shake var(--dur-3) var(--ease-out);
  }
}
@keyframes tf-row-in {
  from {
    background: var(--accent-soft);
    transform: translateY(-4px);
    opacity: 0;
  }
}
@keyframes tf-shake {
  25% { transform: translateX(-4px); }
  50% { transform: translateX(4px); }
  75% { transform: translateX(-2px); }
}

@media (max-width: 479px) {
  .tf-row {
    padding-right: 4px;
  }
  .tf-row__count {
    display: none;
  }
  .tf-tag--milestone .tf-tag__text {
    display: none;
  }
}

/* -- Icon picker popover ------------------------------------------------------------------------ */
.icon-pop {
  display: flex;
  flex-direction: column;
  width: min(372px, calc(100vw - 16px));
  max-width: min(372px, calc(100vw - 16px));
  max-height: min(460px, calc(100vh - 16px));
  padding: 0;
  overflow: hidden;
}
.icon-pop:not(:popover-open) {
  display: none;
}
.icon-pop__head {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 12px 10px;
  border-bottom: 1px solid var(--line);
}
.icon-pop__swatches {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 2px 0;
}
.icon-pop__swatch {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  cursor: pointer;
}
.icon-pop__dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--tone);
  box-shadow: inset 0 0 0 0.5px rgb(0 0 0 / 0.14);
  transition: transform var(--dur-1) var(--ease-out);
}
.icon-pop__swatch:hover .icon-pop__dot {
  transform: scale(1.12);
}
.icon-pop__swatch[aria-checked="true"] .icon-pop__dot {
  box-shadow:
    0 0 0 2px var(--surface-elevated),
    0 0 0 4px var(--tone);
}
.icon-pop__swatch:focus-visible {
  outline: 2px solid var(--focus-outline);
  outline-offset: 1px;
}
.icon-pop__body {
  flex: 1;
  min-height: 0;
  padding: 4px 8px 10px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.icon-pop__group[hidden] {
  display: none;
}
.icon-pop__label {
  margin: 0;
  padding: 10px 4px 6px;
  color: var(--text-3);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.icon-pop__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(36px, 1fr));
  gap: 2px;
}
.icon-pop__icon {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  min-width: 36px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-2);
  cursor: pointer;
  transition:
    background-color var(--dur-1) var(--ease-out),
    color var(--dur-1) var(--ease-out);
}
.icon-pop__icon[hidden] {
  display: none;
}
.icon-pop__icon:hover {
  background: var(--tone-soft);
  color: var(--tone-ink);
}
.icon-pop__icon[aria-pressed="true"] {
  background: var(--tone-soft);
  color: var(--tone-ink);
  box-shadow: inset 0 0 0 1.5px var(--tone);
}
.icon-pop__icon:focus-visible {
  outline: 2px solid var(--focus-outline);
  outline-offset: -2px;
}
.icon-pop__empty {
  margin: 0;
  padding: 24px 8px;
  color: var(--text-3);
  font-size: var(--fs-sm);
  text-align: center;
}
@media (max-width: 639px) {
  .icon-pop {
    max-height: min(70vh, 520px);
  }
  .icon-pop__icon {
    min-width: 40px;
  }
}

/* -- Insights: split legend swatches follow the option colors ------------------------------------ */
.chart-legend__swatch[data-color] {
  --swatch: var(--tone);
}
[data-series="priorities-none"] {
  --swatch: light-dark(color-mix(in srgb, var(--c-gray) 34%, var(--surface)), color-mix(in srgb, var(--c-gray) 50%, var(--surface)));
}
