/* Charts section — widget styles adapted from the graph.html prototype.
   Design tokens (--acc, --nm-*, --bg2 etc.) and base classes (.nm-surface,
   .sec-label, .mi, .epick-input, .epick-fetch-btn, ...) already live in
   style.css and are reused as-is; only chart-specific widget styles live here. */

/* ─── WIDGET HEADER ───────────────────────────────────────── */
.widget-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.widget-title {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--txt2);
  display: flex;
  align-items: center;
  gap: 5px;
}
.widget-title .mi { font-size: 14px; color: var(--acc); }
.widget-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: var(--r-pill);
  font-size: 11px;
  font-family: var(--mono);
  background: var(--s2);
  border: 1px solid var(--bd2);
  box-shadow: var(--nm-btn);
  color: var(--txt2);
}
.widget-badge.up { color: var(--green); background: rgba(26,168,111,0.08); border-color: rgba(26,168,111,0.18); }
.widget-badge.dn { color: var(--red); background: rgba(216,77,97,0.08); border-color: rgba(216,77,97,0.18); }
.badge-dot { width: 5px; height: 5px; border-radius: 50%; flex-shrink: 0; }
.badge-dot.up { background: var(--green); }
.badge-dot.dn { background: var(--red); }

/* ─── PRICE SUMMARY ROW ───────────────────────────────────── */
.price-summary {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 4px;
}
.price-big {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 500;
  color: var(--txt);
  letter-spacing: -0.02em;
}
.price-sub {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 16px;
  font-family: var(--mono);
}

/* ─── CHART TABS ──────────────────────────────────────────── */
.chart-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 12px;
}
.chart-tab {
  padding: 4px 12px;
  border-radius: var(--r-pill);
  font-size: 11px;
  font-family: var(--mono);
  border: 1px solid transparent;
  background: transparent;
  color: var(--txt2);
  cursor: pointer;
  transition: all var(--t);
  letter-spacing: 0.04em;
}
.chart-tab:hover { color: var(--txt); }
.chart-tab.active {
  background: var(--acc-d);
  border-color: var(--bd2);
  color: var(--acc);
  box-shadow: var(--nm-in);
}

/* ─── SVG CHART ───────────────────────────────────────────── */
.chart-wrap {
  position: relative;
  width: 100%;
  height: 140px;
  margin-bottom: 8px;
  /* Reserved as REAL css padding, not viewBox units baked into the plot's
     own coordinate space — a fixed pixel margin never shrinks no matter
     how much the svg itself gets compressed for dense data, which is
     exactly why it used to bleed under the y-axis labels: that reservation
     used to live inside the viewBox and got crushed right along with
     everything else once max-width:100% squeezed a wide chart down. */
  padding-right: 44px;
  touch-action: pan-y;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.chart-wrap svg {
  /* Natural width is set inline per-render (proportional to point count,
     same "fixed spacing per data point" idea as the Z-Index bars) — this
     only caps it back down to the wrap's content box (padding excluded,
     so it never renders under the y-labels) when there's enough points to
     need the space; it does NOT stretch a handful of points out to fill
     the whole screen. */
  display: block;
  max-width: 100%;
  height: 100%;
  overflow: visible;
}
.chart-y-labels {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 9px;
  color: var(--muted);
  padding: 2px 0;
  pointer-events: none;
}
.chart-tooltip {
  position: absolute;
  background: var(--s1);
  border: 1px solid var(--bd2);
  border-radius: var(--r-sm);
  box-shadow: var(--nm-out);
  padding: 6px 10px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--txt);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.1s;
  white-space: nowrap;
  z-index: 10;
}
.chart-tooltip.vis { opacity: 1; }
.chart-crosshair {
  position: absolute;
  top: 0; bottom: 0;
  width: 1px;
  background: var(--bd3);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.1s;
}
.chart-crosshair.vis { opacity: 1; }

/* ─── FGI GAUGE ───────────────────────────────────────────── */
.fgi-gauge-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 4px;
}
.fgi-svg-wrap {
  position: relative;
  width: 140px;
  height: 80px;
  margin: 0 auto 6px;
}
.fgi-svg-wrap svg { overflow: visible; }
.fgi-value {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
}
.fgi-num {
  font-family: var(--mono);
  font-size: 28px;
  font-weight: 500;
  color: var(--txt);
  line-height: 1;
  display: block;
}
.fgi-label {
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.06em;
  display: block;
  margin-top: 2px;
}

/* ─── Z-INDEX BAR WIDGETS ─────────────────────────────────── */
.zbar-wrap {
  position: relative;
  height: 100px;
  overflow-x: auto;
  overflow-y: hidden;
  /* pan-y: default vertical page scroll stays intact — the crosshair
     engine only preventDefault()s while its own double-tap-armed mode is
     on, instead of permanently stealing every touch gesture. */
  touch-action: pan-y;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.zbar-track {
  position: relative;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 100%;
  width: max-content;
  padding: 0 2px;
}
.zbar-zero-line {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  background: var(--bd3);
  pointer-events: none;
}
.zbar-bar {
  position: relative;
  width: 5px;
  flex-shrink: 0;
  height: 50%;
  display: flex;
  flex-direction: column;
}
/* pos bars occupy the top half and grow upward away from the zero line;
   neg bars occupy the bottom half and grow downward away from it. */
.zbar-bar.pos {
  align-self: flex-start;
  justify-content: flex-end;
}
.zbar-bar.neg {
  align-self: flex-end;
  justify-content: flex-start;
}
.zbar-bar-fill {
  width: 100%;
  border-radius: 2px;
}
.zbar-bar.pos .zbar-bar-fill { background: var(--green); }
.zbar-bar.neg .zbar-bar-fill { background: var(--red); }

/* ─── SYNCED CROSSHAIR (bar widgets) ──────────────────────── */
.zbar-crosshair-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--acc);
  opacity: 0.55;
  pointer-events: none;
  display: none;
  z-index: 2;
}
/* Matches the active bar's own color instead of always reading as accent
   (green), which looked wrong sitting on top of a red down-bar. */
.zbar-crosshair-line.pos { background: var(--green); }
.zbar-crosshair-line.neg { background: var(--red); }
.zbar-bar.active .zbar-bar-fill {
  filter: brightness(1.15);
}
.zbar-bar.pos.active .zbar-bar-fill { box-shadow: 0 0 0 1.5px var(--green); }
.zbar-bar.neg.active .zbar-bar-fill { box-shadow: 0 0 0 1.5px var(--red); }

/* Price/Volume header readouts get an accent tint + label suffix while
   the crosshair is scrubbing a past day, so it doesn't read as "live". */
#charts-price-widget.crosshair-active .price-big {
  color: var(--acc);
}
#charts-price-widget.crosshair-active .price-sub::after {
  content: ' · crosshair';
  color: var(--acc);
}

/* ─── INDICATOR PILLS ROW ──────────────────────────────────── */
.indicator-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.ind-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border-radius: var(--r-pill);
  font-size: 11px;
  font-family: var(--mono);
  background: var(--s2);
  border: 1px solid var(--bd2);
  box-shadow: var(--nm-btn);
  color: var(--txt2);
}
.ind-pill .lbl { font-size: 9px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.ind-pill.pos .val { color: var(--acc); }
.ind-pill.neg .val { color: var(--red); }
.ind-pill.neu .val { color: var(--txt); }

/* ─── CHART PATH DRAW-IN ──────────────────────────────────── */
.chart-path-line {
  stroke-dasharray: 2000;
  stroke-dashoffset: 2000;
  animation: chartsDrawLine 1.2s cubic-bezier(0.2,0.8,0.2,1) 0.1s forwards;
}
@keyframes chartsDrawLine {
  to { stroke-dashoffset: 0; }
}
