/* ==========================================================================
   Custom chart hover panel (#4066) — the HTML tooltip that replaces Plotly's
   native hover box on opted-in charts. Colours come entirely from the shared
   --varial-* / --chart-* tokens (branding.css), so light/dark tracks the app
   with no JS theme detection. Logic: static/js/domain/chart-hover-panel.js.
   ========================================================================== */

.vrl-chart-hover {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1040; /* above the sticky results nav (1020) + its dropdown (1031),
                    the "+ N more" pill (1001) and chart controls — the hover must
                    never be occluded by the tab strip it floats over (#4189) */
  pointer-events: none; /* never steal the mousemove from the chart underneath */
  box-sizing: border-box;
  min-width: 180px;
  max-width: 320px;
  padding: 10px 12px;
  /* The Varial X readout look (varial_x_controls.css .vx-hover) in the app's light colours:
     a surface tinted with the brand colour, a brand-tinted border, 10px radius, soft shadow. */
  background: color-mix(in srgb, var(--varial-primary, #0f745b) 5%, var(--varial-card-bg, #ffffff));
  border: 1px solid color-mix(in srgb, var(--varial-primary, #0f745b) 28%, var(--varial-border, #e3e5de));
  border-radius: 10px;
  box-shadow: 0 10px 28px rgb(0 0 0 / 14%);
  font-family: var(--varial-font-family, "Inter", sans-serif);
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--varial-gray-900, #131210);
  font-variant-numeric: tabular-nums;
  opacity: 0;
  transform: translateY(2px);
  transition: opacity 90ms ease, transform 90ms ease;
}

.vrl-chart-hover.is-visible {
  opacity: 1;
  transform: none;
}

/* Title line: the hovered period in bold brand colour, the unit muted beside it. */
.vch-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}

.vch-x {
  flex: 0 0 auto;
  white-space: nowrap;
  font-weight: 700;
  color: var(--varial-primary, #0f745b);
}

/* A long axis title (e.g. a box chart's caption) wraps instead of overflowing the card;
   min-width: 0 lets the flex item shrink so wrapping can kick in. */
.vch-unit {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.6875rem;
  color: var(--varial-gray-500, #6b6763);
  text-align: right;
  overflow-wrap: break-word;
}

.vch-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 1px 0;
}

/* One round colour dot per series, as on the Varial X readout. */
.vch-sw,
.vch-sw--line {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.vch-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vch-val {
  margin-left: auto;
  padding-left: 16px;
  font-weight: 600;
  white-space: nowrap;
  text-align: right;
}

.vch-rng {
  padding: 0 1px;
  font-weight: 400;
  color: var(--varial-gray-500, #6b6763);
}

/* Expanded reference-year sub-rows under a scenario row. */
.vch-sub {
  padding-left: 14px; /* indent past the row dot */
}

/* Keeps name alignment when a group row carries no colour dot (the colour belongs to the
   members, e.g. fuel-coloured MLF). */
.vch-sw--empty {
  background: transparent;
}

/* Sub-rows that carry their own colour dot (member = the colour dimension). */
.vch-sub--color {
  padding-left: 14px;
}

.vch-sub-label,
.vch-sub .vch-val {
  color: var(--varial-gray-600, #4d4a46);
  font-weight: 400;
}

/* Box/whisker stat rows: the median reads first. */
.vch-stat--med .vch-sub-label,
.vch-stat--med .vch-val {
  color: var(--varial-gray-900, #131210);
  font-weight: 700;
}

.vch-more {
  margin-top: 4px;
  font-size: 0.6875rem;
  color: var(--varial-gray-500, #6b6763);
}

/* Grid of values: one row per scenario and one column per weather year or dispatch case,
   used when every scenario has the same set of lines. Far shorter than a row per line. */
.vch-matrix {
  width: 100%;
  margin: 2px 0;
  border-collapse: collapse;
}

.vch-matrix th,
.vch-matrix td {
  padding: 1px 0 1px 10px;
  white-space: nowrap;
}

.vch-matrix th:first-child {
  padding-left: 0;
}

.vch-matrix thead th {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--varial-gray-500, #6b6763);
  text-align: right;
}

.vch-matrix thead .vch-sw {
  display: inline-block;
  margin-right: 4px;
  vertical-align: middle;
}

.vch-matrix tbody th {
  font-weight: 400;
  text-align: left;
}

.vch-matrix tbody th .vch-sw {
  display: inline-block;
  margin-right: 6px;
  vertical-align: middle;
}

.vch-matrix td {
  font-weight: 600;
  text-align: right;
}

/* A grid of five weather years needs more room than a list of rows. */
.vrl-chart-hover:has(.vch-matrix) {
  max-width: min(460px, 92vw);
}

.vch-matrix + .vch-row {
  margin-top: 4px;
}

/* Fixed-dark variant for the marketing hero (data-hover-dark), which owns a dark
   palette independent of the page theme. Values mirror the hero's hover tokens. */
.vrl-chart-hover--dark {
  background: #1e293b;
  border-color: #334155;
  color: #f8f7f5;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.4);
}

.vrl-chart-hover--dark .vch-head {
  border-bottom-color: #334155;
}

.vrl-chart-hover--dark .vch-x,
.vrl-chart-hover--dark .vch-val,
.vrl-chart-hover--dark .vch-matrix td {
  color: #f8f7f5;
}

.vrl-chart-hover--dark .vch-name,
.vrl-chart-hover--dark .vch-sub .vch-val {
  color: #cbd5e1;
}

.vrl-chart-hover--dark .vch-unit,
.vrl-chart-hover--dark .vch-rng,
.vrl-chart-hover--dark .vch-sub-label,
.vrl-chart-hover--dark .vch-more {
  color: #94a3b8;
}

.vrl-chart-hover--dark .vch-more {
  border-top-color: #334155;
}

.vrl-chart-hover--dark .vch-stat--med .vch-sub-label,
.vrl-chart-hover--dark .vch-stat--med .vch-val {
  color: #f8f7f5;
}

/* When the custom panel owns a chart, suppress Plotly's ENTIRE native hover layer
   for it — the unified box AND the per-point labels Plotly can draw alongside it
   (which render outside `.hovertext`, so hiding that node alone leaked a couple of
   labels). The whole `.hoverlayer` holds only hover artifacts, so hiding it is
   complete and safe; hover EVENTS still fire (they drive our panel), and spikelines
   live in a separate layer. Plotly sets no inline `display` here, so a plain rule
   wins — no !important needed (keeps this in the components layer per
   static/CLAUDE.md). */
.js-plotly-plot.vrl-hover-panel-on .hoverlayer {
  display: none;
}

/* Chart legend drawn above each chart rendered by var-results-charts.js (drawLegend), in
   place of Plotly's own (valuation results, the book's payoff diagram), which lands on the axis labels once a chart has rotated dates or
   many series. One entry per series or scenario; a click hides or shows its lines. */
.var-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 14px;
  margin: 0 0 6px;
  font-size: 0.75rem;
  line-height: 1.4;
}

.var-legend__item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0;
  border: 0;
  background: none;
  color: var(--varial-gray-700, #38352f);
  font: inherit;
  cursor: pointer;
}

.var-legend__item:hover {
  color: var(--varial-gray-900, #131210);
}

.var-legend__item:focus-visible {
  outline: 2px solid var(--varial-primary, #0f745b);
  outline-offset: 2px;
  border-radius: 3px;
}

/* A hidden series stays listed, faded, so it can be brought back. */
.var-legend__item[aria-pressed="false"] {
  color: var(--varial-gray-400, #6e6a63);
  text-decoration: line-through;
}

.var-legend__item[aria-pressed="false"] .var-legend__swatch {
  opacity: 0.35;
}

.var-legend__swatch {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.var-legend__swatch--line {
  width: 16px;
  height: 0;
  border-top: 2.5px solid;
  border-radius: 0;
}

.var-legend__swatch--dash {
  border-top-style: dashed;
}

/* Info hovers (Bootstrap tooltips), app-wide, in the same look as the chart hover panel
   above: a light, brand-tinted box, left-aligned text, 10px radius. They were
   Bootstrap's black centred box, unlike every other hover on the page. */
.tooltip {
  --bs-tooltip-bg: color-mix(in srgb, var(--varial-primary, #0f745b) 5%, var(--varial-card-bg, #ffffff));
  --bs-tooltip-color: var(--varial-gray-900, #131210);
  --bs-tooltip-max-width: 320px;
  --bs-tooltip-padding-x: 12px;
  --bs-tooltip-padding-y: 10px;
  --bs-tooltip-border-radius: 10px;
  --bs-tooltip-font-size: 0.8125rem;
  --bs-tooltip-opacity: 1;
}

.tooltip .tooltip-inner {
  border: 1px solid color-mix(in srgb, var(--varial-primary, #0f745b) 28%, var(--varial-border, #e3e5de));
  box-shadow: 0 10px 28px rgb(0 0 0 / 14%);
  line-height: 1.5;
  text-align: left;
}
