/* ==========================================================================
   WORKFLOW — the service's process: the platform's editor, and what an office sees
   --------------------------------------------------------------------------
   Rules for this file: design TOKENS only (no hex, no px colours), LOGICAL
   properties only (inline-start/end, block-start/end — never left/right), and
   nothing that cannot survive dir="rtl" and dir="ltr" alike. Loaded after
   app.css and apple.css, so it may rely on every token they define.

   Every class is prefixed .wf-.

   Contents
     1  The platform's editor: one block per stage
     2  The application page's tracker: who is responsible, and the deadline
     3  The applications list: the "overdue in its stage" filter and badge
   ========================================================================== */


/* ==========================================================================
   1 · THE EDITOR
   ========================================================================== */

.wf-stages {
  display: grid;
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

/* One stage: its own block of the one form, so a stage is read — and its switches are found — as a unit. */
.wf-stage__box {
  display: grid;
  gap: var(--space-4);
  min-inline-size: 0;
  padding: var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}

.wf-stage__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
}

.wf-stage__position {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  inline-size: 2rem;
  block-size: 2rem;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--color-link);
  background: var(--color-primary-soft);
  border: 1px solid var(--color-primary);
  border-radius: var(--radius-circle);
}

.wf-stage__title {
  margin: 0;
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-bold);
  overflow-wrap: anywhere;
}

.wf-stage__count {
  margin-inline-start: auto;
}

/* What "Define the process" writes, said under the button that writes it. */
.wf-hint {
  max-inline-size: 48rem;
  margin: 0;
  margin-inline: auto;
  text-align: center;
}

/* Two columns of fields do not fit a phone: the pairs stack, as they do everywhere in the catalogue (.cat-pairs). */
@media (max-width: 40rem) {
  .wf-stage__box { padding: var(--space-3); }
  .wf-stage__count { margin-inline-start: 0; inline-size: 100%; }
}


/* ==========================================================================
   2 · THE TRACKER
   --------------------------------------------------------------------------
   What the page adds under a stage of the tracker (applications.css .apl-track): who is responsible for the stage the
   application is in, when it is due, and — in a badge with a shape and words, never colour alone — that it is late.
   ========================================================================== */

.wf-track__meta {
  display: flex;
  flex-direction: column;
  align-items: inherit;
  gap: var(--space-1);
  margin-block-start: var(--space-1);
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

.wf-track__line {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  max-inline-size: 100%;
  overflow-wrap: anywhere;
}

.wf-track__line .icon { flex: 0 0 auto; }

.wf-track__due { color: var(--color-text); font-weight: var(--font-weight-medium); }

/* "Overdue in this stage by 24 hours" breaks into two even lines, not "…by 24" and an orphaned "hours". */
.wf-track__late { max-inline-size: 100%; white-space: normal; text-align: start; text-wrap: balance; }

@media (max-width: 47.99rem) {
  .wf-track__meta { align-items: flex-start; }
}


/* ==========================================================================
   3 · THE LIST
   ========================================================================== */

/* The filter sits beside the stage tabs: a toggle with how many it would show, and it says which way it is set in words. */
.wf-late {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
}

.wf-late__button {
  gap: var(--space-2);
}

.wf-late__button[aria-pressed='true'] {
  color: var(--color-danger-fg);
  background: var(--color-danger-soft);
  border-color: var(--color-danger);
}

.wf-late__count {
  display: inline-grid;
  place-items: center;
  min-inline-size: 1.5rem;
  padding-inline: var(--space-2);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  line-height: 1.5;
  color: var(--color-text-muted);
  background: var(--color-fill);
  border-radius: var(--radius-pill);
}

.wf-late__button[aria-pressed='true'] .wf-late__count {
  color: var(--color-danger-fg);
  background: var(--color-surface);
}

/* The small badge on a row, under the status: its own line, so it never widens the cell. */
.wf-row-late {
  display: block;
  margin-block-start: var(--space-1);
}

@media (forced-colors: active) {
  .wf-late__button[aria-pressed='true'] { outline: 2px solid Highlight; }
}
