/* Palm Eye Cloud portal — the Analytics page (pages/analytics.js) and the Reports collection headline (pages/reports.js).
 * Colour only through the theme variables, so dark and light follow styles.css; geometry that depends on data
 * (bar heights, band positions) is set from JS through CSSOM, never a style attribute (the CSP forbids those).
 * Copyright © 2026 Palm Digitalz. All rights reserved. */

:root {
  --an-bar: color-mix(in srgb, var(--blue) 42%, var(--surface2));
  --an-bar-hi: color-mix(in srgb, var(--blue) 62%, var(--surface2));
  --an-line: var(--accent);
  --an-band: color-mix(in srgb, var(--accent) 52%, transparent);
}

/* ---------- page furniture ---------- */
.an-tabs { margin-bottom: 16px; }
.an-panel:focus { outline: none; }
.an-lab { display: inline-flex; flex-direction: column; gap: 4px; min-width: 0; }
.an-lab-t { font-size: var(--t-foot); font-weight: 500; color: var(--tertiary); }
.filters:has(> .an-lab) { align-items: flex-end; }
.filters .an-lab .select { width: auto; min-width: 180px; max-width: min(100%, 440px); flex: none; }
.filters .an-lab .seg { height: 36px; align-items: center; }
.an-basis { margin-top: 8px; }
.an-doctrine { margin-bottom: 0; }
.an-facts { font-size: 12px; color: var(--secondary); margin-top: 4px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.an-pills { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.an-sub-h { font-size: 12px; font-weight: 600; color: var(--secondary); margin: 12px 0 4px; }
.an-pad { padding: 0 var(--inset) var(--inset); }
.explain.an-pad { margin-top: 12px; }
.an-flush > div > .callout, .an-flush > div > .empty { margin: 0 var(--inset) var(--inset); }
.an-flush .paged .tfoot { padding-left: var(--inset); padding-right: var(--inset); }

/* ---------- weekly collection: bars of samples + the counted line on its own axis ---------- */
.an-wk { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; column-gap: 8px; row-gap: 4px; }
.an-wk-axis { display: flex; flex-direction: column; justify-content: space-between; height: 180px; font-size: var(--t-caption); color: var(--tertiary); font-variant-numeric: tabular-nums; line-height: 1; }
.an-wk-axis.l { text-align: right; } .an-wk-axis.r { color: var(--an-line); }
.an-wk-axis span:first-child { transform: translateY(-2px); } .an-wk-axis span:last-child { transform: translateY(2px); }
.an-wk-plot { position: relative; height: 180px; isolation: isolate; }
.an-wk-grid { position: absolute; left: 0; right: 0; height: 1px; background: var(--hairline-soft); }
.an-wk-line { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 2; pointer-events: none; overflow: visible; }
.an-wk-line polyline { fill: none; stroke: var(--an-line); stroke-width: 1.75; stroke-linejoin: round; stroke-linecap: round; }
.an-wk-cols { position: absolute; inset: 0; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); }
.an-wk-col { position: relative; height: 100%; border-radius: 4px; cursor: default; outline: none; }
.an-wk-col:hover, .an-wk-col:focus-visible { background: color-mix(in srgb, var(--label) 6%, transparent); }
.an-wk-col:focus-visible { box-shadow: 0 0 0 2px var(--accent) inset; }
.an-wk-bar { position: absolute; bottom: 0; left: 18%; right: 18%; z-index: 1; background: var(--an-bar); border-radius: 3px 3px 0 0; min-height: 0; }
.an-wk-col:hover .an-wk-bar, .an-wk-col:focus-visible .an-wk-bar { background: var(--an-bar-hi); }
.an-wk-col.gap .an-wk-bar { display: none; }
.an-wk-dot { position: absolute; left: 50%; z-index: 3; width: 7px; height: 7px; border-radius: 50%; transform: translate(-50%, 50%); }
.an-wk-dot.got { background: var(--an-line); box-shadow: 0 0 0 2px var(--surface); }
.an-wk-dot.off { width: 9px; height: 9px; background: var(--surface); border: 1.5px solid var(--an-line); opacity: .8; }
.an-wk-flag { position: absolute; left: 50%; bottom: 0; z-index: 3; width: 7px; height: 7px; transform: translate(-50%, 50%) rotate(45deg); border: 1.5px solid var(--tertiary); background: var(--surface); }
.an-wk-x { display: flex; justify-content: space-between; gap: 8px; font-size: 11px; color: var(--tertiary); font-variant-numeric: tabular-nums; }
.an-sw { display: inline-block; width: 10px; height: 10px; flex: none; }
.an-sw.bar { background: var(--an-bar); border-radius: 2px; }
.an-sw.got { background: var(--an-line); border-radius: 50%; }
.an-sw.off { border: 1.5px solid var(--an-line); border-radius: 50%; }
.an-sw.flag { width: 8px; height: 8px; border: 1.5px solid var(--tertiary); transform: rotate(45deg); }

/* ---------- trends ---------- */
.an-trend .pt.go { cursor: pointer; fill: var(--accent); }
.an-trend .pt.go:hover { stroke: var(--label); stroke-width: 2; }

/* ---------- compare: p05–p95 range bars on one shared axis ---------- */
.an-rr-tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; font-size: var(--t-subhead); }
.an-rr-wrap { display: flex; flex-direction: column; }
.an-rr-list { display: flex; flex-direction: column; max-height: 560px; overflow: auto; }
.an-rr { display: grid; grid-template-columns: minmax(110px, 220px) minmax(0, 1fr) minmax(120px, 160px); gap: 12px; align-items: center; padding: 5px 8px; border-radius: 8px; font-size: 13px; outline: none; }
.an-rr:not(.an-rr-axis):hover, .an-rr:focus-visible { background: var(--surface2); }
.an-rr:focus-visible { box-shadow: 0 0 0 2px var(--accent) inset; }
.an-rr-axis { position: sticky; top: 0; z-index: 1; background: var(--surface); border-bottom: 1px solid var(--hairline-soft); border-radius: 0; padding-top: 0; padding-bottom: 6px; font-size: var(--t-foot); }
.an-rr-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--label); }
.an-rr-name:hover { text-decoration: underline; }
.an-rr-axis .an-rr-name:hover { text-decoration: none; }
.an-rr-scale { position: relative; height: 14px; }
.an-rr-tl { position: absolute; top: 0; transform: translateX(-50%); font-size: var(--t-caption); color: var(--tertiary); white-space: nowrap; font-variant-numeric: tabular-nums; }
.an-rr-tl.first { transform: none; } .an-rr-tl.last { transform: translateX(-100%); }
.an-rr-track { position: relative; height: 20px; }
.an-rr-track::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 2px; transform: translateY(-50%); background: var(--track); border-radius: 1px; }
.an-rr-tick { position: absolute; top: 2px; bottom: 2px; width: 1px; background: var(--hairline-soft); }
.an-rr-band { position: absolute; top: 50%; height: 8px; transform: translateY(-50%); background: var(--an-band); border-radius: 4px; }
.an-rr-med { position: absolute; top: 2px; bottom: 2px; width: 2px; transform: translateX(-1px); background: var(--label); border-radius: 1px; }
.an-rr-val { text-align: right; font-size: var(--t-subhead); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }

/* ---------- explore: two metrics against each other ---------- */
.an-xy { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: var(--gutter); align-items: start; }
.an-xy-plot { max-width: 560px; }
.an-xy-words { display: flex; flex-direction: column; gap: 8px; }

/* ---------- Reports: the collection headline ---------- */
.an-hl { display: flex; gap: 24px; flex-wrap: wrap; align-items: flex-start; }
.an-hl-main { flex: 1 1 340px; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.an-hl-big { font-size: 17px; font-weight: 600; line-height: 1.35; letter-spacing: -.01em; color: var(--label); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.an-hl-big.faint { color: var(--tertiary); font-weight: 500; }
.an-hl-sub { font-size: var(--t-subhead); color: var(--secondary); overflow-wrap: anywhere; }
.an-hl-few { flex: 0 1 360px; min-width: 0; }
.an-hl-few-h { font-size: 12px; font-weight: 600; color: var(--secondary); margin-bottom: 2px; }
.an-hl-few .mini-row { padding: 6px; gap: 10px; }
.an-hl-few .mini-row .mono { font-size: var(--t-subhead); }
.an-hl-pct { min-width: 38px; text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- narrow screens (down to 375 px) ---------- */
@media (max-width: 820px) {
  .an-xy { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .filters .an-lab { flex: 1 1 100%; }
  .filters .an-lab .select { width: 100%; min-width: 0; max-width: none; }
  .an-wk-axis, .an-wk-plot { height: 150px; }
  .an-wk-axis { font-size: 10px; }
  .an-wk-bar { left: 10%; right: 10%; }
  .an-rr { grid-template-columns: minmax(0, 1fr) auto; row-gap: 2px; }
  .an-rr-track { grid-column: 1 / -1; grid-row: 2; }
  .an-rr-axis { grid-template-columns: minmax(0, 1fr); }
  .an-rr-axis .an-rr-name, .an-rr-axis .an-rr-val { display: none; }
  .an-rr-axis .an-rr-scale { grid-column: 1 / -1; }
  .an-hl { gap: 14px; }
  .an-hl-big { font-size: var(--t-body); }
}
@media (prefers-reduced-motion: reduce) {
  .an-wk-col, .an-rr { transition: none; }
}
