/* ==========================================================================
   Data graphics (js/components/dataviz.js) and the small labels that go with
   them. Written against the tokens only, so they render in every look; the
   Tapebook look adds its amber eyebrow square in look-tapebook.css.
   ========================================================================== */

/* ---- Eyebrow: a small uppercase label above a heading or a figure.
   .tb-label is the same label without the Tapebook look's amber square -
   for the labels of individual figures, where a square on every one would
   be noise; the eyebrow marks a section. ---- */
.tb-eyebrow,
.tb-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-family-mono);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-text-tertiary);
}

/* ---- 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-mono);
  font-size: 9.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  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: 8px;
  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;
  }

  .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);
}
