/* ProcurementOS components (D-115, D-132). Plain classes, no JavaScript and no
   inline style: markup chooses the class, this file draws it. Colours come only
   from tokens.css, so the contrast already tested there holds here: text uses the
   text tokens on the surface tokens, a status chip or notice pairs its status
   foreground with its own fill, and every status is said in words beside any
   colour (VS-12, VS-38). Every component is shown with sample content on the
   component reference page. New classes take pos-. */

/* --- buttons: a button or a link that looks like one (VS-9) --- */

.pos-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.5rem;
  padding: var(--pos-space-2) var(--pos-space-4);
  border: 1px solid var(--accent);
  border-radius: var(--pos-radius);
  background: var(--accent);
  color: var(--on-accent);
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
}

.pos-button-secondary {
  border-color: var(--control-border);
  background: var(--surface);
  color: var(--text);
}

.pos-button-secondary:hover {
  background: var(--surface-2);
}

.pos-button:disabled,
.pos-button[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
}

/* The mock-up's .btn-small: 32px, 14px type. */
.pos-button-small {
  align-self: center;
  min-height: 2rem;
  padding: var(--pos-space-1) var(--pos-space-2-5);
  font-size: var(--pos-text-minor);
}

.pos-button-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--pos-space-3);
  margin: 0 0 var(--pos-space-4);
}

/* --- fields: a label above its control --- */

.pos-field {
  margin: 0 0 var(--pos-space-3-5);
}

.pos-label {
  display: block;
  margin-bottom: var(--pos-space-1);
  font-size: var(--pos-text-compact);
  font-weight: 600;
}

/* 40px tall, as the mock-up's inputs: well over the 24px target size. */
.pos-input,
.pos-select {
  display: block;
  width: 100%;
  max-width: 24rem;
  min-width: 0;
  min-height: 2.5rem;
  padding: var(--pos-space-2) var(--pos-space-2-5);
  border: 1px solid var(--control-border);
  border-radius: var(--pos-radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: var(--pos-text-base);
}

/* The box is 20px, as the mock-up's (mockup.css line 152). WCAG 2.5.8 then needs 24px
   between centres, which the row's own height gives however small its label is. */
.pos-field-check {
  min-height: 1.5rem;
  display: flex;
  gap: var(--pos-space-2);
  align-items: center;
}

.pos-field-check .pos-label {
  margin: 0;
}

/* Drawn from the tokens, not left to the browser's default border (VS-36). */
.pos-checkbox {
  appearance: none;
  -webkit-appearance: none;
  flex: 0 0 auto;
  display: inline-grid;
  place-content: center;
  width: 1.25rem;
  height: 1.25rem;
  margin: 0;
  border: 2px solid var(--control-border);
  border-radius: var(--pos-radius);
  background: var(--surface);
}

.pos-checkbox::before {
  content: "";
  width: 0.75rem;
  height: 0.75rem;
  background: var(--on-accent);
  clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0, 43% 62%);
  transform: scale(0);
}

.pos-checkbox:checked {
  border-color: var(--accent);
  background: var(--accent);
}

.pos-checkbox:checked::before {
  transform: scale(1);
}

/* Forced colours replace backgrounds, which would leave the drawn box the same ticked and
   unticked. The browser's own checkbox draws instead (D-132). */
@media (forced-colors: active) {
  .pos-checkbox {
    appearance: auto;
    -webkit-appearance: auto;
  }

  .pos-checkbox::before {
    content: none;
  }
}

/* --- table, in a wrapper that scrolls instead of the page. Compact rows on the
   surface with no alternate shading (VS-24). --- */

.pos-table-scroll {
  max-width: 100%;
  overflow-x: auto;
}

.pos-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--pos-text-compact);
}

.pos-table caption {
  padding: var(--pos-space-2-5) var(--pos-space-4) 0;
  font-weight: 600;
  text-align: left;
}

.pos-table th,
.pos-table td {
  padding: var(--pos-space-2) var(--pos-space-3);
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.pos-table th {
  background: var(--surface-2);
  color: var(--text-muted);
  font-family: var(--pos-font-mono);
  font-size: var(--pos-text-label);
  font-weight: 500;
  letter-spacing: 0.06em;
  line-height: 1.4;
  text-transform: uppercase;
  white-space: nowrap;
}

.pos-table td {
  background: var(--surface);
}

.pos-table tr:last-child td {
  border-bottom: 0;
}

.pos-table .pos-num {
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.pos-table tr[aria-selected="true"] td {
  background: var(--accent-soft);
}

/* The row's title: a block, semibold, as the mock-up's .tbl .title. */
.pos-table .pos-title {
  display: block;
  font-weight: 600;
}

/* At phone width a stacked table shows each row as a block of label and value.
   The headings stay in the document for assistive technology, and script gives
   the table, row groups, rows and cells explicit roles so the semantics survive
   the change of display (VS-28). Each cell carries its heading in data-label. */
@media (max-width: 640px) {
  .pos-table-stack thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  /* The table is a block here, so its caption is too; left as a table caption
     it shrinks to the width of its longest word. */
  .pos-table-stack caption {
    display: block;
    width: 100%;
  }

  /* The cells sit on the surface, so the table does too: the padding between
     the row blocks is then the same surface, not the page behind it. */
  .pos-table-stack {
    background: var(--surface);
  }

  .pos-table-stack,
  .pos-table-stack tbody,
  .pos-table-stack tr,
  .pos-table-stack td,
  .pos-table-stack th[scope="row"] {
    display: block;
    width: 100%;
  }

  .pos-table-stack tr {
    padding: var(--pos-space-2) 0;
    border-bottom: 1px solid var(--border);
  }

  .pos-table-stack tr:last-child {
    border-bottom: 0;
  }

  .pos-table-stack td,
  .pos-table-stack th[scope="row"] {
    padding: var(--pos-space-1) var(--pos-space-4);
    border: 0;
    text-align: left;
  }

  .pos-table-stack td.pos-num {
    text-align: left;
  }

  .pos-table-stack td::before {
    content: attr(data-label);
    display: block;
    color: var(--text-muted);
    font-family: var(--pos-font-mono);
    font-size: var(--pos-text-label);
    font-weight: 500;
    letter-spacing: 0.06em;
    line-height: 1.4;
    text-transform: uppercase;
  }
}

/* --- status chip: always words; the fill and text only add to them (VS-7, VS-25,
   VS-38). The only rounded shape besides the count badge. --- */

.pos-badge {
  display: inline-flex;
  align-items: center;
  min-height: 1.5rem;
  padding: 1px 10px;
  border-radius: var(--pos-radius-pill);
  background: var(--neutral-bg);
  color: var(--neutral-fg);
  font-size: var(--pos-text-small);
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
}

.pos-badge-valid {
  background: var(--success-bg);
  color: var(--success-fg);
}

.pos-badge-indeterminate {
  background: var(--warning-bg);
  color: var(--warning-fg);
}

.pos-badge-breach {
  background: var(--error-bg);
  color: var(--error-fg);
}

.pos-badge-acting {
  background: var(--neutral-bg);
  color: var(--neutral-fg);
}

/* A code beside its title: muted mono, second (VS-3, VS-24, VS-30). It moved here from
   base.css, where nothing used it, now that scripts build it. */
.pos-code {
  color: var(--text-muted);
  font-family: var(--pos-font-mono);
  font-size: var(--pos-text-small);
  line-height: 1.4;
  white-space: nowrap;
}

/* A date or time that must stay on one line in a table cell (VS-27). */
.pos-nowrap {
  white-space: nowrap;
}

/* A status chip built from a sentence of terminology, which may be long: it wraps
   instead of widening the page at 320px or 200% text (VS-40). */
.pos-badge-wrap {
  white-space: normal;
}

/* A chip in a table stays on one line at 860px and wider, where the table is laid out as
   rows; below 860 the tables stack and it may wrap (D-133). */
.pos-table .pos-badge-wrap {
  white-space: nowrap;
}

@media (max-width: 859.98px) {
  .pos-table .pos-badge-wrap {
    white-space: normal;
  }
}

/* --- "About this page" and collapsible notes (VS-33) --- */

.pos-about,
.pos-more {
  color: var(--text-muted);
  font-size: var(--pos-text-minor);
}

.pos-about {
  margin: 0 0 var(--pos-space-4);
}

.pos-more {
  margin-top: var(--pos-space-2-5);
}

/* The summary is a real control: at least 24px high (VS-39), in the link colour. */
.pos-about > summary,
.pos-more > summary {
  display: inline-flex;
  align-items: center;
  min-height: 1.5rem;
  color: var(--accent);
  cursor: pointer;
}

.pos-about[open] > summary,
.pos-more[open] > summary {
  margin-bottom: var(--pos-space-2);
}

/* The notes inside keep their typed notice; they only sit in the collapsed detail. */
.pos-more > .pos-notice,
.pos-about > .pos-notice {
  margin: var(--pos-space-2) 0;
}

/* --- typed notice: success, warning, error or information, only for what
   matters on the record (VS-34) --- */

.pos-notice {
  margin: var(--pos-space-4) 0;
  padding: var(--pos-space-2) var(--pos-space-3);
  border-left: 4px solid currentColor;
  background: var(--neutral-bg);
  color: var(--neutral-fg);
  font-size: var(--pos-text-compact);
}

.pos-notice-success {
  background: var(--success-bg);
  color: var(--success-fg);
}

.pos-notice-warning {
  background: var(--warning-bg);
  color: var(--warning-fg);
}

.pos-notice-error {
  background: var(--error-bg);
  color: var(--error-fg);
}

/* The type is said in words as well as by the colour, so it holds without
   colour (D-119). */
.pos-notice-label {
  margin: 0 0 var(--pos-space-1);
  font-weight: 700;
}

.pos-notice p:last-child {
  margin-bottom: 0;
}

/* A notice whose message a script writes to, shows and hides by its id: the
   notice follows its message, so the type label never shows alone. */
.pos-notice:has(> .pos-notice-message[hidden]) {
  display: none;
}

/* --- description list: a term beside its detail, stacked when narrow --- */

.pos-dl {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: var(--pos-space-1) var(--pos-space-4);
  margin: 0 0 var(--pos-space-4);
}

.pos-dl dt {
  color: var(--text-muted);
}

.pos-dl dd {
  margin: 0;
  overflow-wrap: anywhere;
}

@media (max-width: 30rem) {
  .pos-dl {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* --- authority basis: what stands behind the approvers of a step (D-116, D-117).
   A label says whether it is current or as at a decision, then a description
   list of instrument, version, clause and effective dates. The basis always
   stays on the screen (D-132). --- */

.pos-basis {
  margin: var(--pos-space-4) 0;
  padding: var(--pos-space-3) var(--pos-space-4);
  border: 1px solid var(--border);
  border-left: 4px solid var(--control-border);
  background: var(--surface-2);
}

.pos-basis-heading {
  margin: 0 0 var(--pos-space-1);
}

.pos-basis-label {
  margin: 0 0 var(--pos-space-2);
  font-weight: 700;
}

.pos-basis .pos-dl {
  margin-bottom: 0;
}

/* --- audit history: one request's entries in the order recorded (step 3). Each
   entry is a heading, then a description list of sequence, when, who acted, the
   signed-in person and the position; a decision adds its authority basis, or a
   notice where its record cannot be read. An exception says so in a chip, and its
   edge is heavier, with no status colour on the entry itself (VS-12). --- */

.pos-history {
  margin: 0 0 var(--pos-space-4);
  padding: 0;
  list-style: none;
}

.pos-history-entry {
  margin: 0 0 var(--pos-space-3);
  padding: var(--pos-space-3) var(--pos-space-4);
  border: 1px solid var(--border);
  border-left: 4px solid var(--control-border);
  background: var(--surface);
}

.pos-history-entry-exception {
  border-left-width: 8px;
}

.pos-history-heading {
  margin: 0 0 var(--pos-space-2);
}

.pos-history-entry > .pos-dl {
  margin-bottom: 0;
}

.pos-history-entry > .pos-basis,
.pos-history-entry > .pos-notice {
  margin-bottom: 0;
}

/* --- decision memos (release 13, S5): mock-up 37. The tabs are a row of buttons, one for each memo; the
   chosen one carries aria-current. The paper holds the issued text; the PDF itself stays light. --- */

.pos-memo-tabs {
  display: flex;
  flex-wrap: wrap;
  margin: 0 0 var(--pos-space-4);
  padding: 0;
  list-style: none;
  border: 1px solid var(--border);
  background: var(--surface);
}

.pos-memo-tabs > li {
  flex: 1 1 200px;
  border-right: 1px solid var(--border);
}

.pos-memo-tabs > li:last-child {
  border-right: 0;
}

.pos-memo-tab {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: var(--pos-space-2-5) var(--pos-space-3-5);
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.pos-memo-tab[aria-current="true"] {
  background: var(--accent-soft);
  color: var(--accent);
}

.pos-memo-type {
  display: block;
  font-weight: 600;
}

.pos-memo-paper {
  padding: var(--pos-space-4);
  border: 1px solid var(--border);
  background: var(--surface);
}

.pos-memo-title {
  margin: var(--pos-space-1) 0;
  font-size: var(--pos-text-h2);
  font-weight: 600;
  line-height: 1.2;
}

.pos-memo-endorsement + .pos-memo-endorsement {
  margin-top: var(--pos-space-2);
}

.pos-memo-endorsement > p {
  margin: 0;
}

.pos-memo-step {
  margin-top: var(--pos-space-3);
}

/* --- empty state --- */

.pos-empty {
  padding: var(--pos-space-6) var(--pos-space-4);
  border: 1px dashed var(--control-border);
  background: var(--surface);
  text-align: center;
}

.pos-empty-title {
  margin: 0 0 var(--pos-space-2);
}

/* --- filter bar: a GET form, so the filters live in the address --- */

.pos-filter {
  display: flex;
  flex-wrap: wrap;
  gap: var(--pos-space-3) var(--pos-space-4);
  align-items: flex-end;
  margin: 0 0 var(--pos-space-4);
  padding: var(--pos-space-3) var(--pos-space-4);
  border: 1px solid var(--border);
  background: var(--surface);
}

.pos-filter .pos-field {
  flex: 1 1 12rem;
  margin: 0;
}

.pos-filter .pos-input,
.pos-filter .pos-select {
  max-width: none;
}

/* The filter sits in a panel (mock-up 20): the panel draws the border, and the categories take a
   row of their own above the four fields. */
.pos-panel-body > .pos-filter {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
}

.pos-filter fieldset.pos-field {
  flex: 1 1 100%;
  display: flex;
  flex-wrap: wrap;
  gap: var(--pos-space-1) var(--pos-space-4);
  min-width: 0;
}

.pos-filter-panel {
  margin: 0 0 var(--pos-space-4);
}

/* --- pagination: server-rendered links --- */

.pos-pagination-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--pos-space-1);
  margin: 0 0 var(--pos-space-4);
  padding: 0;
  list-style: none;
}

/* The mock-up's small button (.btn-small): 32px tall, 14px type. */
.pos-pagination-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.5rem;
  min-height: 2rem;
  padding: var(--pos-space-1) var(--pos-space-2-5);
  border: 1px solid var(--control-border);
  background: var(--surface);
  color: var(--accent);
  font-size: var(--pos-text-minor);
  font-weight: 600;
  text-align: center;
  text-decoration: none;
}

.pos-pagination-link:hover {
  background: var(--surface-2);
}

.pos-pagination-link[aria-current="page"] {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
}

/* --- panel: a labelled container (VS-22). Mirrors .panel, .panel-head and
   .panel-body in mockups/v04.2/mockup.css, square and without a shadow. --- */

.pos-panel {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: var(--pos-text-medium);
}

/* Panels that follow one another are spaced as the mock-up's column gap. */
.pos-panel + .pos-panel {
  margin-top: var(--pos-space-4);
}

.pos-panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--pos-space-1) var(--pos-space-3);
  padding: var(--pos-space-2-5) var(--pos-space-4);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

.pos-panel-head h2,
.pos-panel-head h3 {
  margin: 0;
  font-family: var(--pos-font-body);
  font-size: var(--pos-text-base);
  font-weight: 600;
  line-height: 1.3;
}

.pos-panel-body {
  padding: var(--pos-space-3-5) var(--pos-space-4);
}

.pos-panel-body + .pos-panel-body {
  border-top: 1px solid var(--border);
}

/* --- a plain list: no margin, indent or marker, as the mock-up's .rows --- */

.pos-rows {
  margin: 0;
  padding-left: 0;
  list-style: none;
}

/* --- the request and decide pages' arrangement (D-133, stage C): a breadcrumb, a
   heading with its code and status beside it, and two columns that stack below 860px,
   as the mock-ups' .crumb, .page-head and .cols --- */

.pos-crumb ol {
  display: flex;
  flex-wrap: wrap;
  gap: var(--pos-space-1) var(--pos-space-2);
  margin: 0 0 var(--pos-space-3);
  padding-left: 0;
  list-style: none;
  font-size: var(--pos-text-minor);
}

.pos-crumb li + li::before {
  content: "/";
  margin-right: var(--pos-space-2);
  color: var(--text-muted);
}

.pos-page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--pos-space-1) var(--pos-space-4);
}

.pos-page-head h1 {
  margin: 0;
}

/* The steps at a glance: one cell per step, wrapping, as the mock-up's .spine. */
.pos-spine {
  display: flex;
  flex-wrap: wrap;
  gap: var(--pos-space-2) var(--pos-space-4);
  margin: var(--pos-space-3) 0;
  padding-left: 0;
  list-style: none;
}

.pos-spine li {
  min-width: 0;
  padding: var(--pos-space-2) var(--pos-space-3);
  border: 1px solid var(--border);
  background: var(--surface);
}

/* The current step, as the mock-up's li[aria-current="step"], with a heavier edge and a bolder
   title so colour is not the only cue (WCAG 1.4.1). The strip wraps in every layout, so the left
   edge serves at each width. */
.pos-spine li[aria-current="step"] {
  background: var(--accent-soft);
  border-left: 4px solid var(--accent);
}

.pos-spine li[aria-current="step"] .pos-spine-step {
  font-weight: 700;
}

.pos-spine-step {
  display: block;
  font-weight: 600;
}

.pos-spine li p {
  margin: var(--pos-space-1) 0 0;
}

.pos-cols {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--pos-space-4);
  align-items: start;
}

.pos-col {
  min-width: 0;
}

@media (min-width: 860px) {
  .pos-cols {
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  }
}

/* The home queue's two columns (D-135, round 2), as the v04.2 home mock-up: the queue panels on the
   left, Start and Your roles on the right. mockups/v04.2/mockup.css .cols (lines 89-90): one flexible
   column and one of 300 to 380px, a 20px gap. Release 8b (D-136) supersedes the 8a breakpoint of 1101px:
   two columns from 1400px, one column up to 1399px, so the queue tables run full width at 1280. */
.pos-home-cols {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
  gap: 20px;
  align-items: start;
}

.pos-home-cols > .pos-col {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
}

/* The gap alone spaces the panels here (the mock-up's 20px); the shared top margin would add to it. */
.pos-home-cols .pos-panel + .pos-panel {
  margin-top: 0;
}

@media (max-width: 1399px) {
  .pos-home-cols {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* A mono sub-heading inside a panel, as the mock-up's .label. */
.pos-panel-label {
  margin: var(--pos-space-2-5) 0 var(--pos-space-1);
  color: var(--text-muted);
  font-family: var(--pos-font-mono);
  font-size: var(--pos-text-label);
  font-weight: 500;
  letter-spacing: 0.06em;
  line-height: 1.4;
  text-transform: uppercase;
}

/* --- a block of the reference page --- */

.pos-section {
  margin: 0 0 var(--pos-space-6);
}
