/* =============================================================================
   Shared modern page styles — Data Hub (/data-hub), Search (/search),
   Document Library and Business Services. Everything is scoped under .dhm
   so it can't affect any other page.
   ============================================================================= */

.dhm {
  --dhm-navy: var(--trak-navy, #00335F);
  --dhm-navy-dark: #00264a;
  --dhm-ink: #1a1f2b;
  --dhm-body: #3f4756;
  --dhm-muted: #4a5568;
  --dhm-line: #d8dee7;
  --dhm-line-soft: #edf0f5;
  --dhm-surface: #ffffff;
  --dhm-wash: #f5f7fa;
  --dhm-tint: #eef3fa;
  --dhm-focus: #f2b705;
  --dhm-radius: 12px;

  /* Left-aligned under the breadcrumb, same as the original Data Hub's
     .data-catalog-wrapper (max-width 1300px, no auto-centering). Centering
     left a gap beside the sidebar on wide screens. */
  max-width: 1300px;
  margin: 0 0 120px;
  padding: 0;
  color: var(--dhm-ink);
}

.dhm [hidden] { display: none !important; }

.dhm-visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---- Header --------------------------------------------------------------- */

.dhm-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px 32px;
  margin: 1rem 0 1.75rem;
}

.dhm-header__text {
  flex: 1 1 520px;
  min-width: 0;
}

/* Same size/weight as .data-hub-page-title so the H1 matches the site's
   Desktop/H1 spec; left-aligned here to sit with the intro and stats. */
.dhm-title {
  margin: 0 0 .5rem;
  color: var(--dhm-navy);
  font-weight: 700;
  font-size: 3.5rem;
  line-height: 1.1;
}

.dhm-intro {
  margin: 0;
  max-width: 680px;
  font-size: 1.0625rem;
  line-height: 1.55;
  color: var(--dhm-body);
}

.dhm-stats {
  display: flex;
  gap: 12px;
  margin: 0;
}

.dhm-stat {
  background: var(--dhm-surface);
  border: 1px solid var(--dhm-line);
  border-radius: 10px;
  padding: 10px 18px;
  min-width: 120px;
}

.dhm-stat dt {
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--dhm-muted);
}

.dhm-stat dd {
  margin: 2px 0 0;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--dhm-navy);
}

/* ---- Toolbar (search + expand all) ----------------------------------------- */

.dhm-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.dhm-search {
  position: relative;
  flex: 1 1 360px;
  min-width: 0;
}

.dhm-search__icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--dhm-muted);
  pointer-events: none;
}

.dhm-search__input {
  width: 100%;
  height: 50px;
  padding: 0 16px 0 44px;
  border: 1px solid #b9c3d1;
  border-radius: 10px;
  background: var(--dhm-surface);
  font: inherit;
  font-size: 1rem;
  color: var(--dhm-ink);
}

.dhm-search__input::placeholder { color: #6b7280; }

.dhm-search__input:focus {
  outline: 3px solid var(--dhm-focus);
  outline-offset: 1px;
  border-color: var(--dhm-navy);
}

.dhm-result-count {
  margin: 12px 0 16px;
  font-size: .9rem;
  color: var(--dhm-muted);
}

/* ---- Buttons ---------------------------------------------------------------- */

.dhm-btn {
  box-sizing: border-box;   /* so width:100% includes padding and border */
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 10px;
  border: 1.5px solid transparent;
  font: inherit;
  font-size: .95rem;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}

.dhm-btn__size {
  font-weight: 400;
  opacity: .85;
}

.dhm-btn--primary {
  background: var(--dhm-navy);
  border-color: var(--dhm-navy);
  color: #fff;
}
.dhm-btn--primary:hover,
.dhm-btn--primary:focus-visible {
  background: var(--dhm-navy-dark);
  border-color: var(--dhm-navy-dark);
  color: #fff;
  text-decoration: none;
}

.dhm-btn--outline {
  background: var(--dhm-surface);
  border-color: var(--dhm-navy);
  color: var(--dhm-navy);
}
.dhm-btn--outline:hover,
.dhm-btn--outline:focus-visible {
  background: var(--dhm-tint);
  color: var(--dhm-navy-dark);
  text-decoration: none;
}

.dhm-btn--quiet {
  height: 50px;
  background: var(--dhm-surface);
  border-color: #b9c3d1;
  color: var(--dhm-ink);
}
.dhm-btn--quiet:hover { background: var(--dhm-wash); }
.dhm-btn--quiet:disabled { opacity: .5; cursor: default; }

.dhm-btn:focus-visible,
.dhm-toggle:focus-visible,
.dhm-link-btn:focus-visible {
  outline: 3px solid var(--dhm-focus);
  outline-offset: 2px;
}

/* ---- Dataset cards ---------------------------------------------------------- */

.dhm-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.dhm-card {
  background: var(--dhm-surface);
  border: 1px solid var(--dhm-line);
  border-radius: var(--dhm-radius);
  box-shadow: 0 1px 2px rgba(16, 24, 40, .05);
  /* No overflow:hidden here: it would clip the Download menu. The data
     dictionary panel rounds its own bottom corners instead. */
}

.dhm-card.is-open {
  border-color: #b9c3d1;
  box-shadow: 0 4px 14px rgba(16, 24, 40, .08);
}

.dhm-card__top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px 24px;
  padding: 22px 24px 16px;
}

.dhm-card__text {
  flex: 1 1 440px;
  min-width: 0;
}

.dhm-card__title {
  margin: 0 0 6px;
  font-size: 1.3rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--dhm-navy);
}

.dhm-card__desc {
  margin: 0;
  font-size: .95rem;
  line-height: 1.55;
  color: var(--dhm-body);
}

.dhm-card__desc a,
.dhm-table__desc a {
  color: #0b5cad;
  font-weight: 600;
  text-decoration: underline;
}
.dhm-card__desc a:hover,
.dhm-table__desc a:hover { color: #063f7a; }

.dhm-card__desc--empty {
  font-style: italic;
  color: var(--dhm-muted);
}

.dhm-card__downloads {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.dhm-card__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 20px;
  padding: 10px 24px;
  border-top: 1px solid var(--dhm-line-soft);
  font-size: .875rem;
  color: var(--dhm-muted);
}

.dhm-card__meta strong { color: var(--dhm-ink); }

/* Data dictionary toggle */
.dhm-toggle {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  background: var(--dhm-tint);
  color: var(--dhm-navy);
  font: inherit;
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
}
.dhm-toggle:hover { background: #e0e9f5; }

.dhm-toggle__icon { transition: transform .2s ease; }
.dhm-toggle[aria-expanded="true"] .dhm-toggle__icon { transform: rotate(180deg); }

/* ---- Data dictionary table ------------------------------------------------------ */

.dhm-fields {
  border-top: 1px solid var(--dhm-line);
  background: #fafbfd;
  padding: 4px 24px 20px;
  border-radius: 0 0 var(--dhm-radius) var(--dhm-radius);
}

.dhm-fields__scroll {
  overflow-x: auto;
  max-height: 520px;
  overflow-y: auto;
}

.dhm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}

.dhm-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #fafbfd;
  text-align: left;
  padding: 14px 12px 10px;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--dhm-muted);
  border-bottom: 1px solid var(--dhm-line);
  white-space: nowrap;
}

.dhm-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--dhm-line-soft);
  vertical-align: top;
}

.dhm-table th:first-child,
.dhm-table td:first-child { padding-left: 0; }

.dhm-table__field {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .8125rem;
  font-weight: 600;
  color: var(--dhm-ink);
  white-space: nowrap;
}

.dhm-table__desc {
  color: var(--dhm-body);
  line-height: 1.45;
  min-width: 260px;
}

/* Field type badges — grouped so similar types share a color.
   All pairs meet 4.5:1 contrast. */
.dhm-type {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .02em;
  white-space: nowrap;
}
.dhm-type--text   { background: #eef3fa; color: #1f3a68; }
.dhm-type--number { background: #e7f5ee; color: #155b3a; }
.dhm-type--date   { background: #f3ecfb; color: #5b2e91; }
.dhm-type--bool   { background: #fff4cc; color: #6a4a00; }
.dhm-type--geo    { background: #e6f4f7; color: #0d5463; }
.dhm-type--other  { background: #f1f4f8; color: #3f4756; }

/* ---- Empty states ---------------------------------------------------------------- */

.dhm-empty {
  margin-top: 8px;
  padding: 40px 24px;
  text-align: center;
  background: var(--dhm-surface);
  border: 1px dashed #b9c3d1;
  border-radius: var(--dhm-radius);
  color: var(--dhm-body);
}

.dhm-empty p { margin: 0; }

.dhm-empty__title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--dhm-ink);
  margin-bottom: 6px !important;
}

.dhm-link-btn {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: #0b5cad;
  text-decoration: underline;
  cursor: pointer;
}

/* ---- Download menu (District/County filters + CSV/Excel) ------------------- */

.dhm-dl {
  position: relative;
  flex: none;
}

.dhm-dl__chevron {
  font-size: .75em;
  transition: transform .2s ease;
}
.dhm-dl.is-open .dhm-dl__chevron { transform: rotate(180deg); }

.dhm-dl__panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 20;
  width: 300px;
  padding: 16px;
  background: var(--dhm-surface);
  border: 1px solid var(--dhm-line);
  border-radius: var(--dhm-radius);
  box-shadow: 0 12px 32px rgba(16, 24, 40, .16);
}

.dhm-dl__heading {
  margin: 0 0 10px;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--dhm-navy);
}

.dhm-dl__field {
  display: block;
  margin: 0 0 10px;
}

.dhm-dl__field span {
  display: block;
  margin-bottom: 4px;
  font-size: .8125rem;
  font-weight: 600;
  color: var(--dhm-ink);
}

.dhm-dl__field select {
  width: 100%;
  min-height: 44px;
  padding: 0 10px;
  border: 1px solid #b9c3d1;
  border-radius: 8px;
  background: var(--dhm-surface);
  font: inherit;
  font-size: .9375rem;
  color: var(--dhm-ink);
}

.dhm-dl__field select:focus-visible {
  outline: 3px solid var(--dhm-focus);
  outline-offset: 1px;
}

.dhm-dl__hint {
  margin: 0;
  font-size: .8125rem;
  line-height: 1.45;
  color: var(--dhm-muted);
}

.dhm-dl__rule {
  margin: 14px 0 8px;
  border: 0;
  border-top: 1px solid var(--dhm-line-soft);
}

.dhm-dl__items {
  display: flex;
  flex-direction: column;
}

.dhm-dl__item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 10px;
  margin: 0 -10px;
  border-radius: 8px;
  color: var(--dhm-ink);
  font-size: .9375rem;
  font-weight: 600;
  text-decoration: none;
}

.dhm-dl__item i {
  width: 18px;
  text-align: center;
  color: var(--dhm-navy);
}

.dhm-dl__item:hover,
.dhm-dl__item:focus-visible {
  background: var(--dhm-tint);
  color: var(--dhm-navy-dark);
  text-decoration: none;
}

.dhm-dl__item:focus-visible {
  outline: 3px solid var(--dhm-focus);
  outline-offset: 0;
}

.dhm-dl__size {
  margin-left: auto;
  font-weight: 400;
  font-size: .8125rem;
  color: var(--dhm-muted);
}

/* Sizes are for the full file; hide them once a filter is picked. */
.dhm-dl.is-filtered .dhm-dl__size { display: none; }

.dhm-dl.is-busy .dhm-dl__item {
  opacity: .55;
  pointer-events: none;
}

.dhm-dl__status {
  margin: 10px 0 0;
  font-size: .8125rem;
  line-height: 1.4;
  color: var(--dhm-muted);
  /* Long filenames have no spaces; let them wrap inside the menu. */
  overflow-wrap: anywhere;
  min-width: 0;
}
.dhm-dl__status:empty { display: none; }

/* Success / error / working states get a tinted box with a marker. */
.dhm-dl__status.is-success,
.dhm-dl__status.is-error,
.dhm-dl__status.is-busy {
  position: relative;
  padding: 8px 10px 8px 30px;
  border-radius: 8px;
}
.dhm-dl__status.is-success::before,
.dhm-dl__status.is-error::before,
.dhm-dl__status.is-busy::before {
  position: absolute;
  left: 10px;
  top: 8px;
  font-weight: 700;
}

.dhm-dl__status.is-success { background: #e7f5ee; color: #155b3a; }
.dhm-dl__status.is-success::before { content: "\2713"; }   /* check mark */

.dhm-dl__status.is-error { background: #fdecea; color: #b42318; }
.dhm-dl__status.is-error::before { content: "!"; left: 13px; }

.dhm-dl__status.is-busy { background: var(--dhm-tint); color: var(--dhm-navy); }
.dhm-dl__status.is-busy::before {
  content: "";
  top: 11px;
  width: 10px;
  height: 10px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: dhm-spin .8s linear infinite;
}
@keyframes dhm-spin { to { transform: rotate(360deg); } }

.dhm-dl__status-text {
  display: block;
  font-weight: 600;
}
.dhm-dl__status:not(.is-success):not(.is-error):not(.is-busy) .dhm-dl__status-text {
  font-weight: 400;
}

.dhm-dl__file {
  display: block;
  margin-top: 2px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .75rem;
  font-weight: 400;
  color: var(--dhm-body);
  /* Breaks come from <wbr> after each underscore; anywhere is only a
     fallback for a single piece too long for the menu. */
  overflow-wrap: anywhere;
}

.dhm-chip {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: #fff4cc;
  color: #6a4a00;
  font-size: .75rem;
  font-weight: 700;
}

/* ---- Search page (/search) -------------------------------------------------- */

.dhm-searchform {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 0 0 20px;
}

.dhm-searchform__field { flex: 1 1 360px; }

.dhm-searchform__submit {
  height: 50px;
  padding: 0 24px;
}

.dhm-chip--match {
  background: #e7f5ee;
  color: #155b3a;
}

/* Fields that contain a search word */
.dhm-table tr.is-match td {
  background: #fff8db;
}
.dhm-table tr.is-match td:first-child {
  box-shadow: inset 3px 0 0 #f2b705;
  padding-left: 10px;
}

.dhm-empty a,
.dhm-intro a {
  color: #0b5cad;
  font-weight: 600;
}

/* ---- Small screens ----------------------------------------------------------------- */

@media (max-width: 767.98px) {
  .dhm-title { font-size: 2.25rem; }
  .dhm-stats { width: 100%; }
  .dhm-stat { flex: 1 1 0; }
  .dhm-card__top,
  .dhm-card__meta { padding-left: 16px; padding-right: 16px; }
  .dhm-fields { padding-left: 16px; padding-right: 16px; }
  .dhm-dl { width: 100%; }
  .dhm-dl__toggle { width: 100%; justify-content: center; }
  .dhm-dl__panel { position: static; width: auto; margin-top: 8px; box-shadow: none; }
  .dhm-toggle { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .dhm-btn,
  .dhm-toggle__icon,
  .dhm-dl__chevron { transition: none; }
  .dhm-dl__status.is-busy::before { animation: none; }
}