/* ==========================================================================
   Card directory
   --------------------------------------------------------------------------
   The "find the card I already have in mind" page, as opposed to the
   comparison, which is the "tell me which card to get" page. Different job,
   so a different shape: no ranking, no value figures competing for attention,
   just names you can scan and a filter that responds as you type.

   Inherits the .bm-cs token set from card-single.css, which is enqueued as a
   dependency, so the two pages cannot drift apart on colour.
   ========================================================================== */

.bm-dir {
  --d-ink:     #0b0b0b;
  --d-ink-2:   #52514e;
  --d-muted:   #898781;
  --d-line:    #e1e0d9;
  --d-line-2:  #c3c2b7;
  --d-surface: #fcfcfb;
  --d-plane:   #f9f9f7;
  --d-accent:  #2a78d6;
  --d-accent-d:#1c5ba6;

  color-scheme: light;
  color: var(--d-ink);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.55;
  container-type: inline-size;
}

.bm-dir *, .bm-dir *::before, .bm-dir *::after { box-sizing: border-box; }

.bm-dir__main { padding-bottom: 48px; }
.bm-dir__h1 { margin-bottom: 8px; letter-spacing: -0.02em; }
.bm-dir__intro {
  max-width: 62ch; margin: 0 0 22px;
  color: #52514e; font-size: 15.5px; line-height: 1.6;
}

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

/* ---------- Search ---------- */

.bm-dir__head { margin-bottom: 16px; }
.bm-dir__searchwrap { display: block; }

.bm-dir__search {
  width: 100%;
  max-width: 520px;
  padding: 13px 16px;
  font-size: 16px;               /* 16px stops iOS zooming the page on focus */
  font-family: inherit;
  color: var(--d-ink);
  background: var(--d-surface);
  border: 1px solid var(--d-line-2);
  border-radius: 10px;
}
.bm-dir__search::placeholder { color: var(--d-muted); }
.bm-dir__search:focus-visible {
  outline: 2px solid var(--d-accent);
  outline-offset: 1px;
  border-color: var(--d-accent);
}

.bm-dir__count {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--d-muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- Jump links ---------- */

.bm-dir__jump {
  display: flex; flex-wrap: wrap; gap: 7px;
  margin: 0 0 26px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--d-line);
}

.bm-dir__jump a {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--d-line-2);
  background: var(--d-plane);
  color: var(--d-ink-2);
  font-size: 13px; font-weight: 550;
  text-decoration: none;
  transition: border-color 120ms ease, color 120ms ease;
}
.bm-dir__jump a:hover { border-color: var(--d-accent); color: var(--d-accent-d); }
.bm-dir__jump a span {
  font-size: 11.5px; font-weight: 700; color: var(--d-muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- Groups ---------- */

.bm-dir__group { margin-bottom: 30px; scroll-margin-top: 24px; }

.bm-dir__issuer {
  margin: 0 0 4px;
  font-size: 18px; font-weight: 700; letter-spacing: -0.015em;
  display: flex; align-items: baseline; gap: 9px;
}
.bm-dir__n {
  font-size: 12px; font-weight: 650; color: var(--d-muted);
  font-variant-numeric: tabular-nums;
}

.bm-dir__list { list-style: none; margin: 0; padding: 0; }

.bm-dir__item {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 2px 16px;
  padding: 11px 2px;
  border-bottom: 1px solid var(--d-line);
}
.bm-dir__item[hidden] { display: none; }

.bm-dir__link {
  grid-column: 1;
  font-size: 15.5px; font-weight: 650;
  color: var(--d-accent-d);
  text-decoration: none;
}
.bm-dir__link:hover { text-decoration: underline; }
.bm-dir__link:focus-visible { outline: 2px solid var(--d-accent); outline-offset: 2px; }

.bm-dir__meta {
  grid-column: 1;
  font-size: 13px; color: var(--d-muted);
  font-variant-numeric: tabular-nums;
}

.bm-dir__rating {
  grid-row: 1 / span 2;
  grid-column: 2;
  align-self: center;
  font-size: 15px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.bm-dir__of { font-size: 11.5px; font-weight: 500; color: var(--d-muted); }

/* Two columns once there is room, because a 19 row list is a lot of scrolling
   for what is meant to be the fast way to find something. */
@container (min-width: 760px) {
  .bm-dir__list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 34px;
  }
}

.bm-dir__empty {
  margin: 24px 0;
  padding: 20px;
  background: var(--d-plane);
  border: 1px solid var(--d-line);
  border-radius: 10px;
  color: var(--d-ink-2);
  font-size: 14.5px;
}
.bm-dir__empty[hidden] { display: none; }

.bm-dir__group[hidden] { display: none; }
.bm-dir__jump[hidden] { display: none; }

.bm-dir__footer {
  margin-top: 30px; padding-top: 18px;
  border-top: 1px solid var(--d-line);
  font-size: 14px; color: var(--d-ink-2);
}

@media (prefers-reduced-motion: reduce) { .bm-dir__jump a { transition: none; } }

/* The theme's constrained layout centres every direct child of a
   is-layout-constrained group at content width. We render our own wrapper
   instead, so set the measure here rather than inheriting theirs. */
.bm-dir__main {
  max-width: var(--wp--style--global--wide-size, 1200px);
  margin-left: auto;
  margin-right: auto;
}
.bm-dir__main > * { margin-left: 0; margin-right: 0; max-width: none; }
.bm-dir__main > .bm-dir__intro { max-width: 62ch; }
