/* My Child Growth Journey - graphs.
   Marks are thin (bars under 24px, lines 2px), the data end is rounded 4px and the base is square, touching fills are
   separated by a 2px gap of the surface colour, grids are solid hairlines, and text never wears a series colour.
   Series colours are not set here: they arrive with the data from the school's framework. */

:root {
  --viz-track: var(--bg-deep);
  --viz-grid: var(--line);
  --viz-axis: var(--line-strong);
  --viz-label: var(--ink-faint);
}

/* ------------------------------------------------------------------ frame, legend, tooltip */
.viz { margin: 0; min-width: 0; }
.viz-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.75rem 1rem; flex-wrap: wrap; margin-bottom: 0.7rem; }
.viz-head h3 { font-size: var(--step-1); }
.viz-head .sub { margin: 0.15rem 0 0; color: var(--ink-soft); font-size: var(--step--1); }
.viz-tools { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.viz-body { min-width: 0; }
.viz-table { margin-top: 0.25rem; max-height: 26rem; overflow: auto; }
.viz-note { margin: 0.6rem 0 0; color: var(--ink-soft); font-size: 0.82rem; }
.viz-empty { color: var(--ink-soft); padding: 1.5rem 0; margin: 0; }

.legend { list-style: none; display: flex; flex-wrap: wrap; gap: 0.3rem 1.1rem; padding: 0; margin: 0 0 0.7rem; font-size: 0.85rem; }
.legend li { display: inline-flex; align-items: center; gap: 0.4rem; }
.legend .key { display: inline-block; width: 0.75rem; height: 0.75rem; border-radius: 3px; flex: none; }
.legend .key.tick { width: 3px; height: 1rem; background: var(--ink); border-radius: 2px; }
.legend .key.line { width: 1.1rem; height: 3px; border-radius: 2px; }
.legend-btn { display: inline-flex; align-items: center; gap: 0.4rem; border: 0; background: none; padding: 0.1rem 0.2rem; border-radius: 6px; font-size: inherit; }
.legend-btn[aria-pressed="false"] { opacity: 0.4; text-decoration: line-through; }

.tip { position: fixed; left: 0; top: 0; z-index: 120; pointer-events: none; background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong); border-radius: 12px; padding: 0.55rem 0.8rem; box-shadow: 0 12px 32px rgba(37, 35, 75, 0.2); max-width: 19rem; font-size: 0.85rem; }
.tip-title { font-weight: 800; margin-bottom: 0.25rem; overflow-wrap: anywhere; }
.tip-row { display: flex; align-items: center; gap: 0.5rem; padding: 0.05rem 0; }
.tip-row strong { font-size: 1rem; font-weight: 800; }
.tip-row span { color: var(--ink-soft); }
.tip-key { flex: none; width: 0.8rem; height: 3px; border-radius: 2px; }
.tip-key.none { background: transparent; width: 0; }
.tip-note { margin-top: 0.3rem; color: var(--ink-soft); font-size: 0.8rem; max-width: 17rem; }

/* ------------------------------------------------------------------ horizontal bars */
.bars-h { display: grid; gap: 0.1rem; }
.bar-row { display: grid; grid-template-columns: var(--label-w, 11.5rem) minmax(0, 1fr) var(--val-w, 3.4rem); gap: 0.75rem; align-items: center; padding: 0.3rem 0.25rem; border: 0; background: none; text-align: left; width: 100%; border-radius: 8px; color: inherit; }
.bar-row.clickable:hover, .bar-row:hover { background: var(--surface-soft); }
.lbl { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.lbl .t { font-weight: 700; font-size: 0.92rem; overflow-wrap: anywhere; }
.lbl .ic { margin-right: 0.35rem; }
.lbl small { color: var(--ink-soft); font-size: 0.78rem; }
.track { position: relative; height: 14px; background: var(--viz-track); border-radius: 0 4px 4px 0; }
.track .fill { position: absolute; inset: 0 auto 0 0; border-radius: 0 4px 4px 0; transition: filter 0.15s; }
.bar-row:hover .fill { filter: brightness(1.08); }
.track .goal { position: absolute; top: -4px; bottom: -4px; width: 3px; margin-left: -1px; border-radius: 2px; background: var(--ink); box-shadow: 0 0 0 2px var(--surface); }
.bars-h.has-extra .bar-row { grid-template-columns: var(--label-w, 11.5rem) minmax(0, 1fr) var(--val-w, 3.4rem) 5.4rem; }
.bar-row .extra { display: flex; justify-content: flex-end; }
.bar-row .val { font-weight: 800; font-size: 0.92rem; font-variant-numeric: tabular-nums; text-align: right; }

/* ------------------------------------------------------------------ stacked rows */
.stack-rows { display: grid; gap: 0.2rem; }
.stack-row { display: grid; grid-template-columns: var(--label-w, 11.5rem) minmax(0, 1fr); gap: 0.75rem; align-items: center; padding: 0.3rem 0.25rem; }
.stack { display: flex; gap: 2px; height: 28px; }
.seg { position: relative; display: grid; place-items: center; min-width: 0; overflow: visible; }
.seg:last-child { border-radius: 0 4px 4px 0; }
.seg:hover, .seg:focus-visible { filter: brightness(1.08); outline-offset: 1px; }
.seg em { font: 800 0.75rem/1 var(--font-body); font-style: normal; white-space: nowrap; pointer-events: none; }

/* ------------------------------------------------------------------ meter, sparkline, ring */
.meter { height: 10px; border-radius: 0 4px 4px 0; background: var(--meter-track); overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--meter); border-radius: 0 4px 4px 0; }
.spark { display: block; flex: none; }
.spark.none { color: var(--ink-faint); text-align: center; width: 5rem; }
.ring { display: block; }
.ring-text { font: 800 18px var(--font-body); fill: var(--ink); }

/* ------------------------------------------------------------------ heat grid */
.heat { border-collapse: separate; border-spacing: 2px; width: 100%; font-size: 0.9rem; }
.heat th { font-weight: 700; text-align: left; padding: 0.3rem 0.5rem; }
.heat thead th { font-size: 0.78rem; color: var(--ink-soft); text-align: center; vertical-align: bottom; min-width: 4.2rem; }
.heat thead th .ic { display: block; font-size: 1.1rem; }
.heat tbody th { white-space: nowrap; }
.heat tbody th .key { display: inline-block; width: 0.75rem; height: 0.75rem; border-radius: 3px; margin-right: 0.45rem; }
.heat td { position: relative; text-align: center; font-weight: 800; height: 2.6rem; border-radius: 4px; font-variant-numeric: tabular-nums; }
.heat td.none { background: var(--surface-soft); color: var(--ink-faint); }
.heat td:hover, .heat td:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; }
.flag { position: absolute; top: 3px; right: 3px; width: 0; height: 0; border-left: 9px solid transparent; border-top: 9px solid currentColor; }
.heat-scale { display: flex; align-items: center; gap: 0.6rem; margin-top: 0.7rem; font-size: 0.8rem; color: var(--ink-soft); flex-wrap: wrap; }
.heat-scale i:not(.flag) { display: block; width: 9rem; height: 10px; border-radius: 4px; }
.heat-scale .flag-note { display: inline-flex; align-items: center; gap: 0.35rem; margin-left: 0.8rem; }
.heat-scale .flag { position: static; border-top-color: var(--ink); }

/* ------------------------------------------------------------------ path steps (Playgroup -> ... -> school) */
.path-steps { list-style: none; display: flex; margin: 0; padding: 0.25rem 0 0.5rem; overflow-x: auto; }
.step { --step: var(--line-strong); position: relative; flex: 1 1 7.5rem; min-width: 6.5rem; display: flex; flex-direction: column; align-items: center; text-align: center; padding: 0 0.3rem; }
.step .node { position: relative; z-index: 1; width: 3.1rem; height: 3.1rem; display: grid; place-items: center; border-radius: 50%; font-size: 1.45rem; background: var(--surface); border: 3px solid var(--step); }
.step .name { margin-top: 0.45rem; font-family: var(--font-heading); font-weight: 700; font-size: 1.05rem; line-height: 1.15; }
.step small { color: var(--ink-soft); font-size: 0.78rem; line-height: 1.3; }
.step .state { margin-top: 0.3rem; font-size: 0.75rem; font-weight: 800; color: var(--ink-soft); }
.step.done .node { background: color-mix(in srgb, var(--step) 22%, #fff); font-size: 1.3rem; font-weight: 800; }
.step.current .node { background: var(--step); box-shadow: 0 0 0 5px color-mix(in srgb, var(--step) 28%, transparent); }
.step.current .state { color: var(--ink); background: var(--sun); padding: 0 0.6rem; border-radius: 999px; }
.step.next .node { border-style: dashed; }
.step.goal .node { background: var(--sun); border-color: var(--sun); }
.step:not(:last-child)::after { content: ""; position: absolute; top: 1.45rem; left: calc(50% + 1.75rem); width: calc(100% - 3.5rem); height: 4px; border-radius: 2px; background: var(--step); }
.step.plain:not(:last-child)::after { background: var(--step); }
.step-hit { display: flex; flex-direction: column; align-items: center; width: 100%; border: 0; background: none; padding: 0.3rem 0.2rem 0.4rem; border-radius: var(--radius-small); text-align: center; color: inherit; }
.step:has(.step-hit):not(:last-child)::after { top: 1.85rem; }
.step-hit:hover { background: var(--surface-soft); }
.step.selected .step-hit { background: var(--sun-soft); box-shadow: inset 0 0 0 2px var(--sun); }
.step.selected .node { box-shadow: 0 0 0 4px color-mix(in srgb, var(--step) 28%, transparent); }
.step.next:not(:last-child)::after, .step.goal::after { background: repeating-linear-gradient(90deg, var(--line-strong) 0 8px, transparent 8px 14px); }
.step.current:not(:last-child)::after { background: repeating-linear-gradient(90deg, var(--step) 0 8px, transparent 8px 14px); }

/* ------------------------------------------------------------------ svg charts */
.viz svg text { font-family: var(--font-body); }
.line-chart, .radar { display: block; max-width: 100%; height: auto; overflow: visible; }
.line-chart .grid, .radar .grid { stroke: var(--viz-grid); stroke-width: 1; fill: none; }
.line-chart .axis { stroke: var(--viz-axis); stroke-width: 1; }
.line-chart .tick { font-size: 12px; font-weight: 600; fill: var(--viz-label); }
.line-chart .goal-line { stroke: var(--viz-goal); stroke-width: 1.5; }
.line-chart .goal-label { font-size: 11px; font-weight: 800; fill: var(--ink-soft); }
.line-chart .end-label { font-size: 12px; font-weight: 800; fill: var(--ink); }
.line-chart .crosshair { stroke: var(--ink-soft); stroke-width: 1; }
.line-chart:focus-visible { outline-offset: 4px; }
.radar .axis-label { font-size: 12px; font-weight: 700; fill: var(--ink-soft); }
.radar .ring-tick { font-size: 10px; font-weight: 700; fill: var(--viz-label); }
.radar .hit { outline: none; }
.radar .hit:focus-visible circle:last-child { stroke: var(--ink); }
.radar-wrap { display: grid; justify-items: center; }

/* year plan (Gantt) */
.gantt-scroll { padding-bottom: 0.25rem; }
.gantt { position: relative; min-width: 48rem; }
.gantt-row { display: grid; grid-template-columns: 14rem minmax(0, 1fr); align-items: center; border-bottom: 1px solid var(--line); }
.gantt-row.head { border-bottom: 2px solid var(--line-strong); font-size: 0.78rem; color: var(--ink-soft); font-weight: 800; }
.g-label { padding: 0.4rem 0.8rem 0.4rem 0; line-height: 1.25; min-width: 0; }
.g-label .t { display: block; font-weight: 700; font-size: 0.9rem; overflow-wrap: anywhere; }
.g-label small { color: var(--ink-soft); font-size: 0.78rem; }
.g-track { position: relative; height: 2.7rem; }
.gantt-row.head .g-track { height: 1.9rem; }
.gantt-months span { position: absolute; top: 0.3rem; bottom: 0; padding-left: 0.35rem; border-left: 1px solid var(--line); font-size: 0.75rem; font-weight: 800; color: var(--ink-faint); overflow: hidden; white-space: nowrap; }
.mline { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--viz-grid); }
.g-bar { position: absolute; top: 50%; height: 14px; transform: translateY(-50%); border-radius: 4px; background: var(--bar-track); overflow: hidden; min-width: 8px; }
.g-bar:hover, .g-bar:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.g-fill { display: block; height: 100%; background: var(--bar); }
.g-state { position: absolute; top: 50%; transform: translateY(-50%); font-size: 0.75rem; font-weight: 800; color: var(--ink-soft); white-space: nowrap; }
.gantt-today { position: absolute; top: 0; bottom: 0; left: calc(14rem + (100% - 14rem) * var(--today)); width: 2px; background: var(--ink); pointer-events: none; z-index: 2; }
.gantt-today span { position: absolute; top: 0.1rem; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; font-size: 0.7rem; font-weight: 800; padding: 0 0.5rem; border-radius: 999px; }
.gantt { padding-top: 1.4rem; }

/* texture: for print, grayscale readers and forced colours - never on screen by default, always 45 or 135 degrees */
@media print, (forced-colors: active) {
  [data-tx="45"] { background-image: repeating-linear-gradient(45deg, rgba(0, 0, 0, 0.4) 0 2px, transparent 2px 7px) !important; }
  [data-tx="135"] { background-image: repeating-linear-gradient(135deg, rgba(0, 0, 0, 0.4) 0 2px, transparent 2px 7px) !important; }
}
@media (forced-colors: active) {
  .track, .meter, .seg, .g-bar { border: 1px solid CanvasText; }
}
@media (max-width: 40rem) {
  .bar-row, .bars-h.has-extra .bar-row { grid-template-columns: minmax(6.5rem, 9rem) minmax(0, 1fr) 2.6rem; gap: 0.5rem; }
  .bar-row .extra { display: none; }
  .stack-row { grid-template-columns: 1fr; gap: 0.2rem; }
}
