/* ============================================================================
   Browse Z2Market — sitewide navigation directory
   ----------------------------------------------------------------------------
   Server-rendered into every public page by
   server/src/modules/browse-directory/browse-directory.service.ts.

   Styling rules:
     - colours come from the --z2m-m-* tokens in theme.css, so `html.dark`
       (dark-mode.css / navbar.js) themes this block with no extra override;
     - groups sit in a grid of columns and each group is a single-column list,
       so the block reads as a tidy directory instead of a wall of links.
       Nesting multi-column lists inside narrow grid cells made every anchor
       wrap onto 3-4 lines, so the columns live at the group level only;
     - on phones the groups stack and each list breaks into two columns;
     - nothing is hidden, clipped away or positioned off-screen: every label is
       plain visible text in the DOM, so the anchor text stays descriptive.
   ============================================================================ */

.z2m-browse {
  margin-top: 3rem;
  padding: 2.25rem 0 2.5rem;
  background: var(--z2m-m-surface-2);
  border-top: 1px solid var(--z2m-m-border-soft);
  color: var(--z2m-m-text);
}

.z2m-browse-head {
  max-width: 46rem;
  margin: 0 0 1.5rem;
}

.z2m-browse-title {
  margin: 0 0 0.35rem;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--z2m-m-text);
}

.z2m-browse-sub {
  margin: 0;
  font-size: 0.9rem;
  color: var(--z2m-m-muted);
}

.z2m-browse-groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.9rem 2.25rem;
  align-items: start;
}

/* Six groups (the maximum) land as an even 3x2 block on desktop. */
@media (min-width: 1200px) {
  .z2m-browse-groups { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.z2m-browse-group {
  min-width: 0;
}

.z2m-browse-group-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 750;
  color: var(--z2m-m-text);
}

.z2m-browse-group-title::after {
  content: "";
  display: block;
  width: 2rem;
  height: 2px;
  margin-top: 0.45rem;
  border-radius: 2px;
  background: var(--z2m-m-accent);
  opacity: 0.55;
}

.z2m-browse-group-blurb {
  margin: 0.5rem 0 0.7rem;
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--z2m-m-muted);
}

.z2m-browse-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.z2m-browse-list li {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0 0 0.05rem;
}

.z2m-browse-list a {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.24rem 0.35rem;
  border-radius: 6px;
  font-size: 0.85rem;
  line-height: 1.35;
  color: var(--z2m-m-text);
  text-decoration: none;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.z2m-browse-list a:hover,
.z2m-browse-list a:focus-visible {
  background: var(--z2m-m-chip-bg);
  color: var(--z2m-m-accent);
  text-decoration: none;
}

.z2m-browse-list a:focus-visible {
  outline: 2px solid var(--z2m-m-accent);
  outline-offset: 1px;
}

/* Labels are capped in length by the renderer, so this clamp is only a safety
   net: the full text stays in the DOM and remains the anchor text. */
.z2m-browse-label {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: break-word;
}

.z2m-browse-count {
  flex: 0 0 auto;
  padding: 0 0.4rem;
  border-radius: 999px;
  background: var(--z2m-m-chip-bg);
  color: var(--z2m-m-accent);
  font-size: 0.68rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.5;
}

@media (max-width: 991.98px) {
  .z2m-browse {
    margin-top: 2.25rem;
    padding: 1.75rem 0 2rem;
  }
  .z2m-browse-groups {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.4rem 1.6rem;
  }
}

@media (max-width: 575.98px) {
  .z2m-browse-title { font-size: 1.15rem; }
  .z2m-browse-sub { font-size: 0.82rem; }
  .z2m-browse-groups {
    grid-template-columns: 1fr;
    gap: 1.1rem;
  }
  /* Two tidy columns of links instead of one long wall. */
  .z2m-browse-list {
    columns: 2;
    column-gap: 0.75rem;
  }
  .z2m-browse-list li {
    break-inside: avoid;
    /* -webkit-box from the label clamp does not split across CSS columns. */
    display: block;
    position: relative;
  }
  .z2m-browse-list a { font-size: 0.8rem; padding: 0.26rem 0.3rem; }
  .z2m-browse-count {
    position: absolute;
    top: 0.34rem;
    right: 0.15rem;
    padding: 0 0.32rem;
  }
  .z2m-browse-list a { padding-right: 1.9rem; }
}
