/* The price charts: Prisudvikling on the product page and Samlingens prisudvikling on /mit-brickzone
   (site/partials/price-chart.html.twig, drawn by price-chart.js): the 3 / 6 / 12 months buttons, the four tiles and the plot */

.segmented { display: flex; gap: 4px; padding: 4px; background: var(--page); border-radius: var(--r-md); }

.segmented button {
  min-height: 40px;
  padding: 0 14px;
  background: transparent;
  border: 0;
  border-radius: var(--r-sm);
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 700;
}

.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1); }

.history__stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }

.history__stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding: 12px 14px;
  background: var(--surface-2);
  border-radius: var(--r-md);
}

.history__stat > span { font-size: 13px; color: var(--ink-3); }
.history__stat > span + strong + span { font-size: 12px; }

.history__stat strong {
  overflow: hidden;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 800;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.history__chart { display: flex; gap: 12px; }

/* Amounts at the top, middle and bottom of the plot (product.js sets their top) */
.history__y { position: relative; flex-shrink: 0; width: 54px; height: 274px; font-size: 12px; color: var(--ink-3); }
.history__y span { position: absolute; right: 0; transform: translateY(-50%); white-space: nowrap; }

.history__plot-wrap { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }

.history__plot {
  position: relative;
  height: 274px;
  border-left: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  touch-action: pan-y;
}

.history__plot::before { content: ''; position: absolute; left: 0; right: 0; top: 50%; border-top: 1px dashed var(--line); }
.history__plot svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.history__plot polyline { fill: none; stroke: var(--ink); stroke-width: 2.5; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
/* Days no shop had it in stock: a dotted bridge */
.history__plot .is-gap { stroke: var(--ink-3); stroke-width: 1.5; stroke-dasharray: 3 3; }

.history__today {
  position: absolute;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  background: var(--cta);
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--cta);
}

.history__today-label {
  position: absolute;
  right: 12px;
  transform: translateY(-130%);
  padding: 2px 6px;
  background: var(--surface);
  border-radius: var(--r-xs);
  color: var(--cta);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

/* Hover read-out */
.history__guide { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--line-strong); pointer-events: none; }

.history__point {
  position: absolute;
  width: 10px;
  height: 10px;
  margin: -7px 0 0 -7px;
  background: var(--ink);
  border: 2px solid #fff;
  border-radius: 50%;
  box-sizing: content-box;
  pointer-events: none;
}

.history__tip {
  position: absolute;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 6px 10px;
  background: var(--ink);
  border-radius: var(--r-sm);
  color: #fff;
  font-size: 12px;
  line-height: 16px;
  white-space: nowrap;
  transform: translateX(-50%);
  pointer-events: none;
}

.history__tip strong { font-size: 15px; line-height: 20px; }
.history__x { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-3); }

@media (max-width: 767px) {
  .segmented { width: 100%; }
  .segmented button { flex: 1; }
  .history__stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .history__y { display: none; }
  .history__plot { height: 174px; }
}
