/* timeline-slider template (scripts/blog-interactives/templates/timeline-slider.mjs).
   Linked from the template's own panel, so only pages with this figure load it.
   Builds on interactive.css (bi-panel, bi-legend, bi-readout*, bi-replay). */
.bi-ts { --bi-thumb: 30px; --bi-fill: 0; }

.bi-ts-head { display: flex; align-items: baseline; justify-content: space-between; gap: 6px 14px; flex-wrap: wrap; margin-bottom: 10px; }
.bi-ts-legend { display: block; margin: 0; }
.bi-ts-output {
  font: 600 1.3rem/1.2 "Fredoka", "Nunito", sans-serif;
  color: var(--purple);
  font-variant-numeric: tabular-nums;
}

/* The instrument: chart + slider share one inner width, so the chart's x axis
   lines up with the thumb's travel (inset by half a thumb on each side). */
.bi-ts-card {
  padding: 12px 14px 8px;
  border: 2px solid var(--line);
  border-radius: 20px;
  background: var(--card);
}
.bi-ts-chart-head { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 18px; }
.bi-ts-chart-axis, .bi-ts-chart-note {
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--violet);
}
.bi-ts-chart-note { color: #a08cb8; text-align: right; }
.bi-ts-plot {
  position: relative;
  height: 92px;
  margin: 0 calc(var(--bi-thumb) / 2);
  border-bottom: 2px solid #efe6ff;
}
.bi-ts-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.bi-ts-chart-top { stroke: #efe6ff; stroke-width: 1.5; stroke-dasharray: 4 5; vector-effect: non-scaling-stroke; }
.bi-ts-chart-marker { stroke: #ffb3d6; stroke-width: 2; stroke-dasharray: 3 4; vector-effect: non-scaling-stroke; }
.bi-ts-chart-ideal { fill: none; stroke: #c9b8ff; stroke-width: 2; stroke-dasharray: 6 5; vector-effect: non-scaling-stroke; }
.bi-ts-chart-area { fill: rgba(124, 92, 255, 0.12); stroke: none; }
.bi-ts-chart-run {
  fill: none;
  stroke: var(--purple);
  stroke-width: 3.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}
.bi-ts-chart-skips line { stroke: var(--bi-sky, #5aa9f5); stroke-width: 3; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.bi-ts-chart-tag {
  position: absolute;
  top: -17px;
  transform: translateX(-50%);
  font: 700 0.72rem/1 "Nunito", sans-serif;
  color: var(--pink-deep, #e83a8f);
  white-space: nowrap;
}
.bi-ts-chart-tag-end { transform: translateX(-100%); }
.bi-ts-dot {
  position: absolute;
  width: 16px;
  height: 16px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--purple);
  box-shadow: 0 0 0 2px var(--purple), 0 3px 6px rgba(124, 92, 255, 0.3);
  transform: translate(-50%, 50%);
}

/* Native range input, restyled: 44 px tall hit area, 12 px track, 30 px thumb.
   The filled part of the track ends under the thumb's centre (--bi-fill). */
.bi-ts-track { position: relative; height: 44px; }
.bi-ts-tick {
  position: absolute;
  top: 50%;
  left: calc(var(--bi-thumb) / 2 + var(--bi-at) * (100% - var(--bi-thumb)));
  width: 4px;
  height: 24px;
  border-radius: 2px;
  background: var(--pink);
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.bi-ts-range {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  display: block;
  width: 100%;
  height: 44px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}
.bi-ts-range:disabled { cursor: default; }
.bi-ts-range:focus { outline: none; }
.bi-ts-range::-webkit-slider-runnable-track {
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--purple) 0, var(--purple) calc(var(--bi-thumb) / 2 + var(--bi-fill) * (100% - var(--bi-thumb))), #ece4ff calc(var(--bi-thumb) / 2 + var(--bi-fill) * (100% - var(--bi-thumb))), #ece4ff 100%);
}
.bi-ts-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: var(--bi-thumb);
  height: var(--bi-thumb);
  margin-top: calc((12px - var(--bi-thumb)) / 2);
  border: 4px solid var(--purple);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 3px 0 rgba(124, 92, 255, 0.28);
}
.bi-ts-range::-moz-range-track { height: 12px; border-radius: 999px; background: #ece4ff; }
.bi-ts-range::-moz-range-progress { height: 12px; border-radius: 999px; background: var(--purple); }
.bi-ts-range::-moz-range-thumb {
  box-sizing: border-box;
  width: var(--bi-thumb);
  height: var(--bi-thumb);
  border: 4px solid var(--purple);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 3px 0 rgba(124, 92, 255, 0.28);
}
.bi-ts-range:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--purple); }
.bi-ts-range:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--purple); }
.bi-ts-scale {
  display: flex;
  justify-content: space-between;
  padding: 0 calc(var(--bi-thumb) / 2 - 6px);
  margin-top: -4px;
  font-size: 0.8rem;
  color: var(--ink-soft);
}

/* Marker buttons: the article's numbers, as jump targets. */
.bi-ts-markers { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.bi-ts-marker {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  min-height: 48px;
  padding: 6px 16px 6px 32px;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  line-height: 1.25;
  text-align: left;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.bi-ts-marker::before {
  content: "";
  position: absolute;
  left: 13px;
  top: 50%;
  width: 4px;
  height: 18px;
  border-radius: 2px;
  background: var(--pink);
  transform: translateY(-50%);
}
.bi-ts-marker:disabled { color: var(--ink); opacity: 1; }
.bi-ts-marker-label { font-weight: 800; font-size: 0.95rem; }
.bi-ts-marker-caption { font-size: 0.84rem; color: var(--ink-soft); }
.bi-ts-marker.is-current { border-color: var(--pink); background: #fff0f7; box-shadow: 0 3px 0 rgba(255, 79, 163, 0.18); }
.blog-interactive[data-state="ready"] .bi-ts-marker { cursor: pointer; }
.blog-interactive[data-state="ready"] .bi-ts-marker:hover { border-color: #ff9ccb; }
.bi-ts-marker:focus-visible { outline: 3px solid var(--purple); outline-offset: 3px; }

.bi-ts-actions { display: flex; flex: 0 0 auto; flex-wrap: wrap; gap: 8px; }
.bi-ts-actions .bi-replay { flex: 0 0 auto; }

@media (max-width: 600px) {
  .bi-ts-card { padding: 10px 10px 6px; }
  .bi-ts-plot { height: 76px; }
  .bi-ts-markers { display: grid; grid-template-columns: 1fr 1fr; }
  .bi-ts-marker { padding-right: 10px; }
  .bi-ts-marker:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .bi-ts-actions { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .bi-ts-marker { transition: none; }
}
