/* ==========================================================================
   Data graphics (js/components/dataviz.js) and the small labels that go with
   them. Written against the tokens only.
   ========================================================================== */

/* ---- Label: a plain sentence-case caption above a heading or a figure
   (13px, the secondary tone; no capitals, no tracking). ---- */
.tb-eyebrow,
.tb-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-family);
  font-size: var(--fs-caption);
  font-weight: 500;
  line-height: 1.3;
  color: var(--color-text-secondary);
}

/* ---- Orbit ---- */
.orbit {
  position: relative;
  width: 100%;
  max-width: 300px;
  margin-inline: auto;
}

.orbit__svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.orbit__limit {
  font-family: var(--font-family);
  font-size: 12px;
  fill: var(--color-text-tertiary);
}

/* ---- Day strip ---- */
.daystrip {
  --plot-h: 150px;
  container-type: inline-size;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.daystrip__plot,
.daystrip__labels,
.daystrip__limits {
  display: grid;
  grid-template-columns: repeat(var(--n), minmax(0, 1fr));
}

.daystrip__plot {
  position: relative;
  height: var(--plot-h);
  margin-top: 18px;
  margin-bottom: 18px;
}

.daystrip__zero {
  position: absolute;
  left: 0;
  right: 0;
  top: var(--zero);
  height: 1px;
  background: var(--color-border-strong);
}

.daystrip__col {
  position: relative;
  height: 100%;
}

/* A week (or, over a long range, a month) starts on a faint rule. */
.daystrip__col.is-divider::before {
  content: "";
  position: absolute;
  left: 0;
  top: -10px;
  bottom: -4px;
  width: 1px;
  background: var(--color-border);
}

.daystrip__col.is-today::after {
  content: "";
  position: absolute;
  inset: -16px 1px -46px;
  border-radius: 10px;
  border: 1px solid var(--color-border-strong);
  background: var(--color-accent-soft);
  pointer-events: none;
}

.daystrip__bar,
.daystrip__flat,
.daystrip__none {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.daystrip__bar {
  width: min(46%, 16px);
  min-width: 3px;
  border-radius: 3px;
}

.daystrip__bar--pos {
  background: var(--color-profit);
}

.daystrip__bar--neg {
  background: var(--color-loss);
}

.daystrip__flat {
  width: min(46%, 16px);
  height: 2px;
  margin-top: -1px;
  border-radius: 1px;
  background: var(--color-text-tertiary);
}

.daystrip__none {
  width: 3px;
  height: 3px;
  margin-top: -1.5px;
  border-radius: 50%;
  background: var(--color-border-strong);
}

.daystrip__col.is-future .daystrip__none {
  opacity: 0.5;
}

.daystrip__note {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  padding: 2px 0;
  font-size: 11px;
  font-weight: var(--fw-semibold);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.daystrip__note--pos {
  color: var(--color-profit);
}

.daystrip__note--neg {
  color: var(--color-loss);
}

.daystrip__labels span {
  text-align: center;
  font-family: var(--font-family-mono);
  font-size: 10px;
  color: var(--color-text-tertiary);
  font-variant-numeric: tabular-nums;
}

.daystrip__labels span.is-today {
  color: var(--color-text-primary);
  font-weight: 600;
}

.daystrip--dense .daystrip__labels span {
  text-align: left;
  white-space: nowrap;
  overflow: visible;
}

.daystrip__limits span {
  display: flex;
  justify-content: center;
}

.daystrip__limits i {
  display: block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.daystrip__ok {
  box-shadow: inset 0 0 0 1.5px var(--color-profit);
}

.daystrip__breach {
  background: var(--color-loss);
}

.daystrip__empty {
  margin: 0;
  padding: var(--space-8) 0;
  text-align: center;
  font-size: var(--fs-footnote);
  color: var(--color-text-tertiary);
}

/* A narrow card: every other date, smaller dots. */
@container (max-width: 560px) {
  .daystrip:not(.daystrip--dense) .daystrip__labels span:nth-child(even):not(.is-today) {
    visibility: hidden;
  }

  /* Today's date always shows, so on an even day its two odd neighbours
     would print "27 28 29" into three narrow columns: they give way. */
  .daystrip:not(.daystrip--dense) .daystrip__labels span.is-today + span,
  .daystrip:not(.daystrip--dense) .daystrip__labels span:has(+ span.is-today) {
    visibility: hidden;
  }

  .daystrip__limits i {
    width: 5px;
    height: 5px;
  }

  .daystrip__plot {
    height: 120px;
  }
}

/* ---- Sparkline ---- */
.spark {
  display: block;
  width: 100%;
  height: 56px;
  overflow: visible;
}

.spark--empty {
  display: block;
  height: 56px;
}

.spark__zero {
  stroke: var(--color-border-strong);
  stroke-dasharray: 2 4;
}

/* ---- Ring ---- */
.ring {
  display: block;
  flex: none;
}

/* ---- Limit bar (the RiskDeck panel's idiom) ---- */
.tb-bar {
  position: relative;
  display: block;
  height: 4px;
  border-radius: 4px;
  background: var(--color-surface-raised);
}

.tb-bar__fill {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  display: block;
  border-radius: inherit;
  background: var(--c);
}

.tb-bar__fill::after {
  content: "";
  position: absolute;
  right: -4px;
  top: 50%;
  width: 8px;
  height: 8px;
  margin-top: -4px;
  border-radius: 50%;
  background: var(--c);
}

.tb-bar--zero .tb-bar__fill::after {
  right: auto;
  left: -1px;
}

.tb-bar__limit {
  position: absolute;
  top: -5px;
  bottom: -5px;
  width: 1.5px;
  border-radius: 1px;
  background: var(--color-text-secondary);
}

/* ---- Form strip (formStrip): every closed trade's result, one scale ---- */
.form-strip {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--n), minmax(0, 1fr));
  height: 96px;
}

.form-strip__zero {
  position: absolute;
  left: 0;
  right: 0;
  top: var(--zero);
  height: 1px;
  background: var(--color-border-strong);
}

.form-strip__col {
  position: relative;
}

.form-strip__bar,
.form-strip__flat {
  position: absolute;
  left: 50%;
  width: min(52%, 18px);
  min-width: 3px;
  transform: translateX(-50%);
  border-radius: 3px;
}

.form-strip__bar--pos {
  background: var(--color-profit);
}

.form-strip__bar--neg {
  background: var(--color-loss);
}

.form-strip__flat {
  top: calc(var(--zero) - 1px);
  height: 2px;
  background: var(--color-text-tertiary);
}

/* ---- Tick axis (ticks): where one trade sits among the period's ---- */
.tick-axis {
  position: relative;
  display: block;
  height: 30px;
  margin: 0 5px;
}

.tick-axis::before {
  content: "";
  position: absolute;
  left: -5px;
  right: -5px;
  top: 23px;
  height: 1px;
  background: var(--color-border-strong);
}

.tick-axis__zero,
.tick-axis__tick,
.tick-axis__hi {
  position: absolute;
  width: 1.5px;
  margin-left: -0.75px;
}

.tick-axis__zero {
  top: 17px;
  height: 12px;
  background: var(--color-text-tertiary);
}

.tick-axis__tick {
  top: 17px;
  height: 6px;
  background: var(--color-text-tertiary);
  opacity: 0.7;
}

.tick-axis__hi {
  top: 7px;
  height: 16px;
  width: 2px;
  background: var(--c);
}

.tick-axis__hi::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -4px;
  width: 8px;
  height: 8px;
  margin-left: -4px;
  border-radius: 50%;
  background: var(--c);
}

/* ==========================================================================
   v12 desk graphics for Analytics and Planner (dev/mockups/redesign/v12.html):
   the dimension bars, the dot plot, the list rows, the table and the
   challenge chart. Percentage geometry, text as text, tokens only.
   ========================================================================== */

/* ---- Chips: a select drawn as v12's pill (period, direction, account) ---- */
.dv-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.dv-chips .cselect {
  width: auto;
  max-width: 100%;
}

:root .dv-chips .cselect .cselect__trigger {
  width: auto;
  gap: 6px;
  min-height: 36px;
  padding: 6px 14px;
  border: 0;
  border-radius: 999px;
  background: var(--tile);
  box-shadow: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-1);
}

:root .dv-chips .cselect .cselect__trigger:hover {
  background: var(--tile-2);
}

:root .dv-chips .cselect.is-open .cselect__trigger,
:root .dv-chips .cselect .cselect__trigger:focus-visible {
  box-shadow: inset 0 0 0 1px var(--line);
  outline: 2px solid var(--lead);
  outline-offset: 1px;
}

/* ---- Dimension bars (the Analytics desk chart) ---- */
.dv-bars {
  display: grid;
  grid-template-columns: 172px minmax(0, 1fr) 92px;
  grid-template-rows: auto repeat(var(--rows), 48px) auto;
  column-gap: 14px;
  align-items: center;
}

.dv-bars__head {
  grid-column: 3;
  justify-self: end;
  padding-bottom: 6px;
  font-size: 13px;
  color: var(--text-2);
}

.dv-bars__plot {
  grid-column: 2;
  position: relative;
  align-self: stretch;
}

.dv-bars__grid {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 0;
  border-left: 1px dashed var(--line);
}

.dv-bars__grid.is-zero {
  border-left-style: solid;
}

.dv-bars__lab {
  grid-column: 1;
  min-width: 0;
}

.dv-bars__lab b {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dv-bars__lab small {
  display: block;
  font-size: 13px;
  color: var(--text-2);
}

.dv-bars__cell {
  grid-column: 2;
  position: relative;
  height: 22px;
}

.dv-bars__bar {
  position: absolute;
  top: 0;
  bottom: 0;
  display: block;
  border-radius: 6px;
}

.dv-bars__bar--gain { background: var(--gain); opacity: 0.8; }
.dv-bars__bar--loss { background: var(--loss); opacity: 0.8; }
.dv-bars__bar.is-faint { opacity: 0.35; }

.dv-bars__val {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.dv-bars__wr {
  grid-column: 3;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  font-size: 13px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

/* Faint = too few trades: the figure steps down a text tone, never an opacity
   (that put text under 4.5:1). The ring stays a graphic and may fade. */
.dv-bars__wr.is-faint { color: var(--text-3); }
.dv-bars__wr.is-faint .dv-bars__ring { opacity: 0.45; }

.dv-bars__ring {
  flex: none;
  box-sizing: border-box;
  width: var(--d);
  height: var(--d);
  border: 1.5px solid var(--text-1);
  border-radius: 50%;
  opacity: 0.7;
}

.dv-bars__axis {
  grid-column: 2;
  position: relative;
  height: 18px;
  margin-top: 4px;
}

.dv-bars__axis em {
  position: absolute;
  transform: translateX(-50%);
  font-size: 12px;
  font-style: normal;
  color: var(--text-2);
  white-space: nowrap;
}

.dv-bars__lab.is-faint b { color: var(--text-2); }
.dv-bars__lab.is-faint small { color: var(--text-3); }

/* ---- Dot plot (the result distribution) ---- */
.dv-dots {
  display: flex;
  flex-direction: column;
}

.dv-dots__median {
  align-self: flex-end;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--text-2);
}

.dv-dots__cols {
  display: flex;
  align-items: flex-end;
  gap: 2px;
}

.dv-dots__col {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.dv-dots__stack {
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 3px;
  width: 100%;
  height: var(--h);
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}

.dv-dots__dot {
  display: block;
  flex: none;
  width: min(var(--d), 78%);
  aspect-ratio: 1;
  border-radius: 50%;
  opacity: 0.85;
}

.dv-dots__dot--loss { background: var(--loss); }
.dv-dots__dot--profit { background: var(--gain); }
.dv-dots__dot--zero { background: var(--text-3); }
.dv-dots__dot--median { background: var(--lead); }

.dv-dots__lab {
  display: flex;
  justify-content: center;
  width: 100%;
  height: 14px;
  margin-top: 5px;
  font-size: 12px;
  color: var(--text-2);
  white-space: nowrap;
}

/* ---- List rows (v12 .tr / .st): a name and a note, a figure or a state ---- */
.dv-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 0;
  border: 0;
  border-top: 1px solid var(--line);
  background: none;
  font: inherit;
  color: inherit;
  text-align: left;
}

button.dv-row {
  cursor: pointer;
}

button.dv-row:hover .dv-row__main b {
  text-decoration: underline;
  text-underline-offset: 3px;
}

button.dv-row:focus-visible {
  outline: 2px solid var(--lead);
  outline-offset: 2px;
  border-radius: 10px;
}

.dv-row__main {
  display: block;
  min-width: 0;
}

.dv-row__main b {
  display: block;
  font-size: 14px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.dv-row__sub {
  display: block;
  font-size: 13px;
  color: var(--text-2);
  overflow-wrap: anywhere;
}

.dv-row__value {
  flex: none;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.dv-row__value--gain { color: var(--gain); }
.dv-row__value--loss { color: var(--loss); }
.dv-row__value--warn { color: var(--warn); }

.dv-row__state {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-2);
  white-space: nowrap;
}

.dv-row__state i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

/* Faint row: the name steps down a text tone and the note to the quiet one;
   no opacity on text. */
.dv-row.is-faint .dv-row__main b { color: var(--text-2); }
.dv-row.is-faint .dv-row__sub,
.dv-row.is-faint .dv-row__state { color: var(--text-3); }
.dv-row.is-faint .dv-row__value { font-weight: 500; }

/* .dv-empty is the one empty state of compose.css (.tb-empty). */

/* ---- Challenge chart (Planner desk) ---- */
.dv-chal {
  position: absolute;
  inset: 14px 16px;
}

.dv-chal__plot {
  position: absolute;
  left: 36px;
  right: 6px;
  top: 8px;
  bottom: 22px;
}

.dv-chal__plot svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.dv-chal svg line,
.dv-chal svg path {
  fill: none;
  vector-effect: non-scaling-stroke;
}

.dv-chal__zero { stroke: var(--line); }
.dv-chal__target { stroke: var(--gain); stroke-dasharray: 4 4; }
.dv-chal__floor { stroke: var(--loss); stroke-dasharray: 4 4; }
.dv-chal__line { stroke: var(--lead); stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; }

.dv-chal__y {
  position: absolute;
  right: calc(100% + 8px);
  transform: translateY(-50%);
  font-size: 12px;
  color: var(--text-2);
  white-space: nowrap;
}

.dv-chal__y--gain { color: var(--gain); }
.dv-chal__y--loss { color: var(--loss); }

.dv-chal__dot {
  position: absolute;
  box-sizing: border-box;
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  border: 2.5px solid var(--lead);
  border-radius: 50%;
  background: var(--desk);
}

.dv-chal__dot--gain { border-color: var(--gain); }
.dv-chal__dot--loss { border-color: var(--loss); }

.dv-chal__end {
  position: absolute;
  transform: translateY(-50%);
  font-size: 13px;
  color: var(--text-1);
  white-space: nowrap;
}

.dv-chal__x {
  position: absolute;
  bottom: 0;
  font-size: 12px;
  color: var(--text-2);
}

.dv-chal__x--l { left: 36px; }
.dv-chal__x--r { right: 6px; }

/* ==========================================================================
   The new look (stage 3, 2026-10-17): Apple's segmented control, a faded edge
   where a row scrolls on, the gain / loss triangle, and the windows of the
   Analytics and Planner (the structure of mockup v13, our tokens).
   ========================================================================== */

/* ---- Segmented control: a capsule track, a raised thumb, exactly one on ---- */
.dv-segwrap {
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden; /* sideways only (card.css .pill-toggle--scroll) */
  scrollbar-width: none;
  border-radius: 999px;
}

.dv-segwrap::-webkit-scrollbar {
  display: none;
}

.dv-seg {
  display: inline-flex;
  padding: 2px;
  border-radius: 999px;
  background: var(--seg-track);
}

.dv-seg__b {
  flex: none;
  min-height: 32px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: none;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-standard), color var(--dur-fast) var(--ease-standard);
}

.dv-seg__b:hover {
  color: var(--text-1);
}

.dv-seg__b.is-active {
  background: var(--seg-thumb);
  color: var(--seg-ink);
  box-shadow: var(--seg-lift);
}

.dv-seg__b:focus-visible {
  outline: 2px solid var(--lead);
  outline-offset: -2px;
}

@media (pointer: coarse) {
  .dv-seg__b {
    min-height: 40px;
  }
}

/* A row that scrolls sideways shows where there is more: the edge that has
   more fades out (TJ.Components.Dataviz.watchFade sets data-fade). */
.dv-fade[data-fade="end"] {
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
  mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
}

.dv-fade[data-fade="start"] {
  -webkit-mask-image: linear-gradient(to left, #000 calc(100% - 28px), transparent);
  mask-image: linear-gradient(to left, #000 calc(100% - 28px), transparent);
}

.dv-fade[data-fade="both"] {
  -webkit-mask-image: linear-gradient(to right, transparent, #000 28px, #000 calc(100% - 28px), transparent);
  mask-image: linear-gradient(to right, transparent, #000 28px, #000 calc(100% - 28px), transparent);
}

/* ---- The triangle beside a gain or a loss ---- */
.dv-arrow {
  display: inline-block;
  margin-right: 0.3em;
  font-size: 0.7em;
  vertical-align: 0.1em;
}

.dv-arrow--gain { color: var(--gain); }
.dv-arrow--loss { color: var(--loss); }

/* The unit beside a figure read in R where money is the rule (a profit factor
   over mixed currencies): small and quiet, never part of the figure's name. */
.dv-unit {
  font-size: 0.6em;
  font-weight: 400;
  letter-spacing: 0;
  color: var(--text-2);
  white-space: nowrap;
}

/* The windows under a desk (Analytics, Planner) are styled in css/views/analytics.css
   and planner.css: this file holds only what several views share. */

/* A bar on its track (v13 .sbar / .tbar): 6 to 8 high, radius half. */
.dv-track {
  height: 8px;
  border-radius: 4px;
  background: var(--track);
  overflow: hidden;
}

.dv-track > i {
  display: block;
  height: 100%;
  border-radius: 4px;
  background: var(--text-2);
}

.dv-track--gain > i { background: var(--gain); }
.dv-track--loss > i { background: var(--loss); }
.dv-track--warn > i { background: var(--warn); }

/* The link at a window's foot (v13 .fl). */
.dv-fl {
  align-self: flex-start;
  margin-top: auto;
  padding: 14px 0 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--lead);
  cursor: pointer;
}

.dv-fl:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.dv-fl:focus-visible {
  outline: 2px solid var(--lead);
  outline-offset: 2px;
  border-radius: 6px;
}
