/* The catalogue (scripts/views/catalogue.mjs, js/views/catalogue.js): every simulation, as an index you can
   explore. The sum of the catalogue as three chips that filter by way, the names grouped by way, and one panel
   for the simulation picked. Below 60rem the names are one list of rows, each with its question, and the
   panel opens in place under the row tapped. From 60rem the names stand in two columns and the panel stays
   beside them, so the names and the answer share a laptop screen. The marks use the technique map's looks:
   solid for run for real, a dotted centre for a stand-in, a ring for reach shown, a dashed edge for never
   run, and an outlined diamond for a step computed on the model. White and grey only: nothing here says how a
   test went. Without scripting the figure is the sum and the plain list. */

.view--catalogue { overflow: clip; border-radius: var(--radius-frame); background: var(--color-paper-2); box-shadow: inset 0 0 0 1px var(--color-frame-edge); }
.cat { --pad: var(--space-xl); display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-lg); margin: 0; padding: var(--space-xl) var(--pad); }

/* ---------- The marks ---------- */

.cat__glyph { --under: transparent; position: relative; flex: none; display: block; width: var(--space-md); height: var(--space-md); border-radius: var(--space-2xs); }
.cat__glyph[data-look="solid"] { background: currentColor; }
.cat__glyph[data-look="dot"], .cat__glyph[data-look="ring"] { background: var(--under); box-shadow: inset 0 0 0 2px currentColor; }
.cat__glyph[data-look="dot"]::before { content: ""; position: absolute; inset: 32%; border-radius: var(--space-3xs); background: currentColor; }
.cat__glyph[data-look="dash"] { background: var(--under); border: 2px dashed var(--color-line); }
.cat__glyph[data-look="model"]::before { content: ""; position: absolute; inset: 15%; border-radius: var(--space-3xs); background: var(--under); box-shadow: inset 0 0 0 2px currentColor; transform: rotate(45deg); }

/* ---------- The sum: a sentence without scripting, three chips that filter with it ---------- */

.cat__sum { display: flex; flex-wrap: wrap; gap: var(--space-xs) var(--space-lg); margin: 0; font-size: var(--text-md); line-height: 1.3; color: var(--color-ink-2); }
.cat__sum-part { display: inline-flex; align-items: center; gap: var(--space-xs); }
.cat.is-ready .cat__sum { display: none; }
.cat__filters { display: flex; flex-wrap: wrap; gap: var(--space-xs); }
.cat__filter { display: inline-flex; align-items: center; gap: var(--space-xs); min-height: var(--control-hit); white-space: nowrap; }

/* ---------- The names: one list of rows, grouped by way ---------- */

.cat__names { display: grid; grid-template-columns: minmax(0, 1fr); min-width: 0; }
.cat__col { display: grid; grid-template-columns: minmax(0, 1fr); align-content: start; min-width: 0; }
.cat__group { margin: 0; padding: var(--space-lg) 0 var(--space-xs); font-size: var(--text-md); line-height: 1.3; color: var(--color-ink-3); }
.cat__col:first-child > .cat__group:first-child { padding-top: 0; }
/* A row: its mark, its name, its question on a second line, and a chevron that turns when the row is open.
   The row reaches a little past its text on both sides, so its hover and focus have room. */
.cat__name {
  position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: start; gap: var(--space-3xs) var(--space-sm);
  width: auto; min-height: var(--control-hit); margin: 0 calc(-1 * var(--space-sm)); padding: var(--space-sm); border: 0; border-radius: var(--radius-input);
  background: none; color: var(--color-ink); font: inherit; font-size: var(--text-md); line-height: 1.3; text-align: left; cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: background-color var(--dur-hover) var(--ease-out), color var(--dur-hover) var(--ease-out), opacity 240ms var(--ease-out);
}
.cat__name::before { content: ""; position: absolute; inset: 0 var(--space-sm) auto; height: 1px; background: var(--color-rule); }
.cat__name::after { content: ""; grid-column: 3; grid-row: 1; width: var(--space-xs); height: var(--space-xs); margin: var(--space-2xs) var(--space-2xs) 0; border: solid var(--color-ink-3); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.cat__name[aria-expanded="true"]::after { transform: translateY(var(--space-2xs)) rotate(225deg); border-color: var(--color-ink); }
html:not(.rm) .cat__name::after { transition: transform var(--dur-short) var(--ease-out); }
.cat__name .cat__glyph { grid-column: 1; grid-row: 1; margin-top: var(--space-2xs); color: var(--color-ink-2); }
.cat__name-text { grid-column: 2; grid-row: 1; }
.cat__name-q { grid-column: 2; grid-row: 2; color: var(--color-ink-3); }
.cat__name[aria-expanded="true"] .cat__name-q { color: var(--color-ink-2); }
@media (hover: hover) {
  .cat__name:hover { background: var(--color-paper-3); }
}
.cat__name:focus-visible { outline: 2px solid var(--color-focus); outline-offset: -2px; transition: none; }
.cat__name:active { background: var(--color-paper-4); }

/* ---------- The panel ---------- */

/* The facts and the chain lay themselves out by the panel's own width, which differs under a row and beside
   the names. */
.cat__panel { container-type: inline-size; display: flex; flex-direction: column; gap: var(--space-lg); min-width: 0; margin: var(--space-2xs) 0 var(--space-lg); padding: var(--space-lg) var(--space-md); border-radius: var(--radius-view); background: var(--color-paper-3); color: var(--color-ink); box-shadow: inset 0 0 0 1px var(--color-frame-edge); }
.cat__panel[hidden] { display: none; }
.cat__panel p, .cat__panel dl, .cat__panel dd { margin: 0; }
.cat__way { display: flex; align-items: center; gap: var(--space-xs); font-size: var(--text-md); line-height: 1.3; color: var(--color-ink-2); }
/* Under its row the panel leaves the question to the row above it. */
.cat__q { display: none; max-width: 24ch; font-size: var(--text-card); line-height: var(--leading-card); letter-spacing: var(--tracking-card); }
.cat__does { max-width: 44ch; font-size: var(--text-lead); line-height: var(--leading-lead); color: var(--color-ink-2); }
.cat__facts { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-md) var(--space-lg); padding-top: var(--space-lg); border-top: 1px solid var(--color-rule); }
.cat__facts > div { display: grid; align-content: start; gap: var(--space-2xs); min-width: 0; }
.cat__facts dt { font-size: var(--text-md); line-height: 1.3; color: var(--color-ink-3); }
.cat__facts dd { font-size: var(--text-md); line-height: 1.4; color: var(--color-ink-2); }

/* The chain: one mark per technique on a faint line, and the line of words that reads them. The line sits
   under the strip, and beside it where the panel has room. */
.cat__chain { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-xs) var(--space-lg); padding-top: var(--space-lg); border-top: 1px solid var(--color-rule); }
.cat__strip { position: relative; display: flex; margin-inline: calc(-1 * var(--space-xs)); }
.cat__strip::before { content: ""; position: absolute; inset: 0 calc(var(--control-hit) / 2); margin-block: auto; height: 1px; background: var(--color-line); }
.cat__tile { position: relative; display: grid; place-items: center; width: var(--control-hit); height: var(--control-hit); padding: 0; border: 0; border-radius: var(--radius-input); background: none; color: var(--color-ink); cursor: pointer; -webkit-tap-highlight-color: transparent; }
.cat__tile .cat__glyph { --under: var(--color-paper-3); width: var(--space-lg); height: var(--space-lg); border-radius: var(--radius-nav-btn); }
html:not(.rm) .cat__tile .cat__glyph { transition: transform var(--dur-hover) var(--ease-out); }
.cat__tile:hover .cat__glyph { transform: scale(1.16); }
.cat__tile.is-on .cat__glyph { outline: 2px solid var(--color-ink); outline-offset: 2px; }
.cat__tile:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; transition: none; }
.cat__tile:active .cat__glyph { transform: scale(0.94); }
.cat__key { flex: 1 1 100%; display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2xs) var(--space-md); min-width: 0; min-height: var(--control-hit); font-size: var(--text-md); line-height: 1.3; color: var(--color-ink-2); }
.cat__key-item { display: inline-flex; flex-wrap: wrap; align-items: center; gap: var(--space-2xs) var(--space-xs); }
.cat__key-name { color: var(--color-ink); }
.cat__go { align-self: flex-start; }

html:not(.rm) .cat__panel.is-swap > * { animation: cat-in 360ms var(--ease-out) both; }
@keyframes cat-in { from { opacity: 0; transform: translateY(6px); } }

/* ---------- Without scripting: the plain list ---------- */

.cat__plain { display: grid; gap: var(--space-md); font-size: var(--text-md); line-height: 1.45; color: var(--color-ink-2); }
.cat__plain .cat__group { padding-top: var(--space-md); }
.cat__list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 18rem), 1fr)); gap: var(--space-xl); margin: 0; padding: 0; list-style: none; }
.cat__item { display: grid; align-content: start; gap: var(--space-xs); min-width: 0; }
.cat__item-name { max-width: none; font-size: var(--text-title); line-height: 1.2; color: var(--color-ink); }
.cat__item-q { color: var(--color-ink); }
.cat__item-facts { display: grid; gap: var(--space-xs); margin: 0; }
.cat__item-facts dt { color: var(--color-ink-3); }
.cat__item-facts dd { margin: 0; }
.cat__item-chain { display: grid; gap: var(--space-2xs); margin: 0; padding-left: 1.4em; }
.cat.is-ready .cat__plain { display: none; }

@container (min-width: 26rem) {
  /* Two facts side by side, and the pattern on a row of its own under them. */
  .cat__facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cat__facts > [data-cat-pattern] { grid-column: 1 / -1; }
  .cat__key { flex-basis: 14rem; }
}
@container (min-width: 42rem) {
  /* Room for the facts in one row: three, or two wide ones when the entry names no pattern. */
  .cat__facts { grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); }
  .cat__facts > [data-cat-pattern] { grid-column: auto; }
}
@media (min-width: 40rem) {
  .cat__panel { padding: var(--space-lg); }
}
@media (max-width: 59.99rem) {
  /* A chip leaves only its own rows in the list. */
  .cat__name[data-off], .cat__group[data-off] { display: none; }
}
@media (min-width: 60rem) {
  /* Two columns of names, the panel beside them. Whichever is shorter stays under the nav while the other
     scrolls past, so a name and its answer are on the screen together. */
  .cat { grid-template-columns: minmax(0, 28rem) minmax(0, 1fr); gap: var(--space-md) var(--space-lg); padding-block: var(--space-lg); }
  .cat__filters, .cat__sum, .cat__plain { grid-column: 1 / -1; }
  .cat__names { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: var(--space-xs); align-items: start; align-self: start; position: sticky; top: var(--nav-clear); }
  /* Two columns of eight. The chips above are the key to the marks and stay on the screen with the names, so
     the group labels of the list are left out here. */
  .cat__names .cat__group { display: none; }
  /* A name is one line: its question is in the panel. */
  .cat__name { grid-template-columns: auto minmax(0, 1fr); align-items: center; margin: 0; padding: 0 var(--space-md); border-radius: var(--radius-pill); color: var(--color-ink-2); white-space: nowrap; }
  .cat__name::before, .cat__name::after { content: none; }
  .cat__name .cat__glyph { margin-top: 0; color: var(--color-ink-3); }
  .cat__name-q { display: none; }
  .cat__name:hover { color: var(--color-ink); }
  .cat__name[aria-expanded="true"], .cat__name[aria-expanded="true"]:hover { background: var(--color-ink); color: var(--color-paper); }
  .cat__name[aria-expanded="true"] .cat__glyph { color: inherit; }
  .cat__name:focus-visible { outline-offset: 2px; }
  .cat__name:active { transform: scale(0.98); }
  /* A name the filter leaves out dims. It is still a button: picking it clears the filter. */
  .cat__name[data-off] { opacity: 0.6; }
  .cat__name[data-off]:hover, .cat__name[data-off]:focus-visible { opacity: 1; }
  .cat__panel { position: sticky; top: var(--nav-clear); align-self: start; gap: var(--space-md); margin: 0; }
  .cat__q { display: block; }
  .cat__facts, .cat__chain { padding-top: var(--space-md); }
}
@media (min-width: 80rem) {
  .cat { column-gap: var(--space-xl); }
  .cat__panel { padding: var(--space-lg) var(--space-xl); }
}
@media (max-width: 39.99rem) {
  .view--catalogue { margin-inline: calc(-1 * var(--gutter)); border-radius: 0; box-shadow: inset 0 1px 0 var(--color-frame-edge), inset 0 -1px 0 var(--color-frame-edge); }
  .cat { --pad: var(--gutter); padding-block: var(--space-lg); }
}
