/* Goal visuals (light): [data-widget="lifespan"] + [data-widget="morphology"]
   A matched pair of small figure cards: same height, same label system. */
:where([data-widget="lifespan"], [data-widget="morphology"]) {
  margin-top: clamp(28px, 3vw, 40px);
}
[data-widget="lifespan"],
[data-widget="morphology"] {
  position: relative;
  display: block;
  width: 100%;
  max-width: 100%;
}
[data-widget="lifespan"] > .gv-plate,
[data-widget="morphology"] .gv-plate {
  position: relative;
  box-sizing: border-box;
  width: 100%;
  height: 248px;
  border: 1px solid var(--line, #e2e8f0);
  border-radius: var(--r-plate, 16px);
  background:
    radial-gradient(120% 90% at 50% 100%, var(--bg-alt, #f8fafc), rgba(248, 250, 252, 0) 70%),
    var(--bg, #ffffff);
  box-shadow: var(--shadow-plate, 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px -12px rgba(15, 23, 42, .12));
  overflow: hidden;
  contain: layout paint;
}
@media (max-width: 600px) {
  [data-widget="lifespan"] > .gv-plate,
  [data-widget="morphology"] .gv-plate { height: 232px; }
}

/* morphology: the figure (role="img") fills the tab panel */
[data-widget="morphology"] .gv-fig { position: absolute; inset: 0; }
[data-widget="lifespan"] .gv-svg,
[data-widget="morphology"] .gv-svg {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* label system (shared; the lifespan key and row labels) */
[data-widget] .gv-svg .gv-lbl {
  font-family: var(--mono, "JetBrains Mono"), ui-monospace, Menlo, monospace;
  font-size: 0.6875rem; /* 11px at the default 16px; follows the browser text size */
  font-weight: 500;
  letter-spacing: .14em;
  text-transform: uppercase;
  fill: var(--muted, #64748b);
}
[data-widget] .gv-svg .gv-lbl-hi { fill: var(--head, #0f172a); }
/* small text uses the ink tokens (AA on white); bright hues stay for fills and strokes */
[data-widget] .gv-svg .gv-lbl-o  { fill: var(--orange-ink, #c2410c); }
[data-widget] .gv-svg .gv-lbl-s  { fill: var(--sky-ink, #0369a1); }

/* grid language (shared): fine slate hairlines */
[data-widget] .gv-svg .gv-grid  { fill: none; stroke: var(--line, #e2e8f0); stroke-width: 1; opacity: .75; }
[data-widget] .gv-svg .gv-rule  { fill: none; stroke: var(--line, #e2e8f0); stroke-width: 1; }

/* lifespan */
[data-widget="lifespan"] .gv-line   { fill: none; stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
[data-widget="lifespan"] .gv-line-h { stroke: var(--orange, #f97316); }
[data-widget="lifespan"] .gv-base   { fill: none; stroke: var(--line-2, #cbd5e1); stroke-width: 1; }
[data-widget="lifespan"] .gv-tick   { fill: none; stroke: var(--line-2, #cbd5e1); stroke-width: 1; }
[data-widget="lifespan"] .gv-tick-on { stroke: var(--orange, #f97316); }
[data-widget="lifespan"] .gv-guide  { fill: none; stroke: var(--muted, #64748b); stroke-opacity: .55; stroke-width: 1; stroke-dasharray: 2 3; }
[data-widget="lifespan"] .gv-div    { fill: none; stroke: #ffffff; stroke-opacity: .7; stroke-width: 1; }
[data-widget="lifespan"] .gv-head   { fill: #ffffff; stroke: var(--orange, #f97316); stroke-width: 1.5; }
[data-widget="lifespan"] .gv-halo   { fill: var(--amber, #f59e0b); }

/* morphology */
[data-widget="morphology"] .gv-cross   { fill: none; stroke: var(--line-2, #cbd5e1); stroke-width: 1; }
[data-widget="morphology"] .gv-ghost   { fill: none; stroke: var(--sky, #0ea5e9); stroke-width: 1.25; stroke-dasharray: 2 4; stroke-linecap: round; }
[data-widget="morphology"] .gv-inner   { fill: none; stroke: var(--amber, #f59e0b); stroke-width: 1; stroke-linejoin: round; }
[data-widget="morphology"] .gv-dots    { fill: var(--orange, #f97316); }
[data-widget="morphology"] .gv-form    { fill: none; stroke: var(--orange, #f97316); stroke-width: 1.75; stroke-linejoin: round; stroke-linecap: round; }
[data-widget="morphology"] .gv-dmg     { fill: none; stroke: var(--red, #ef4444); stroke-width: 1.5; stroke-dasharray: 3 3; stroke-linecap: round; }
[data-widget="morphology"] .gv-heal    { fill: none; stroke: var(--sky, #0ea5e9); stroke-width: 6; stroke-linecap: round; }
/* the healed arc keeps a faint sky seam until the phase changes */
[data-widget="morphology"] .gv-seam    { fill: none; stroke: var(--sky, #0ea5e9); stroke-width: 1.25; stroke-linecap: round; }

/* full 10X span, shown faintly before and under the growing bar */
[data-widget="lifespan"] .gv-target { fill: rgba(249, 115, 22, .05); stroke: rgba(249, 115, 22, .5); stroke-width: 1; stroke-dasharray: 3 3; }

/* morphology phase tabs: real controls laid over the plate header (44px tall).
   Same type as the SVG labels; the bar under the active tab fills with phase progress. */
[data-widget="morphology"] .gv-stage { position: relative; }
[data-widget="morphology"] .gv-tabs {
  position: absolute;
  z-index: 2;
  top: 0;
  left: 14px;
  display: flex;
  gap: 10px;
  height: 44px;
}
[data-widget="morphology"] .gv-tab {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: flex-start;
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
  height: 44px;
  min-width: 44px;
  padding: 14px 8px 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted, #64748b);
  font-family: var(--mono, "JetBrains Mono", ui-monospace, Menlo, monospace);
  font-size: 0.6875rem; /* 11px at the default 16px */
  font-weight: 500;
  line-height: 1;
  letter-spacing: .14em;
  text-transform: uppercase;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color var(--dur-2, 250ms) var(--ease-in-out, cubic-bezier(.65, 0, .35, 1));
}
[data-widget="morphology"] .gv-tab > span { display: block; margin-right: -.14em; }
[data-widget="morphology"] .gv-tab::before,
[data-widget="morphology"] .gv-tab::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  top: calc(20px + 1em); /* 31px at 11px: 14px padding + one line + 6px */
  height: 3px;
  border-radius: 1.5px;
}
[data-widget="morphology"] .gv-tab::before { background: var(--line, #e2e8f0); }
[data-widget="morphology"] .gv-tab::after {
  background: linear-gradient(90deg, var(--sky-deep, #0284c7), var(--sky, #0ea5e9));
  transform: scaleX(var(--p, 0));
  transform-origin: 0 50%;
}
[data-widget="morphology"] .gv-tab:hover { color: var(--head, #0f172a); }
[data-widget="morphology"] .gv-tab[aria-selected="true"] { color: var(--sky-ink, #0369a1); }
[data-widget="morphology"] .gv-tab:focus { outline: none; }
/* same ring colour as the rest of the site; inset, because the tabs sit on the plate's top edge */
[data-widget="morphology"] .gv-tab:focus-visible {
  outline: 2px solid var(--orange-ink, #c2410c);
  outline-offset: -2px;
  border-radius: 8px;
}
@media (prefers-reduced-motion: reduce) {
  [data-widget="morphology"] .gv-tab { transition: none; }
}

/* More contrast: site.css darkens --line, --line-2, --muted and --text, and every
   hairline and label here reads those tokens live through var(), so they follow the
   switch with no redraw. The dashed Today guide drops its faint opacity; the
   background grid keeps its .75 so it stays behind the data at the darker --line. */
@media (prefers-contrast: more) {
  [data-widget="lifespan"] .gv-guide { stroke-opacity: 1; }
}

/* Forced colours (Windows high contrast): text and essential strokes take system
   colours, Highlight marks the emphasised element (the healthy years; the target and
   the wound), and decorative fills, sheens, glows and shadows drop out. */
@media (forced-colors: active) {
  [data-widget] .gv-svg text,
  [data-widget] .gv-svg .gv-lbl,
  [data-widget] .gv-svg .gv-lbl-hi,
  [data-widget] .gv-svg .gv-lbl-o,
  [data-widget] .gv-svg .gv-lbl-s { fill: CanvasText; }
  [data-widget] .gv-svg .gv-grid { stroke: CanvasText; opacity: .22; }
  [data-widget] .gv-svg .gv-rule { stroke: CanvasText; opacity: .5; }

  /* lifespan: healthy years = Highlight bars cut into spans by Canvas dividers; decline = a CanvasText line */
  [data-widget="lifespan"] .gv-sw-h { fill: Highlight; }
  [data-widget="lifespan"] .gv-sw-d { fill: Canvas; stroke: CanvasText; stroke-width: 1; }
  [data-widget="lifespan"] .gv-ha { fill: Highlight; filter: none; }
  [data-widget="lifespan"] .gv-hv,
  [data-widget="lifespan"] .gv-shim,
  [data-widget="lifespan"] .gv-halo,
  [data-widget="lifespan"] .gv-da { display: none; }
  [data-widget="lifespan"] .gv-line { stroke: CanvasText; }
  [data-widget="lifespan"] .gv-line-h { stroke: Highlight; }
  [data-widget="lifespan"] .gv-base,
  [data-widget="lifespan"] .gv-tick,
  [data-widget="lifespan"] .gv-guide { stroke: CanvasText; stroke-opacity: 1; }
  [data-widget="lifespan"] .gv-tick-on { stroke: Highlight; }
  [data-widget="lifespan"] .gv-div { stroke: Canvas; stroke-opacity: 1; }
  [data-widget="lifespan"] .gv-target { fill: none; stroke: CanvasText; }
  [data-widget="lifespan"] .gv-head { fill: Canvas; stroke: Highlight; }

  /* morphology: the form in CanvasText on Canvas; target pattern, wound and seam in Highlight */
  [data-widget="morphology"] .gv-body { fill: Canvas; filter: none; }
  [data-widget="morphology"] .gv-form,
  [data-widget="morphology"] .gv-inner,
  [data-widget="morphology"] .gv-cross { stroke: CanvasText; }
  [data-widget="morphology"] .gv-dots { fill: CanvasText; }
  [data-widget="morphology"] .gv-ghost,
  [data-widget="morphology"] .gv-dmg,
  [data-widget="morphology"] .gv-seam { stroke: Highlight; }
  [data-widget="morphology"] .gv-heal { display: none; }

  [data-widget="morphology"] .gv-tab { color: ButtonText; }
  [data-widget="morphology"] .gv-tab[aria-selected="true"] { color: Highlight; }
  /* the track is a quiet CanvasText rail (GrayText reads as "disabled"); progress fills in Highlight */
  [data-widget="morphology"] .gv-tab::before { background: CanvasText; opacity: .3; forced-color-adjust: none; }
  [data-widget="morphology"] .gv-tab::after { background: Highlight; forced-color-adjust: none; }
  [data-widget="morphology"] .gv-tab:focus-visible { outline-color: Highlight; }
}
