/* The console home's "Needs you" list (HomeAttentionTableComponent), and the small square an office's name has before it wherever the home names an office.

   The list is a table: When (a pill in the bucket's tone and a thin bar for how late), What (the title as a link, its state, and how many more like it), About (a monogram and a name) and
   Office (a square and the name, and what kind of record it is). The glance strip and the office cards filter the rows. Where its own box is narrower than 600 CSS px (a container query: the section's width,
   not the screen's) the same markup is a list of two-line cards: what and when on the first line, about and office on the second. A table that still has a word too long for its columns scrolls
   inside its own region, which is focusable and named, and the page itself never scrolls sideways.

   Every row is in the markup. A row the filter (the server's, then home_filter_controller.js) does not show carries `hidden`; where a browser runs no script (`@media (scripting: none)`) the
   rows the default view holds back behind "Show more" are shown instead, as there is no button to press.

   Tokens only and logical properties only, both enforced (test/styles/tokens_test.rb, test/styles/components_test.rb), so it reads on the light shell and the console, in light and in dark, and
   mirrors in a right-to-left language. Nothing pinned to an edge, no height in vh, and everything that holds words may shrink and wrap, so a language 40% longer never widens the page
   (WCAG 1.4.10). Nothing here is color alone: the pill and the days are words, and an office is its name. */

/* ── The office's mark ─────────────────────────────────────────────────────
   A small square in the office's tone (Home::OfficeTone, from the spine's eight), a memory aid beside the name that is always written. */

.home-office-mark {
  --mark: var(--spine-neutral-line);
  display: inline-block;
  flex: none;
  inline-size: 0.625rem;
  block-size: 0.625rem;
  border-radius: 2px;
  background: var(--mark);
}

.home-office-mark[data-tone="plum"] {
  --mark: var(--spine-plum-line);
}

.home-office-mark[data-tone="rose"] {
  --mark: var(--spine-rose-line);
}

.home-office-mark[data-tone="teal"] {
  --mark: var(--spine-teal-line);
}

.home-office-mark[data-tone="blue"] {
  --mark: var(--spine-blue-line);
}

.home-office-mark[data-tone="amber"] {
  --mark: var(--spine-amber-line);
}

.home-office-mark[data-tone="green"] {
  --mark: var(--spine-green-line);
}

.home-office-mark[data-tone="slate"] {
  --mark: var(--spine-slate-line);
}

/* ── Needs attention ───────────────────────────────────────────────────────── */

.home-attention {
  /* The section's own width decides when a row is a card; `position` holds the visually hidden words (the caption, the live region, the headers of the cards) where they belong. */
  position: relative;
  container-type: inline-size;
  min-inline-size: 0;
  background: var(--surface-raised);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
}

.home-attention__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-1) var(--space-3);
  padding: var(--space-4) var(--space-4) var(--space-2);
}

.home-attention__title {
  margin: 0;
  color: var(--fg1);
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.home-attention__count {
  color: var(--fg3);
  font-size: var(--text-sm);
  font-weight: 600;
  overflow-wrap: anywhere;
}

.home-attention__show-more:focus-visible,
.home-attention__link:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* Nothing needs the person: one line, and what is next. It goes when a filter shows rows; the table goes while it has no row to show, so an empty table is never drawn. */
.home-attention__nothing {
  display: grid;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-4) var(--space-4);
}

.home-attention:has(.home-attention__row:not([hidden])) .home-attention__nothing,
.home-attention__scroll:not(:has(.home-attention__row:not([hidden]))) {
  display: none;
}

.home-attention__clear {
  margin: 0;
  color: var(--fg1);
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-style: italic;
  overflow-wrap: anywhere;
}

.home-attention__next {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-1) var(--space-2);
  margin: 0;
  color: var(--fg2);
  font-size: var(--text-sm);
  overflow-wrap: anywhere;
}

.home-attention__next-label {
  color: var(--fg3);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

/* The table scrolls here when a word is longer than its column; it is focusable, so the keyboard reaches what is past its edge (WCAG 2.1.1, 1.4.10). */
.home-attention__scroll {
  overflow-x: auto;
}

.home-attention__scroll:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
}

.home-attention__table {
  inline-size: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.home-attention__table th {
  padding: var(--space-2) var(--space-3);
  color: var(--fg3);
  font-size: var(--text-xs);
  font-weight: 800;
  letter-spacing: 0.1em;
  text-align: start;
  text-transform: uppercase;
}

.home-attention__table td {
  padding: var(--space-2) var(--space-3);
  border-block-start: 1px solid var(--rule);
  vertical-align: top;
  overflow-wrap: break-word;
}

.home-attention__table :is(th, td):first-child {
  padding-inline-start: var(--space-4);
}

.home-attention__table :is(th, td):last-child {
  padding-inline-end: var(--space-4);
}

/* A row's own `display` is a variable so the three things that set it (the table, the card, the `hidden` attribute) never fight over the property. */
.home-attention__row {
  display: var(--row-display, table-row);
}

.home-attention__row[hidden] {
  display: none;
}

.home-attention__row:hover {
  background: var(--surface-tint);
}

/* When: the column is as wide as its pill and no wider. The pill keeps its words on one line in a column (anywhere would let the table shrink the column to a letter), and the bar is how late, up to nine days. */
.home-attention__when {
  inline-size: 1%;
  white-space: nowrap;
}

.home-attention__when .pill[data-tone] {
  white-space: nowrap;
  overflow-wrap: normal;
}

.home-attention__bar {
  display: block;
  min-inline-size: 3rem;
  block-size: 4px;
  margin-block-start: var(--space-1);
  border-radius: 2px;
  background: var(--meter-track);
  overflow: hidden;
}

.home-attention__bar > span {
  display: block;
  inline-size: var(--late, 0%);
  block-size: 100%;
  border-radius: inherit;
  background: var(--tone-bad-fg);
}

/* What: the title is the link; the state and "And 2 more like it here" follow it. A target at least 24 CSS px tall (44 on touch). */
.home-attention__link {
  display: inline-block;
  min-block-size: 1.5rem;
  font-weight: 700;
  /* A title is the one text with no limit on its length, and no word of it may widen the table: it breaks where it must (the other cells break only when they are out of room). */
  overflow-wrap: anywhere;
}

.home-attention__more {
  display: block;
  color: var(--fg2);
  font-size: var(--text-xs);
  overflow-wrap: anywhere;
}

/* A hearing's row: the link says it is the reader's hearing, and the case type it is for is a quiet line under it. */
.home-attention__type {
  display: block;
  color: var(--fg2);
  font-size: var(--text-xs);
  overflow-wrap: anywhere;
}

.home-attention__person {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-inline-size: 0;
  font-weight: 600;
}

.home-attention__office-name {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-inline-size: 0;
}

.home-attention__office-name > bdi {
  min-inline-size: 0;
}

.home-attention__kind {
  display: block;
  color: var(--fg3);
  font-size: var(--text-xs);
}

/* Show more: the rest of the default rows. Nothing to press without script, so it is not drawn then. */
.home-attention__show-more {
  appearance: none;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-1) var(--space-2);
  box-sizing: border-box;
  inline-size: 100%;
  min-block-size: 2rem;
  padding: var(--space-3) var(--space-4);
  border: 0;
  border-block-start: 1px solid var(--rule);
  background: transparent;
  color: var(--accent-text);
  font: inherit;
  font-weight: 700;
  text-align: start;
  cursor: pointer;
}

.home-attention__show-more:hover {
  background: var(--surface-tint);
}

.home-attention__show-more-items {
  color: var(--fg3);
  font-weight: 600;
}

/* Under 760 CSS px of the section's own width a row is a card of two lines (a row of flex items with a break between them). The headers stay for a screen reader and are not drawn; the pill, the link, the monogram and name, and the
   office say what each part is. */
@container (max-width: 47.5rem) {
  .home-attention__table,
  .home-attention__table tbody {
    display: block;
  }

  .home-attention__table thead {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  /* Its row and cells too: a table cell lays itself out at its words' width whatever box holds it, so each is clipped where it is, not only the head around them (a screen reader still reads them). */
  .home-attention__table thead tr,
  .home-attention__table thead th {
    display: block;
    inline-size: 1px;
    overflow: hidden;
  }

  .home-attention__row {
    --row-display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    column-gap: var(--space-3);
    row-gap: 0;
    padding: var(--space-3) var(--space-4);
    border-block-start: 1px solid var(--rule);
  }

  /* The line break between the two lines: an empty item the width of the card, between what and when above it and about and office below. */
  .home-attention__row::after {
    content: "";
    order: 3;
    flex: 0 0 100%;
  }

  .home-attention__row > td,
  .home-attention__table td:first-child,
  .home-attention__table td:last-child {
    display: block;
    inline-size: auto;
    min-inline-size: 0;
    padding: 0;
    border: 0;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .home-attention__what {
    order: 1;
    flex: 1 1 0;
  }

  /* The two cells at the end of a line take what they need up to half of it, and wrap beyond that, so the title and the name keep the rest. */
  .home-attention__when {
    order: 2;
    flex: 0 1 auto;
    max-inline-size: 50cqi;
    text-align: end;
  }

  .home-attention__when .pill[data-tone] {
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .home-attention__about {
    order: 4;
    flex: 1 1 0;
    margin-block-start: var(--space-2);
  }

  .home-attention__row > .home-attention__office {
    order: 5;
    flex: 0 1 auto;
    max-inline-size: 50cqi;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0 var(--space-2);
    margin-block-start: var(--space-2);
    text-align: end;
  }
}

/* A browser that runs no script filters by its links (the server draws the filter), but cannot ask for the rest of the default view: the rows held back by the limit (`data-held`) are shown,
   and "Show more" is not drawn. The reset hides what has `hidden` with `!important`
   in `@layer base` (00-preflight.css), and among important declarations the earlier layer wins, so the rule that shows them again is `!important` in `@layer theme`, the layer before it: nothing
   outside this component's rows is touched, and a row's own `display` is still the variable that says whether it is a table row or a card. */
@media (scripting: none) {
  @layer theme {
    .home-attention__row[hidden][data-held] {
      display: var(--row-display, table-row) !important;
    }
  }

  .home-attention__show-more {
    display: none;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .home-attention__show-more {
    transition: background-color 0.2s ease, border-color 0.2s ease;
  }
}

@media (pointer: coarse) {
  .home-attention__link {
    min-block-size: var(--target-min);
    align-content: center;
  }
}

