/* statistic widget styles (mount #tb-statistic; class prefix .tbst-) */
#tb-statistic .tbst-body { container: tbst / inline-size; }
#tb-statistic .figure__head { align-items: flex-start; }
#tb-statistic .figure__title small { min-height: 1.3em; }
#tb-statistic .tbst-tabs button b { font-weight: 700; }
@media (max-width: 420px) { #tb-statistic .tbst-tabs button { padding: 7px 10px; font-size: 0.78rem; } }

/* both views share one grid cell, so the frame keeps the height of the taller view */
.tbst-views { display: grid; }
.tbst-view { grid-area: 1 / 1; min-width: 0; opacity: 0; visibility: hidden; transform: translateY(6px);
  transition: opacity .32s ease, transform .32s cubic-bezier(.2,.7,.2,1), visibility 0s linear .32s; }
.tbst-view.is-on { opacity: 1; visibility: visible; transform: none; transition: opacity .32s ease, transform .32s cubic-bezier(.2,.7,.2,1), visibility 0s; }

.tbst-sr { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------------------------------------------------------------- view 1: mine */
.tbst-mine-top { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 14px; align-items: start; }
.tbst-heat-wrap { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.tbst-heat { overflow: visible; max-width: 100%; height: auto; }
.tbst-heat-cap { margin: 0; font-size: 12px; line-height: 1.35; color: var(--muted); text-align: center; max-width: 250px; }
.tbst-axis-t { font: 600 12px/1 var(--sans); fill: var(--muted); }
.tbst-ic-img { fill: var(--img); }
.tbst-ic-txt { fill: var(--txt); }
.tbst-cell { stroke: none; }
.tbst-band { fill: var(--ink); fill-opacity: 0.07; stroke: var(--ink-2); stroke-opacity: .28; stroke-width: 1; opacity: 0;
  transition: transform .26s cubic-bezier(.2,.7,.2,1), opacity .25s ease; pointer-events: none; }
.tbst-band.is-on { opacity: 1; }

.tbst-mk { opacity: 0; transform: scale(.55); transform-box: fill-box; transform-origin: center;
  transition: opacity .3s ease, transform .42s cubic-bezier(.3,1.5,.5,1); pointer-events: none; }
.tbst-mk.is-on { opacity: 1; transform: none; }
.tbst-mk--pos { fill: none; stroke: var(--good); stroke-width: 2.6; }
.tbst-mk--img { fill: none; stroke: var(--bad); stroke-width: 2.6; }
.tbst-mk--cap { fill: var(--surface); fill-opacity: .55; stroke: var(--bad); stroke-width: 2; stroke-dasharray: 3 2.2; }

/* steps (also the legend of the marks) */
.tbst-side { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.tbst-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.tbst-step { display: flex; gap: 10px; align-items: flex-start; width: 100%; text-align: left; padding: 8px 10px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: transparent; cursor: pointer; transition: background .2s, border-color .2s, opacity .2s; opacity: .62; }
.tbst-step:hover { background: var(--surface-2); opacity: 1; }
.tbst-step.is-active { background: var(--surface-2); border-color: var(--rule-2); opacity: 1; }
.tbst-step.is-done { opacity: 1; }
.tbst-step-g { flex: none; padding-top: 1px; }
.tbst-glyph { display: block; overflow: visible; }
.tbst-glyph-bg { fill: color-mix(in srgb, var(--ink-2) 18%, var(--surface)); }
.tbst-glyph-d { font: 700 12px/1 var(--serif); fill: var(--ink); }
.tbst-step-tx { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tbst-step-t { font: 600 0.84rem/1.25 var(--sans); color: var(--ink); }
.tbst-step-d { font-size: 12px; line-height: 1.4; color: var(--muted); }
.tbst-play { align-self: flex-start; margin-left: 4px; }
.tbst-play svg { fill: currentColor; flex: none; }

/* the three terms of D */
.tbst-eqn-wrap { margin-top: 16px; padding: 14px 12px 12px; border: 1px solid var(--rule); border-radius: var(--radius-sm); background: var(--surface-2);
  display: flex; flex-direction: column; align-items: center; gap: 10px; }
.tbst-eqn { display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-start; gap: 6px 4px; }
.tbst-term { display: flex; align-items: flex-start; gap: 4px; opacity: .16; transform: translateY(8px) scale(.96);
  transition: opacity .45s ease, transform .55s cubic-bezier(.2,.7,.2,1); }
.tbst-term.is-on { opacity: 1; transform: none; }
.tbst-op { font: 400 1.25rem/42px var(--serif); color: var(--ink-2); min-width: 18px; text-align: center; white-space: nowrap; }
.tbst-half { display: inline-flex; align-items: center; gap: 3px; }
.tbst-half .m-frac { font-family: var(--serif); font-size: 0.62em; }
.tbst-term-box { display: flex; flex-direction: column; align-items: center; gap: 5px; width: 86px; }
.tbst-mini { display: block; border-radius: 6px; box-shadow: 0 0 0 1px var(--rule); background: var(--surface); }
.tbst-term-l { font: 600 12px/1.25 var(--sans); text-align: center; color: var(--ink-2); }
.tbst-term--pos .tbst-term-l { color: var(--good); }
.tbst-term--neg .tbst-term-l { color: var(--bad); }
.tbst-term--d .tbst-term-l { font: 700 1rem/1 var(--serif); color: var(--ink); }
.tbst-term--d .tbst-mini { box-shadow: 0 0 0 1.5px var(--ink-2); }
.tbst-next { opacity: 0; transform: translateY(4px); pointer-events: none; transition: opacity .35s ease, transform .35s ease, border-color .15s; }
.tbst-next.is-on { opacity: 1; transform: none; pointer-events: auto; }
.tbst-next b { font-weight: 700; }

/* mining sizes */
.tbst-sizes { margin-top: 14px; }
.tbst-sizes-h { margin: 0 0 8px; font: 600 0.74rem/1.2 var(--sans); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.tbst-sizes-g { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tbst-size { display: flex; flex-direction: column; gap: 3px; padding: 9px 11px; border: 1px solid var(--rule); border-radius: var(--radius-sm); background: var(--surface); }
.tbst-size-v { font-weight: 600; font-size: 1.22rem; line-height: 1.15; color: var(--ink); }
.tbst-size-l { font-size: 12px; line-height: 1.3; color: var(--muted); }

/* ---------------------------------------------------------------- view 2: spectrum */
.tbst-spec-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 14px; margin-bottom: 10px; }
.tbst-legend { font-size: 12px; }
.tbst-legend i.tbst-sw-ours { background: var(--ours); }
.tbst-legend i.tbst-sw-neu { background: var(--neutral); }
.tbst-scale button { padding: 6px 12px; font-size: 0.78rem; }
.tbst-view.tbst-spec { display: flex; flex-direction: column; }
.tbst-chart { position: relative; width: 100%; flex: 1 1 320px; min-height: 300px; max-height: 420px; }
.tbst-read { margin: 10px 0 0; font-size: 0.86rem; line-height: 1.5; color: var(--ink-2); }
.tbst-read .c-ours { font-weight: 600; }
.tbst-svg { position: absolute; inset: 0; display: block; width: 100%; height: 100%; overflow: visible; touch-action: pan-y; border-radius: 6px; }
.tbst-svg:focus-visible { outline: 2px solid var(--ours); outline-offset: 4px; }
.tbst-svg text { font: 500 12px/1 var(--sans); fill: var(--muted); }
.tbst-svg text.num { font-family: var(--mono); font-size: 11.5px; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.tbst-svg .tbst-sup { font-size: 9px; }
.tbst-svg text.tbst-k { fill: var(--ours-ink); font-weight: 700; }
.tbst-svg .tbst-axis-t { font: 600 12px/1 var(--sans); fill: var(--muted); }
.tbst-grid line { stroke: var(--rule); stroke-width: 1; stroke-dasharray: 2 3; }
.tbst-grid, .tbst-ticks { transition: opacity .25s ease; }
.tbst-grid.is-fading, .tbst-ticks.is-fading { opacity: 0; }
.tbst-tick { stroke: var(--rule-2); }
.tbst-zero { stroke: var(--ink-2); stroke-width: 1.2; }
.tbst-kline { stroke: var(--ours); stroke-width: 1; stroke-dasharray: 3 3; opacity: .7; }
.tbst-bar-ours { fill: var(--ours); }
.tbst-bar-neu { fill: var(--neutral); fill-opacity: .72; }
.tbst-brk { fill: none; stroke: var(--ours); stroke-width: 1.5; stroke-linejoin: round; }
.tbst-svg .tbst-brk-t { font: 650 12px/1 var(--sans); fill: var(--ours-ink); }
.tbst-svg .tbst-ann-t { font: 500 12px/1 var(--sans); fill: var(--ink-2); }
.tbst-hl { opacity: 0; transition: opacity .12s; pointer-events: none; }
.tbst-hl.is-on { opacity: 1; }
.tbst-hl-line { stroke: var(--ink-2); stroke-width: 1; stroke-dasharray: 2 2; opacity: .55; }
.tbst-hl-bar { fill: var(--ink); }
.tbst-hl-dot { fill: var(--surface); stroke: var(--ink); stroke-width: 2; }
.tbst-hl.is-ours .tbst-hl-bar { fill: var(--ours-ink); }
.tbst-hl.is-ours .tbst-hl-dot { stroke: var(--ours-ink); }
.tbst-hit { fill: transparent; cursor: crosshair; }

.tbst-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.tbst-fact { display: flex; flex-direction: column; gap: 3px; padding: 8px 10px; border: 1px solid var(--rule); border-radius: var(--radius-sm); background: var(--surface-2); min-width: 0; }
.tbst-fact-l { font-size: 12px; line-height: 1.25; color: var(--muted); }
.tbst-fact-v { font-weight: 600; font-size: 0.86rem; line-height: 1.3; color: var(--ink); }
.tbst-fact-v .num { font-size: 0.95em; }

@container tbst (min-width: 620px) { .tbst-facts { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
/* ---------------------------------------------------------------- narrow containers (phones) */
@container tbst (max-width: 440px) {
  .tbst-mine-top { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .tbst-steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tbst-step { padding: 7px 8px; gap: 8px; }
  .tbst-play { align-self: center; margin-left: 0; }
  .tbst-chart { min-height: 270px; }
}
@container tbst (max-width: 440px) {
  .tbst-eqn { gap: 6px 2px; }
  .tbst-term { gap: 2px; }
  .tbst-term-box { width: 54px; }
  .tbst-mini { width: 34px; height: 34px; }
  .tbst-op { line-height: 34px; min-width: 12px; font-size: 1.1rem; }
  .tbst-sizes-g { gap: 6px; }
  .tbst-size { padding: 8px; }
}
.tbst--still .tbst-view, .tbst--still .tbst-view.is-on, .tbst--still .tbst-mk, .tbst--still .tbst-term, .tbst--still .tbst-next, .tbst--still .tbst-band { transition: none; }
@media (prefers-reduced-motion: reduce) {
  .tbst-view, .tbst-view.is-on, .tbst-mk, .tbst-term, .tbst-next, .tbst-band { transition: none; }
}
