/* The live filter component (facets.js). It reuses the explorer's tile, pane, chip and pill rules in
   styles.css and changes their shape: square tiles on a 3×3 that keeps three columns on a phone,
   square option chips on a ceil(sqrt(n)) grid with the dominant one 2×2 (the owner's workbench),
   a "Next" hint and a sticky Apply bar. Colours are the site's tokens; each group's colour is --fc. */
.facets { --fc: var(--accent); }
.facets .grid9 { --gap: 8px; --w: min(540px, 100vw - 48px); width: var(--w);
  grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: calc((var(--w) - 2 * var(--gap)) / 3); }
.facets .tile { min-width: 0; }
.facets .top .note { flex: 1 1 220px; }
.facets.collapsed .panes { display: block; }  /* folded, the pills still open panes */
.facets .filterhead, .facets .minisel { min-width: 0; max-width: 100%; }
.facets .offgrid { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.facets .offgrid[hidden] { display: none; }
.facets .minisel { flex: 1 1 0; }
.facets .pill { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.facets .pill.open { border-color: var(--fc); box-shadow: inset 0 0 0 1px var(--fc); }
.facets .tile.next, .facets .pill.next { border-color: var(--fc); box-shadow: 0 0 0 2px var(--fc); animation: fx-nudge 1.6s ease-in-out 2; }
@keyframes fx-nudge { 50% { box-shadow: 0 0 0 4px var(--fc); } }
@media (prefers-reduced-motion: reduce) { .facets .tile.next, .facets .pill.next { animation: none; } }
.facets .tile:focus-visible, .facets .chip:focus-visible, .facets .pill:focus-visible, .facets button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* "Next: Evidence ›": the guided step after each choice. */
.facets .nextbar { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; font-size: 14px; color: var(--muted); }
.facets .nextbar[hidden] { display: none; }
.facets .nextbar .go { font: inherit; font-size: 14px; font-weight: 500; padding: 6px 14px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--fc); background: var(--fc); color: #fff; }
.facets .nextbar .skip { color: var(--muted); }

/* The open pane. */
.facets .panehead { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; }
.facets .panes .glabel { flex: none; }  /* outranks the explorer's 92px label column */
.facets .panes .panehead .glabel { padding: 0; }
.facets .panehead .pclose { margin-left: auto; color: var(--muted); }
.facets .panes .hint { padding: 0; font-size: 12px; color: var(--muted); }
.facets .panes .hint:empty { display: none; }
.facets .pbody { display: flex; flex-direction: column; gap: 6px; }
.facets .panes .glabel.sub { padding: 8px 0 2px; }
.facets .panes .chips { --cols: 3; display: grid; gap: 8px; grid-auto-flow: row dense;
  grid-template-columns: repeat(var(--cols), minmax(0, min(148px, calc((100% - (var(--cols) - 1) * 8px) / var(--cols))))); }
.facets .panes .chip { aspect-ratio: 1; min-width: 0; padding: 9px 10px; font-size: 14px; }
.facets .panes .chip .cl { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.facets .panes .chip .cn { font-size: 11px; color: var(--muted); }
.facets .panes .chip.on .cn { color: #fff; opacity: 0.85; }
.facets .panes .chip.big { grid-column: span 2; grid-row: span 2; font-size: 18px; }
.facets .panes .chip.big .cn { font-size: 13px; }
.facets .panes .chip.empty { opacity: 0.42; cursor: not-allowed; border-style: dashed; }
.facets .panes .chip.empty:hover { border-color: var(--line); background: var(--wash-light); }
.facets .panes .empty { padding: 8px 0; }
.facets .panefoot { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; position: sticky; bottom: 0; z-index: 2;
  padding: 10px 0 4px; background: var(--paper); border-top: 1px solid var(--line); }
.facets .panefoot .chosen { font-size: 13px; color: var(--ink); flex-basis: 100%; }
.facets .panefoot .fhint { flex-basis: 100%; font-size: 12px; color: var(--muted); }
.facets .panefoot .apply { font: inherit; font-size: 14px; font-weight: 500; padding: 6px 16px; border-radius: 2px; cursor: pointer;
  border: 1px solid var(--fc); background: var(--fc); color: #fff; }
.facets .panefoot .cta { font-size: 14px; padding: 6px 14px; }

/* A phone keeps the 3×3: the cells shrink and their words get smaller instead. */
@media (max-width: 600px) {
  .facets .tile { padding: 7px 8px; gap: 2px; }
  .facets .tile .tl { font-size: 9.5px; letter-spacing: 0.04em; }
  .facets .tile .tv { font-size: 13px; line-height: 1.1; }
  .facets .panes .pane { padding: 12px 10px; }
  .facets .panes .chip { font-size: 13px; padding: 7px 8px; }
  .facets .panes .chip.big { font-size: 15px; }
}
