/* Indices pages (/indices/, /indices/sp500/), on top of the shared «Бенто,
   графит» classes in style.css. The S&P 500 is blue (--spx), falls red
   (--cash), gains and losses --good / --bad, so every theme works. */

/* big numbers in ink, the deepest fall in red */
.idx-red { color: var(--cash-ink); }

/* the page's inflation switch under the lead; indices.js shows it (without
   JavaScript it would do nothing) */
.intro .idx-mode { justify-self: start; margin-top: 4px; }
.idx-wait { visibility: hidden; }
/* what indices.js hides: the plot of the chart type not shown, a switch it cannot run */
#idx [hidden] { display: none; }

/* spacing inside tiles */
.idx-top-s { margin-top: 8px; }
.idx-top-m { margin-top: 12px; }
p.idx-flat { margin-bottom: 0; }
.idx-head { flex-wrap: nowrap; align-items: flex-start; }
.idx-spark { height: 80px; }
.idx-tm { display: flex; flex-direction: column; align-items: flex-start; }
.idx-tm .sentence { margin-bottom: 0; }
.idx-more { display: inline-block; margin-top: 14px; font-size: 13px; font-weight: 600; color: var(--accent-ink); }

/* notes next to charts and tables */
.idx-note { margin: -4px 0 12px; max-width: 82ch; }
.idx-foot { margin: 10px 0 0; max-width: 82ch; }
.idx-h3 { margin: 28px 0 8px; }

/* price chart controls: period chips on the left, the three switches together */
.idx-segs { display: flex; flex-wrap: wrap; gap: 8px; }

/* charts: legend inside the card, room reserved before the JS draws */
.chart .legend { padding: 2px 10px 0; margin: 0 0 4px; }
.idx-plot { min-height: 300px; }
.idx-plot-dd { min-height: 220px; }
.idx-plot-bars { min-height: 260px; }
.idx-plot-dy { min-height: 220px; }
.idx-plot.idx-fail { min-height: 0; padding: 28px 12px; font-size: 14px; color: var(--muted); }

/* tables */
.idx-gap { margin-top: 14px; }
.idx-table td { vertical-align: top; }
.idx-table .idx-sub { display: block; font-size: 11px; line-height: 1.4; font-weight: 500; color: var(--muted); }
.idx-table th[scope="row"] { text-align: left; font-weight: 600; }
.idx-mark { color: var(--muted); margin-left: 1px; }
.idx-fall { font-weight: 700; color: var(--cash-ink); }
.idx-open { font-weight: 700; color: var(--bad); }
.idx-table td, .idx-table th { font-variant-numeric: tabular-nums; }

/* older years: one <details> under each long table */
.idx-older { margin: 12px 0 0; }
.idx-older > summary { cursor: pointer; font-weight: 600; font-size: 14px; color: var(--accent-ink); padding: 6px 2px; width: max-content; max-width: 100%; }
.idx-older[open] > summary { margin-bottom: 10px; }

/* monthly returns heatmap (#months): a grid of cells, green up and red down,
   the shade by the size of the move in steps (HM_STEPS in indices.py: 1, 2,
   4, 7, 10%+); text stays ink, so it reads on every shade */
.idx-hm { border-collapse: separate; border-spacing: 2px; font-size: 12.5px; }
.idx-hm th, .idx-hm td { padding: 6px 5px; text-align: center; vertical-align: middle; border-radius: 6px; min-width: 50px; }
.idx-hm tbody tr { border-bottom: 0; }
.idx-hm th[scope="row"] { text-align: left; color: var(--ink-2); min-width: 0; padding-left: 12px; }
.idx-hm .idx-hm-total { font-weight: 650; border-left: 6px solid var(--surface); }
.idx-hm .hu1, .idx-hm-key .hu1 { background: color-mix(in srgb, var(--good) 10%, transparent); }
.idx-hm .hu2, .idx-hm-key .hu2 { background: color-mix(in srgb, var(--good) 18%, transparent); }
.idx-hm .hu3, .idx-hm-key .hu3 { background: color-mix(in srgb, var(--good) 28%, transparent); }
.idx-hm .hu4, .idx-hm-key .hu4 { background: color-mix(in srgb, var(--good) 40%, transparent); }
.idx-hm .hu5, .idx-hm-key .hu5 { background: color-mix(in srgb, var(--good) 54%, transparent); }
.idx-hm .hd1, .idx-hm-key .hd1 { background: color-mix(in srgb, var(--bad) 10%, transparent); }
.idx-hm .hd2, .idx-hm-key .hd2 { background: color-mix(in srgb, var(--bad) 18%, transparent); }
.idx-hm .hd3, .idx-hm-key .hd3 { background: color-mix(in srgb, var(--bad) 28%, transparent); }
.idx-hm .hd4, .idx-hm-key .hd4 { background: color-mix(in srgb, var(--bad) 40%, transparent); }
.idx-hm .hd5, .idx-hm-key .hd5 { background: color-mix(in srgb, var(--bad) 54%, transparent); }
/* graphite: its lighter surface makes the strongest greens too bright for white
   text; a lighter touch keeps it at 4.5:1 or more */
:root[data-theme="dark"] .idx-hm .hu4, :root[data-theme="dark"] .idx-hm-key .hu4 { background: color-mix(in srgb, var(--good) 34%, transparent); }
:root[data-theme="dark"] .idx-hm .hu5, :root[data-theme="dark"] .idx-hm-key .hu5 { background: color-mix(in srgb, var(--good) 44%, transparent); }
.idx-hm-key { display: flex; align-items: center; gap: 3px; margin: 0 0 12px; font-size: 12px; color: var(--muted); }
.idx-hm-key span { width: 18px; height: 12px; border-radius: 3px; }
.idx-hm-key .hz { background: var(--track); }
.idx-hm-key b { font-weight: 500; font-variant-numeric: tabular-nums; margin: 0 6px; }
.idx-hm-key b:first-child { margin-left: 0; }

/* the overview (/indices/): the headline after inflation over the comparison
   chart, then one card per index, side by side */
.idx-ov { margin: 22px 0 0; }
.idx-headline { margin: 0 0 10px; max-width: 78ch; color: var(--ink-2); font-size: 15px; }
.idx-headline strong { display: block; color: var(--ink); font: 650 clamp(21px, 2.4vw, 28px)/1.25 var(--display); letter-spacing: -0.02em; margin: 0 0 6px; }
.idx-plot-ov { min-height: 320px; }
.idx-trio { display: grid; gap: 16px; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 16px 0 0; }
.idx-trio .big { font-size: clamp(34px, 3.4vw, 46px); }
@media (max-width: 900px) { .idx-trio { grid-template-columns: minmax(0, 1fr); } }

.idx-links { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 24px; font-size: 15px; font-weight: 600; }

@media (max-width: 640px) {
  /* wide tables scroll sideways; the first column stays in view */
  .idx-table th:first-child, .idx-table td:first-child { position: sticky; left: 0; z-index: 1; background: var(--surface); box-shadow: 1px 0 0 var(--border); }
  .idx-table thead th:first-child { z-index: 2; }
  .idx-hm th:first-child { border-radius: 0; box-shadow: -2px 0 0 var(--surface), 2px 0 0 var(--surface), 3px 0 0 var(--border); }
  .idx-spark { height: 64px; }
}

/* a period of one's own: two year pickers next to the range chips */
.idx-period { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.idx-period select { font: 600 14px var(--font); color: var(--ink); background: var(--track); border: 0; border-radius: 999px; padding: 8px 12px; cursor: pointer; }
.idx-period select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
