/* ============================================================
   CHART — equity curve container + SVG styling
   The SVG itself uses CSS variables for colors, so it auto-themes.
   ============================================================ */

.chart-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-width: 0;
}

.chart-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.chart-card__title-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.chart-card__title {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
}

.chart-card__subtitle {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
}

/* Chart legend */
.chart-legend {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.chart-legend__item {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  white-space: nowrap;
}

.chart-legend__swatch {
  width: 14px;
  height: 2px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.chart-legend__swatch--equity { background: var(--color-primary); height: 2px; }
.chart-legend__swatch--target {
  background: transparent;
  border-top: 2px dashed var(--color-success);
}
.chart-legend__swatch--floor {
  background: transparent;
  border-top: 2px dashed var(--color-danger);
}

/* SVG sizing wrapper */
.chart-svg-wrap {
  width: 100%;
  position: relative;
  /* Cap the chart height — SVG viewBox can scale wider than the side panel
     allows, leaving empty space. This keeps the chart proportional. */
  aspect-ratio: 800 / 280;
  max-height: 360px;
}

.chart-svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}

/* SVG element styles — referenced via class inside the SVG */
.chart__grid-line {
  stroke: var(--border-subtle);
  stroke-width: 1;
  stroke-dasharray: 0;
}

.chart__axis-label {
  fill: var(--text-tertiary);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: var(--weight-medium);
}

.chart__target-line {
  stroke: var(--color-success);
  stroke-width: 1.5;
  stroke-dasharray: 4 4;
  fill: none;
}

.chart__floor-line {
  stroke: var(--color-danger);
  stroke-width: 1.5;
  stroke-dasharray: 4 4;
  fill: none;
}

.chart__line-label {
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
}

.chart__line-label--target { fill: var(--color-success-text); }
.chart__line-label--floor  { fill: var(--color-danger-text); }

.chart__equity-area {
  fill: var(--color-primary);
  fill-opacity: 0.08;
}

.chart__equity-line {
  stroke: var(--color-primary);
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart__equity-point {
  fill: var(--color-primary);
  stroke: var(--bg-surface);
  stroke-width: 2;
}

.chart__equity-point--current {
  fill: var(--color-primary);
  stroke: var(--bg-surface);
  stroke-width: 3;
  r: 5;
}

/* Vertical "today" indicator */
.chart__today-line {
  stroke: var(--border-strong);
  stroke-width: 1;
  stroke-dasharray: 2 3;
}

/* Chart footer — small stat tiles below the SVG.
   Fills the visual space and adds useful at-a-glance numbers. */
.chart-footer {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-3);
  margin-top: auto;       /* push to bottom of card */
  padding-top: var(--space-4);
  border-top: 1px solid var(--border-subtle);
}

.chart-footer__stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.chart-footer__stat-label {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  font-weight: var(--weight-medium);
  letter-spacing: 0;
  text-transform: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chart-footer__stat-value {
  font-family: var(--font-mono);
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.chart-footer__stat-value--positive { color: var(--color-success-text); }
.chart-footer__stat-value--negative { color: var(--color-danger-text); }

@media (max-width: 540px) {
  .chart-footer { grid-template-columns: repeat(2, 1fr); }
}
