/* ==========================================================================
   Public county registries: /public/documents/counties[/{id}] and the
   "County Documents" branch of the Resources category tree.
   pub-reg- prefix, tokens only, every selector rooted at .ds-pub-shell.
   ========================================================================== */

/* Branch tones: each top-level category keeps one hue through its subtree. */
.ds-pub-shell .pub-reg-tone-1 { --pub-reg-tone: var(--pub-primary); --pub-reg-tint: var(--pub-tint-1); }
.ds-pub-shell .pub-reg-tone-2 { --pub-reg-tone: var(--pub-success); --pub-reg-tint: var(--pub-tint-2); }
.ds-pub-shell .pub-reg-tone-3 { --pub-reg-tone: var(--pub-info); --pub-reg-tint: var(--pub-tint-3); }
.ds-pub-shell .pub-reg-tone-4 { --pub-reg-tone: var(--pub-accent-ink); --pub-reg-tint: var(--pub-tint-4); }
.ds-pub-shell .pub-reg-tone-5 { --pub-reg-tone: var(--pub-tint-5-ink); --pub-reg-tint: var(--pub-tint-5); }
.ds-pub-shell .pub-reg-tone-6 { --pub-reg-tone: var(--pub-chart-2); --pub-reg-tint: var(--pub-tint-6); }

.ds-pub-shell .pub-reg-num {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--pub-reg-tone, var(--pub-ink-3));
}

/* ---------- Tree (sidebar and the Resources "County Documents" branch) ---------- */

.ds-pub-shell .pub-reg-tree-root { margin-top: var(--pub-space-2); padding-top: var(--pub-space-2); border-top: 1px solid var(--pub-border); }
.ds-pub-shell .pub-facet .pub-reg-num { min-width: 1.6em; font-size: var(--pub-text-xs); }
.ds-pub-shell .pub-facet__label { display: inline-flex; align-items: baseline; gap: 6px; min-width: 0; }
.ds-pub-shell .pub-facet.is-empty { color: var(--pub-ink-3); }
.ds-pub-shell .pub-facet.is-empty .pub-facet__count { opacity: .6; }
.ds-pub-shell .pub-facet .pub-icon { flex: 0 0 auto; color: var(--pub-reg-tone, var(--pub-ink-3)); }
.ds-pub-shell .pub-reg-tree-filter { margin-bottom: var(--pub-space-3); }
.ds-pub-shell .pub-reg-tree-empty { padding: var(--pub-space-2); color: var(--pub-ink-3); font-size: var(--pub-text-sm); }
.ds-pub-shell .pub-reg-tree mark { background: var(--pub-accent-soft); color: inherit; border-radius: 2px; }

.ds-pub-shell .pub-reg-counties { display: grid; gap: 2px; list-style: none; }

/* Long nowrap names must truncate inside the 264px facet column instead of widening its grid tracks. */
.ds-pub-shell .pub-res__facets .pub-panel,
.ds-pub-shell .pub-res__facets .pub-panel__group,
.ds-pub-shell .pub-reg-tree,
.ds-pub-shell .pub-reg-tree ul,
.ds-pub-shell .pub-reg-tree-root,
.ds-pub-shell .pub-reg-tree-root ul { grid-template-columns: minmax(0, 1fr); min-width: 0; }
.ds-pub-shell .pub-facet__label { flex: 1 1 auto; }
.ds-pub-shell .pub-facet__count { flex: none; }

/* Search scope ("In 2.3" / "Whole county") inside the hero search box. */
.ds-pub-shell .pub-reg-scope-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--pub-space-2); margin-top: var(--pub-space-3); font-size: var(--pub-text-sm); color: var(--pub-ink-2); }
.ds-pub-shell .pub-reg-scope-row .pub-reg-scope { max-width: min(100%, 360px); }

/* ---------- Toolbar ---------- */

.ds-pub-shell .pub-reg-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--pub-space-3);
  padding-bottom: var(--pub-space-4);
  margin-bottom: var(--pub-space-4);
  border-bottom: 1px solid var(--pub-border);
}

.ds-pub-shell .pub-reg-toolbar__row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--pub-space-2); min-width: 0; }

.ds-pub-shell .pub-reg-crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  list-style: none;
  font-size: var(--pub-text-md);
  min-width: 0;
}

.ds-pub-shell .pub-reg-crumbs li { display: inline-flex; align-items: center; min-width: 0; }

.ds-pub-shell .pub-reg-crumb {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  max-width: 260px;
  padding: 4px 8px;
  border-radius: var(--pub-radius-sm);
  color: var(--pub-ink-2);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ds-pub-shell a.pub-reg-crumb:hover { background: var(--pub-surface-hover); color: var(--pub-ink); }
.ds-pub-shell .pub-reg-crumb.is-current { color: var(--pub-ink); font-family: var(--pub-font-display); font-weight: 500; font-size: var(--pub-text-lg); }
.ds-pub-shell .pub-reg-crumb-menu .mud-icon-button { padding: 2px; color: var(--pub-ink-3); }
.ds-pub-shell .pub-reg-crumb-menu .mud-icon-button:hover { color: var(--pub-ink); }
.ds-pub-shell .pub-reg-crumb-sep { color: var(--pub-ink-3); padding: 0 2px; }

.ds-pub-shell .pub-reg-kbd {
  display: inline-flex;
  align-items: center;
  margin-left: 6px;
  padding: 1px 6px;
  border: 1px solid var(--pub-border-strong);
  border-radius: var(--pub-radius-sm);
  font-size: var(--pub-text-2xs);
  font-weight: 600;
  color: var(--pub-ink-3);
}

.ds-pub-shell .pub-reg-filters { display: flex; flex-wrap: wrap; align-items: center; gap: var(--pub-space-2); margin-bottom: var(--pub-space-4); }
.ds-pub-shell .pub-reg-filters .pub-select { width: auto; min-width: 140px; }
.ds-pub-shell .pub-reg-count { margin-left: auto; }

/* ---------- Section headings and description ---------- */

.ds-pub-shell .pub-reg-heading {
  display: flex;
  align-items: baseline;
  gap: var(--pub-space-2);
  margin: 0 0 var(--pub-space-3);
  font-size: var(--pub-text-xs);
  font-weight: 600;
  letter-spacing: var(--pub-ls-caps);
  text-transform: uppercase;
  color: var(--pub-ink-3);
}

.ds-pub-shell .pub-reg-desc { margin: calc(-1 * var(--pub-space-2)) 0 var(--pub-space-5); color: var(--pub-ink-2); }
.ds-pub-shell .pub-reg-block { margin-bottom: var(--pub-space-8); }

/* ---------- Category tiles ---------- */

.ds-pub-shell .pub-reg-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: var(--pub-space-3);
  list-style: none;
}

.ds-pub-shell .pub-reg-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--pub-space-2);
  height: 100%;
  min-height: 128px;
  padding: var(--pub-space-4);
  border: 1px solid var(--pub-border);
  border-radius: var(--pub-radius-lg);
  background: var(--pub-surface);
  color: var(--pub-ink);
  text-decoration: none;
  overflow: hidden;
  transition: border-color var(--pub-dur-fast) var(--pub-ease), box-shadow var(--pub-dur-fast) var(--pub-ease), transform var(--pub-dur-fast) var(--pub-ease);
}

.ds-pub-shell .pub-reg-tile::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: var(--pub-reg-tone, var(--pub-primary));
}

.ds-pub-shell .pub-reg-tile:hover { border-color: var(--pub-border-strong); box-shadow: var(--pub-shadow-md); transform: translateY(-1px); color: var(--pub-ink); }
.ds-pub-shell .pub-reg-tile:focus-visible { outline: none; box-shadow: var(--pub-focus-ring); }

.ds-pub-shell .pub-reg-tile__head { display: flex; align-items: center; gap: var(--pub-space-3); }

.ds-pub-shell .pub-reg-tile__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  min-width: 38px;
  height: 38px;
  padding: 0 8px;
  border-radius: var(--pub-radius);
  background: var(--pub-reg-tint, var(--pub-primary-soft));
  color: var(--pub-reg-tone, var(--pub-primary));
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.ds-pub-shell .pub-reg-tile__name { font-family: var(--pub-font-display); font-weight: 500; font-size: var(--pub-text-lg); line-height: var(--pub-lh-heading); }
.ds-pub-shell .pub-reg-tile__desc { color: var(--pub-ink-2); font-size: var(--pub-text-sm); }
.ds-pub-shell .pub-reg-tile__meta { margin-top: auto; display: flex; flex-wrap: wrap; gap: 4px var(--pub-space-3); color: var(--pub-ink-3); font-size: var(--pub-text-xs); }
.ds-pub-shell .pub-reg-tile__meta span { display: inline-flex; align-items: center; gap: 4px; }
.ds-pub-shell .pub-reg-tile.is-empty .pub-reg-tile__name { color: var(--pub-ink-2); }

/* ---------- Document cards ---------- */

.ds-pub-shell .pub-reg-docs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--pub-space-3);
  list-style: none;
}

.ds-pub-shell .pub-reg-doc {
  position: relative;
  display: flex;
  gap: var(--pub-space-3);
  height: 100%;
  padding: var(--pub-space-4);
  border: 1px solid var(--pub-border);
  border-radius: var(--pub-radius-lg);
  background: var(--pub-surface);
  transition: border-color var(--pub-dur-fast) var(--pub-ease), box-shadow var(--pub-dur-fast) var(--pub-ease);
}

.ds-pub-shell .pub-reg-doc:hover { border-color: var(--pub-border-strong); box-shadow: var(--pub-shadow-md); }
.ds-pub-shell .pub-reg-doc__body { display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 1; }
.ds-pub-shell .pub-reg-doc__title { font-weight: 600; color: var(--pub-ink); text-decoration: none; }
.ds-pub-shell .pub-reg-doc__title::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.ds-pub-shell .pub-reg-doc__title:focus-visible { outline: none; }
.ds-pub-shell .pub-reg-doc:focus-within { box-shadow: var(--pub-focus-ring); }
.ds-pub-shell .pub-reg-doc__path { display: inline-flex; align-items: center; gap: 4px; color: var(--pub-ink-3); font-size: var(--pub-text-xs); min-width: 0; }
.ds-pub-shell .pub-reg-doc__path span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ds-pub-shell .pub-reg-doc__meta { display: flex; flex-wrap: wrap; gap: 2px var(--pub-space-3); color: var(--pub-ink-3); font-size: var(--pub-text-xs); }
.ds-pub-shell .pub-reg-doc__actions { position: relative; z-index: 1; display: flex; gap: var(--pub-space-2); margin-top: var(--pub-space-1); }

/* ---------- Columns (Miller) view ---------- */

.ds-pub-shell .pub-reg-columns {
  display: flex;
  min-height: 420px;
  border: 1px solid var(--pub-border);
  border-radius: var(--pub-radius-lg);
  background: var(--pub-surface);
  overflow-x: auto;
}

.ds-pub-shell .pub-reg-column {
  flex: 0 0 250px;
  padding: var(--pub-space-2);
  border-right: 1px solid var(--pub-border);
  max-height: 600px;
  overflow-y: auto;
}

.ds-pub-shell .pub-reg-column:last-child { flex: 1 0 300px; border-right: 0; }
.ds-pub-shell .pub-reg-column__head { padding: var(--pub-space-2); font-size: var(--pub-text-xs); font-weight: 600; letter-spacing: var(--pub-ls-caps); text-transform: uppercase; color: var(--pub-ink-3); }
.ds-pub-shell .pub-reg-column ul { list-style: none; display: grid; gap: 2px; }

.ds-pub-shell .pub-reg-col-item {
  display: flex;
  align-items: center;
  gap: var(--pub-space-2);
  padding: 7px var(--pub-space-2);
  border-radius: var(--pub-radius-sm);
  color: var(--pub-ink);
  font-size: var(--pub-text-sm);
  text-decoration: none;
}

.ds-pub-shell .pub-reg-col-item:hover { background: var(--pub-surface-hover); color: var(--pub-ink); }
.ds-pub-shell .pub-reg-col-item.is-open { background: var(--pub-primary-soft); color: var(--pub-primary-soft-ink); font-weight: 600; }
.ds-pub-shell .pub-reg-col-item__name { flex: 1; min-width: 0; }
.ds-pub-shell .pub-reg-col-item .pub-facet__count { margin-left: auto; }
.ds-pub-shell .pub-reg-col-empty { padding: var(--pub-space-3) var(--pub-space-2); color: var(--pub-ink-3); font-size: var(--pub-text-sm); }

/* ---------- County index ---------- */

.ds-pub-shell .pub-reg-county-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--pub-space-4);
  list-style: none;
}

.ds-pub-shell .pub-reg-county {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--pub-space-3);
  height: 100%;
  padding: var(--pub-space-5);
  border: 1px solid var(--pub-border);
  border-radius: var(--pub-radius-lg);
  background: var(--pub-surface);
}

.ds-pub-shell .pub-reg-county:hover { border-color: var(--pub-border-strong); box-shadow: var(--pub-shadow-md); }
.ds-pub-shell .pub-reg-county__name { font-family: var(--pub-font-display); font-weight: 500; font-size: var(--pub-text-xl); color: var(--pub-ink); text-decoration: none; }
.ds-pub-shell .pub-reg-county__name::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.ds-pub-shell .pub-reg-county:focus-within { box-shadow: var(--pub-focus-ring); }
.ds-pub-shell .pub-reg-county__list { list-style: none; display: grid; gap: 4px; font-size: var(--pub-text-sm); color: var(--pub-ink-2); }
.ds-pub-shell .pub-reg-county__list li { display: flex; align-items: baseline; gap: var(--pub-space-2); }
.ds-pub-shell .pub-reg-county__list .pub-facet__count { margin-left: auto; }

/* ---------- Quick jump dialog ---------- */

.ds-pub-shell .pub-reg-jump__list { list-style: none; display: grid; gap: 2px; max-height: 50vh; overflow-y: auto; margin-top: var(--pub-space-3); }
.ds-pub-shell .pub-reg-jump__group { padding: var(--pub-space-3) var(--pub-space-2) var(--pub-space-1); font-size: var(--pub-text-2xs); font-weight: 600; letter-spacing: var(--pub-ls-caps); text-transform: uppercase; color: var(--pub-ink-3); }

.ds-pub-shell .pub-reg-jump__item {
  display: flex;
  align-items: center;
  gap: var(--pub-space-3);
  width: 100%;
  padding: var(--pub-space-2) var(--pub-space-3);
  border: 0;
  border-radius: var(--pub-radius);
  background: transparent;
  color: var(--pub-ink);
  text-align: left;
  font: inherit;
  cursor: pointer;
  justify-content: flex-start;
}

.ds-pub-shell .pub-reg-jump__item > span { min-width: 0; text-align: left; }
.ds-pub-shell .pub-reg-jump__item.is-active,
.ds-pub-shell .pub-reg-jump__item:hover { background: var(--pub-primary-soft); }
.ds-pub-shell .pub-reg-jump__item small { display: block; color: var(--pub-ink-3); font-size: var(--pub-text-xs); }
.ds-pub-shell .pub-reg-jump__foot { display: flex; gap: var(--pub-space-4); margin-top: var(--pub-space-3); padding-top: var(--pub-space-2); border-top: 1px solid var(--pub-border); color: var(--pub-ink-3); font-size: var(--pub-text-xs); }

/* ---------- Document page: where it is filed ---------- */

.ds-pub-shell .pub-reg-filed { display: inline-flex; align-items: center; gap: 6px; }

@media (max-width: 959.98px) {
  .ds-pub-shell .pub-segmented .pub-reg-view-columns { display: none; }
  .ds-pub-shell .pub-reg-crumb { max-width: 180px; }
}

@media (max-width: 599.98px) {
  .ds-pub-shell .pub-reg-tiles { grid-template-columns: 1fr; }
  .ds-pub-shell .pub-reg-tile { min-height: 0; }
  .ds-pub-shell .pub-reg-docs { grid-template-columns: 1fr; }
  .ds-pub-shell .pub-reg-count { margin-left: 0; width: 100%; }
  .ds-pub-shell .pub-reg-kbd { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .ds-pub-shell .pub-reg-tile { transition: none; }
}
