/* The console home's head and side (show.html.erb): the summary under the greeting (HomeSummaryComponent), a student's tools, the glance strip (HomeCountersComponent), the office notices
   at the top of "Needs you" (HomeNeedsYouComponent) and "Your offices" (HomeOfficesComponent).

   THE GLANCE STRIP is one row of quiet chips, a count and its words: "Needs you" first, then by when. A count with something in it is a link that filters the list; a zero is muted, with no
   field and no edge, so the eye passes over it. Past due and due today, when not zero, take the bad and warn tones' field, edge and text, beside their words. The filter shown is marked with
   the accent's edge and well (`aria-current`), never by color alone: the edge thickens too.

   THE SWATCH is a bucket's mark, the same on the strip and in each office's bar and counts, so the strip is the bar's key: past due the bad tone, due today the warn tone, new the info tone,
   the reader's hearings and this week the accent, later the control line, no date a hollow square in it. Each is 3:1 at the least on the surfaces it sits on (config/contrast_pairs.yml), and
   never alone: every count is said in words beside it.

   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 (WCAG 1.4.10). */

/* ── The summary and the tools ─────────────────────────────────────────── */
.home-summary {
  max-inline-size: 72ch;
  margin: 0 0 var(--space-5);
  color: var(--fg2);
  font-size: var(--text-md);
  line-height: 1.5;
  text-wrap: pretty;
  overflow-wrap: anywhere;
}

.home-tools__list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: 0 0 var(--space-5);
  padding: 0;
  list-style: none;
}

/* ── The swatch ────────────────────────────────────────────────────────── */
.home-swatch {
  display: inline-block;
  flex: none;
  inline-size: 0.625rem;
  block-size: 0.625rem;
  border-radius: 2px;
  background: var(--control-line);
}

:is(.home-swatch, .home-office__segment)[data-bucket="overdue"] {
  background: var(--tone-bad-fg);
}

:is(.home-swatch, .home-office__segment)[data-bucket="today"] {
  background: var(--tone-warn-fg);
}

:is(.home-swatch, .home-office__segment)[data-bucket="new"] {
  background: var(--tone-info-fg);
}

:is(.home-swatch, .home-office__segment):is([data-bucket="hearing"], [data-bucket="week"]) {
  background: var(--accent);
}

:is(.home-swatch, .home-office__segment)[data-bucket="later"] {
  background: var(--control-line);
}

:is(.home-swatch, .home-office__segment)[data-bucket="waiting"] {
  background: transparent;
  box-shadow: inset 0 0 0 2px var(--control-line);
}

/* ── The glance strip ──────────────────────────────────────────────────── */
.home-glance__list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  min-inline-size: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.home-glance__item {
  display: flex;
  min-inline-size: 0;
}

/* "Needs you" is the whole of the default view: a hairline sets it apart from the buckets it adds up. */
.home-glance__item[data-bucket="attention"] {
  padding-inline-end: var(--space-2);
  border-inline-end: 1px solid var(--rule);
}

.home-glance__stat {
  display: inline-flex;
  align-items: baseline;
  gap: var(--space-2);
  min-block-size: 2.5rem;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
  color: var(--fg1);
  text-decoration: none;
}

.home-glance__count {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1;
}

.home-glance__label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--fg2);
  font-size: var(--text-sm);
  font-weight: 600;
  overflow-wrap: anywhere;
}

a.home-glance__stat:hover {
  border-color: var(--accent-line);
  background: var(--surface-tint);
}

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

.home-glance__stat[data-tone="bad"] {
  border-color: var(--tone-bad-line);
  background: var(--tone-bad-bg);
}

.home-glance__stat[data-tone="warn"] {
  border-color: var(--tone-warn-line);
  background: var(--tone-warn-bg);
}

.home-glance__stat[data-tone="bad"] :is(.home-glance__count, .home-glance__label) {
  color: var(--tone-bad-fg);
}

.home-glance__stat[data-tone="warn"] :is(.home-glance__count, .home-glance__label) {
  color: var(--tone-warn-fg);
}

.home-glance__stat[data-tone="bad"] .home-glance__count,
.home-glance__stat[data-tone="warn"] .home-glance__count {
  font-weight: 600;
}

.home-glance__stat[aria-current="true"] {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.home-glance__stat[aria-current="true"]:not([data-tone]) {
  background: var(--accent-soft);
}

/* A zero: no field and no edge, in the faint text, so the eye passes over it. It still says its number. */
.home-glance__stat[data-zero] {
  border-color: transparent;
  background: transparent;
}

.home-glance__stat[data-zero] :is(.home-glance__count, .home-glance__label) {
  color: var(--fg-faint);
}

/* ── The office notices ────────────────────────────────────────────────── */
.home-notices {
  display: grid;
  gap: var(--space-3);
  min-inline-size: 0;
}

.home-notices__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.home-notices__list {
  display: grid;
  gap: var(--space-2);
  min-inline-size: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.home-notice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-4);
  min-inline-size: 0;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
}

.home-notice[data-tone="warn"] {
  border-color: var(--tone-warn-line);
  border-inline-start: 3px solid var(--tone-warn-fg);
  background: var(--tone-warn-bg);
}

.home-notice__body {
  display: flex;
  flex: 1 1 18rem;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-1) var(--space-3);
  min-inline-size: 0;
}

.home-notice__office {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-inline-size: 0;
  margin: 0;
  color: var(--fg1);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.home-notice__quiet {
  margin: 0;
  color: var(--fg3);
  font-size: var(--text-sm);
}

.home-notice__counts {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-3);
  min-inline-size: 0;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: var(--text-sm);
}

.home-notice__counts a {
  display: inline-block;
  min-block-size: 24px;
  color: var(--tone-warn-fg);
  font-weight: 600;
  overflow-wrap: anywhere;
}

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

/* ── Your offices ──────────────────────────────────────────────────────── */
.home-offices {
  display: grid;
  gap: var(--space-2);
  min-inline-size: 0;
}

.home-offices__list {
  display: grid;
  gap: var(--space-2);
  min-inline-size: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.home-office {
  display: grid;
  gap: var(--space-2);
  min-inline-size: 0;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
}

.home-office__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-1) var(--space-3);
  min-inline-size: 0;
}

.home-office__name {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-inline-size: 0;
  margin: 0;
  color: var(--fg1);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.home-office__total {
  color: var(--fg3);
  font-size: var(--text-sm);
  font-weight: 600;
  white-space: nowrap;
}

/* One bar, its parts as wide as their counts; a part is never thinner than a few pixels, so one item in a hundred still shows. */
.home-office__bar {
  display: flex;
  gap: 2px;
  block-size: 0.5rem;
  min-inline-size: 0;
  overflow: hidden;
  border-radius: 999px;
}

.home-office__segment {
  flex: var(--n, 1) 1 0%;
  min-inline-size: 0.25rem;
}

.home-office__counts {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-3);
  min-inline-size: 0;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--fg2);
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
}

.home-office__counts li {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.home-office__foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-1) var(--space-3);
  min-inline-size: 0;
}

.home-office__oldest {
  color: var(--fg3);
  font-size: var(--text-xs);
  overflow-wrap: anywhere;
}

.home-office__link {
  display: inline-flex;
  align-items: center;
  min-block-size: 24px;
  margin-inline-start: auto;
  color: var(--accent-text);
  font-size: var(--text-sm);
  font-weight: 650;
}

.home-office__link[aria-current="true"] {
  text-decoration-thickness: 2px;
}

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

/* ── The list under these, filtered ─────────────────────────────────────── */
[data-home-filter-target="row"][hidden],
[data-home-filter-target="more"][hidden] {
  display: none !important;
}

@media (pointer: coarse) {
  .home-glance__stat,
  .home-notice__counts a,
  .home-office__link {
    min-block-size: var(--target-min);
  }

  .home-notice__counts a {
    display: inline-flex;
    align-items: center;
  }
}

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

/* Forced colors (Windows High Contrast) replace every background, so a swatch or a part of the bar would vanish: they are drawn in the text color, the hollow one as an outline, and the
   filter shown keeps a heavier edge. */
@media (forced-colors: active) {
  .home-swatch,
  .home-office__segment {
    forced-color-adjust: none;
    background: CanvasText;
  }

  :is(.home-swatch, .home-office__segment)[data-bucket="waiting"] {
    background: Canvas;
    box-shadow: none;
    outline: 2px solid CanvasText;
    outline-offset: -2px;
  }

  .home-glance__stat[aria-current="true"] {
    border-color: Highlight;
    border-width: 2px;
  }
}
