/* Blood tests (26 Nov 2026). Loaded last. Same type scale, 4px spacing and hairlines as the rest of the page;
   the square stays the mark for a result in range, a circle marks one raised or above target, a diamond one outside
   the normal range, so the colour is never the only clue (29 Nov 2026). */

.hd {
  /* strong enough to see against the page: at least 3:1 in both themes (the earlier 50% tint was 1.8:1 on white) */
  --hd-bt-ok: var(--hd-c5);
  --hd-bt-warn: color-mix(in srgb, var(--color-warn) 80%, var(--color-fg));
}

/* words for screen readers only */
.hd-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- Key: one shape per status ---------- */
.hd-bt-sw { width: 10px; height: 10px; }
.hd-bt-sw--ok { background: var(--hd-bt-ok); }
.hd-bt-sw--warn { background: var(--hd-bt-warn); border-radius: 50%; }
.hd-bt-sw--bad { background: var(--color-bad); transform: rotate(45deg) scale(.84); }
.hd-bt-sw--none { box-shadow: inset 0 0 0 1px var(--color-fg-muted); }
.hd-tip .hd-bt-tipsw.is-warn { border-radius: 50%; }
.hd-tip .hd-bt-tipsw.is-bad { transform: rotate(45deg) scale(.84); }
.hd-tip .hd-bt-tipsw.is-none { box-shadow: inset 0 0 0 1px currentColor; }

/* ---------- Every result, by test day ---------- */
.hd-bt-days { min-height: 160px; }
.hd-bt-sq { transition: opacity .15s; }
.hd-bt-days svg.is-hovering .hd-bt-sq:not(.is-hot) { opacity: .2; }
.hd-bt-sq.is-hot { stroke: var(--color-fg); stroke-width: 1.5px; }
.hd-bt-col.is-hot .hd-bt-sq { opacity: 1 !important; }
.hd-bt-colbg { fill: transparent; }
.hd-bt-col.is-hot .hd-bt-colbg { fill: var(--hd-soft); }
.hd-bt-overlay { cursor: pointer; }
.hd-bt-day { fill: var(--cds-text-secondary, var(--color-fg-muted)); font-size: 11px; font-variant-numeric: tabular-nums; }
.hd-bt-year { fill: var(--color-fg); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.hd-bt-yearrule { stroke: var(--hd-line); stroke-width: 1; }

/* ---------- Test by test ---------- */
.hd-bt-head-tools { display: flex; align-items: center; gap: 8px; }
.hd-bt-groups { display: grid; margin-top: 4px; border-top: 1px solid var(--hd-rule); }
.hd-bt-group { border-bottom: 1px solid var(--hd-line); }
.hd-bt-group > summary {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 4px 16px;
  padding: 16px 0; cursor: pointer; list-style: none;
}
.hd-bt-group > summary::-webkit-details-marker { display: none; }
.hd-bt-group > summary::after {
  content: "+"; grid-column: 2; grid-row: 1; justify-self: end;
  font-size: 20px; line-height: 1; color: var(--color-fg-muted); transition: transform .2s;
}
.hd-bt-group[open] > summary::after { content: "\2212"; }
.hd-bt-group > summary:hover .hd-bt-group__name { color: var(--hd-accent); }
.hd-bt-group > summary:focus-visible { outline: 2px solid var(--hd-accent); outline-offset: 2px; }
.hd-bt-group__name { font-family: var(--hd-display); font-weight: 600; font-size: 16px; line-height: 1.3; transition: color .15s; }
.hd-bt-group__sum { grid-column: 1; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; font-size: 13px; color: var(--color-fg-muted); font-variant-numeric: tabular-nums; }
.hd-bt-group__sum.dash-skeleton { min-width: 180px; }
.hd-bt-keys { display: inline-flex; flex-wrap: wrap; gap: 2px; }
.hd-bt-key { display: block; width: 8px; height: 8px; background: var(--hd-bt-ok); }
.hd-bt-key.is-warn { background: var(--hd-bt-warn); border-radius: 50%; }
.hd-bt-key.is-bad { background: var(--color-bad); transform: rotate(45deg) scale(.84); }
.hd-bt-key.is-none { background: transparent; box-shadow: inset 0 0 0 1px var(--color-fg-muted); }

.hd-bt-table { width: 100%; margin: 0 0 16px; border-collapse: collapse; table-layout: fixed; }
.hd-bt-table col.hd-bt-c1 { width: 30%; }
.hd-bt-table col.hd-bt-c2 { width: 16%; }
.hd-bt-table col.hd-bt-c3 { width: 18%; }
.hd-bt-table thead th {
  padding: 0 16px 8px 0; border-bottom: 1px solid var(--hd-line); text-align: left; vertical-align: bottom;
  font-size: 12px; font-weight: 500; color: var(--color-fg-muted);
}
.hd-bt-table thead th:last-child { padding-right: 0; }
.hd-bt-axis { position: relative; display: block; height: 16px; }
.hd-bt-axis span { position: absolute; top: 0; padding-left: 6px; font-size: 12px; font-weight: 600; color: var(--color-fg); font-variant-numeric: tabular-nums; border-left: 1px solid var(--hd-line); line-height: 16px; }
.hd-bt-row > * { padding: 12px 16px 12px 0; border-bottom: 1px solid var(--hd-line); text-align: left; vertical-align: middle; font-weight: 400; }
.hd-bt-row > :last-child { padding-right: 0; }
.hd-bt-row:last-child > * { border-bottom: 0; }
.hd-bt-row > * { transition: background-color .6s; }
.hd-bt-row.is-flash > * { background-color: color-mix(in srgb, var(--hd-c1) 9%, transparent); transition: none; }
.hd-bt-name { display: block; font-size: 14px; font-weight: 500; line-height: 1.35; color: var(--color-fg); }
.hd-bt-about { display: block; margin-top: 2px; font-size: 12px; line-height: 1.4; color: var(--color-fg-muted); }
.hd-bt-value { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 4px; }
.hd-bt-num { font-family: var(--hd-display); font-weight: 600; font-size: 20px; line-height: 1.2; letter-spacing: -.01em; }
.hd-bt-num.is-text { font-family: var(--hd-text); font-weight: 500; font-size: 13px; letter-spacing: 0; }
.hd-bt-unit { font-size: 12px; color: var(--color-fg-muted); }
.hd-bt-when { display: block; margin-top: 2px; font-size: 12px; color: var(--color-fg-muted); font-variant-numeric: tabular-nums; }
.hd-bt-state .hd-pill { display: flex; }
.hd-bt-first { display: block; margin-top: 4px; font-size: 12px; color: var(--color-fg-muted); }
.hd-bt-spark { position: relative; height: 44px; }
.hd-bt-spark svg { display: block; overflow: visible; }
.hd-bt-spark .hd-tip { min-width: 180px; }
.hd-bt-trace { fill: none; stroke: var(--color-fg-muted); stroke-width: 1.5; stroke-linejoin: round; opacity: .5; }
.hd-bt-pt { stroke: var(--color-bg); stroke-width: 2px; paint-order: stroke; }
.hd-bt-yline { stroke: var(--cds-chart-grid, var(--hd-line)); stroke-width: 1; shape-rendering: crispEdges; }
.hd-bt-ring { fill: none; stroke: var(--color-fg); stroke-width: 1.5; pointer-events: none; }
.hd-bt-empty { padding: 12px 0; font-size: 13px; color: var(--color-fg-muted); }

/* ---------- The whole record ---------- */
.hd-bt-more { margin-top: 8px; }
.hd-bt-more > summary {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 0; cursor: pointer; list-style: none;
  font-size: 14px; font-weight: 500; color: var(--color-fg);
}
.hd-bt-more > summary::-webkit-details-marker { display: none; }
.hd-bt-more > summary::after { content: "+"; font-size: 18px; line-height: 1; color: var(--color-fg-muted); }
.hd-bt-more[open] > summary::after { content: "\2212"; }
.hd-bt-more > summary:hover { color: var(--hd-accent); }
.hd-bt-more > summary:focus-visible { outline: 2px solid var(--hd-accent); outline-offset: 2px; }
.hd-bt-allwrap { max-height: 560px; margin-top: 8px; overflow: auto; overscroll-behavior: contain; border-top: 1px solid var(--hd-rule); }
.hd-bt-all { min-width: 600px; }
.hd-bt-all thead th { position: sticky; top: 0; z-index: 1; background: var(--color-bg); }
.hd-bt-all td { padding-block: 8px; }
.hd-bt-all tr.is-day td { border-top: 1px solid var(--hd-rule); }
.hd-bt-all tr:first-child td { border-top: 0; }
.hd-bt-all .hd-bt-tdate { white-space: nowrap; color: var(--color-fg-muted); }
.hd-bt-all .hd-bt-tdate.is-repeat { color: transparent; }
.hd-bt-all .hd-num { font-weight: 600; text-align: right; }
.hd-bt-all .hd-bt-tunit, .hd-bt-all .hd-bt-trange { color: var(--color-fg-muted); }

/* ---------- Narrow: each test becomes a small card ---------- */
@container hd (max-width: 720px) {
  .hd-bt-table, .hd-bt-table tbody { display: block; }
  .hd-bt-table colgroup, .hd-bt-table thead { display: none; }
  .hd-bt-row {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 16px;
    grid-template-areas: "test latest" "state state" "hist hist";
    padding: 16px 0; border-bottom: 1px solid var(--hd-line);
  }
  .hd-bt-row:last-child { border-bottom: 0; }
  .hd-bt-row > * { display: block; padding: 0; border: 0; }
  .hd-bt-test { grid-area: test; }
  .hd-bt-latest { grid-area: latest; text-align: right; }
  .hd-bt-value { justify-content: flex-end; }
  .hd-bt-state { grid-area: state; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
  .hd-bt-state .hd-pill { display: inline-flex; }
  .hd-bt-first { margin-top: 0; }
  .hd-bt-hist { grid-area: hist; }
}
@container hd (max-width: 600px) {
  .hd-bt-group > summary { padding: 12px 0; }
  .hd-bt-num { font-size: 18px; }
}

@media print {
  .hd-bt-allwrap { max-height: none; overflow: visible; }
  .hd-bt-group > summary::after { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .hd-bt-sq, .hd-bt-row > *, .hd-bt-group__name { transition: none; }
}
