/* CohortLoom free-20 explorer (#414). Components only: every colour, face, size and margin is a site.css token
   (the #407 design system), so the explorer follows the site in light and dark. Phone rules: 16px gutters come from
   --m; wide things (the timeline overview, tables) scroll or turn into cards inside their own frame, never the page. */
.explore > :last-child { padding-bottom: var(--sec); }
.x-synth { display: flex; flex-wrap: wrap; gap: 2px 10px; margin: 16px 0 0; padding: 10px 14px; background: var(--field-2); color: var(--field-2-ink); font: 500 var(--t-small)/1.4 var(--f-head); }
.x-synth strong { font-weight: 700; }
.x-dev { margin: 4px 0 0; padding: 10px 14px; background: var(--warm-bg); color: var(--warm); font: 500 var(--t-small)/1.4 var(--f-head); }
/* #430: the list page's Download button and the one-line cohort label under the intro */
.x-cta { margin: 16px 0 0; }
.x-cohort { margin: 12px 0 0; color: var(--muted, inherit); }
.x-dev code { background: none; padding: 0; color: inherit; overflow-wrap: anywhere; }
.x-nav ul { list-style: none; display: flex; flex-wrap: wrap; gap: 0 24px; margin: 8px 0 0; padding: 0; }
.x-nav li { margin: 0; }
.x-nav a { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; min-width: 44px; font: 600 var(--t-small)/1.2 var(--f-head); text-decoration: underline 2px transparent; text-underline-offset: 7px; }
.x-nav a:hover, .x-nav a[aria-current="page"] { text-decoration-color: currentColor; }
.explore .page-head.x-head { padding: clamp(28px, 4vw, 64px) 0 clamp(24px, 3vw, 40px); }
.explore .page-head.x-head h1 { margin-bottom: 20px; }
.x-crumb { font: 500 var(--t-small)/1.3 var(--f-head); margin: 0 0 8px; }
.x-crumb a { display: inline-flex; align-items: center; min-height: 44px; }
.x-section { padding: clamp(28px, 4vw, 56px) 0 0; min-width: 0; }
.x-section > h2 { font-size: clamp(1.5rem, 1rem + 1.2vw, 2.25rem); margin-bottom: 20px; }
.x-section h3 { margin: 28px 0 12px; }
.x-k { display: block; font: 600 var(--t-small)/1.3 var(--f-head); color: var(--muted); margin-bottom: 2px; }

/* filters and the patient cards */
.x-filterbox { margin: 0 0 16px; background: var(--surface); }
.x-filterbox[hidden] { display: none; }
.x-filterbox > summary { padding: 4px 16px; font: 600 var(--t-small)/1.3 var(--f-head); gap: 8px; }
.x-active { font-weight: 500; color: var(--muted); }
.x-filterbox .x-filters { padding: 4px 16px 16px; margin: 0; }
.x-filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 13.5rem), 1fr)); gap: 12px 16px; align-items: end; margin: 0 0 20px; }
.x-filters[hidden] { display: none; }
.x-field label { margin-bottom: 4px; }
.x-reset .btn { width: 100%; }
.x-count { font: 600 var(--t-small)/1.3 var(--f-head); color: var(--muted); margin: 0 0 12px; }
.x-cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr)); }
.x-cards li { margin: 0; min-width: 0; }
.x-cards li[hidden] { display: none; }
.x-card a { display: grid; gap: 4px; height: 100%; min-height: 44px; padding: 18px 20px; background: var(--surface); color: var(--ink); text-decoration: none; transition: background .15s ease; }
.x-card a:hover { background: var(--surface-2); }
.x-card strong { font: 700 var(--t-lead)/1.15 var(--f-head); letter-spacing: -.02em; }
.x-id { font: 600 var(--t-small)/1.2 var(--f-code); color: var(--muted); }
.x-meta { font: 500 var(--t-small)/1.35 var(--f-head); }
.x-probs { font-size: var(--t-small); color: var(--muted); line-height: 1.4; }
.x-empty { margin: 16px 0 0; }
.x-empty[hidden] { display: none; }

/* patient: overview, visits, notes */
.x-scroll { overflow-x: auto; overscroll-behavior-x: contain; background: var(--surface); padding: 14px 16px; max-width: 100%; scrollbar-width: thin; }
.x-scroll svg.x-overview { width: 100%; min-width: 960px; max-width: none; height: auto; }
svg.x-overview .label { font-size: 12px; }
.x-vdot { fill: var(--ink); }
.x-vnum { fill: var(--bg); font: 700 11px var(--f-head); pointer-events: none; }
svg.chart .x-med { fill: var(--muted); }
.x-before { margin: 16px 0 0; font-size: var(--t-small); }
.x-visits > li[id], .x-note[id] { scroll-margin-top: 24px; }
.x-num { font-variant-numeric: tabular-nums; }
.x-visits { list-style: none; margin: 20px 0 0; padding: 0; display: grid; gap: 4px; }
.x-visits > li { margin: 0; padding: 18px 20px; background: var(--surface); min-width: 0; }
.x-visits > li > :last-child { margin-bottom: 0; }
.x-visits h3 { margin: 0 0 6px; font-size: 1.25rem; }
.x-vn { color: var(--muted); }
.x-vmeta { font: 500 var(--t-small)/1.3 var(--f-head); color: var(--muted); margin: 0 0 8px; }
.x-reason { margin: 0 0 10px; }
.x-visits p { font-size: var(--t-small); line-height: 1.5; margin: 0 0 10px; }
.x-chip { display: inline-block; margin: 2px 0; padding: 3px 8px; background: var(--bg); }
.x-chip code, .x-codes code { background: none; padding: 0; font-weight: 600; }
.x-codes code + code { margin-left: 6px; }
.x-ev { margin: 0 0 10px; font-size: var(--t-small); }
.x-visits > li.x-between { background: none; border-left: 4px solid var(--line); padding: 10px 16px; }
.x-between h3 { font-size: 1rem; color: var(--muted); }
.x-badge { display: inline-block; padding: 2px 8px; border: 1px solid var(--ink); font: 600 var(--t-small)/1.3 var(--f-head); }
.x-badge { white-space: nowrap; }
.x-withheld > .x-badge { display: table; margin-bottom: 6px; white-space: normal; }
.x-visits p.x-withheld, .x-note > .x-withheld { font-size: var(--t-small); line-height: 1.5; }
.x-note > .x-withheld { padding: 0 16px; margin: 10px 0; }
.x-notelink { display: inline-flex; align-items: center; min-height: 44px; font: 600 var(--t-small)/1.2 var(--f-head); }
.x-charts { margin: 0; }
.x-figcap { font: 600 var(--t-small)/1.3 var(--f-head); color: var(--ink); margin: 0 0 8px; }
.chart-fig .x-figcap { margin-top: 0; }
.x-mini { font-size: var(--t-small); }
.x-mini th, .x-mini td { padding: 4px 8px 4px 0; font-variant-numeric: tabular-nums; }
.x-single { font-size: var(--t-small); margin: 16px 0 0; }
.x-table code { background: none; padding: 0; }
.x-notes { display: grid; gap: 4px; }
.x-note { background: var(--surface); }
.x-note > summary { gap: 10px; padding: 4px 16px; font: 600 var(--t-small)/1.3 var(--f-head); }
.x-note > summary .muted { font-weight: 500; }
.x-note > .x-codes { padding: 0 16px; font-size: var(--t-small); }
.x-notetext { margin: 0 4px 4px; padding: 14px 16px; background: var(--bg); white-space: pre-wrap; overflow-wrap: anywhere; font-size: .8125rem; line-height: 1.55; max-height: 70svh; overflow: auto; overscroll-behavior: contain; }
.x-pager { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-top: clamp(28px, 4vw, 56px); }
.x-pager a { display: grid; align-content: center; min-height: 64px; padding: 10px 16px; background: var(--surface); font: 600 var(--t-body)/1.2 var(--f-head); text-decoration: none; }
.x-pager a[rel="next"] { text-align: right; }
.x-pager a:hover { background: var(--surface-2); }

/* cohort charts: bar rows as a table (label, bar, value) */
.x-cohort { display: grid; gap: 4px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 26rem), 1fr)); }
.x-pairs { display: grid; gap: 4px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr)); }
.x-barfig { margin: 0; }
.x-bars { font-size: var(--t-small); }
.x-bars th { font-weight: 500; padding: 6px 12px 6px 0; width: 45%; overflow-wrap: anywhere; }
.x-bars th code { background: none; padding: 0; font-weight: 600; }
.x-bars td { padding: 6px 0; vertical-align: middle; }
.x-bar svg { display: block; width: 100%; height: 14px; }
.x-bar rect.s1-fill:hover { fill: var(--muted); }
.x-val { width: 3em; text-align: right; font: 600 var(--t-small)/1 var(--f-head); font-variant-numeric: tabular-nums; }

/* codes */
.x-codefilter { max-width: 28rem; margin: 0 0 8px; }
.x-codefilter[hidden] { display: none; }
.x-codefilter input { min-height: 48px; width: 100%; box-sizing: border-box; }
.x-codefilter p { margin: 6px 0 0; min-height: 1.4em; }
.x-chapter { margin: 0 0 28px; }
.x-chapter[hidden], .x-codetable tr[hidden] { display: none; }
.x-chh { font-size: 1.375rem; letter-spacing: -.02em; line-height: 1.15; margin: 0 0 10px; }
.x-chh span { display: block; font: 500 var(--t-small)/1.3 var(--f-head); letter-spacing: 0; color: var(--muted); margin-top: 4px; }
.x-codetable td a { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; min-width: 44px; font: 500 var(--t-small)/1 var(--f-code); }
.x-codetable tbody td:first-child { width: 12%; }

/* downloads */
.x-dl { list-style: none; padding: 0; margin: 0; }
.x-dl li { margin: 0 0 8px; }
.x-dl a { display: inline-flex; align-items: center; min-height: 44px; font: 600 var(--t-body)/1.2 var(--f-head); }
.x-dlgrid { display: grid; gap: 0 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 13rem), 1fr)); }

@media (max-width: 640px) {
  .x-synth { margin-top: 8px; }
  .x-nav ul { gap: 0 18px; }
  .x-visits > li { padding: 14px 16px; }
  .x-bars tr { display: grid; grid-template-columns: minmax(0, 1fr) 3em; column-gap: 8px; padding: 4px 0; }
  .x-bars th { grid-column: 1 / -1; width: auto; padding: 0 0 2px; }
  .x-bars td { padding: 0; }
  .x-val { width: auto; }
  .x-table td[data-label]::before { content: attr(data-label) ": "; font: 600 var(--t-small)/1.3 var(--f-head); color: var(--muted); }
  .x-codetable tbody td:first-child { width: auto; }
  .x-pager a { min-height: 56px; }
}
.x-licence { margin: 16px 0 0; }
.x-licence code { overflow-wrap: anywhere; }
