/* The spine and the Directory: the components built from the kernel ones to show a person and the contacts that
   have been had with them (FigureStripComponent, PaginationComponent, AvatarComponent, Timeline::EntryComponent,
   TimelineComponent, PersonHeaderComponent, FactListComponent, ContactSheetComponent and
   Directory::TableComponent in app/components; design-direction.md section 5, items 13 and 18).

   Linked after 38-shell.css and before 40-native.css, so the touch target floor in 40-native.css still wins over
   this file's. 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 decides no mode and no surface, except that the person header's title
   is the smaller one on the console, as the page header's is. Nothing is pinned to an edge and nothing sets a
   height in vh.

   Everything that holds words may shrink (`min-inline-size: 0`) and breaks a word that has no room (`overflow-wrap`),
   so one long unbroken word, or a language 40% longer, never widens the page (WCAG 1.4.10). Where it matters the
   tests that read this file say so (test/styles/spine_and_directory_test.rb), and the 320px reflow test looks. */

/* ── Figure strip ─────────────────────────────────────────────────────────
   A hairline above and below and a tick at the start of each figure, in place of a card for each: the console's
   "figure strip" (design-direction.md section 2.4). A figure is one line, its label and then its number, so the strip is
   the height of a row; the figures wrap to more lines when a screen, or a longer language, has no room for them side by
   side. A zero is dimmed and still reads "0". */

.figure-strip {
  min-inline-size: 0;
  border-block: 1px solid var(--rule);
}
.figure-strip-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 9rem), 1fr));
  gap: 0;
  margin: 0;
}
.figure {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 var(--density-gap);
  min-inline-size: 0;
  padding: 0.35rem var(--density-block);
  border-inline-start: 2px solid var(--rule);
}
.figure-label {
  overflow-wrap: anywhere;
}
.figure-value {
  color: var(--fg1);
  font-size: var(--text-md);
  font-weight: 650;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.figure[data-zero] .figure-value {
  color: var(--fg3);
}

/* ── Pagination ───────────────────────────────────────────────────────────
   The two ways and where this page is. They are buttons that are links, so they already wrap, are 24px at the least
   and 44px on touch; the bar wraps under a longer language. */

.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem 1rem;
  min-inline-size: 0;
  margin-block-start: 1rem;
}
.pagination-range {
  color: var(--fg2);
  font-size: var(--text-sm);
  text-align: center;
}

/* ── Avatar sizes ─────────────────────────────────────────────────────────
   The tint and the monogram's colors are the ported `.avatar` rules and the `--avatar-*` tokens; the size is the
   component's. */

.avatar-sm {
  inline-size: 1.5rem;
  block-size: 1.5rem;
  font-size: 0.65rem;
}
.avatar-md {
  inline-size: 2.25rem;
  block-size: 2.25rem;
  font-size: 0.8rem;
}
.avatar-lg {
  inline-size: 2.5rem;
  block-size: 2.5rem;
  font-size: 0.9rem;
}

/* ── The spine ────────────────────────────────────────────────────────────
   A heading, the figures, the choices, then the contacts a year at a time. Each contact is a row tinted by its
   compartment's tone (`--spine-<tone>-bg`, `--spine-<tone>-line`; 10-globals.css), with a bar at its start. The tone
   is read by the contrast check on every tint and every surface, and is never the only signal: the row says its office
   in words. A key the list does not know is the neutral tone.

   A phone gets the day and how it happened on one line, then what it was, then who and where. With room (52rem of the
   spine's own width, a container query, so a spine in a side panel of a wide page keeps the stacked rows) the four are
   columns. The order in the markup is the reading order either way. */

.spine {
  container: spine / inline-size;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--density-block);
  min-inline-size: 0;
}
.spine-heading {
  font-size: var(--text-lg);
  overflow-wrap: anywhere;
}
.spine-years,
.spine-entries {
  display: grid;
  gap: 0.25rem;
  min-inline-size: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}
.spine-years {
  gap: var(--density-block);
}
.spine-year-heading {
  display: flex;
  align-items: center;
  gap: var(--density-block);
  margin-block-end: 0.25rem;
  color: var(--fg2);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: 0.08em;
}
.spine-year-heading::after {
  content: "";
  flex: 1;
  border-block-start: 1px solid var(--rule);
}

.spine-entry {
  --spine-bg: var(--spine-neutral-bg);
  --spine-line: var(--spine-neutral-line);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-areas:
    "when channel"
    "main main"
    "who who";
  gap: 0.1rem var(--density-block);
  min-inline-size: 0;
  padding: 0.4rem var(--density-block);
  border-inline-start: 4px solid var(--spine-line);
  border-radius: var(--radius-md);
  background: var(--spine-bg);
  color: var(--fg1);
  overflow-wrap: anywhere;
}
.spine-entry[data-tone="plum"] {
  --spine-bg: var(--spine-plum-bg);
  --spine-line: var(--spine-plum-line);
}
.spine-entry[data-tone="green"] {
  --spine-bg: var(--spine-green-bg);
  --spine-line: var(--spine-green-line);
}
.spine-entry[data-tone="teal"] {
  --spine-bg: var(--spine-teal-bg);
  --spine-line: var(--spine-teal-line);
}
.spine-entry[data-tone="blue"] {
  --spine-bg: var(--spine-blue-bg);
  --spine-line: var(--spine-blue-line);
}
.spine-entry[data-tone="amber"] {
  --spine-bg: var(--spine-amber-bg);
  --spine-line: var(--spine-amber-line);
}
.spine-entry[data-tone="rose"] {
  --spine-bg: var(--spine-rose-bg);
  --spine-line: var(--spine-rose-line);
}
.spine-entry[data-tone="slate"] {
  --spine-bg: var(--spine-slate-bg);
  --spine-line: var(--spine-slate-line);
}
.spine-entry[data-tone="neutral"] {
  --spine-bg: var(--spine-neutral-bg);
  --spine-line: var(--spine-neutral-line);
}

.spine-entry-when {
  grid-area: when;
  color: var(--fg2);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}
.spine-entry-channel {
  display: flex;
  grid-area: channel;
  align-items: center;
  gap: 0.4rem;
  min-inline-size: 0;
  color: var(--fg2);
  font-size: var(--text-sm);
}
.spine-glyph {
  flex: none;
  inline-size: 1rem;
  block-size: 1rem;
}
/* Which way the contact went (W1-UI-direction): a word, set off from the channel by a rule; an inbound one is also in the accent's text color with
   a mark, a second signal and never the only one. */
.spine-entry-channel {
  flex-wrap: wrap;
}
.spine-entry-direction {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding-inline-start: 0.4rem;
  border-inline-start: 1px solid var(--rule-strong);
}
.spine-entry-direction[data-direction="inbound"] {
  color: var(--accent-text);
  font-weight: 600;
}
.spine-direction-mark {
  flex: none;
  inline-size: 1rem;
  block-size: 1rem;
}
.spine-entry-main {
  grid-area: main;
  min-inline-size: 0;
}
/* A contact's kind and its title share a line: "NOTIFICATION  A subject", then what was said under it. */
.spine-entry-category {
  display: inline;
  margin-inline-end: 0.5rem;
}
.spine-entry-category + .spine-entry-lead {
  display: inline;
}
.spine-entry-lead {
  font-weight: 650;
  line-height: 1.35;
}
.spine-entry-markers {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.4rem;
  margin-block-start: 0.2rem;
}
.spine-entry-text {
  margin-block-start: 0.2rem;
  white-space: pre-line;
  line-height: 1.4;
}
.spine-entry .spine-entry-absence {
  margin-block-start: 0.25rem;
  padding: 0.4rem 0.75rem;
}
.spine-entry-outcome {
  margin-block-start: 0.2rem;
  color: var(--fg2);
  font-size: var(--text-sm);
}
.spine-entry-who {
  grid-area: who;
  display: flex;
  flex-wrap: wrap;
  gap: 0.1rem 0.9rem;
  min-inline-size: 0;
  font-size: var(--text-sm);
}
.spine-entry-office {
  font-weight: 650;
}
.spine-entry-by {
  color: var(--fg2);
}
@container spine (min-width: 52rem) {
  .spine-entry {
    grid-template-columns: 9.5rem 9rem minmax(0, 1fr) minmax(8rem, 14rem);
    grid-template-areas: "when channel main who";
    align-items: start;
  }
  .spine-entry-who {
    display: grid;
    align-content: start;
  }
}

/* ── The person header ────────────────────────────────────────────────────
   One row that wraps: who they are, and the actions under it when there is no room. The name is the page's title;
   on the console it is the one-line size the page header uses there. */

.person-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--density-gap);
  min-inline-size: 0;
  padding-block: 0.5rem;
}
.person-header-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--density-gap) 1.5rem;
}
.person-header-who {
  display: flex;
  flex: 1 1 18rem;
  align-items: flex-start;
  gap: var(--density-block);
  min-inline-size: 0;
}
.person-header-text {
  display: grid;
  gap: 0.1rem;
  min-inline-size: 0;
}
/* What the header says about them besides the name, the facts and the identifiers, run together on lines of their own that wrap: the class and
   the student id, then the roles and the address, each identifier a label and what it says on the one line. */
.person-header-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.1rem 1.25rem;
  min-inline-size: 0;
}
.person-header-crumb {
  font-size: var(--text-sm);
}
/* The way back above the name is a link on a line of its own and not a link in a sentence, so on a finger it is a target
   of its own: 44px tall (`--target-min`, AGENTS.md section 11), as every other control is (40-native.css says why the
   floor is for controls and the spacing exception of WCAG 2.5.8 is for links inside text). The desktop look is
   untouched. */
@media (pointer: coarse) {
  .person-header-crumb a {
    display: inline-flex;
    align-items: center;
    min-block-size: var(--target-min);
  }
}
.person-header-name {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.6rem;
}
/* The title is in the display face; a badge beside it is a word in the working face, as it is everywhere else. */
.person-header-name .pill {
  font-family: var(--font-sans);
  font-weight: 600;
}
.person-header-name-text {
  min-inline-size: 0;
  overflow-wrap: anywhere;
}
.person-header-goes-by {
  color: var(--fg2);
  overflow-wrap: anywhere;
}
.person-header-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--fg2);
  font-size: var(--text-sm);
}
.person-header-facts li {
  min-inline-size: 0;
  overflow-wrap: anywhere;
}
.person-header-facts li + li {
  padding-inline-start: 0.75rem;
  border-inline-start: 1px solid var(--control-line);
}
.person-header-identifiers {
  display: flex;
  flex-wrap: wrap;
  gap: 0.1rem 1.25rem;
  margin: 0;
}
.person-header-identifier {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 0.4rem;
  min-inline-size: 0;
}
.person-header-identifier dd {
  overflow-wrap: anywhere;
}
.person-header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  min-inline-size: 0;
}
[data-surface="console"] .person-header-name {
  font-size: clamp(1.5rem, 1.25rem + 0.9vw, 1.9rem);
}

/* ── The fact list ────────────────────────────────────────────────────────
   A label and what it says, with where it came from. A fact is a row between two hairlines: with room (the list's own width, not the
   screen's, 48rem) it is one line of three columns, the label, the value and the source and day, so a person's whole record is a short
   block they read down; with less, the label is a column and the value and its source are stacked beside it, and on a phone the label
   is above them. A fact that sources disagree about says so in a badge and lists the others under it, with a bar at their start, across
   the row. The source and the day are always on the page and never behind a hover: a value with no provenance is not a fact. */

.fact-list {
  container-type: inline-size;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
  min-inline-size: 0;
  margin: 0;
  border-block-start: 1px solid var(--rule);
}
.fact {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0 var(--density-block);
  min-inline-size: 0;
  padding-block: var(--density-row);
  border-block-end: 1px solid var(--rule);
}
.fact-label {
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.fact-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0 var(--density-block);
  min-inline-size: 0;
}
.fact-value {
  font-weight: 650;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.fact-provenance {
  color: var(--fg2);
  font-size: var(--text-sm);
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.fact-contested,
.fact-dissent {
  grid-column: 1 / -1;
}
.fact-contested {
  margin-block-start: 0.15rem;
}
.fact-dissent {
  display: grid;
  gap: 0.1rem;
  margin: 0.15rem 0 0;
  padding: 0;
  padding-inline-start: 0.75rem;
  border-inline-start: 2px solid var(--control-line);
  color: var(--fg2);
  font-size: var(--text-sm);
  list-style: none;
  overflow-wrap: anywhere;
}
@container (min-width: 28rem) {
  .fact {
    grid-template-columns: minmax(6.5rem, 12rem) minmax(0, 1fr);
    align-items: baseline;
  }
}
@container (min-width: 48rem) {
  .fact {
    grid-template-columns: 14rem minmax(0, 1fr);
  }
  .fact-body {
    grid-template-columns: minmax(0, 1fr) minmax(0, 26rem);
    align-items: baseline;
  }
}

/* ── The Directory ────────────────────────────────────────────────────────
   The strip, the bar and the table stacked, with the table's own region scrolling when the screen is narrow (37). The
   name cell is the monogram beside the name and the few words under it. What the list says about itself, under the table,
   is `.page-note` (41-page-structure.css), a paragraph for each sentence. */

.directory {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  /* The parts of the page are a step of the space scale apart (the strip, the bar, the table, its notes and its pager): they were the density tokens' 0.5rem, which is the room between two rows of a table. */
  gap: var(--space-3);
  min-inline-size: 0;
}
/* The grid's own gap is the room between the bar and the table, so the bar's margin is not added to it. */
.directory .filter-bar {
  margin-block-end: 0;
}
/* Nine columns want room, and the table is made to fit the room there is. At 1280px, beside the rail, the region is some 975px wide and the
   nine columns fit it: the cells keep 0.5rem on each side and not 0.75, a header may wrap ("Contacts in 30 days" on two lines, not one of 166px),
   and a name wraps inside its cell. Under 52rem of room the table keeps a width of its own and scrolls inside its region (37) rather than squeeze nine
   columns into words a line each. A date and the "Open" link do not break, as a badge in a cell does not (37): the ported `.btn` breaks anywhere,
   which in a table column lowers the column's minimum to one letter and the link to "Op / en". */
.directory table.data.data-table {
  min-inline-size: 52rem;
}
.directory table.data.data-table thead th,
.directory table.data.data-table tbody th[scope="row"],
.directory table.data.data-table td {
  padding-inline: var(--density-cell);
}
/* A row is one line: its cells are as tall as the line and a few pixels, and sit on its middle, so the row that has to wrap (two advisors, a long name) is
   still the shape of the others. */
.directory table.data.data-table tbody th[scope="row"],
.directory table.data.data-table td {
  padding-block: var(--density-row);
  line-height: 1.25;
  vertical-align: middle;
}
/* The link in a row is as tall as WCAG asks of any pointer (24px, 2.5.8) and no taller, so a row of one line is the height of its monogram and not of its
   button; on touch it is the floor again (`--target-min`, 40-native.css), which this selector would otherwise lower. */
.directory table.data.data-table td .btn {
  min-block-size: 1.5rem;
  padding-block: 0.15rem;
}
@media (pointer: coarse) {
  .directory table.data.data-table td .btn {
    min-block-size: var(--target-min);
    padding-block: 0.36rem;
  }
}
.directory table.data.data-table thead th {
  padding-block: 0.4rem;
  white-space: normal;
  vertical-align: bottom;
}
/* The name's column is never squeezed to a word a line (its words may break anywhere, below, which lowers the column's minimum to nothing), and never
   wider than the region shows. */
.directory table.data.data-table tbody th[scope="row"] {
  min-inline-size: min(15rem, 100cqi);
}
.directory table.data.data-table td time,
.directory table.data.data-table td .btn {
  white-space: nowrap;
  overflow-wrap: normal;
}
/* Where the table is wider than the room and scrolls in its region (a phone, a narrow window), the link to the person stays at the end of the row, in view, and the other columns pass under it:
   it is the last of nine columns, and the way into a person was off the edge until the table had been scrolled to it. It has the page's own colour (and the row's tint under the pointer), so what passes
   under it does not show through, and a hairline at its start, drawn as a shadow because a collapsed table's borders do not travel with a sticky cell. */
@container (max-width: 51.99rem) {
  .directory table.data.data-table :is(thead th, tbody td):last-child {
    position: sticky;
    inset-inline-end: 0;
    background: var(--bg);
    box-shadow: var(--sticky-edge, -1px) 0 0 var(--rule);
  }
  .directory table.data.data-table tbody tr:hover td:last-child {
    background: var(--surface-tint);
  }
}
.directory .data-table-region:dir(rtl) {
  --sticky-edge: 1px;
}
/* The region is a container, so the name can be held to what the region shows: a name cell never grows past the room the person has, a badge or an address
   in it wraps inside that room (a long word breaks), and nothing of the name is out of sight at the region's edge at 320px, in a longer language too. The
   cell's own padding and its bar are the 1.25rem. */
.directory .data-table-region {
  container-type: inline-size;
  /* What the browser scrolls into view (a sort link reached by keyboard) stops short of the link that stays at the end of the row on a phone, which would otherwise cover it (WCAG 2.4.11). */
  scroll-padding-inline-end: 5rem;
}
.directory-name {
  display: flex;
  align-items: center;
  gap: var(--density-gap);
  min-inline-size: 0;
  max-inline-size: calc(100cqi - 1.25rem);
}
.directory-name-text {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 0.5rem;
  min-inline-size: 0;
}
.directory-name-main,
.directory-pronouns,
.directory-detail {
  overflow-wrap: anywhere;
}
.directory-name-main {
  font-weight: 650;
}
.directory-pronouns,
.directory-detail {
  color: var(--fg2);
  font-size: var(--text-xs);
  font-weight: 400;
}

/* ── The person page ──────────────────────────────────────────────────────
   The person header, what is known about them, and the spine, stacked: the facts are a short list and the spine is the
   long one, so the spine gets the whole width and a phone reads them in that order. A control on a row (the outcome) is a
   native disclosure, so it opens with the keyboard, announces itself and needs no script; the form in it is the ordinary
   one. */

.person-page {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.25rem;
  min-inline-size: 0;
  margin-block-start: var(--density-block);
}
.person-page-facts {
  display: grid;
  gap: var(--density-gap);
  max-inline-size: 64rem;
  min-inline-size: 0;
}
.person-page-heading {
  font-size: var(--text-lg);
  overflow-wrap: anywhere;
}
.person-status {
  margin-block-start: var(--density-block);
}
.spine-entry-action {
  margin-block-start: 0.3rem;
  min-inline-size: 0;
}
.spine-entry-action summary {
  display: inline-block;
  max-inline-size: 100%;
  color: var(--fg1);
  font-size: var(--text-sm);
  font-weight: 650;
  text-decoration: underline;
  cursor: pointer;
  overflow-wrap: anywhere;
}
.outcome-form {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.6rem 0.75rem;
  margin-block-start: 0.5rem;
  min-inline-size: 0;
}
.outcome-form .field {
  flex: 1 1 12rem;
  min-inline-size: 0;
}
/* The form system makes a form a size container (36-form-fields.css), which gives it no width of its own; in the row's
   shrink-to-fit column that collapsed it to a word wide. This one-field form has no sections to lay out, so it is not one. */
.outcome-form.tform {
  container-type: normal;
  inline-size: 100%;
}
/* The form system's actions sit beside the field here, on the row, not under a section's title column. */
.outcome-form > .form-actions {
  margin: 0;
  padding: 0;
  border: 0;
}
.record-contact {
  display: grid;
  gap: 1rem;
  min-inline-size: 0;
}
