/* ============================================================================
   COMPONENTS (UI/UX PR 4, 2026-11-20) — the patterns every page shares
   ----------------------------------------------------------------------------
   Built only on tokens.css, and linked LAST (index.html), after the shells:
   a page's header and its buttons must look the same whichever of the older
   sheets drew the rest of the page. Three things, each an audit finding:

   1. ONE BUTTON SET (audit item 10). One screen had a red "New worker", a
      black "Review" and a pale-blue "Give a job" — three answers to "which
      button acts". There are three kinds now, and only three:
        PRIMARY    `.primary` (and `.btn-play`, its older twin)  — filled ink
        SECONDARY  `.ghost`                                       — white, a hairline
        QUIET      `.quiet`                                       — a word; a fill on hover
      Their shape and sizes are style.css's ONE BUTTON SCALE (two heights,
      40 and 32 with `.small`, all capsules); their colours come from the
      tokens. One primary per view, at most: the page's main act.

      Why primary is INK and not the brand red: the beta shell (the owner's
      approved mocks, 2026-11-17) already fills every pressable with ink —
      Send, the side panel's Review, Today's Review — and spends red only on
      the mark, the counts and the unread dots. The red page buttons were the
      odd ones out, so they moved, not the shell. It is done in one place:
      `--primary-strong` (the filled button's colour) is an alias of
      `--color-ink` in tokens.css. Red stays the accent: never a button fill,
      never a status, never an error.

      A card's or a row's own action (Give a job on a teammate, Plan this goal,
      Download) was a fourth look, tinted in its section's hue; it is the
      secondary button now (style.css, "the action a card or a row owns").

   2. ONE PAGE HEADER (audit item 11). "Team" sat indented beside a flush
      "Spaces" and "November", because Team, Goals and the Library drew a
      section tile before their title and the other pages did not, and on a
      wide screen each page centred its own column at its own width. Now:
        <header class="page-head">
          <div class="page-words">
            <h1|h2 class="page-title">…</h1>
            <p class="page-sub">…</p>          optional
          </div>
          <div class="page-actions">…</div>   optional, on the right
        </header>
      at the same top (80px, the topbar and a title's gap), the same left
      edge (`--page-max` centred, `--space-8` at least), in the title type.
      Applied to Spaces, Team, Goals, Calendar, Library and Results; the title
      type alone to Customize and This shop, whose heads are laid out around
      tabs and a mark. Settings is a dialog with its own head, not a page.

   3. THE TEAM CARD'S DETAILS (audit item 9): the model, the most a job may
      spend, the tools in words and the handle, behind a closed "Details" on
      the Simple card (coworkers.js `detailsNode`).

   The phone keeps phone.css and one-shell.css: everything here that moves a
   box is under `min-width: 821px`, the width at which the rail is a column.
   ============================================================================ */

/* ---------- 1. the button set ------------------------------------------------ */

/* QUIET: a word that acts — Refresh, Edit, Pause. No box at rest, so a row of
   them reads as options rather than as four buttons; the selected-row fill on
   hover says it can be pressed. Same heights as the other two, so a quiet
   button beside a secondary one lines up. */
.quiet {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--btn-h); padding: 0 var(--space-3);
  border: 1px solid transparent; border-radius: var(--radius-pill);
  background: transparent; color: var(--color-ink-muted);
  font: inherit; font-size: var(--btn-fs); font-weight: var(--weight-medium); line-height: 1.2;
  white-space: nowrap; cursor: pointer;
  transition: background-color var(--dur-tap) var(--ease-standard), color var(--dur-tap) var(--ease-standard);
}
.quiet:hover:not(:disabled) { background: var(--color-fill-hover); color: var(--color-ink); }
.quiet:active:not(:disabled) { background: var(--color-fill-selected); }
.quiet:disabled { opacity: .45; cursor: not-allowed; }
.quiet.small { min-height: var(--btn-h-sm); padding: 0 var(--space-2); font-size: var(--btn-fs-sm); }
.quiet.danger { color: var(--color-danger); }

/* A page header's controls are one height (DS-07, style.css's `.mv-actions`
   rule), the quiet one included. */
.page-actions :is(.primary, .btn-play, .ghost, .quiet) {
  min-height: var(--btn-h); font-size: var(--btn-fs);
}
.page-actions .quiet { padding: 0 var(--space-3); }

/* ---------- 2. the page header ----------------------------------------------- */

/* The tile is a rail icon repeated beside a title; in a page title it is the
   indent the audit found, at every width. It stays in the markup (aria-hidden,
   so a reader never heard it) and is not drawn here. */
.page-title > .sec-tile { display: none; }

@media (min-width: 821px) {
  /* `#app` so it outranks the id rules each page set its own title with
     (`#results-h`, `#spaces-h` …) and the tiled `.mv-head h2:has(…)`. */
  #app .page-head {
    display: flex; align-items: flex-end; justify-content: space-between;
    gap: var(--space-3) var(--space-4); flex-wrap: wrap;
    margin: 0; padding: 0;
  }
  #app .page-words { display: grid; gap: var(--space-1); min-width: 0; }
  #app .page-title {
    display: block; margin: 0;
    font-family: var(--font-sans); font-size: var(--type-title); line-height: var(--type-title-lh);
    font-weight: var(--weight-semibold); letter-spacing: -.02em; color: var(--color-ink);
  }
  #app .page-sub {
    display: block; margin: 0;
    font-size: var(--type-body); line-height: var(--type-body-lh); color: var(--color-ink-muted);
  }
  #app .page-actions { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; min-width: 0; }
  /* The Calendar's title shares its row with the month arrows. */
  #app .cal-title.page-words { display: flex; align-items: center; gap: var(--space-3); }

  /* One column for every page: `--page-max` wide, centred, never nearer the
     edge than `--space-8`. Results, the Calendar and Spaces had their own
     inner column (the Calendar's at 1180px); Team, Goals and the Library had
     none and ran edge to edge, so a title moved as you changed page. The
     percentage is of `#main`, the views' parent. */
  #app :is(#coworkers-view, #goals-view, #library-view) {
    padding-left: max(var(--space-8), calc((100% - var(--page-max)) / 2));
    padding-right: max(var(--space-8), calc((100% - var(--page-max)) / 2));
  }
  #app :is(.rs-inner, .cal-inner, .sp-list-page) { width: min(var(--page-max), 100%); }
}

/* The page's foot: the Simple / Advanced switch on Team and Goals, out of the
   header where it sat among the page's own actions (audit item 9). Quiet, at
   the end of the page, for the person who goes looking. */
.page-foot { display: flex; justify-content: flex-start; margin-top: var(--space-6); padding-top: var(--space-4); border-top: 1px solid var(--color-line); }
.page-foot .seg { padding: 2px; }
.page-foot .seg-btn { font-size: var(--type-footnote); }

/* ---------- 3. the Team card's Details ---------------------------------------- */

.cw-details { font-size: var(--type-footnote); line-height: var(--type-footnote-lh); color: var(--color-ink-muted); }
.cw-details > summary {
  display: inline-flex; align-items: center; gap: var(--space-1);
  padding: 2px 0; border-radius: var(--radius-xs);
  list-style: none; cursor: pointer; font-weight: var(--weight-medium); color: var(--color-ink-muted);
}
/* 24px at the least anywhere (the 2.5.8 floor), and the full touch floor under
   a finger: as a footnote word it measured 54x22 at 390 (ui:flows, 2026-11-20),
   and it is the only door to the model, the cap, the tools and the handle. */
.cw-details > summary { min-height: 24px; }
@media (max-width: 820px), (pointer: coarse) {
  .cw-details > summary { min-height: var(--tap-min); padding-right: var(--space-2); }
}
.cw-details > summary::-webkit-details-marker { display: none; }
/* A chevron that turns, drawn in the text colour: right while shut, down when
   open — the disclosure's own state, as a list row's chevron says it. */
.cw-details > summary::after {
  content: ""; width: 5px; height: 5px; margin-left: 2px;
  border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg); transition: transform var(--dur-tap) var(--ease-standard);
}
.cw-details[open] > summary::after { transform: rotate(45deg); }
.cw-details > summary:hover { color: var(--color-ink); }
.cw-facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: var(--space-1) var(--space-3); margin: var(--space-2) 0 0; }
.cw-facts > div { display: contents; }
.cw-facts dt { color: var(--color-ink-muted); }
.cw-facts dd { margin: 0; color: var(--color-ink); overflow-wrap: anywhere; }
/* The handle is the one identifier on the card. In the card's own face: it is
   read, not typed, and mono was what made the old card look like a console. */
.cw-facts code { font: inherit; color: var(--color-ink-muted); }

/* ---------- 4. the Team header in a narrow column ------------------------------
   At 390 the header's three buttons did not fit beside "Team": the actions
   took a row of their own under the title and New worker wrapped onto a
   third (ui:flows, 2026-11-20; the same at 360 and 320, since the column is
   326px at 390 and 256px at 320 inside the view's 32px gutters). One row now:
   the title on the left, ⋯ and the one primary on the right, the count under
   both. Refresh and Give a job move INTO ⋯'s menu (coworkers.js, the same
   topbar-more.js the top bar folds its buttons with), so their handlers and
   their `hidden` travel with them — Give a job is absent with nobody to give
   a job to, in the menu as on the header. Nothing is drawn smaller than
   `--tap-min`: the ⋯ and an icon-only New worker are 44 square.

   The width is the view's own (it is the `coworkers` container, style.css),
   not the window's: beside an open workbench a desk's Team column is as
   narrow as a phone's. 560 is the width at which style.css already gave the
   actions a row of their own; coworkers.js folds at the same number. */
@container coworkers (max-width: 560px) {
  /* `display: contents` on the words lets the subtitle span both columns
     under the title, instead of being squeezed into what the buttons leave. */
  #app #coworkers-view > .page-head {
    display: grid; grid-template-columns: minmax(0, 1fr) auto;
    align-items: center; gap: var(--space-1) var(--space-2);
  }
  #app #coworkers-view > .page-head > .page-words { display: contents; }
  #app #coworkers-view > .page-head .page-title {
    grid-column: 1; grid-row: 1; display: block; min-width: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  #app #coworkers-view > .page-head .page-sub { grid-column: 1 / -1; grid-row: 2; }
  #app #coworkers-view > .page-head > .page-actions {
    grid-column: 2; grid-row: 1; flex-basis: auto;
    flex-wrap: nowrap; justify-content: flex-end; gap: var(--space-2);
  }
}
/* ⋯ is a word-less quiet button: a square the size of a fingertip. */
#cw-more { min-width: var(--tap-min); min-height: var(--tap-min); padding: 0; }
#cw-more .ic { width: 20px; height: 20px; }
/* Under 280px (a 320 phone: 256px of column) "New worker" and ⋯ together left
   the title 67px, and "Team" set at 28px needs about 70: it read "Te…". At 360
   (296px) the title has 99px and the word stays. The
   primary keeps its plus and its name — visually hidden, so a screen reader
   and a voice command still say "New worker" — and is 44 square. */
@container coworkers (max-width: 279px) {
  #app #coworkers-view #cw-new { min-width: var(--tap-min); padding: 0; gap: 0; }
  #cw-new .cw-new-word {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
    overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
  }
}
/* The menu ⋯ opens: the top bar's ⋯ menu (`.th-menu.mb-menu`), its items
   drawn as rows rather than as the pill and the word they are on the header. */
#cw-more-menu > button {
  display: flex; align-items: center; justify-content: flex-start; width: 100%;
  min-height: var(--tap-min); padding: 0 var(--space-3);
  border: 0; border-radius: var(--radius-sm); background: transparent; box-shadow: none;
  font: inherit; font-size: var(--type-body); font-weight: var(--weight-medium); color: var(--color-ink);
  text-align: left; cursor: pointer;
}
#cw-more-menu > button:hover, #cw-more-menu > button:focus-visible { background: var(--color-fill-hover); }
#cw-more-menu > button:focus-visible { outline: 2px solid var(--color-focus); outline-offset: -2px; }
