/* T-5059, T-5082: the explorer page around the Portal's data view (explorer/explorer.css). These
   rules name this page's own elements only, so they never restyle the view's table or controls.
   Light by default, dark by the reader's system or `&theme=dark`. */
:root { color-scheme: light; --bg: #fff; --fg: #0f172a; --muted: #475569; --line: #cbd5e1; --soft: #f1f5f9; --accent: #1d4ed8; --err-bg: #fef2f2; --err: #991b1b; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { color-scheme: dark; --bg: #0b1220; --fg: #e2e8f0; --muted: #a3b1c6; --line: #334155; --soft: #142033; --accent: #93c5fd; --err-bg: #3b1219; --err: #fecaca; }
}
:root[data-theme="dark"] { color-scheme: dark; --bg: #0b1220; --fg: #e2e8f0; --muted: #a3b1c6; --line: #334155; --soft: #142033; --accent: #93c5fd; --err-bg: #3b1219; --err: #fecaca; }
[hidden] { display: none !important; }
/* T-5415: the page's own background on the root too: the view's stylesheet paints the root the
   Portal's grey, which showed as a second panel inside the catalogue's white card. */
html, body { background: var(--bg); }
/* The view honours `&theme=light` on a dark device (explorer.css); on a light device it follows the
   device alone, so with `&theme=dark` the root keeps the view's ground and its text stays readable. */
@media (prefers-color-scheme: light) { :root[data-theme="dark"], :root[data-theme="dark"] body { background: var(--portal-bg, var(--bg)); } }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--fg); background: var(--bg); }
main { padding: 12px 16px 16px; }
.inline main { padding: 0 2px 8px; }
.page-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.inline .page-head { justify-content: flex-end; }
/* T-5415: Data API and Embed as one row of equal buttons, full width on a phone. */
@media (max-width: 600px) {
  .page-head .actions { flex: 1 1 100%; flex-wrap: nowrap; gap: 8px; }
  .page-head .actions .page-button { flex: 1 1 0; min-width: 0; }
}
.inline #title { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
#title { font-size: 1.15rem; margin: 0; }
#map-title { font-size: 1rem; margin: 16px 0 6px; }
.hint { color: var(--muted); font-size: 0.85rem; margin: 2px 0 0; }
.page-button { font: inherit; min-height: 44px; padding: 8px 14px; border-radius: 6px; border: 1px solid var(--line); background: var(--soft); color: var(--fg); cursor: pointer; }
.page-button:focus-visible, dialog a:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.status { margin: 10px 0 4px; color: var(--muted); }
.status:empty { display: none; }
.status.error { padding: 10px 12px; border-radius: 8px; background: var(--err-bg); color: var(--err); }
#map { height: 420px; border: 1px solid var(--line); border-radius: 8px; }
@media (max-width: 600px) { #map { height: 300px; } }
#detail, #embed { max-width: min(40rem, calc(100vw - 32px)); width: 100%; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--fg); padding: 16px; box-sizing: border-box; }
#detail::backdrop, #embed::backdrop { background: rgba(15, 23, 42, 0.5); }
dialog a { color: var(--accent); overflow-wrap: break-word; }
.detail-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.detail-head h2 { margin: 0; font-size: 1rem; overflow-wrap: anywhere; }
/* DM-135 (T-5231): the row card a reader opens from the table or the map. */
.detail-head > div { min-width: 0; }
.card-type { margin: 0 0 2px; color: var(--muted); font-size: 0.8rem; font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase; }
.detail-head h2 { font-size: 1.2rem; line-height: 1.3; }
.card-map { height: 180px; margin: 12px 0 4px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.card-onmap { min-height: 44px; margin: 4px 0 0; }
.card-list { margin: 12px 0 0; }
.card-row { display: grid; grid-template-columns: minmax(7rem, 38%) 1fr; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.card-row:first-child { border-top: 0; }
.card-list dt { color: var(--muted); }
.card-list dd { margin: 0; overflow-wrap: anywhere; }
.card-list a, .card-source a { display: inline-flex; align-items: center; min-height: 44px; }
@media (max-width: 480px) { .card-row { grid-template-columns: 1fr; gap: 2px; } }
.card-source { margin: 8px 0 0; padding-top: 8px; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.9rem; }
.card-dev { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 4px; }
.card-dev summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; color: var(--muted); font-weight: 600; }
.card-dev summary:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.card-dev .card-list dd { font-family: ui-monospace, monospace; font-size: 0.85rem; }
#detail h3 { font-size: 0.95rem; margin: 12px 0 4px; }
#detail ul { margin: 0; padding-left: 1.2rem; }
#detail li { min-height: 44px; display: flex; align-items: center; }
/* T-5129: the Embed dialog and an embed's source line. */
#embed { max-width: min(48rem, calc(100vw - 32px)); }
.page-button.primary { background: var(--accent); border-color: var(--accent); color: var(--bg); }
.page-button:disabled { opacity: 0.55; cursor: not-allowed; }
.embed-form { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 8px 0; }
.embed-form .field { flex: 1 1 12rem; min-width: 0; margin: 0; display: flex; flex-direction: column; gap: 2px; }
.embed-form .wide { flex-basis: 100%; }
fieldset.field { border: 0; padding: 0; }
.embed-form legend, .embed-form label, label[for="embed-code"] { font-weight: 600; }
.embed-form .check { font-weight: normal; display: inline-flex; align-items: center; gap: 6px; min-height: 44px; }
.embed-form select, .embed-form input[type="number"] { font: inherit; min-height: 44px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--fg); box-sizing: border-box; max-width: 100%; }
.embed-form input[type="checkbox"], .embed-form input[type="radio"] { width: 20px; height: 20px; }
.embed-form :focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.embed-form [aria-invalid="true"] { border-color: var(--err); }
textarea { font: 0.85rem/1.4 ui-monospace, monospace; width: 100%; box-sizing: border-box; color: var(--fg); background: var(--soft); border: 1px solid var(--line); border-radius: 6px; padding: 8px; margin: 4px 0 8px; resize: vertical; }
textarea:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; }
.actions a { min-height: 44px; display: inline-flex; align-items: center; }
.attribution { margin: 0 0 10px; padding-bottom: 8px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 0.85rem; }
.attribution a { color: var(--accent); }
/* T-5192, T-5231: in a frame as tall as its content, a modal opens in the middle of the slice the
   reader sees (the host page posts it as --jc-vv-top/--jc-vv-height); alone in a tab both fall back
   to the window. Centred by its middle, never taller than the slice less 16 px each side, so its top
   never rises above the slice; auto inline margins centre it across the frame (the Portal's preflight
   zeroes every margin, which pinned it to the left edge). */
#detail, #embed { position: fixed; inset-block: calc(var(--jc-vv-top, 0px) + var(--jc-vv-height, 100dvh) / 2) auto; inset-inline: 0; transform: translateY(-50%); margin: 0 auto; max-height: calc(var(--jc-vv-height, 100dvh) - 32px); overflow: auto; overscroll-behavior: contain; }
.jc-grid-detail { position: fixed; inset-block-start: calc(var(--jc-vv-top, 0px) + 16px); margin-block: 0; max-height: calc(var(--jc-vv-height, 100dvh) - 32px); overflow: auto; }
@media (max-width: 639px) {
  .jc-grid-detail { inset-block-start: var(--jc-vv-top, 0px); height: var(--jc-vv-height, 100dvh); max-height: var(--jc-vv-height, 100dvh); }
}
.card-dev summary::before { content: "\25B8"; margin-inline-end: 8px; }
.card-dev[open] summary::before { content: "\25BE"; }
/* T-5233: the map's count line, its Mapa panel, the reader's chips and the legend. */
.map-head { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; margin: 16px 0 6px; }
.map-head #map-title { margin: 0; }
.map-panel { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 0 0 8px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--soft); }
.map-panel h3 { flex-basis: 100%; margin: 0; font-size: 1rem; font-weight: 600; }
.map-panel .field { flex: 1 1 14rem; min-width: 0; margin: 0; display: flex; flex-direction: column; gap: 2px; border: 0; padding: 0; }
.map-panel .wide { flex-basis: 100%; }
.map-panel label, .map-panel legend { font-weight: 600; }
.map-panel .check { font-weight: normal; display: inline-flex; align-items: center; gap: 6px; min-height: 44px; margin-inline-end: 16px; }
.map-panel .checks { display: flex; flex-wrap: wrap; }
.map-panel select { font: inherit; min-height: 44px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--fg); max-width: 100%; }
.map-panel input[type="checkbox"] { width: 20px; height: 20px; }
.map-panel :focus-visible, .chip:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.map-chips { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; }
.map-chips:empty, .map-chips:has(#map-chips:empty) { display: none; }
#map-chips { display: contents; }
.chip { font: inherit; font-size: 0.9rem; min-height: 44px; padding: 4px 12px; border-radius: 999px; border: 1px solid var(--accent); background: var(--bg); color: var(--fg); cursor: pointer; }
.map-fallback { margin: 4px 0; }
.map-box { position: relative; margin-top: 6px; }
.map-count { position: absolute; top: 8px; left: 8px; z-index: 2; margin: 0; padding: 4px 10px; max-width: calc(100% - 64px); border-radius: 6px; background: var(--bg); color: var(--fg); border: 1px solid var(--line); font-size: 0.85rem; box-shadow: 0 1px 3px rgb(0 0 0 / 0.15); }
.map-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; list-style: none; margin: 6px 0 0; padding: 0; font-size: 0.9rem; }
.map-legend li { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 12px; height: 12px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); }
.map-bubble { font: 0.85rem/1.4 system-ui, sans-serif; color: #0f172a; }
.map-bubble strong { display: block; margin-bottom: 2px; }
.map-bubble .muted { color: #475569; }
