/*
   OpenData directory pages (/us, states, counties, places, offices). Loaded after site.css (the shared
   header, footer, buttons, forms and icons) and uses its tokens. Everything works without JavaScript:
   locate.js adds "Use my location" to /us, and the list filter only hides entries that are all in the
   page.
*/
:root {
    --dp-fresh: #1f7a4d;
    --dp-aging: #9a5b00;
    --dp-stale: #b42318;
    --dp-unknown: #7a8496;
    --dp-badge-bg: #f1f4f8;
    --dp-tile-code: #1e3a8a;
}

/* Dark: the system setting unless the visitor chose light, or the visitor's own choice (html[data-theme]). */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --dp-fresh: #5ad48a;
        --dp-aging: #f4b860;
        --dp-stale: #ff8f86;
        --dp-unknown: #8c97a9;
        --dp-badge-bg: #1d2836;
        --dp-tile-code: #a9c8fd;
    }
}
:root[data-theme="dark"] {
    --dp-fresh: #5ad48a;
    --dp-aging: #f4b860;
    --dp-stale: #ff8f86;
    --dp-unknown: #8c97a9;
    --dp-badge-bg: #1d2836;
    --dp-tile-code: #a9c8fd;
}

.dp-page { --toc-h: 3.25rem; }
.dp-page p, .dp-page li { max-width: none; }
.dp-muted { color: var(--muted); }

/* Hero: breadcrumbs, name, actions; on /us "Find my governments" sits beside it on wide screens. */
.dp-hero { display: grid; gap: 1.5rem; padding: 1.25rem 0 1.75rem; }
.dp-hero h1 { margin: .9rem 0 .5rem; overflow-wrap: anywhere; }
.dp-subtitle { max-width: 42rem; margin: 0; color: var(--muted); font-size: 1.125rem; line-height: 1.5; }
.dp-hero .button-row { margin-top: 1.5rem; }
@media (min-width: 62rem) {
    .dp-hero-split { grid-template-columns: minmax(0, 1fr) minmax(0, 25rem); gap: 3rem; align-items: start; padding-top: 1.75rem; }
    .dp-hero-split .dp-hero-main { padding-top: .5rem; }
}

/* Breadcrumbs */
.dp-crumbs { font-size: .875rem; }
.dp-crumbs ol { display: flex; flex-wrap: wrap; gap: .2rem 0; margin: 0; padding: 0; list-style: none; }
.dp-crumbs li { display: inline-flex; align-items: center; color: var(--muted); }
.dp-crumbs li + li::before { content: ""; width: .38rem; height: .38rem; margin: 0 .6rem 0 .45rem; border-top: 1.5px solid var(--subtle); border-right: 1.5px solid var(--subtle); transform: rotate(45deg); }
.dp-crumbs a { color: var(--muted); }
.dp-crumbs a:hover { color: var(--accent); }

/* Key figures: one bordered strip, hairlines between the figures, wrapping on small screens. */
.dp-hero .dp-stats { margin-top: 2rem; }
.dp-stats { display: flex; flex-wrap: wrap; gap: 1px; margin: 0; overflow: hidden; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.dp-stats > div { flex: 1 1 10rem; padding: 1rem 1.25rem 1.1rem; background: var(--surface); }
@media (min-width: 62rem) { .dp-hero-split .dp-stats > div { flex-basis: 40%; } }
.dp-stats dt { color: var(--muted); font-size: .8125rem; font-weight: 550; }
.dp-stats dd { margin: .3rem 0 0; font-size: 1.375rem; font-weight: 700; letter-spacing: -.015em; line-height: 1.2; font-variant-numeric: tabular-nums; }
.dp-stats dd.dp-stat-note { margin-top: .15rem; color: var(--muted); font-size: .8125rem; font-weight: 500; letter-spacing: 0; }
.dp-stat-release dd:first-of-type { font-size: 1.125rem; padding-top: .3rem; }
.dp-stats-compact dd { font-size: 1.375rem; }

/* "On this page": sticky under the header on wide screens, a scrolling row on narrow ones. */
.dp-toc { position: relative; z-index: 10; margin: 1.5rem -1rem 0; padding: 0 1rem; background: var(--bg); border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.dp-toc::-webkit-scrollbar { display: none; }
.dp-toc ul { display: flex; gap: .25rem; margin: 0; padding: 0; list-style: none; }
.dp-toc a { display: inline-flex; align-items: center; gap: .45rem; padding: .85rem .6rem; color: var(--muted); font-size: .9375rem; font-weight: 550; white-space: nowrap; text-decoration: none; }
.dp-toc a:hover { color: var(--text); }
.dp-toc-count { padding: 0 .4rem; border-radius: var(--radius-sm); background: var(--dp-badge-bg); color: var(--muted); font-size: .75rem; font-weight: 600; line-height: 1.5; font-variant-numeric: tabular-nums; }
/* One line at every width (it scrolls sideways when the sections do not fit), so the sticky bar stays
   the height scroll-margin-top allows for and never covers the heading a link jumps to. */
@media (min-width: 48rem) {
    .dp-toc { position: sticky; top: 0; margin: 2rem 0 0; padding: 0; }
}

/* Sections */
.dp-section { margin-top: 2.75rem; scroll-margin-top: calc(var(--toc-h) + 1rem); }
.dp-section > h2 { display: flex; align-items: baseline; flex-wrap: wrap; gap: .6rem; margin: 0 0 1rem; font-size: 1.5rem; }
.dp-count { color: var(--muted); font-size: 1rem; font-weight: 500; letter-spacing: 0; font-variant-numeric: tabular-nums; }
.dp-group[hidden], [data-filter-item][hidden] { display: none !important; }
.dp-letter, .dp-set { scroll-margin-top: calc(var(--toc-h) + 1rem); }
.dp-letter { margin: 1.5rem 0 .5rem; padding-bottom: .35rem; border-bottom: 1px solid var(--line); color: var(--muted); font-size: .9375rem; font-weight: 700; }
.dp-set { margin: 1.5rem 0 .75rem; font-size: 1rem; font-weight: 650; }
.dp-group:first-of-type .dp-set { margin-top: .25rem; }

/* The filter and the A–Z row */
.dp-filter { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem; margin: 0 0 1rem; }
.dp-filter[hidden] { display: none; }
.dp-filter-field { position: relative; flex: 1 1 18rem; max-width: 28rem; }
.dp-filter-field .ic { position: absolute; left: .75rem; top: 50%; margin-top: -.5em; color: var(--subtle); pointer-events: none; }
.dp-filter-field input { max-width: none; padding-left: 2.25rem; }
.dp-filter select { width: auto; max-width: 16rem; }
.dp-filter-status { margin: 0; color: var(--muted); font-size: .875rem; font-variant-numeric: tabular-nums; }
.dp-filter-status:empty { display: none; }
.dp-filter-empty { margin: 1rem 0 0; padding: 1rem 1.25rem; border: 1px dashed var(--line-strong); border-radius: var(--radius); color: var(--muted); }
.dp-jump { display: flex; flex-wrap: wrap; gap: .25rem; margin: 0 0 .5rem; padding: 0; list-style: none; }
.dp-jump[hidden] { display: none; }
.dp-jump a { display: inline-flex; align-items: center; justify-content: center; min-width: 2rem; height: 2rem; padding: 0 .35rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font-size: .875rem; font-weight: 600; text-decoration: none; }
.dp-jump a:hover { border-color: var(--accent); color: var(--accent); }

/* Office rows: name and type, contacts on one line where they fit, freshness at the end. */
.dp-rows { margin: 0; padding: 0; list-style: none; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.dp-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: .4rem; padding: .9rem 1.1rem; border-top: 1px solid var(--line); }
.dp-row:first-child { border-top: 0; }
.dp-row-title { margin: 0; font-size: 1rem; font-weight: 650; line-height: 1.35; letter-spacing: -.005em; overflow-wrap: anywhere; }
.dp-row-title a { color: var(--accent); text-decoration: none; }
.dp-row-title a:hover { color: var(--accent); text-decoration: underline; }
.dp-row-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .6rem; margin: .3rem 0 0; color: var(--muted); font-size: .875rem; }
.dp-badge { display: inline-block; padding: .05rem .45rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--dp-badge-bg); color: var(--muted); font-size: .75rem; font-weight: 600; line-height: 1.6; }
.dp-row-contact { display: flex; flex-wrap: wrap; gap: .3rem 1.25rem; margin: 0; font-size: .9375rem; }
.dp-row-contact > div { display: flex; align-items: baseline; gap: .45rem; min-width: 0; }
.dp-row-contact dt { flex: none; color: var(--subtle); }
/* A contact's label: its icon on screen, its word for screen readers (the text is indented out of view). */
.dp-ci { align-self: center; width: .95rem; height: .95rem; overflow: hidden; white-space: nowrap; text-indent: 110%; background: currentColor; -webkit-mask: var(--i) center / contain no-repeat; mask: var(--i) center / contain no-repeat; }
.dp-row-contact dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.dp-row-positions dt { color: var(--muted); }
.dp-row-none { margin: 0; color: var(--muted); font-size: .9375rem; }
@media (min-width: 48rem) {
    .dp-row { grid-template-columns: minmax(0, 1fr) auto; column-gap: 1.5rem; padding: 1rem 1.25rem; }
    .dp-row-main { grid-column: 1; }
    .dp-row > .dp-fresh { grid-column: 2; grid-row: 1; align-self: start; justify-self: end; margin-top: .15rem; }
    .dp-row-contact, .dp-row-none { grid-column: 1 / -1; }
}

/* Freshness: a shape and a word, never colour alone; quiet next to the contacts. */
.dp-fresh { display: inline-flex; align-items: center; gap: .4rem; margin: 0; color: var(--muted); font-size: .8125rem; white-space: nowrap; }
.dp-fresh-mark { flex: none; width: .5rem; height: .5rem; border-radius: 50%; border: 1.5px solid var(--dp-unknown); }
.dp-fresh-fresh .dp-fresh-mark { background: var(--dp-fresh); border-color: var(--dp-fresh); }
.dp-fresh-aging .dp-fresh-mark { background: linear-gradient(90deg, var(--dp-aging) 50%, transparent 50%); border-color: var(--dp-aging); }
.dp-fresh-stale .dp-fresh-mark { border-radius: 1px; background: var(--dp-stale); border-color: var(--dp-stale); }
.dp-lead .dp-fresh, .dp-card .dp-fresh { margin-top: .9rem; white-space: normal; }

/* The jurisdiction's own government, an office's contact card */
.dp-lead { padding: 1.25rem 1.4rem; background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: var(--radius-lg); }
.dp-lead h3 { margin: 0; font-size: 1.1875rem; overflow-wrap: anywhere; }
.dp-lead h3 a { color: var(--text); text-decoration: none; }
.dp-lead h3 a:hover { color: var(--accent); text-decoration: underline; }
.dp-contact { display: grid; grid-template-columns: 8rem minmax(0, 1fr); gap: .45rem 1rem; margin: 1rem 0 0; font-size: .9375rem; }
.dp-contact > div { display: contents; }
.dp-contact dt { color: var(--muted); }
.dp-contact dd { margin: 0; overflow-wrap: anywhere; }
.dp-lead > .dp-muted { margin: .75rem 0 0; }

/* Officials and governments */
.dp-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 20rem), 1fr)); gap: 1rem; margin: 0; padding: 0; list-style: none; }
.dp-card { padding: 1.1rem 1.25rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.dp-card h3 { margin: 0; font-size: 1.0625rem; }
.dp-card .dp-contact { grid-template-columns: 7rem minmax(0, 1fr); }
.dp-card p { margin: .35rem 0 0; }
.dp-person { display: flex; gap: .6rem; align-items: flex-start; margin: 0 !important; font-size: 1.0625rem; }
.dp-person > .ic { margin-top: .3rem; color: var(--subtle); }
.dp-person-role { display: block; color: var(--muted); font-size: .9375rem; }
.dp-note { color: var(--dp-aging); font-size: .9375rem; }

/* State tiles: the postal code is the handle a reader scans for. */
.dp-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 10.5rem), 1fr)); gap: .625rem; margin: 0; padding: 0; list-style: none; }
.dp-tile { display: flex; flex-direction: column; height: 100%; padding: .85rem 1rem .95rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: var(--text); text-decoration: none; }
.dp-tile:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.dp-tile:hover .dp-tile-name { color: var(--accent); }
.dp-tile-code { color: var(--dp-tile-code); font-size: 1.625rem; font-weight: 800; letter-spacing: .02em; line-height: 1.05; font-variant-numeric: tabular-nums; }
.dp-tile-name { margin-top: .45rem; font-size: .9375rem; font-weight: 650; line-height: 1.3; }
.dp-tile-meta { margin-top: .15rem; color: var(--muted); font-size: .8125rem; line-height: 1.4; font-variant-numeric: tabular-nums; }

/* Lists of counties and places */
.dp-index { columns: 3 14rem; column-gap: 2rem; margin: 0; padding: 0; list-style: none; }
.dp-index li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0 .75rem; break-inside: avoid; padding: .45rem 0; border-bottom: 1px solid var(--line); }
.dp-index a { font-weight: 550; text-decoration: none; }
.dp-index a:hover { text-decoration: underline; }
.dp-index .dp-muted { font-size: .8125rem; font-variant-numeric: tabular-nums; }

/* "Find my governments" on /us: a plain GET form, its answer below it. */
.dp-locate { padding: 1.35rem 1.4rem 1.4rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: 0 1px 2px rgb(15 23 41 / .04), 0 12px 32px -20px rgb(15 23 41 / .25); scroll-margin-top: 1rem; }
.dp-locate > h2 { display: flex; align-items: center; gap: .55rem; margin: 0 0 .35rem; font-size: 1.1875rem; }
.dp-locate > h2 .ic { color: var(--accent); }
.dp-locate-intro { margin: 0 0 1rem; color: var(--muted); font-size: .9375rem; }
.dp-locate-geo[hidden] { display: none; }
.dp-locate-me { width: 100%; }
.dp-locate-or { display: flex; align-items: center; gap: .75rem; margin: 1rem 0 .25rem; color: var(--muted); font-size: .8125rem; }
.dp-locate-or::before, .dp-locate-or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.dp-locate-fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 .75rem; align-items: end; }
.dp-locate-fields label { margin: .75rem 0 .3rem; font-size: .875rem; }
.dp-locate-fields input[type=text] { max-width: none; font-variant-numeric: tabular-nums; }
.dp-locate-find { grid-column: 1 / -1; margin-top: .85rem; }
[data-geo] .dp-locate-find { background: var(--surface); border-color: var(--line-strong); color: var(--text); }
[data-geo] .dp-locate-find:hover { background: var(--surface-2); border-color: var(--subtle); color: var(--text); }
.dp-locate-note { display: flex; gap: .5rem; margin: 1rem 0 0; color: var(--muted); font-size: .8125rem; line-height: 1.5; }
.dp-locate-note .ic { margin-top: .2rem; color: var(--subtle); }
.dp-locate-status:empty { display: none; }
.dp-locate-status, .dp-locate-message { margin: .85rem 0 0; font-size: .9375rem; font-weight: 600; }
.dp-locate-message { padding: .65rem .85rem; border-radius: var(--radius); background: var(--err-bg); color: var(--err-fg); }
.dp-locate-result { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.dp-locate-result h3 { margin: 0; font-size: 1rem; font-variant-numeric: tabular-nums; }
.dp-locate-result .dp-contact { grid-template-columns: 7rem minmax(0, 1fr); }
.dp-locate-result .button-row { margin-top: 1rem; }

/* The page's line in the site footer */
.site-footer-meta .dp-footer { max-width: 46rem; }

@media (max-width: 30rem) {
    .dp-contact, .dp-card .dp-contact, .dp-locate-result .dp-contact { grid-template-columns: 1fr; gap: 0; }
    .dp-contact dd { margin-bottom: .5rem; }
    .dp-lead, .dp-locate { padding: 1.1rem; }
    .dp-hero .button-row .button { flex: 1 1 auto; }
    .dp-stats > div { padding: .85rem 1rem; }
    .dp-stats dd { font-size: 1.3125rem; }
}

@media (forced-colors: active) {
    .dp-fresh-mark { forced-color-adjust: none; }
    .dp-ci { forced-color-adjust: none; background: CanvasText; }
}

@media print {
    .dp-rows, .dp-lead, .dp-card, .dp-tile, .dp-stats { border-color: #999; }
}
