/* Working a case (CasePeopleComponent, CaseStepsComponent, CaseContactsComponent, CaseActionsComponent and PersonSearchComponent in app/components; the sheets in app/views/case_*;
   docs/data_model/05-interactions-and-cases.md section 5, "As built (C1: working a case)"). Built from the case page's own lists (`.case-facts`, `.case-source` in 53-case-pages.css), the form
   fields, the badge, the callout and the button, so what is here is only how they sit together: each section as wide as the case's facts, its entries a plain list under a hairline, the forms
   laid out as the case sheet is, and a step's words drawn the way a team's reason is. The case's own sheets (a page header and then `.case-work-sheet`) are in here too: the page that holds a
   sheet's parts, the person search that comes before a choice, what is still open on the sheet that closes a case, and the words of a step, a reason or an answer read on a page of their own.

   Numbered 62, the number the simulation build reserved for this card. Tokens only and logical properties only, both enforced (test/styles/tokens_test.rb, test/styles/components_test.rb), so
   all of it reads on the light shell and on the console, in light and in dark, and mirrors in a right-to-left language. It declares no token and decides no mode. Nothing is pinned to an edge
   and nothing sets a height. Everything that holds words may shrink and breaks a long word, so a language 40% longer never widens the page (WCAG 1.4.10). */

.case-work,
.case-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--density-gap);
  max-inline-size: 64rem;
  min-inline-size: 0;
}

/* The page of a sheet: what comes after its header, in one column, `--section-gap` apart (the page flow, 41-page-structure.css; `data-gap="tight"` for a sheet of small parts, like a search and the
   form that follows it). Held to the form's own measure, 60rem, so the callout above a form, the person search, the work helper and the form itself end at the same edge. */
.case-work-sheet {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--section-gap);
  max-inline-size: 60rem;
  min-inline-size: 0;
}
.case-work-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  min-inline-size: 0;
}
.case-work-head > * {
  min-inline-size: 0;
  margin: 0;
}
.case-work-subheading {
  margin: 0;
  font-size: var(--text-base);
  font-weight: 650;
  overflow-wrap: anywhere;
}
.case-work-history {
  display: grid;
  gap: var(--density-gap);
  min-inline-size: 0;
}
.case-work-empty {
  min-inline-size: 0;
  margin: 0;
  color: var(--fg2);
  overflow-wrap: anywhere;
}

/* ── A list of entries: newest first, under a hairline ──────────────────── */

.case-work-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
  min-inline-size: 0;
  margin: 0;
  padding: 0;
  list-style: none;
  border-block-start: 1px solid var(--rule);
}
.case-work-entry {
  display: grid;
  gap: 0.25rem;
  min-inline-size: 0;
  padding-block: var(--density-row);
  border-block-end: 1px solid var(--rule);
}
.case-work-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.75rem;
  min-inline-size: 0;
  margin: 0;
}
.case-work-line .pill {
  max-inline-size: 100%;
}
.case-work-name {
  min-inline-size: 0;
  font-weight: 650;
  overflow-wrap: anywhere;
}
.case-work-name bdi {
  unicode-bidi: isolate;
}
.case-work-meta {
  min-inline-size: 0;
  margin: 0;
  color: var(--fg2);
  font-size: var(--text-sm);
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.case-work-change {
  min-inline-size: 0;
  margin: 0;
  overflow-wrap: anywhere;
}
.case-work-inline-form {
  margin: 0;
  margin-block-start: 0.25rem;
}

/* ── A step's words, when someone asks for them ─────────────────────────── */

.case-work-text {
  display: grid;
  gap: 0.25rem;
  min-inline-size: 0;
  margin-block-start: 0.25rem;
  padding-block: 0.5rem;
  padding-inline-start: 0.75rem;
  border-inline-start: 2px solid var(--rule-strong);
}
.case-work-text-label {
  margin: 0;
  color: var(--fg2);
  font-size: var(--text-sm);
}
.case-work-text-body {
  min-inline-size: 0;
  margin: 0;
  white-space: pre-line;
  overflow-wrap: anywhere;
}
.case-work-text-body bdi {
  unicode-bidi: isolate;
}

/* ── The words, read on a page of their own ─────────────────────────────── */

/* A Read button opens the words in the frame it was pressed in, where they are the plain block above. The same words opened as a page (no Turbo, a link followed, the native shell) are a card of
   their own under the page header, the way a sheet is one: what it is called in the small tracked capitals the records use, the words, and who can read them under a hairline. */
.case-work-text--page {
  max-inline-size: 60rem;
  margin-block-start: 0;
  padding-block: var(--space-4);
  padding-inline: var(--space-5);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
  box-shadow: var(--shadow-soft);
  gap: var(--space-3);
}
.case-work-text--page .case-work-text-label {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  line-height: 1.4;
  text-transform: uppercase;
}
/* Scripts whose letters join (Arabic and its neighbours) are not put in capitals or spaced apart: tracking breaks the joining. */
.case-work-text--page .case-work-text-label:is(:lang(ar), :lang(fa), :lang(ur), :lang(ps), :lang(sd), :lang(ug), :lang(ku)) {
  letter-spacing: normal;
  text-transform: none;
}
.case-work-text--page .case-work-text-body {
  max-inline-size: 66ch;
}
.case-work-text--page > .case-source {
  padding-block-start: var(--space-3);
  border-block-start: 1px solid var(--rule);
}
/* What was said in a contact, opened as a page (Directory::ContactBodiesController#show): the same words, on the same card (`.sheet`, 45-sheet.css). The card is the edge, so the block loses the rule and the
   padding that set it apart in a row of the timeline, and the focus it takes on arrival rings it a little way out. */
.sheet .contact-body {
  margin-block-start: 0;
  padding: 0;
  border-inline-start: 0;
  outline-offset: var(--space-2);
}
@media (max-width: 40rem) {
  .case-work-text--page {
    padding-inline: var(--space-4);
  }
}

/* ── What is still open, on the sheet that closes a case ─────────────────── */

/* The parts of the section (what is owed, what is in force, who loses access, the summary): a subheading over its list or its sentence, a step of the scale further apart than the lines inside one. */
.case-closing-check .page-section__body {
  gap: var(--space-5);
}
.case-closing-check__part {
  display: grid;
  gap: var(--space-3);
  min-inline-size: 0;
}
.case-closing-check__part > p {
  max-inline-size: 66ch;
  margin: 0;
  overflow-wrap: anywhere;
}
.case-closing-check__part > h3 {
  overflow-wrap: anywhere;
}

/* ── The form that adds a step (the form system draws its summary and fields) ── */

.case-steps-form {
  padding-block-start: var(--density-gap);
}

/* ── What can be done to the case: a row of links that wraps ────────────── */

.case-actions-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  min-inline-size: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}
.case-actions-list > li {
  min-inline-size: 0;
  max-inline-size: 100%;
}

/* ── A link that is the thing to do, on a line of its own ───────────────────
   Check an item off, open one of the office's letters, go to the rest of the list of what is owed, add a person the Directory does not have, open a referral or a report from its queue, open a referral from the case it came by or went by (T3, the keyboard pass of a matter opened by a referral), record what was found for an inquiry's item, read a goal's words on a meeting note: each is a link
   with no sentence around it, so it is a target of its own, and at 17 to 20px tall it was under WCAG 2.5.8's 24 CSS px (AGENTS.md section 11). It is made a box that tall at the least with its words in
   the middle of it, and the touch floor on a finger (40-native.css's rule is for controls, which a link of this kind is not). A link inside a sentence is not named here: it stays as tall as its line
   (WCAG 2.5.8, "inline"). Found by the keyboard and touch passes of the Threat Assessment Group's screens (test/system/threat_assessment_keyboard_test.rb). */

:is(.case-plan, .case-next__owed, .case-findings) .case-work-meta > a,
a.case-work-inline-link,
.case-letters .case-work-line > a.case-work-name,
.case-referrals .case-work-line > a.case-work-name,
.person-search-alternative > a,
.requests-page table.data.data-table tbody th > a {
  display: inline-flex;
  align-items: center;
  min-block-size: 1.5rem;
}
@media (pointer: coarse) {
  :is(.case-plan, .case-next__owed, .case-findings) .case-work-meta > a,
  a.case-work-inline-link,
  .case-letters .case-work-line > a.case-work-name,
  .case-referrals .case-work-line > a.case-work-name,
  .person-search-alternative > a,
  .requests-page table.data.data-table tbody th > a {
    min-block-size: var(--target-min);
  }
}

/* ── Finding a person in the Directory, on a sheet ──────────────────────── */

.person-search {
  display: grid;
  gap: var(--space-2);
  min-inline-size: 0;
}
.person-search-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-2) var(--space-3);
  min-inline-size: 0;
}
.person-search-row > .field {
  flex: 1 1 14rem;
  min-inline-size: 0;
}
.person-search-found {
  min-inline-size: 0;
  margin: 0;
  color: var(--fg2);
  font-size: var(--text-sm);
  overflow-wrap: anywhere;
}
.person-search-found:empty {
  display: none;
}
/* The way round the search, said under it on the same card: "Someone who is not in the Directory?" */
.person-search-alternative {
  min-inline-size: 0;
  margin: 0;
  padding-block-start: var(--space-3);
  border-block-start: 1px solid var(--rule);
  font-size: var(--text-sm);
  overflow-wrap: anywhere;
}

/* The log under the form that adds to it: room between the form's button and the log's heading. */
.case-steps-form + .case-work-history {
  margin-block-start: var(--density-block);
}
