/* The Charts page sector rail: the eleven SPDR sectors, and the basket behind
 * whichever one is open.
 *
 * IT IS ITS OWN STYLESHEET FOR THE SAME REASON IT IS ITS OWN SCRIPT. charts.css
 * dresses the chart; this dresses everything to the right of it. The class
 * prefixes are deliberately distinct (csec for the rail, chld for the
 * holdings) so the two files can be edited at the same time without either one
 * quietly restyling the other.
 *
 * THIS REPLACED charts_sidebar.css, which dressed a watchlist. Two rules came
 * across with it because the rail's pickers and column headings are the same
 * objects the watchlist's were, and they are renamed here rather than left
 * carrying a `cwl-` prefix that no longer refers to anything.
 *
 * Tokens only, from static/css/banana-tokens.css. Boundaries are made with
 * tone, not with rules: the panel sits one step up from the void, and nothing
 * here draws a border to say where a thing ends. 8 px gaps, 4 px radius. Every
 * number is mono with tabular figures so a column of prices lines up on the
 * decimal point, and no body text is pure white.
 */

/* ── the pickers and the column headings ────────────────────────────────── */

.chld-cols__num { text-align: right; }

.csec-select {
  width: 100%;
  padding: 1px 2px;
  border: 0;
  border-radius: var(--banana-radius);
  background: var(--banana-surface-container);
  color: var(--banana-text-body);
  font-family: var(--banana-font-body);
  font-size: 9px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-align: right;
  cursor: pointer;
}

.csec-select:focus-visible {
  outline: 1px solid var(--banana-primary-fixed);
  outline-offset: 1px;
}

/* ── the sector rail and its holdings ───────────────────────────────────── */
/*
 * THE RAIL IS 340 px WIDE AND THE PANEL EATS 12 EACH SIDE, so every track
 * below is budgeted against 316. The names are the only elastic column, and
 * they are the only thing here allowed to truncate: a clipped price or a
 * clipped percent is a wrong number, while a clipped fund name is still the
 * right fund, and the ticker beside it never truncates at all.
 */

/* `[hidden]` is a user agent rule of `display: none`, and any class that sets
   `display` beats it on specificity. Both of these do. */
.chld-cols[hidden],
.csec-row[hidden] { display: none; }

.charts-panel--sectors { flex: 0 0 auto; }

/* The holdings panel takes the slack, so the thing that grows with the window
   is the list of names inside the open sector. That is the part a reader wants
   more of; the eleven sectors above it are a fixed height by definition. */
.charts-panel--holdings {
  flex: 1 1 auto;
  min-height: 0;
}

.csec-pick { justify-self: end; min-width: 0; }
.csec-pick .csec-select { width: auto; }

.csec-rows,
.chld-rows {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-height: 0;
}

.chld-rows {
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* ── a sector row ───────────────────────────────────────────────────────── */

.csec-row {
  position: relative;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 62px;
  gap: 6px;
  align-items: baseline;
  width: 100%;
  padding: 6px;
  border: 0;
  border-radius: var(--banana-radius);
  background: transparent;
  text-align: left;
  cursor: pointer;
  font-family: var(--banana-font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--banana-text-body);
}

/* THE BAR IS BEHIND THE TEXT, NOT BESIDE IT. A rail this narrow has no column
   to spare for a chart, and a bar that reads as a background tint is legible
   at a glance without taking any width from the numbers. It is scaled in the
   script against the widest magnitude on the rail. */
.csec-row__bar {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  border-radius: var(--banana-radius);
  background: var(--banana-outline);
  opacity: 0.16;
  pointer-events: none;
}

.csec-row__bar[data-dir="up"] { background: var(--banana-chart-call); }
.csec-row__bar[data-dir="down"] { background: var(--banana-chart-put); }

.csec-row:hover { background: var(--banana-surface-container); }
.csec-row[aria-pressed="true"] { background: var(--banana-surface-container-high); }

/* Charted and open are different states and they are shown differently. A
   sector can be open in the panel below while the chart shows one of its
   holdings, and a reader has to be able to tell which is which. */
.csec-row[aria-current="true"] .csec-row__sym { color: var(--banana-primary-fixed); }

.csec-row:focus-visible,
.chld-row:focus-visible {
  outline: 1px solid var(--banana-primary-fixed);
  outline-offset: 1px;
}

.csec-row__sym,
.csec-row__name,
.csec-row__val { position: relative; }

.csec-row__sym {
  font-size: 12px;
  letter-spacing: 0.04em;
}

.csec-row__name {
  font-family: var(--banana-font-body);
  font-size: 10px;
  line-height: 1.4;
  color: var(--banana-on-surface-variant);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.csec-row__val {
  font-size: 11px;
  text-align: right;
  color: var(--banana-text-body);
}

.csec-row__val[data-dir="up"] { color: var(--banana-chart-call); }
.csec-row__val[data-dir="down"] { color: var(--banana-chart-put); }

/* The benchmark is on the rail but is not one of the eleven. It is separated
   by tone rather than by a rule, the same way every other boundary here is. */
.csec-row[data-benchmark="true"] {
  margin-bottom: 3px;
  background: var(--banana-surface-container);
}

.csec-row[data-benchmark="true"] .csec-row__name { font-style: italic; }

/* Asked for and not answered. It keeps its placeholder and draws no bar,
   because a zero length bar and a missing one look the same. */
.csec-row[data-noquote] .csec-row__sym,
.csec-row[data-noquote] .csec-row__name { color: var(--banana-outline); }

/* ── the holdings table ─────────────────────────────────────────────────── */

.chld-cols,
.chld-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 52px 56px 56px;
  gap: 6px;
  min-width: 0;
}

.chld-cols {
  align-items: center;
  padding: 0 6px 2px;
  font-family: var(--banana-font-body);
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--banana-on-surface-variant);
}

.chld-row {
  align-items: baseline;
  width: 100%;
  padding: 5px 6px;
  border: 0;
  border-radius: var(--banana-radius);
  background: transparent;
  text-align: left;
  cursor: pointer;
  font-family: var(--banana-font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--banana-text-body);
}

.chld-row:hover { background: var(--banana-surface-container); }
.chld-row[aria-current="true"] { background: var(--banana-surface-container-high); }
.chld-row[aria-current="true"] .chld-row__sym { color: var(--banana-primary-fixed); }

.chld-row__sym {
  font-size: 12px;
  letter-spacing: 0.04em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chld-row__num {
  font-size: 11px;
  text-align: right;
  color: var(--banana-on-surface-variant);
}

.chld-row__num[data-dir="up"] { color: var(--banana-chart-call); }
.chld-row__num[data-dir="down"] { color: var(--banana-chart-put); }

/* A holding with no listed options is still chartable, but none of the page's
   overlays will have anything to draw on it. It is marked here rather than
   letting the reader discover it by clicking and getting an empty chart. */
.chld-row[data-nooptions="true"] .chld-row__sym::after {
  content: "\00b7";
  margin-left: 4px;
  color: var(--banana-outline);
}
