/* Interaction layer: one set of hover, pressed, focus and selected states for the content
   surfaces (T-detail, WI-01405). Linked from partials/head.eta straight after styles.css.

   Ported from the cohesive-UI lab at 12365bee (code 21ebb4f1), not reinvented:
     - ui/public/cohesive/states.css            (states-1, D-68: one hover tint, one ring)
     - ui/public/cohesive/nav-glass.css  4/6/7   (D-103d, D-103g, D-103i: glass on the
                                                 current selection and the table controls)
     - docs/ui-explorations/cohesive-ui/interaction-states.md (the model and the audit)
   The navigation chrome (top bar, sidebar, rail, nav count pills, the 1px nudge on sidebar
   items) is the shell's and lives in styles.css; nothing here targets it.

   The rule (D-103): glass marks the chrome and the current selection; data surfaces stay flat.
   So a chosen toggle segment, an applied filter, an active Filter / Group by and a filtered
   column get the glass piece; tiles, cards and rows get a flat tint on hover and nothing else.

   Every selector starts with :root. ag-grid.css and board.css are injected at runtime and
   landing.css is linked from the page body, so all three come later in source order; the
   extra specificity lets these states win without editing those files (the lab did the same).
   Tokens only: every colour is mixed from the theme tokens, so light, explicit dark and auto
   dark all follow. */

/* ---- Tokens: the content-glass --ng-c-* tokens (lab nav-glass-4 and -7) and the shared
   --st-hover, --st-press and --st-ring are defined once on :root in styles.css (WI-01405
   shell block); this file only consumes them. ---- */

/* The glass piece's hairline edge: a 1px indigo-to-teal ring drawn with a mask, so it takes
   no layout. Shared by every selected control below. */
:root :is(
  .grid-tool.is-active,
  .grid-tool:has(.grid-tool-count:not([hidden])),
  .platform-grid-header-filter.is-active,
  .platform-grid-filter-chip,
  .platform-grid-modes button[aria-pressed="true"],
  .seg button[aria-pressed="true"],
  .seg a[aria-current="true"],
  .wbs-status-preset.is-active,
  .fb-conj-btn.is-active
)::before {
  content: "";
  position: absolute;
  inset: 0;
  padding: 1px;
  border-radius: inherit;
  background: var(--ng-c-edge);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  pointer-events: none;
}
/* Bordered controls: the edge sits over their own (now transparent) 1px border. */
:root :is(.grid-tool.is-active, .grid-tool:has(.grid-tool-count:not([hidden])), .platform-grid-filter-chip, .platform-grid-modes button[aria-pressed="true"])::before {
  inset: -1px;
}

/* ===================================================================================
   1. Table controls (lab nav-glass-6 #2, nav-glass-7; D-103g, D-103i)
   Production: grid.js builds .grid-toolbar.platform-grid-tools with .grid-tool buttons
   (Search, Filter, Fields, Group by), .grid-search, .platform-grid-chips and the
   Table | Board .platform-grid-modes. ag-grid.css gave hover and active the same
   accent-soft fill, so hover read as selected; this separates them.
   =================================================================================== */

/* The toolbar strip: the toggle track's faint tint at half strength, in place of grey. */
:root .grid-toolbar {
  background: color-mix(in srgb, var(--ng-c-track) 52%, transparent);
}

/* Hover and open: a faint accent wash and a soft indigo edge, ink text. */
:root .grid-tool { position: relative; }   /* no transition: the lab's state change is instant */
:root .grid-tool:hover,
:root .grid-tool[aria-expanded="true"] {
  border-color: var(--ng-c-hover-edge);
  background: var(--ng-c-hover);
  box-shadow: var(--ng-c-highlight);
  color: var(--ink);
}
:root .grid-search:hover {
  border-color: var(--ng-c-hover-edge);
}

/* Active (a filter is applied, a grouping is chosen): the glass piece, the same as the chosen
   toggle segment. Production marks both with .is-active (grid.js syncControls); the count
   badge test also covers any toolbar that shows a count without the class. */
:root .grid-tool:is(.is-active, :has(.grid-tool-count:not([hidden]))) {
  border-color: transparent;
  background: var(--ng-c-fill);
  box-shadow: var(--ng-c-highlight);
  color: var(--accent-strong);
}
:root .grid-tool:is(.is-active, :has(.grid-tool-count:not([hidden]))):hover {
  box-shadow: var(--ng-c-highlight), 0 1px 2px color-mix(in srgb, var(--accent) 16%, transparent);
}
:root .grid-tool .grid-tool-count {
  background: color-mix(in srgb, var(--accent) 16%, var(--surface));
  color: var(--accent-strong);
}

/* Column header filter button (production .platform-grid-header-filter, grid-ag.js; lab
   .cohesive-view-column-filter). Hover and open: a light accent wash. Filtered: the glass
   piece. */
:root .platform-grid-header-filter { position: relative; }
:root .platform-grid-header-filter:is(:hover, [aria-expanded="true"]):not(.is-active) {
  background: color-mix(in srgb, var(--accent) 11%, transparent);
  color: var(--accent-strong);
}
:root .platform-grid-header-filter.is-active {
  background: var(--ng-c-fill);
  box-shadow: var(--ng-c-highlight);
  color: var(--accent-strong);
}

/* An active sort arrow or caret takes the selection colour; idle ones keep the heading's
   (lab nav-glass-7: .cohesive-view-sort-arrow:not(.is-idle), .cohesive-grid-sort.is-*). */
:root .platform-grid-sort-arrow:not(.is-idle),
:root .platform-grid-sort-caret:is(.is-ascending, .is-descending) {
  color: var(--accent-strong);
  opacity: 1;
}

/* Applied filter chips (production .platform-grid-filter-chip; lab .cohesive-view-filters):
   the glass piece in the lab's pill form (999px radius, 0.78rem / 500). */
:root .platform-grid-filter-chip {
  position: relative;
  padding: 0.15rem 0.55rem;
  border-color: transparent;
  border-radius: 999px;
  background: var(--ng-c-fill);
  box-shadow: var(--ng-c-highlight);
  color: var(--accent-strong);
  font: 500 0.78rem/1.3 var(--font-body);
}
:root .platform-grid-filter-chip:hover {
  box-shadow: var(--ng-c-highlight), 0 1px 2px color-mix(in srgb, var(--accent) 16%, transparent);
}

/* Table | Board on a grid (production .platform-grid-modes; lab .cl-seg "View layout"). */
:root .platform-grid-modes button { position: relative; }
:root .platform-grid-modes button:hover:not([aria-pressed="true"]) {
  background: color-mix(in srgb, var(--accent) 7%, transparent);
  color: var(--ink);
}
:root .platform-grid-modes button[aria-pressed="true"] {
  border-color: transparent;
  background: var(--ng-c-fill);
  box-shadow: var(--ng-c-highlight);
  color: var(--accent-strong);
}

/* WBS status preset: the same selected look as every other chosen segment. Its group clips
   (overflow: hidden), so the edge stays inside. */
:root .wbs-status-preset { position: relative; }
:root .wbs-status-preset:hover:not(.is-active) {
  background: color-mix(in srgb, var(--accent) 7%, var(--surface));
  color: var(--ink);
}
:root .wbs-status-preset.is-active {
  background: var(--ng-c-fill);
  box-shadow: var(--ng-c-highlight);
  color: var(--accent-strong);
}

/* Focus: the shared D-68 ring, 2px outside, distinct from hover and active. The WBS preset
   group clips, so its ring sits inside. */
:root :is(.grid-tool, .grid-search, .platform-grid-header-filter, .platform-grid-filter-chip, .platform-grid-modes button):focus-visible {
  outline: 2px solid var(--st-ring);
  outline-offset: 2px;
}
:root .wbs-status-preset:focus-visible {
  outline: 2px solid var(--st-ring);
  outline-offset: -2px;
}

/* ===================================================================================
   2. Grid rows (lab states.css §1): the one surface tint, a pressed step, the shared ring
   inset because the grid clips its edges. AG Grid reads --ag-row-hover-color per row.
   =================================================================================== */
:root .platform-ag-grid-host .ag-row { --ag-row-hover-color: var(--st-hover); }
:root .platform-ag-grid-host .ag-row:active { --ag-row-hover-color: var(--st-press); }
:root .platform-ag-grid-host .ag-row:focus-visible { box-shadow: inset 0 0 0 2px var(--st-ring); }
/* Server-rendered fallback rows (JavaScript off, or before hydration). */
:root .data-table tbody tr.row-link:hover { background: var(--st-hover); }
:root .data-table tbody tr.row-link:active { background: var(--st-press); }

/* Row links: underline, colour held at --accent-strong (the base a:hover would lighten it); the
   shared ring 2px outside with a 4px corner on keyboard focus (lab states.css §2). The Preview
   launcher keeps its own chip-like states. */
:root .platform-grid-cell a:not([data-record-preview]):hover { color: var(--accent-strong); text-decoration: underline; }
:root .platform-grid-cell a:not([data-record-preview]):focus-visible {
  outline: 2px solid var(--st-ring);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ===================================================================================
   3. Toggles (lab states.css §4 + nav-glass-4): Mine / Everyone, period, theme and the
   other production .seg controls. A faintly tinted track; the chosen segment is the glass
   piece; hover is a light wash with ink text; pressed is one step deeper.
   =================================================================================== */
:root .seg { background: var(--ng-c-track); }
:root .seg :is(button, a) { position: relative; }
:root .seg :is(button, a):hover:not([aria-pressed="true"], [aria-current="true"]) {
  background: color-mix(in srgb, var(--accent) 7%, transparent);
  color: var(--ink);
}
:root .seg :is(button, a):active:not([aria-pressed="true"], [aria-current="true"]) {
  background: var(--st-press);
}
:root .seg :is(button[aria-pressed="true"], a[aria-current="true"]) {
  background: var(--ng-c-fill);
  box-shadow: var(--ng-c-highlight);
  color: var(--accent-strong);
}
:root .seg :is(button, a):focus-visible {
  outline: 2px solid var(--st-ring);
  outline-offset: 2px;
}

/* ===================================================================================
   4. Landing surfaces: lab states.css §1, §2 and §4, 1:1. The landing frame (T-frame,
   wi-01418-landing-frame) renders the lab's own hooks and keeps no state rules of its own:
   tiles a.cl-tile, attention .cl-subcard with its link .cl-subcard-head, member rows
   .cl-alist a, count-list rows a.cl-clist-row, doors .cl-door / .cl-card-door /
   .cl-figure-door / .cl-more, toggles .cl-seg (resting selected glass is the frame's).
   Surface items: the tint only, no underline, no text colour change.
   =================================================================================== */
:root :is(.cl-tile, .cl-subcard, a.cl-clist-row) { transition: background-color 120ms ease; }

:root a.cl-tile:hover,
:root .cl-subcard:has(a.cl-subcard-head:hover),
:root a.cl-clist-row:hover { background: var(--st-hover); color: var(--ink); }

:root a.cl-tile:active,
:root .cl-subcard:has(a.cl-subcard-head:active),
:root a.cl-clist-row:active { background: var(--st-press); }

:root a.cl-subcard-head:hover,
:root a.cl-subcard-head:hover .cl-subcard-title { color: var(--ink); text-decoration: none; }
:root a.cl-tile:hover .cl-tile-door { text-decoration: none; }   /* one signal: the tint */
:root a.cl-clist-row:hover .cl-clist-label { text-decoration: none; }

/* Focus on a surface: inside where the metrics card clips; the attention card's ring goes on
   the whole sub-card, not its inner link. */
:root a.cl-tile:focus-visible,
:root a.cl-clist-row:focus-visible { outline: 2px solid var(--st-ring); outline-offset: -2px; }
:root a.cl-subcard-head:focus-visible { outline: none; }
:root .cl-subcard:has(a.cl-subcard-head:focus-visible) { outline: 2px solid var(--st-ring); outline-offset: 2px; }

/* Inline links: underline, colour held at --accent-strong (the base a:hover lightens it to
   --accent); the ring 2px outside, 4px radius. */
:root :is(.cl-door, .cl-card-door, .cl-figure-door, .cl-more, .cl-alist a):hover {
  color: var(--accent-strong);
  text-decoration: underline;
}
:root :is(.cl-door, .cl-card-door, .cl-figure-door, .cl-more, .cl-alist a):focus-visible {
  outline: 2px solid var(--st-ring);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Landing toggles: hover, pressed and focus only (lab states.css §4 + the nav-glass-4 wash).
   The chosen segment's glass is the frame's resting look; a fixed single option is a label. */
:root .cl-seg :is(a, button):hover:not([aria-current="true"], [aria-pressed="true"], [aria-selected="true"]) {
  background: color-mix(in srgb, var(--accent) 7%, transparent);
  color: var(--ink);
}
:root .cl-seg :is(a, button):active:not([aria-current="true"], [aria-pressed="true"], [aria-selected="true"]) { background: var(--st-press); }
:root .cl-seg :is(a, button):focus-visible { outline: 2px solid var(--st-ring); outline-offset: 2px; }

/* ===================================================================================
   5. Board (lab states.css §1, board.css, nav-glass-6 #4 and -7). Production board.js
   renders .pb-* (board.css, injected by grid.js).
   =================================================================================== */
/* A card is a surface item: the tint, no border change; its title link does not underline or
   turn accent (one signal per hover). */
:root .pb-card { transition: background-color 120ms ease; }
:root .pb-card:hover { background: var(--st-hover); border-color: var(--line); }
:root .pb-card:active { background: var(--st-press); }
:root .pb-card-title:hover { color: var(--ink); text-decoration: none; }

/* The card "..." menu button: a light wash on hover and while its menu is open. */
:root .pb-card-menu:is(:hover, [aria-expanded="true"]) {
  border-color: transparent;
  background: color-mix(in srgb, var(--accent) 9%, transparent);
  color: var(--accent-strong);
}
/* Menu choices: the quiet grey row the platform's other menus use (lab .cb-menu button). */
:root .pb-menu-item:hover { background: var(--surface-2); color: inherit; }

/* Lane count, lane total and "+N more" are inline links (lab states.css §2: .cb-count, .cb-total,
   .cb-more): underline with the colour held, and the shared ring 2px outside with a 4px corner. */
:root .pb-cohesive :is(a.pb-lane-count, a.pb-lane-total):hover,
:root a.pb-more:hover { color: var(--accent-strong); text-decoration: underline; }
:root .pb-cohesive :is(a.pb-lane-count, a.pb-lane-total):focus-visible,
:root a.pb-more:focus-visible { outline: 2px solid var(--st-ring); outline-offset: 2px; border-radius: 4px; }

/* Lane count badge: still a plain badge on a data surface, with only a hairline so it belongs
   to the same family as the nav count pills. */
:root .pb-lane-count { box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 26%, transparent); }

/* ===================================================================================
   6. D-110 (Louis, 30 Nov 2026; lab type-colour.css §4-§6 at 19093c92)
   =================================================================================== */
/* §4 Table controls take the lanes' border (--field-border), not the lighter --line. Lower
   specificity than the hover and active rules above, so those still win. */
:root :is(.grid-search, .grid-tool) { border-color: var(--field-border); }

/* §5 Active toolbar controls are "lifted + soft fill": a soft-indigo face, a plain 1px
   soft-indigo edge in place of the iridescent ring, a white top highlight and a small lift.
   It retunes the glass tokens inside the toolbar only (Filter with a count, Group by with a
   value, applied chips, the WBS preset); the column filter and the header toggles outside the
   toolbar keep the glass piece. */
:root .grid-toolbar {
  --ng-c-edge: color-mix(in srgb, var(--accent) 34%, transparent);
  --ng-c-fill: color-mix(in srgb, var(--accent) 15%, var(--surface));
  --ng-c-highlight:
    inset 0 1px 0 color-mix(in srgb, var(--on-accent) 45%, transparent),
    0 1px 2px color-mix(in srgb, var(--chrome-2) 8%, transparent),   /* = rgba(26, 9, 64, 0.08) */
    0 2px 6px color-mix(in srgb, var(--accent) 18%, transparent);
}

/* §6 Filter builder Match All / Any: off solid indigo onto the glass toggle (as .cl-seg): a
   tinted track, a wash on hover, the glass segment when chosen. The builder is portalled to
   <body>, so it reads the root glass tokens, never the toolbar's retuned ones. */
:root .fb-conj {
  gap: 2px;
  padding: 2px;
  border-color: var(--field-border);
  background: color-mix(in srgb, var(--accent) 5%, var(--surface-2));
}
:root .fb-conj-btn {
  position: relative;
  border-radius: 4px;
  background: transparent;
  font-weight: 600;
}
:root .fb-conj-btn:hover:not(.is-active) {
  background: color-mix(in srgb, var(--accent) 7%, transparent);
  color: var(--ink);
}
:root .fb-conj-btn.is-active {
  background: var(--ng-c-fill);
  box-shadow: var(--ng-c-highlight);
  color: var(--accent-strong);
}
:root .fb-conj-btn:focus-visible { outline: 2px solid var(--st-ring); outline-offset: 2px; }

/* ===================================================================================
   7. In-page action buttons: "Mark as Done" / "Reopen" (.fv-action-btn, field-value.eta;
   Louis, 30 Nov: the text went white on hover). The base button:hover (styles.css, Buttons)
   pairs the accent fill with white text; this outlined button changed only its background, so
   its label turned white on lavender. Hover: the light-accent tint with the text held at
   --accent-strong, one signal. The tint is --accent-soft, a step above the row's --st-hover,
   because the button always sits in a hovered row. Pressed: one step deeper. Focus: the shared
   ring. The filled --primary variant keeps its own hover and press.
   =================================================================================== */
:root .fv-action-btn:not(.fv-action-btn--primary):hover {
  background: var(--accent-soft);
  color: var(--accent-strong);
}
:root .fv-action-btn:not(.fv-action-btn--primary):active {
  background: color-mix(in srgb, var(--accent) 20%, var(--accent-soft));
}
:root .fv-action-btn:focus-visible {
  outline: 2px solid var(--st-ring);
  outline-offset: 2px;
}

/* ---- Reduced transparency: the glass piece becomes a solid accent tint with a plain edge. ---- */
@media (prefers-reduced-transparency: reduce) {
  :root :is(
    .grid-tool.is-active,
    .grid-tool:has(.grid-tool-count:not([hidden])),
    .platform-grid-header-filter.is-active,
    .platform-grid-filter-chip,
    .platform-grid-modes button[aria-pressed="true"],
    .seg button[aria-pressed="true"],
    .seg a[aria-current="true"],
    .wbs-status-preset.is-active,
    .fb-conj-btn.is-active
  )::before { background: var(--accent); opacity: 0.45; }
}

/* ---- Reduced motion: no transitions on these states. ---- */
@media (prefers-reduced-motion: reduce) {
  :root :is(.cl-tile, .cl-subcard, a.cl-clist-row, .pb-card) { transition: none; }
}
