/* ---------- SVG chart primitives (js/charts.js) ---------- */

.chart {
  display: block;
  width: 100%;
  height: auto;
}

/* Wraps lineArea/bars/gradientSlider's <svg> together with an HTML overlay
   of their numeric axis labels (see chartHtmlWrap in charts.js) — SVG
   <text> on this dark background shows visible colour fringing that
   font-weight/text-rendering/shape-rendering hints don't clear, so those
   specific labels render as ordinary HTML text instead, positioned with
   percentages that line up with the SVG's own coordinate space. */
.chart-html-wrap {
  position: relative;
  width: 100%;
}

.chart-html-wrap svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* Cumulative P&L, Net daily P&L, Account balance, Drawdown: fixed card
   height instead of scaling with container width (preserveAspectRatio
   "none" on these two chart types lets the box control the aspect). */
.chart-html-wrap--line-area,
.chart-html-wrap--bars {
  height: 200px;
}

/* Fixed height matching the default viewBox height (see gradientSlider in
   charts.js) so preserveAspectRatio="none" gives it a true 1:1 vertical
   scale — otherwise the tick labels' position would drift from the track
   they're supposed to sit under as the slider's width changes. */
.chart-html-wrap--gradient-slider {
  height: 64px;
}

/* Dashboard charts 21/22 — taller than the other bar/line charts since
   they're full-width section content, not squeezed into a 2/3-column
   dashboard row. */
.chart-html-wrap--categorical-bars {
  height: 260px;
}

.chart-html-wrap--grouped-bars {
  height: 300px;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  margin-bottom: var(--space-3);
}

.chart-legend__item {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.8rem;
  color: var(--muted);
}

.chart-legend__swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.chart-html-axis {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.chart-html-axis__label {
  position: absolute;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--chart-label);
  white-space: nowrap;
}

/* The slider's track column is narrow next to the radar on desktop
   (~70-90px) but goes full-width once the row collapses to one column on
   mobile — the old SVG ticks fit six labels at any width by riding
   preserveAspectRatio="none"'s horizontal squeeze; HTML text has no
   equivalent, so it needs a smaller size specifically when its own box is
   too narrow for six 12px labels to avoid overlapping each other. A
   container query (not a viewport media query) is what's needed here,
   since the same card is narrow or wide depending on dashboard layout, not
   screen size. */
.chart-html-wrap--gradient-slider {
  container-type: inline-size;
}

.chart-html-wrap--gradient-slider .chart-html-axis__label {
  font-size: 9px;
}

@container (max-width: 60px) {
  .chart-html-wrap--gradient-slider .chart-html-axis__label {
    font-size: 7px;
  }
}

@container (min-width: 160px) {
  .chart-html-wrap--gradient-slider .chart-html-axis__label {
    font-size: 12px;
  }
}

.chart-value-text {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 600;
  fill: var(--text);
}

.chart-value-text--sm {
  font-size: 16px;
}

/* font-size/fill are also set inline wherever these classes are used in
   charts.js — that's the source of truth (see AXIS_LABEL_STYLE), since it
   must survive independent of container width tricks like
   preserveAspectRatio. These are just the matching fallback/default. */
.chart-axis-label {
  font-family: var(--font-sans);
  font-size: 13px;
  fill: var(--chart-label);
}

/* x-axis date labels only now — the y-axis $ values and slider ticks that
   used to share this class moved to HTML (see .chart-html-axis__label). */
.chart-axis-x-label {
  font-family: var(--font-mono);
  font-size: 12px;
  fill: var(--chart-label);
}

.chart-empty-text {
  font-family: var(--font-sans);
  font-size: 13px;
  fill: var(--muted);
}

/* Month calendar (HTML grid, not SVG — see charts.js header comment) */

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.cal-weekday {
  text-align: center;
  font-size: 0.78rem;
  color: var(--muted);
  padding-bottom: var(--space-1);
}

.cal-cell {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px;
  min-height: 92px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: var(--surface);
}

.cal-cell--empty {
  border-color: transparent;
  background: transparent;
}

.cal-cell--win {
  border-color: var(--green);
  background: rgba(52, 211, 153, 0.08);
}

.cal-cell--loss {
  border-color: var(--red);
  background: rgba(244, 80, 106, 0.08);
}

.cal-cell--scratch {
  border-color: var(--muted);
}

.cal-cell__day {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--muted);
}

.cal-cell__pnl {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

.cal-cell--win .cal-cell__pnl {
  color: var(--green);
}

.cal-cell--loss .cal-cell__pnl {
  color: var(--red);
}

.cal-cell__count {
  font-size: 0.78rem;
  color: var(--muted);
}

@media (max-width: 599px) {
  .cal-cell {
    min-height: 54px;
    padding: 4px;
  }

  .cal-cell__count {
    display: none;
  }
}
