/* Fig. 1, the card sorter. Drawing rules follow the kit's ISO_CSS, scoped to
   this figure, with every colour taken from the site tokens in base.css. */

.fig-card-sorter {
  --anatomy-page: var(--bg);
  --anatomy-card: var(--bg-deep);
  --anatomy-paper: var(--surface);
  --anatomy-face: var(--surface-raised);
  --anatomy-top: var(--surface-high);
  --anatomy-shade-0: #171717;
  --anatomy-shade-1: #1b1b1b;
  --anatomy-shade-2: #202020;
  --anatomy-shade-3: #262626;
  --anatomy-lit-top: #2c3a22;
  --anatomy-lit-shade: #212c18;
  --anatomy-hi: var(--ink-soft);
  --anatomy-mid: var(--faint);
  --anatomy-lo: #4b4944;
  --anatomy-faint: #302f2c;
  --anatomy-lit: var(--brand);
  --anatomy-halo: #000;
  --anatomy-halo-opacity: 0.85;
  --anatomy-dot: var(--ink);
  --anatomy-weight: 0.6px;
  --anatomy-ease: var(--ease);
  margin: var(--s-40) 0;
  color: var(--muted);
}

.fig-card-sorter__plate {
  position: relative;
  padding: var(--s-16) var(--s-16) var(--s-16);
  background: var(--anatomy-card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
}

.fig-card-sorter__stage {
  position: relative;
  border-radius: var(--r-md);
  touch-action: pan-y;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.fig-card-sorter__stage:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 6px;
}

.fig-card-sorter .iso-svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.fig-card-sorter .iso-svg path,
.fig-card-sorter .iso-svg circle {
  vector-effect: non-scaling-stroke;
}

/* Solids: four side tones by facing, a lighter top, and a lit accent. */
.fig-card-sorter .iso-fill {
  fill: var(--anatomy-paper);
  stroke: none;
}

.fig-card-sorter .iso-solid[data-lit] > .iso-fill {
  fill: var(--anatomy-face);
}

.fig-card-sorter .iso-shade,
.fig-card-sorter .iso-top {
  stroke: none;
}

.fig-card-sorter .iso-shade[data-shade="0"] { fill: var(--anatomy-shade-0); }
.fig-card-sorter .iso-shade[data-shade="1"] { fill: var(--anatomy-shade-1); }
.fig-card-sorter .iso-shade[data-shade="2"] { fill: var(--anatomy-shade-2); }
.fig-card-sorter .iso-shade[data-shade="3"] { fill: var(--anatomy-shade-3); }

.fig-card-sorter .iso-top {
  fill: var(--anatomy-top);
}

.fig-card-sorter .iso-solid[data-lit] > .iso-top {
  fill: var(--anatomy-lit-top);
}

.fig-card-sorter .iso-solid[data-lit] > .iso-shade {
  fill: var(--anatomy-lit-shade);
}

.fig-card-sorter .iso-solid[data-lit] > .iso-edge {
  stroke: var(--anatomy-lit);
}

.fig-card-sorter .iso-halo {
  fill: var(--anatomy-halo);
  stroke: none;
  filter: blur(9px);
  opacity: var(--anatomy-halo-opacity);
  transform: translateY(3px);
}

/* Lines: hairlines in tones; every line ends on a face or an edge. */
.fig-card-sorter .iso-line {
  fill: none;
  stroke: var(--anatomy-lo);
  stroke-width: var(--anatomy-weight);
  stroke-linecap: round;
  stroke-linejoin: round;
}

.fig-card-sorter .iso-line[data-tone="hi"] { stroke: var(--anatomy-hi); }
.fig-card-sorter .iso-line[data-tone="mid"] { stroke: var(--anatomy-mid); }
.fig-card-sorter .iso-line[data-tone="lo"] { stroke: var(--anatomy-lo); }
.fig-card-sorter .iso-line[data-tone="faint"] { stroke: var(--anatomy-faint); }
.fig-card-sorter .iso-line[data-tone="lit"] { stroke: var(--anatomy-lit); }

.fig-card-sorter .iso-dots circle {
  fill: var(--anatomy-dot);
  stroke: none;
  opacity: 0.32;
}

.fig-card-sorter .iso-dots[data-tone="mid"] circle { opacity: 0.45; }
.fig-card-sorter .iso-dots[data-tone="lo"] circle { opacity: 0.22; }

/* Card faces: holes are dark; a notch is a hole cut open to the card's top edge. */
.fig-card-sorter .fig-hole,
.fig-card-sorter .fig-notch {
  fill: var(--bg-deep);
  stroke: none;
}

.fig-card-sorter .fig-query-notch {
  opacity: 0;
  transition: opacity 260ms var(--ease);
}

.fig-card-sorter .fig-query-notch[data-on] {
  opacity: 1;
}

/* The needles: one per position. The one under the cursor is lit. */
.fig-card-sorter .fig-needle {
  transition: stroke 200ms var(--ease);
}

.fig-card-sorter .fig-needle[data-cursor] {
  stroke: var(--anatomy-lit);
  stroke-width: 1.1px;
}

.fig-card-sorter .fig-cursor {
  fill: none;
  stroke: var(--anatomy-lit);
  stroke-width: 1px;
  opacity: 0;
  transition: opacity 220ms var(--ease);
}

.fig-card-sorter .fig-cursor[data-on] {
  opacity: 1;
}

/* Readout, hint and the ranked list, set in the site's mono for data. */
.fig-card-sorter__foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--s-8) var(--s-16);
  margin-top: var(--s-12);
  font-size: var(--text-sm);
  line-height: 1.5;
}

.fig-card-sorter__hint {
  margin: 0;
  color: var(--faint);
  max-width: 44ch;
}

.fig-card-sorter__readout {
  margin: 0;
  color: var(--ink);
  font-family: var(--mono);
  font-size: var(--text-xs);
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.fig-card-sorter__ranks {
  list-style: none;
  margin: var(--s-16) 0 0;
  padding: var(--s-12) 0 0;
  border-top: 1px solid var(--line);
  display: grid;
  gap: var(--s-4);
}

.fig-card-sorter__rank {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "name role"
    "numbers numbers";
  gap: 0 var(--s-12);
  padding: var(--s-4) 0;
  font-size: var(--text-sm);
  transition: opacity 300ms var(--ease);
}

.fig-card-sorter__name {
  grid-area: name;
  color: var(--ink-soft);
}

.fig-card-sorter__numbers {
  grid-area: numbers;
  color: var(--faint);
  font-family: var(--mono);
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
}

.fig-card-sorter__role {
  grid-area: role;
  color: var(--faint);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  align-self: center;
}

.fig-card-sorter__rank[data-role="note"] .fig-card-sorter__role {
  color: var(--brand);
}

.fig-card-sorter__caption {
  margin-top: var(--s-16);
  font-size: var(--text-sm);
  line-height: 1.6;
  color: var(--muted);
  max-width: var(--measure);
}

.fig-card-sorter__caption strong {
  color: var(--ink-soft);
  font-weight: 600;
}

.fig-card-sorter__sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
  padding: 0;
}

@media (min-width: 560px) {
  .fig-card-sorter__rank {
    grid-template-columns: minmax(0, 1fr) auto auto;
    grid-template-areas: "name numbers role";
    align-items: baseline;
  }
}

@media (max-width: 560px) {
  .fig-card-sorter__plate {
    padding: var(--s-12) var(--s-12) var(--s-12);
  }

  .fig-card-sorter__readout {
    text-align: left;
  }
}

@media (prefers-reduced-motion: reduce) {
  .fig-card-sorter .fig-query-notch,
  .fig-card-sorter .fig-cursor,
  .fig-card-sorter .fig-needle,
  .fig-card-sorter__rank {
    transition: none;
  }
}
