/*
 * PE-013 branch governance (IRC-1804).
 *
 * Its own file rather than an addition to site.css, for the reason circuit.css
 * is its own file: the design layer stays untouched and several client tasks are
 * editing site.css in parallel. Nothing here is a design-system pattern another
 * area reuses - a RAG badge and a committee return table are this area's
 * furniture.
 *
 * Not scoped CSS either, because these classes are shared between seven
 * components (the section nav, the scope strip and the refusal panel are their
 * own components, and the RAG badge is used on four pages). Blazor's scoped CSS
 * marks only the elements written in one component's own markup, so a shared
 * class would need the same rule copied into every file that uses it.
 *
 * Every value is a token. No colour, font or spacing value is hardcoded.
 */

/* ---------- the scope strip ---------- */

/*
 * Which branch the page is about, on every section. It sits directly under the
 * h1's standfirst, so it must not inherit the muted standfirst treatment - the
 * branch name is the one thing on the line that has to be unambiguous.
 */
.governance-scope {
  border-left: 3px solid var(--accent-text);
  padding-left: var(--irc-s4);
}

.governance-scope strong {
  display: block;
  font-family: var(--irc-font-display);
  font-size: var(--irc-fs-400);
}

.governance-scope .hint {
  display: block;
  margin: 0;
}

/* ---------- the section nav ---------- */

.governance-sections ul {
  display: flex;
  flex-wrap: wrap;
  gap: var(--irc-s2) var(--irc-s4);
  list-style: none;
  margin: 0;
  padding: 0;
}

.governance-sections li {
  align-items: center;
  display: flex;
  gap: var(--irc-s2);
}

.governance-sections a {
  border-bottom: 2px solid transparent;
  display: inline-block;
  font-family: var(--irc-font-display);
  font-weight: 600;
  padding-block: var(--irc-s2);
  text-decoration: none;
}

.governance-sections a:hover {
  border-bottom-color: var(--border-strong);
}

/* The current section is marked by the underline AND by aria-current, so it is
   not colour alone that says where you are. */
.governance-sections a[aria-current="page"] {
  border-bottom-color: var(--accent-text);
  color: var(--fg);
}

/* ---------- RAG ---------- */

/*
 * The badge always carries words. The tint only agrees with them, so a reader
 * who cannot tell the three apart loses nothing (WCAG 1.4.1) - and the text
 * colour stays on --fg so contrast cannot fall below AA in either scheme
 * whatever the background is doing.
 */
.rag-badge {
  border: 1px solid var(--border-strong);
  color: var(--fg);
}

.rag-badge--green {
  background: color-mix(in srgb, var(--success) 14%, transparent);
  border-color: var(--success);
}

.rag-badge--amber {
  background: color-mix(in srgb, var(--warning) 18%, transparent);
  border-color: var(--warning);
}

.rag-badge--red {
  background: color-mix(in srgb, var(--error) 12%, transparent);
  border-color: var(--error);
}

/* The compliance card's own edge repeats its RAG, so the state is legible from
   the top of the page rather than only from the badge inside it. */
.governance-rag[data-rag="green"] {
  border-top-color: var(--success);
}

.governance-rag[data-rag="amber"] {
  border-top-color: var(--warning);
}

.governance-rag[data-rag="red"] {
  border-top-color: var(--error);
}

.governance-rag__state {
  margin-bottom: var(--irc-s2);
}

/* ---------- refusals and the data-use gate ---------- */

.governance-notice {
  border-top-color: var(--accent-text);
}

/* The gate's two halves reuse PE-012's .gate-status list from site.css, so
   there is nothing to add here - the point of borrowing it is that the officer
   meets the same screen on both surfaces. */

/* ---------- outstanding work ---------- */

.governance-tasks {
  display: grid;
  gap: var(--irc-s4);
  list-style: none;
  margin: 0;
  padding: 0;
}

.governance-tasks li {
  border-left: 3px solid var(--border-strong);
  padding-left: var(--irc-s4);
}

.governance-tasks li[data-rag="red"] {
  border-left-color: var(--error);
}

.governance-tasks li[data-rag="amber"] {
  border-left-color: var(--warning);
}

.governance-tasks h3 {
  margin: 0;
}

.governance-tasks .hint {
  margin-top: var(--irc-s1);
}

/* ---------- record lists ---------- */

/*
 * .card-grid is used on a div everywhere else in the portal, so it has never
 * needed a list reset. These are real lists - a run of committee members, a run
 * of equipment - because that is what they are.
 */
.committee-list,
.minutes-list,
.compliance-list,
.equipment-list,
.task-list,
.boca-sections,
.report-sections {
  display: grid;
  gap: var(--irc-s5);
  list-style: none;
  margin: 0;
  padding: 0;
}

/* Two up on a desktop where the rows are cards, one up on a phone. min-width: 0
   on the track is what stops a long serial number widening the whole grid. */
.compliance-list,
.equipment-list,
.task-list {
  grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr));
}

@media (max-width: 30rem) {
  .compliance-list,
  .equipment-list,
  .task-list {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ---------- branch tasks (PE-013b) ---------- */

/*
 * The overdue edge, and it is a repeat rather than the signal. Every late row
 * also carries the word "Overdue" in a badge and says how many days late it is
 * in a sentence, so the colour is the third way of knowing and never the first
 * (WCAG 1.4.1). A discharged row loses the red because it is no longer late - it
 * was, and the date the branch discharged it is on the row saying so.
 */
.task-row[data-due-state='overdue'] {
  border-top-color: var(--error);
}

.task-row[data-due-state='done'] {
  border-top-color: var(--success);
}

/* The badges wrap onto their own line on a phone rather than widening the card,
   which is where a 360px overflow on a grid of cards usually comes from. */
.task-row__state {
  display: flex;
  flex-wrap: wrap;
  gap: var(--irc-s2);
  align-items: center;
  margin-bottom: var(--irc-s2);
}

.task-row__form {
  margin-top: var(--irc-s4);
}

/* `hidden` is how the completion panel closes, and it is the one element on this
   page whose closed state has to be absolute - a stray display rule beating it
   would leave a live date field and a live idempotency key on every row. */
.task-row__form[hidden] {
  display: none;
}

.committee-list li,
.minutes-list li,
.boca-sections li,
.report-sections li {
  border-top: 1px solid var(--border);
  padding-top: var(--irc-s4);
}

.committee-list li:first-child,
.minutes-list li:first-child,
.boca-sections li:first-child,
.report-sections li:first-child {
  border-top: 0;
  padding-top: 0;
}

.committee-list h3,
.committee-list h4,
.minutes-list h3,
.boca-sections h3,
.report-sections h3 {
  margin: 0 0 var(--irc-s2);
}

/* A past appointment is still evidence, so it is present and quiet rather than
   hidden. */
.committee-list--ended,
.equipment-list--retired {
  color: var(--muted);
}

.boca-sections__items {
  margin: var(--irc-s2) 0 0;
  padding-left: var(--irc-s5);
}

/* ---------- the annual committee return ---------- */

/*
 * The table can be wider than a phone, so it scrolls inside its own region
 * rather than pushing the document sideways. The wrapper carries tabindex and a
 * label because a scrollable region has to be reachable from the keyboard -
 * axe's scrollable-region-focusable, and it is a real barrier rather than a
 * technicality.
 */
.table-scroll {
  max-width: 100%;
  overflow-x: auto;
}

.committee-return__table {
  border-collapse: collapse;
  min-width: 30rem;
  width: 100%;
}

.committee-return__table th,
.committee-return__table td {
  border-bottom: 1px solid var(--border);
  padding: var(--irc-s3) var(--irc-s4) var(--irc-s3) 0;
  text-align: left;
  vertical-align: top;
}

.committee-return__table thead th {
  border-bottom-color: var(--border-strong);
  color: var(--muted);
  font-size: var(--irc-fs-200);
  letter-spacing: var(--irc-tracking-caps);
  text-transform: uppercase;
}

/* A vacancy is the thing the return exists to declare, so it reads as a state
   rather than as an empty cell. */
.committee-return__table tr[data-vacant="true"] td {
  color: var(--muted);
  font-style: italic;
}

/* ---------- activity ---------- */

.governance-activity[data-testid] {
  border-top-color: var(--border-strong);
}

/* ---------- upload inputs ---------- */

/*
 * InputFile renders a bare file input. It is the keyboard path and it must stay
 * visible; all this does is stop a long file name widening the grid track it
 * sits in, which is what produced a sideways scroll at 360px.
 */
.field input[type="file"] {
  max-width: 100%;
}
