/* The stock chart (src/dashboard/chart.js, docs/stock-chart.md). It builds on the dashboard's `.chart`, `.seg`, `.card` and the colours of app.css. */
/* The series take the app's tokens where they don't collide (the slow average in --watch, which is 4.5:1 on either panel, so the legend's words use it too); the 20-day line and the second comparison keep their teal, because the accent is the price line's and the main symbol's own; the 100- and 200-day lines and the third comparison keep their hues too, each with a dark twin. */
.sc {
  --sc-20: #1b8579;
  --sc-50: var(--watch);
  --sc-100: #7c55d6;
  --sc-200: #c2417c;
  --sc-vwap: var(--muted);
  --sc-cmp-1: var(--watch);
  --sc-cmp-2: #1b8579;
  --sc-cmp-3: #7c55d6;
  --sc-50-text: var(--watch);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .sc {
    --sc-20: #3fc1b0;
    --sc-cmp-2: #3fc1b0;
    --sc-100: #a78bfa;
    --sc-200: #f472b6;
    --sc-cmp-3: #a78bfa;
  }
}
:root[data-theme="dark"] .sc {
  --sc-20: #3fc1b0;
  --sc-cmp-2: #3fc1b0;
  --sc-100: #a78bfa;
  --sc-200: #f472b6;
  --sc-cmp-3: #a78bfa;
}

/* The title, what the lines are, then the bar size and the range side by side (they wrap on a phone, each on its own line when they do not fit). */
.sc .card-title { margin: 0 0 4px; }
.sc-legend { gap: 4px 12px; margin-bottom: 6px; }
.sc-ctl { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin: 6px 0 4px; }
.sc-ctl .seg, .sc-bar .seg { max-width: 100%; }
.sc .seg button { white-space: nowrap; padding: 0 10px; }
.sc .seg button:disabled { opacity: 0.45; cursor: default; }
/* The controls under the picture: the type, the scale, zoom and the two pickers. They wrap on a phone. */
.sc-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 10px 0 6px; }
.sc-tools { display: inline-flex; gap: 4px; }
.sc-tool { min-width: 34px; min-height: 34px; padding: 0 8px; font-size: 16px; line-height: 1; }
.sc-tool[hidden] { display: none; }
.sc-tool:disabled { opacity: 0.4; }
.sc-picker, .sc-compare { position: relative; }
.sc-picker > summary, .sc-compare > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; min-height: 34px; }
.sc-picker > summary::-webkit-details-marker, .sc-compare > summary::-webkit-details-marker { display: none; }
.sc-picker > summary .chip, .sc-compare > summary .chip { margin: 0; }
.sc-pop { margin-top: 6px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow); box-sizing: border-box; width: 100%; max-width: 420px; }
.sc-pop .meta { margin: 8px 0 4px; }
.sc-pop .meta:first-child { margin-top: 0; }
.sc-pop .row { gap: 6px; align-items: center; margin: 4px 0; }
.sc-pop .row.wrap { flex-wrap: wrap; }
.sc-checks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 12px; }
.sc-checks .check-row { min-height: 32px; }
.sc-checks .check-row.sc-wide { grid-column: 1 / -1; }
.sc-pop input.in { min-width: 0; width: 100%; }
.sc-pop .chip { cursor: pointer; }
.sc-chip { display: inline-flex; align-items: center; gap: 4px; }
.sc-chip.sc-c1 { color: var(--sc-cmp-1); }
.sc-chip.sc-c2 { color: var(--sc-cmp-2); }
.sc-chip.sc-c3 { color: var(--sc-cmp-3); }
.sc-x { border: 0; background: transparent; color: inherit; font-size: 16px; line-height: 1; padding: 0 2px; cursor: pointer; }
@media (min-width: 900px) {
  .sc-pop { position: absolute; z-index: 5; inset-inline-start: 0; }
}

/* The figures under the crosshair: a fixed place above the chart, so a finger never covers them. */
.sc-readout { min-height: 62px; margin: 6px 0 4px; font-size: 13px; font-variant-numeric: tabular-nums; }
.sc-ro-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sc-ro-head .chip { margin-inline-start: 4px; }
.sc-ro-cells, .sc-ro-inds { display: flex; flex-wrap: wrap; gap: 2px 14px; margin-top: 3px; }
.sc-ro-cell { white-space: nowrap; }
.sc-ro-mark { margin: 3px 0 0; color: var(--muted); }

/* The picture */
.sc-plot { margin-top: 2px; outline-offset: 2px; cursor: crosshair; transition: opacity 0.15s; }
.sc-plot.busy { opacity: 0.55; }
.sc-plot:focus-visible { outline: 2px solid var(--accent); }
.sc-plot text { fill: var(--faint); font-size: 11px; }
.sc-plot .sc-ptitle { fill: var(--muted); font-size: 11px; font-weight: 600; }
.sc-plot .sc-up { fill: var(--pos); stroke: var(--pos); stroke-width: 1; shape-rendering: crispEdges; }
.sc-plot .sc-down { fill: var(--neg); stroke: var(--neg); stroke-width: 1; shape-rendering: crispEdges; }
.sc-plot .sc-vol.up { fill: var(--pos); opacity: 0.55; }
.sc-plot .sc-vol.down { fill: var(--neg); opacity: 0.55; }
.sc-plot .sc-last { stroke: var(--faint); stroke-width: 1; stroke-dasharray: 1 3; }
.sc-plot .sc-ref { stroke: var(--faint); stroke-width: 1; stroke-dasharray: 3 4; }
.sc-plot .sc-hit { cursor: crosshair; }
.sc-plot .sc-ov { fill: none; stroke-width: 1.4; stroke-linejoin: round; }
.sc-plot .sc-ov.ema { stroke-dasharray: 5 3; }
.sc-plot .sc-ov-sma20, .sc-plot .sc-ov-ema20 { stroke: var(--sc-20); }
.sc-plot .sc-ov-sma50, .sc-plot .sc-ov-ema50 { stroke: var(--sc-50); }
.sc-plot .sc-ov-sma100, .sc-plot .sc-ov-ema100 { stroke: var(--sc-100); }
.sc-plot .sc-ov-sma200, .sc-plot .sc-ov-ema200 { stroke: var(--sc-200); }
.sc-plot .sc-ov-vwap { stroke: var(--sc-vwap); stroke-dasharray: 2 2; }
.sc-plot .sc-bb-fill { fill: var(--accent); opacity: 0.08; stroke: none; }
.sc-plot .sc-bb { fill: none; stroke: var(--accent); stroke-width: 1; opacity: 0.7; }
.sc-plot .sc-bb.mid { stroke-dasharray: 3 3; opacity: 0.55; }
.sc-plot .sc-rsi { fill: none; stroke: var(--accent); stroke-width: 1.4; }
.sc-plot .sc-macd { fill: none; stroke: var(--accent); stroke-width: 1.4; }
.sc-plot .sc-macd.signal { stroke: var(--sc-50); }
.sc-plot .sc-cmp { fill: none; stroke-width: 1.7; stroke-linejoin: round; }
.sc-plot .sc-cmp.main { stroke: var(--accent); }
.sc-plot .sc-cmp.sc-c1 { stroke: var(--sc-cmp-1); }
.sc-plot .sc-cmp.sc-c2 { stroke: var(--sc-cmp-2); }
.sc-plot .sc-cmp.sc-c3 { stroke: var(--sc-cmp-3); }
.sc-plot .tag-rect.main, .sc-plot .tag-rect.sc-c0 { stroke: var(--accent); }
.sc-plot .tag-text.main, .sc-plot .tag-text.sc-c0 { fill: var(--accent); }
.sc-plot .tag-rect.sc-c1 { stroke: var(--sc-cmp-1); }
.sc-plot .tag-text.sc-c1 { fill: var(--sc-cmp-1); }
.sc-plot .tag-rect.sc-c2 { stroke: var(--sc-cmp-2); }
.sc-plot .tag-text.sc-c2 { fill: var(--sc-cmp-2); }
.sc-plot .tag-rect.sc-c3 { stroke: var(--sc-cmp-3); }
.sc-plot .tag-text.sc-c3 { fill: var(--sc-cmp-3); }
/* A pattern's day is marked in a neutral colour: it describes, it does not point up or down. */
.sc-plot .sc-sig { fill: var(--muted); stroke: var(--panel); stroke-width: 1; }

/* The legend: the same swatches as before, for the lines this chart can have */
.sc-legend .sc-lg-sma20 { color: var(--sc-20); }
.sc-legend .sc-lg-sma50 { color: var(--sc-50-text); }
.sc-legend .sc-lg-sma100 { color: var(--sc-100); }
.sc-legend .sc-lg-sma200 { color: var(--sc-200); }
.sc-legend .sc-lg-ema20 { color: var(--sc-20); }
.sc-legend .sc-lg-ema50 { color: var(--sc-50-text); }
.sc-legend .sc-lg-ema100 { color: var(--sc-100); }
.sc-legend .sc-lg-ema200 { color: var(--sc-200); }
.sc-legend .sc-lg-vwap { color: var(--sc-vwap); }
.sc-legend .sc-lg-bb { color: var(--accent); }
.sc-legend .sc-c1 { color: var(--sc-50-text); }
.sc-legend .sc-lg-sma50 i, .sc-legend .sc-lg-ema50 i { border-top-color: var(--sc-50); }
.sc-legend .sc-c1 i { border-top-color: var(--sc-cmp-1); }
.sc-legend .sc-c2 { color: var(--sc-cmp-2); }
.sc-legend .sc-c3 { color: var(--sc-cmp-3); }
.sc .sc-notes .meta, .sc .sc-notes p { margin: 4px 0 0; }
.sc .sc-source { color: var(--muted); }

/* The tools that draw on the chart and save it (src/dashboard/chart-tools.js) */
.sc-draw-btn { min-height: 34px; }
.sc-draw-btn[hidden] { display: none; }
.sc-draw-btn.on { background: var(--accent-bg); border-color: var(--accent); }
/* The toolbar is compact on a desktop; on a touch screen or a narrow window its buttons are a finger's 44 px like every other .btn (app.css). After the 34 px rules above, which it has to win. */
@media (pointer: coarse), (max-width: 899px) { .sc-tool, .sc-draw-btn, .sc-picker > summary, .sc-compare > summary { min-height: 44px; } .sc-tool { min-width: 44px; } }
.sc-plot .sc-draw { fill: none; stroke: var(--text); stroke-width: 1.3; }
.sc-plot .sc-draw.selected { stroke: var(--accent); stroke-width: 2; }
.sc-plot .sc-draw.preview { stroke-dasharray: 4 3; }
.sc-plot .tag-rect.draw { stroke: var(--text); }
.sc-plot .tag-text.draw { fill: var(--text); }
.sc-legend .c-draw { color: var(--text); }
.sc-plot .sc-handle { fill: var(--panel); stroke: var(--accent); stroke-width: 2; }
.sc-plot.drawing { touch-action: none; }
.sc-plot.placing, .sc-plot.placing .sc-hit { cursor: copy; }

/* The holding period of a trade under review (src/dashboard/trade-review.js): a faint band behind the candles. */
.sc-plot .sc-hold { fill: var(--accent); fill-opacity: 0.07; stroke: none; }
.legend-inline .c-hold { color: var(--accent); }
.legend-inline .c-hold i { height: 8px; border-top: 0; background: currentColor; opacity: 0.25; border-radius: 2px; }

/* A phone: the controls are one button, "Chart tools", under the picture with the choice made beside it; the button opens every one of them (a wide screen shows them where they were). */
.sc-toolsrow { display: none; }
@media (max-width: 899px) {
  .sc-toolsrow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 8px 0 4px; }
  .sc-toolsbtn { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; }
  .sc-toolschip { margin: 0; white-space: normal; height: auto; }
  .sc-panel[hidden] { display: none; }
}
/* A phone: the figures above the picture and the line of what is drawn are set closer (the figures run on in one wrapping line), so that the picture is as near the top of the page as the screen allows. */
@media (max-width: 899px) {
  .sc-readout { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 10px; min-height: 0; margin: 2px 0 0; font-size: 12.5px; line-height: 1.35; }
  .sc-ro-cells, .sc-ro-inds { display: contents; }
  .sc-ro-head { margin-inline-end: 4px; }
  .sc-ro-mark { flex: 1 0 100%; }
  .sc.card { padding-top: 10px; }
  .sc-legend { margin-bottom: 0; }
}
