/* energy_chart.css - chart chrome and colour tokens for energy_chart.js
 *
 * Light tokens are the default (the page is light). The dark set is selected, not
 * auto-flipped: it applies when the document root carries data-theme="dark"
 * (<html data-theme="dark">), so a dark card never appears inside a light page.
 *
 * Series colours: one categorical slot per generation source, assigned by meaning
 * (water blue, gas orange, wind aqua, sun yellow, storage magenta, biomass green,
 * nuclear red, coal violet). The stack order in the JS was chosen among the
 * sequences that pass the colour-blindness (adjacent ΔE >= 8) and normal-vision
 * (ΔE >= 15) gates for both surfaces. Demand and generation are ink, not hue: they
 * are the reference lines, drawn over the stack (generation rides its top edge
 * in grey, demand is the black line). The balance uses the diverging
 * pair (import warm, export cool) around a neutral zero line.
 * Every mark paints with currentColor; the JS sets color: var(--chart-s-<key>)
 * on each series group, swatch and tooltip key.
 */

.energy-chart {
  --chart-surface: #fcfcfb;
  --chart-ink: #0b0b0b;
  --chart-ink-secondary: #52514e;
  --chart-ink-muted: #898781;
  --chart-grid: #e1e0d9;
  --chart-axis: #c3c2b7;
  --chart-border: rgba(11, 11, 11, 0.10);
  --chart-focus: #2a78d6;
  --chart-tooltip-bg: #ffffff;
  --chart-tooltip-shadow: 0 4px 16px rgba(11, 11, 11, 0.12), 0 0 0 1px rgba(11, 11, 11, 0.06);

  --chart-s-consum: var(--chart-ink);
  --chart-s-productie: var(--chart-ink-secondary);
  --chart-s-hidro: #2a78d6;
  --chart-s-hidrocarburi: #eb6834;
  --chart-s-eolian: #1baf7a;
  --chart-s-fotovolt: #eda100;
  --chart-s-stocare: #e87ba4;
  --chart-s-biomasa: #008300;
  --chart-s-nuclear: #e34948;
  --chart-s-carbune: #4a3aa7;
  --chart-import: #e34948;
  --chart-export: #2a78d6;
  --chart-s-sold: var(--chart-ink-secondary);

  color-scheme: light;
  font-family: system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 13px;
  line-height: 1.35;
  color: var(--chart-ink);
  background: var(--chart-surface);
  border: 1px solid var(--chart-border);
  border-radius: 10px;
  box-sizing: border-box;
  width: calc(100% - 90px);
  max-width: 1280px;
  margin: 28px auto 32px;
  padding: 16px 20px 10px;
}

:root[data-theme="dark"] .energy-chart {
  --chart-surface: #1a1a19;
  --chart-ink: #ffffff;
  --chart-ink-secondary: #c3c2b7;
  --chart-ink-muted: #898781;
  --chart-grid: #2c2c2a;
  --chart-axis: #383835;
  --chart-border: rgba(255, 255, 255, 0.10);
  --chart-focus: #3987e5;
  --chart-tooltip-bg: #262624;
  --chart-tooltip-shadow: 0 4px 16px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.08);

  --chart-s-hidro: #3987e5;
  --chart-s-hidrocarburi: #d95926;
  --chart-s-eolian: #199e70;
  --chart-s-fotovolt: #c98500;
  --chart-s-stocare: #d55181;
  --chart-s-biomasa: #008300;
  --chart-s-nuclear: #e66767;
  --chart-s-carbune: #9085e9;
  --chart-import: #e66767;
  --chart-export: #3987e5;
  color-scheme: dark;
}

@media (max-width: 720px) {
  .energy-chart { width: calc(100% - 16px); padding: 12px 10px 6px; }
}

.energy-chart [hidden] {
  display: none !important;
}

/* ---- header: title, period, tools, stats ------------------------------ */

.energy-chart__header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 20px;
  margin: 0 0 8px;
  padding: 0;
}

.energy-chart__title {
  font-size: 15px;
  font-weight: 600;
  color: var(--chart-ink);
}

.energy-chart__unit {
  font-weight: 500;
  color: var(--chart-ink-muted);
}

.energy-chart__period {
  color: var(--chart-ink-secondary);
}

.energy-chart__stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 24px;
  margin-left: auto;
}

.energy-chart__stat {
  display: flex;
  flex-direction: column;
  min-width: 64px;
}

.energy-chart__stat-label {
  font-size: 11px;
  color: var(--chart-ink-muted);
}

.energy-chart__stat-value {
  font-size: 15px;
  font-weight: 600;
  color: var(--chart-ink);
}

.energy-chart__stat-time {
  font-size: 11px;
  color: var(--chart-ink-muted);
}

.energy-chart__tools {
  display: flex;
  align-items: center;
  gap: 14px;
}

.energy-chart__button,
.energy-chart__mode,
.energy-chart__legend-all {
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  color: var(--chart-ink);
  background: transparent;
  border: 1px solid var(--chart-border);
  border-radius: 6px;
  padding: 5px 10px;
  cursor: pointer;
}

.energy-chart__button:hover,
.energy-chart__mode:hover,
.energy-chart__legend-all:hover {
  background: var(--chart-grid);
}

.energy-chart__button:focus-visible,
.energy-chart__link:focus-visible,
.energy-chart__mode:focus-visible,
.energy-chart__legend-item:focus-visible,
.energy-chart__legend-all:focus-visible {
  outline: 2px solid var(--chart-focus);
  outline-offset: 2px;
}

.energy-chart__link {
  font-size: 12px;
  color: var(--chart-ink-secondary);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--chart-axis);
}

.energy-chart__link:hover {
  color: var(--chart-ink);
  text-decoration-color: currentColor;
}

.energy-chart__hint {
  margin: 6px 0 0;
  font-size: 11px;
  color: var(--chart-ink-muted);
}

/* ---- legend: toggles that double as a readout ------------------------- */

.energy-chart__legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 4px;
  margin: 0 0 6px;
  padding: 0 0 8px;
  border-bottom: 1px solid var(--chart-grid);
}

.energy-chart__legend-time {
  font-size: 11px;
  color: var(--chart-ink-muted);
  font-variant-numeric: tabular-nums;
  margin-right: 8px;
  min-width: 12em;
}

.energy-chart__legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-size: 12px;
  line-height: 1;
  color: var(--chart-ink-secondary);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 5px 8px;
  cursor: pointer;
  white-space: nowrap;
}

.energy-chart__legend-item:hover {
  background: var(--chart-grid);
  color: var(--chart-ink);
}

.energy-chart__legend-item.is-hidden {
  color: var(--chart-ink-muted);
}

.energy-chart__legend-item.is-hidden .energy-chart__legend-name {
  text-decoration: line-through;
  text-decoration-color: var(--chart-axis);
}

.energy-chart__legend-item.is-hidden .energy-chart__swatch {
  opacity: 0.3;
}

.energy-chart__legend-item.is-hidden .energy-chart__legend-value {
  visibility: hidden;
}

.energy-chart__legend-note {
  color: var(--chart-ink-muted);
}

.energy-chart__legend-value {
  min-width: 4.2em;
  text-align: right;
  font-weight: 600;
  color: var(--chart-ink);
  font-variant-numeric: tabular-nums;
}

/* swatches mirror the mark: a band (wash + 2px edge), a line key, or the two poles */
.energy-chart__swatch {
  display: inline-block;
  width: 14px;
  height: 12px;
  flex: none;
  position: relative;
  box-sizing: border-box;
}

.energy-chart__swatch--band {
  border-top: 2px solid currentColor;
  background-image: linear-gradient(currentColor, currentColor);
  background-color: var(--chart-surface);
  border-radius: 0 0 2px 2px;
}

.energy-chart__swatch--band::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--chart-surface);
  opacity: 0.64;
}

.energy-chart__swatch--line {
  height: 2px;
  background: currentColor;
  border-radius: 1px;
}

/* the totals' keys mirror their lines: cerută heavier and solid, debitată dashed */
.energy-chart__swatch--line.energy-chart__swatch--demand,
.energy-chart__key.energy-chart__key--demand {
  height: 3px;
  border-radius: 1.5px;
}

.energy-chart__swatch--line.energy-chart__swatch--generation,
.energy-chart__key.energy-chart__key--generation {
  background: repeating-linear-gradient(90deg, currentColor 0 4px, transparent 4px 7px);
  border-radius: 0;
}

.energy-chart__swatch--balance {
  background: linear-gradient(var(--chart-import) 0, var(--chart-import) 50%, var(--chart-export) 50%, var(--chart-export) 100%);
  border-radius: 2px;
  opacity: 0.55;
}

.energy-chart__legend-all {
  margin-left: 6px;
  font-weight: 500;
  color: var(--chart-ink-secondary);
}

.energy-chart__modes {
  display: inline-flex;
  margin-left: auto;
  border: 1px solid var(--chart-border);
  border-radius: 6px;
  overflow: hidden;
}

.energy-chart__mode {
  border: none;
  border-radius: 0;
  font-weight: 500;
  color: var(--chart-ink-secondary);
}

.energy-chart__mode + .energy-chart__mode {
  border-left: 1px solid var(--chart-border);
}

.energy-chart__mode[aria-pressed="true"] {
  background: var(--chart-ink);
  color: var(--chart-surface);
  font-weight: 600;
}

/* ---- body: plot, status, tooltip ------------------------------------- */

.energy-chart__body {
  position: relative;
  user-select: none;
  -webkit-user-select: none;
}

.energy-chart__plot {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  border-radius: 4px;
  touch-action: pan-y;
}

.energy-chart__plot:focus { outline: none; }
.energy-chart__plot:focus-visible { outline: 2px solid var(--chart-focus); outline-offset: 2px; }

.energy-chart__status {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--chart-ink-muted);
  pointer-events: none;
}

.energy-chart__hit-area {
  fill: transparent;
  pointer-events: all;
  cursor: crosshair;
}

.energy-chart__grid line {
  stroke: var(--chart-grid);
  stroke-width: 1;
  shape-rendering: crispEdges;
}

.energy-chart__grid line.energy-chart__zero-line,
.energy-chart__axis-line {
  stroke: var(--chart-axis);
  stroke-width: 1;
  shape-rendering: crispEdges;
}

.energy-chart__tick {
  fill: var(--chart-ink-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.energy-chart__tick--major {
  fill: var(--chart-ink-secondary);
  font-weight: 600;
}

.energy-chart__panel-title {
  fill: var(--chart-ink-secondary);
  font-size: 12px;
  font-weight: 600;
}

.energy-chart__region {
  fill: var(--chart-ink-muted);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  pointer-events: none;
}

/* ---- series ----------------------------------------------------------- */

.energy-chart__band-fill {
  fill: currentColor;
  fill-opacity: 0.36;
  stroke: none;
}

.energy-chart__band-edge,
.energy-chart__line {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

/* The two totals run close together on top of the coloured stack, so they are told
   apart by pattern and weight rather than by tone alone: Putere cerută is the solid,
   heavier ink line, Putere debitată is dashed. Each sits on a surface-coloured halo
   (same geometry, wider stroke) so it stays crisp over any band or source line. */
.energy-chart__line-halo {
  fill: none;
  stroke: var(--chart-surface);
  stroke-width: 5.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.energy-chart__line--demand {
  stroke-width: 2.5;
}

.energy-chart__line--generation,
.energy-chart__line-halo--generation {
  stroke-dasharray: 6 4;
  stroke-linecap: butt;
}

.energy-chart__balance-fill {
  fill: currentColor;
  fill-opacity: 0.16;
  stroke: none;
}

.energy-chart__balance-line {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.energy-chart__marker,
.energy-chart__hover-marker {
  fill: currentColor;
  stroke: var(--chart-surface);
  stroke-width: 2;
}

[data-series].is-dim {
  opacity: 0.18;
  transition: opacity 120ms ease-out;
}

.energy-chart__label {
  fill: var(--chart-ink);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  paint-order: stroke;
  stroke: var(--chart-surface);
  stroke-width: 3px;
  stroke-linejoin: round;
}

.energy-chart__label-tag {
  fill: var(--chart-ink-muted);
  font-weight: 500;
}

.energy-chart__crosshair {
  stroke: var(--chart-axis);
  stroke-width: 1;
  shape-rendering: crispEdges;
}

/* ---- tooltip ---------------------------------------------------------- */

.energy-chart__tooltip {
  position: absolute;
  z-index: 2;
  visibility: hidden;
  pointer-events: none;
  white-space: nowrap;
  padding: 7px 10px 8px;
  border-radius: 6px;
  background: var(--chart-tooltip-bg);
  box-shadow: var(--chart-tooltip-shadow);
  font-size: 12px;
  color: var(--chart-ink-secondary);
}

.energy-chart__tooltip-date {
  margin: 0 0 4px;
  font-weight: 600;
  color: var(--chart-ink);
}

.energy-chart__tooltip-row {
  display: flex;
  align-items: center;
  gap: 7px;
  line-height: 1.5;
}

.energy-chart__tooltip-sep {
  height: 1px;
  margin: 4px 0;
  background: var(--chart-grid);
}

.energy-chart__key {
  display: inline-block;
  width: 12px;
  height: 2px;
  flex: none;
  border-radius: 1px;
  background: currentColor;
}

.energy-chart__tooltip-name {
  flex: 1 1 auto;
  min-width: 7.5em;
}

.energy-chart__tooltip-value {
  font-weight: 600;
  color: var(--chart-ink);
  font-variant-numeric: tabular-nums;
}

.energy-chart__tooltip-note {
  font-weight: 400;
  color: var(--chart-ink-muted);
}

/* ---- zoom: selection band, navigator --------------------------------- */

.energy-chart__brush {
  fill: var(--chart-focus);
  fill-opacity: 0.12;
  stroke: var(--chart-focus);
  stroke-opacity: 0.6;
  stroke-width: 1;
  shape-rendering: crispEdges;
  pointer-events: none;
}

.energy-chart__nav-track {
  fill: transparent;
  stroke: var(--chart-grid);
  stroke-width: 1;
  shape-rendering: crispEdges;
  pointer-events: all;
  cursor: crosshair;
}

.energy-chart__nav-series {
  pointer-events: none;
}

.energy-chart__nav-area {
  fill: var(--chart-ink-muted);
  fill-opacity: 0.12;
}

.energy-chart__nav-line {
  fill: none;
  stroke: var(--chart-ink-muted);
  stroke-opacity: 0.7;
  stroke-width: 1;
  stroke-linejoin: round;
}

.energy-chart__nav-veil {
  fill: var(--chart-surface);
  fill-opacity: 0.65;
  pointer-events: none;
}

.energy-chart__nav-window {
  fill: transparent;
  stroke: var(--chart-focus);
  stroke-width: 1;
  shape-rendering: crispEdges;
  pointer-events: all;
  cursor: grab;
}

.energy-chart__nav-window:active {
  cursor: grabbing;
}

.energy-chart__nav-handle {
  fill: var(--chart-focus);
  stroke: var(--chart-surface);
  stroke-width: 2;
  pointer-events: none;
}

.energy-chart__nav-handle-hit {
  fill: transparent;
  pointer-events: all;
  cursor: ew-resize;
}

@media (forced-colors: active) {
  .energy-chart__band-edge, .energy-chart__line, .energy-chart__balance-line, .energy-chart__crosshair, .energy-chart__axis-line,
  .energy-chart__nav-line, .energy-chart__nav-window, .energy-chart__brush { stroke: CanvasText; }
  .energy-chart__marker, .energy-chart__hover-marker, .energy-chart__nav-handle { fill: CanvasText; }
  .energy-chart__band-fill, .energy-chart__balance-fill, .energy-chart__nav-area { fill: CanvasText; fill-opacity: 0.25; }
  .energy-chart__tick, .energy-chart__label, .energy-chart__panel-title, .energy-chart__region { fill: CanvasText; }
  .energy-chart__swatch, .energy-chart__key { background: CanvasText; forced-color-adjust: none; }
  .energy-chart__line-halo { stroke: Canvas; }
}

@media print {
  .energy-chart { border: none; width: 100%; }
  .energy-chart__tooltip, .energy-chart__hover, .energy-chart__tools, .energy-chart__hint, .energy-chart__modes, .energy-chart__legend-all { display: none; }
}
