/* PathTrove chart components shared by index.html and atlas.html.
   Charts are plain HTML/CSS; numbers are hard-coded from the PathTrove snapshot. */

.vz-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.vz-wide { grid-column: 1 / -1; }
.vz-card { padding: 28px 32px 22px; display: flex; flex-direction: column; min-width: 0; }
.vz-kicker { font-size: 12px; font-weight: 500; color: var(--teal-ink); letter-spacing: 0.02em; }
.vz-title { margin-top: 6px; font-size: 20px; font-weight: 600; line-height: 1.35; color: var(--ink); letter-spacing: -0.01em; }
.vz-lede { margin-top: 6px; font-size: 14px; color: var(--muted); }
.vz-lede b { color: var(--ink); font-weight: 600; }
/* Scope sentence under a chart title: how to read the counts. Body size and color. */
.vz-scope { margin-top: 6px; font-size: 15px; line-height: 1.6; color: var(--text); }
.vz-body { margin: 24px 0 20px; }
.vz-note { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line-soft); font-size: 12px; color: var(--faint); line-height: 1.6; }
.vz-scroll { overflow-x: auto; }
.vz-sub { margin: 20px 0 8px; font-size: 13px; font-weight: 600; color: var(--ink); display: flex; justify-content: space-between; gap: 12px; }
.vz-sub small { font-weight: 400; color: var(--faint); font-size: 12px; }
.vz-more { display: flex; justify-content: center; margin-top: 36px; }
.pink-tag {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  padding: 2px 9px; border-radius: 999px; background: var(--pink-soft);
  color: var(--pink-ink); font-size: 11.5px; font-weight: 500;
}
.teal-tag {
  display: inline-flex; align-items: center; white-space: nowrap;
  padding: 2px 9px; border-radius: 999px; background: var(--teal-soft);
  color: var(--teal-ink); font-size: 11.5px; font-weight: 500;
}
.gray-tag {
  display: inline-flex; align-items: center; white-space: nowrap;
  padding: 2px 9px; border-radius: 999px; background: var(--bg-alt); border: 1px solid var(--line);
  color: var(--muted); font-size: 11.5px; font-weight: 500;
}

/* ---- Log-scale strip ---- */
.scale { position: relative; min-width: 720px; height: 230px; margin: 0 12px; }
.scale-axis { position: absolute; left: 0; right: 0; top: 118px; height: 2px; background: var(--line); }
.scale-tick { position: absolute; top: 112px; width: 1px; height: 14px; background: var(--bar); }
.scale-tick span { position: absolute; top: 20px; left: 50%; transform: translateX(-50%); font-size: 11.5px; color: var(--faint); white-space: nowrap; }
.scale-dot { position: absolute; top: 119px; border-radius: 50%; transform: translate(-50%, -50%); background: var(--teal); opacity: 0.85; box-shadow: 0 0 0 4px var(--teal-soft); }
.scale-lab { position: absolute; transform: translateX(-50%); text-align: center; white-space: nowrap; }
.scale-lab.up { bottom: 136px; }
.scale-lab.down { top: 158px; }
.scale-name { font-size: 13px; font-weight: 600; color: var(--ink); }
.scale-val { font-size: 12.5px; color: var(--text); font-variant-numeric: tabular-nums; }
.scale-res { font-size: 11.5px; color: var(--faint); }
.scale-span { position: absolute; top: 8px; height: 12px; border: 1px solid var(--pink-line); border-bottom: 0; border-radius: 6px 6px 0 0; }
.scale-span span { position: absolute; top: -10px; left: 50%; transform: translateX(-50%); padding: 0 8px; background: var(--bg); font-size: 12px; font-weight: 600; color: var(--pink-ink); white-space: nowrap; }
.scale-legend { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.scale-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--teal); vertical-align: middle; margin-right: 6px; }

/* ---- Horizontal bars ---- */
.hb { display: grid; grid-template-columns: var(--hb-label, 104px) minmax(0, 1fr); gap: 4px 14px; align-items: center; }
.hb-label { font-size: 13px; color: var(--text); text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hb-row { display: flex; align-items: center; gap: 10px; min-height: 28px; min-width: 0; }
.hb-bar { height: 10px; border-radius: 999px; background: var(--teal); opacity: 0.8; flex: none; min-width: 4px; }
.hb-row.is-gray .hb-bar { background: var(--bar); opacity: 1; }
.hb-row.is-pink .hb-bar { background: var(--pink-ink); opacity: 0.75; }
.hb-val { font-size: 13px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; flex: none; }
.hb-row .pink-tag, .hb-row .teal-tag, .hb-row .gray-tag { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.hb-divider { grid-column: 1 / -1; height: 1px; background: var(--line-soft); margin: 4px 0; }
.hb.is-compact .hb-row { min-height: 22px; }
.hb.is-compact .hb-label, .hb.is-compact .hb-val { font-size: 12px; }
.hb.is-compact .hb-bar { height: 8px; }

/* ---- Column bars (organ long tail, years) ---- */
.cols { display: flex; align-items: flex-end; gap: 3px; height: 170px; padding-top: 20px; }
.col { position: relative; flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; }
.col-bar { background: var(--teal); opacity: 0.8; border-radius: 3px 3px 0 0; min-height: 3px; }
.col.is-gray .col-bar { background: var(--bar); opacity: 1; }
.col.is-pink .col-bar { background: var(--pink-ink); opacity: 0.75; }
.col-val { position: absolute; left: 50%; transform: translateX(-50%); font-size: 10.5px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.cols-axis { display: flex; gap: 3px; margin-top: 6px; }
.cols-axis span { flex: 1; min-width: 0; font-size: 10.5px; color: var(--faint); text-align: center; white-space: nowrap; overflow: hidden; }
.cols-axis.is-rot { height: 92px; }
.cols-axis.is-rot span { writing-mode: vertical-rl; transform: rotate(180deg); text-align: right; overflow: visible; font-size: 11px; color: var(--muted); }
.cols-legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 10px; font-size: 12px; color: var(--muted); }
.cols-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }

/* ---- 100% stacks ---- */
.st-row + .st-row { margin-top: 20px; }
.st-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.st-name { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.st-n { font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; white-space: nowrap; }
.st-bar { display: flex; height: 26px; margin-top: 8px; border-radius: 8px; overflow: hidden; gap: 2px; }
.st-bar span { display: flex; align-items: center; justify-content: center; min-width: 0; font-size: 12px; font-weight: 600; color: #fff; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; }
.c-teal { background: var(--teal); }
.c-teal2 { background: #7cc3d7; }
.c-teal3 { background: #b5dde8; color: var(--teal-ink) !important; }
.c-gray { background: #9ca3af; }
.c-gray2 { background: #d1d5db; color: var(--text) !important; }
.c-pink { background: var(--pink-ink); }
.c-pink2 { background: var(--pink); }
.c-empty { background: var(--line-soft); color: var(--text) !important; }
.st-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.st-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; }
.st-insight { margin-top: 6px; font-size: 12.5px; color: var(--pink-ink); }

/* ---- Patient timeline ---- */
.tl { position: relative; display: grid; grid-template-columns: 4fr 4fr 3fr; }
.tl::before { content: ""; position: absolute; left: 0; right: 18px; top: 44px; height: 2px; background: linear-gradient(90deg, var(--teal-line), var(--teal) 55%, var(--pink)); }
.tl::after { content: ""; position: absolute; right: 8px; top: 38px; border-left: 12px solid var(--pink); border-top: 7px solid transparent; border-bottom: 7px solid transparent; }
.tl-seg { position: relative; padding: 0 12px; }
.tl-seg + .tl-seg { border-left: 1px dashed var(--line); }
.tl-phase { font-size: 13px; font-weight: 600; color: var(--ink); }
.tl-phase small { margin-left: 6px; font-weight: 400; color: var(--faint); font-size: 12px; }
.tl-nodes { display: flex; justify-content: space-around; align-items: flex-start; gap: 6px; margin-top: 8px; }
.tl-node { display: flex; flex-direction: column; align-items: center; text-align: center; min-width: 0; flex: 1; }
.tl-dotbox { height: 40px; display: flex; align-items: center; justify-content: center; }
.tl-dot { border-radius: 50%; background: var(--teal); opacity: 0.85; box-shadow: 0 0 0 3px #fff; }
.tl-node.is-end .tl-dot { background: var(--pink-ink); opacity: 0.9; }
.tl-num { margin-top: 10px; font-size: 18px; font-weight: 600; color: var(--ink); line-height: 1.1; font-variant-numeric: tabular-nums; }
.tl-name { margin-top: 3px; font-size: 12px; color: var(--muted); line-height: 1.35; }
.tl-kind { margin-top: 2px; font-size: 11px; color: var(--faint); }

/* ---- Big numbers ---- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.kpi { padding: 18px 20px; border-radius: 14px; background: var(--bg); border: 1px solid var(--line-soft); }
.kpi-v { font-size: 30px; font-weight: 600; letter-spacing: -0.02em; color: var(--ink); line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi-l { margin-top: 6px; font-size: 13px; color: var(--muted); }
.mini-kpis { display: flex; flex-wrap: wrap; gap: 10px 28px; }
.mini-kpi b { display: block; font-size: 22px; font-weight: 600; color: var(--ink); line-height: 1.15; font-variant-numeric: tabular-nums; }
.mini-kpi span { font-size: 12px; color: var(--muted); }
.mini-kpi.is-pink b { color: var(--pink-ink); }
.mini-kpi.is-teal b { color: var(--teal-ink); }

@media (max-width: 900px) {
  .vz-grid { grid-template-columns: minmax(0, 1fr); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .vz-card { padding: 22px 18px 18px; }
  .vz-title { font-size: 18px; }
  .tl { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .tl::before, .tl::after { display: none; }
  .tl-seg, .tl-seg + .tl-seg { padding: 0 0 0 14px; border-left: 2px solid var(--teal-line); }
  .tl-seg:last-child { border-left-color: var(--pink-line); }
  .hb { --hb-label: 112px !important; }
  .hb-row { flex-wrap: wrap; row-gap: 2px; }
  .cols { height: 140px; }
  .col-val { display: none; }
  .col.is-labeled .col-val { display: block; }
}
html[lang="zh-CN"] .cols-axis.is-rot span { transform: none; writing-mode: vertical-rl; text-orientation: upright; text-align: left; letter-spacing: 0; font-size: 11px; }

/* ---- Chart draw-in ----
   Bars grow, stacks wipe left-to-right and dots settle in once the card
   holding them gets .is-visible. Text is never scaled, so nothing distorts. */
@media (prefers-reduced-motion: no-preference) {
  [data-reveal] .hb-bar {
    transform: scaleX(0); transform-origin: left center;
    transition: transform 1.1s cubic-bezier(0.16, 1, 0.3, 1);
    transition-delay: calc(var(--reveal-delay, 0ms) + 180ms);
  }
  [data-reveal].is-visible .hb-bar { transform: scaleX(1); }

  [data-reveal] .col-bar {
    transform: scaleY(0); transform-origin: center bottom;
    transition: transform 1.1s cubic-bezier(0.16, 1, 0.3, 1);
    transition-delay: calc(var(--reveal-delay, 0ms) + 180ms);
  }
  [data-reveal].is-visible .col-bar { transform: scaleY(1); }

  [data-reveal] .st-bar {
    clip-path: inset(0 100% 0 0);
    transition: clip-path 1.25s cubic-bezier(0.16, 1, 0.3, 1);
    transition-delay: calc(var(--reveal-delay, 0ms) + 200ms);
  }
  [data-reveal].is-visible .st-bar { clip-path: inset(0 0 0 0); }

  [data-reveal] .scale-dot {
    opacity: 0; transform: translate(-50%, -50%) scale(0.3);
    transition: opacity 0.8s ease, transform 0.9s cubic-bezier(0.34, 1.4, 0.64, 1);
    transition-delay: calc(var(--reveal-delay, 0ms) + 260ms);
  }
  [data-reveal].is-visible .scale-dot { opacity: 0.85; transform: translate(-50%, -50%) scale(1); }

  [data-reveal] .tl-dot {
    opacity: 0; transform: scale(0.3);
    transition: opacity 0.8s ease, transform 0.9s cubic-bezier(0.34, 1.4, 0.64, 1);
    transition-delay: calc(var(--reveal-delay, 0ms) + 260ms);
  }
  [data-reveal].is-visible .tl-dot { opacity: 0.85; transform: scale(1); }
}
