/*
 * VISUAL PROGRESS CHART
 * =====================
 * Hand-rolled inline-SVG curve (built in JS at runtime). Two series —
 * HAR1 in brand blue, HAR2 in dark blue — and an optional pair of
 * thumbnail strips below, aligned to the same time axis.
 */

.vp-chart {
  position: relative;
  width: 100%;
  padding: 4px 0 0 0;

  svg {
    display: block;
    width: 100%;
    height: 240px;
    overflow: visible;
  }

  .vp-axis-label,
  .vp-tick-label {
    fill: var(--color-text-secondary);
    font-family: var(--font-sans);
    font-size: 11px;
  }

  .vp-grid {
    stroke: var(--color-border);
    stroke-width: 1;
  }

  .vp-baseline {
    stroke: var(--color-border-strong);
    stroke-width: 1;
  }

  .vp-series--1 {
    fill: none;
    stroke: var(--color-blue);
    stroke-width: 2;
    stroke-linejoin: round;
  }

  .vp-series--2 {
    fill: none;
    stroke: var(--color-blue-dark);
    stroke-width: 2;
    stroke-linejoin: round;
    stroke-dasharray: 4 4;
  }

  /*
   * Marker lines anchor the chart in time at FCP / LCP / FVC /
   * Speed Index. HAR1 markers are solid; HAR2 markers are dashed
   * (matches the HAR2 series style). Colour-coded per metric so a
   * regressed LCP shows up as a pair of orange lines drifting apart.
   */
  .vp-marker {
    stroke-width: 1.5;
    opacity: 0.55;
    stroke-linecap: round;
  }
  .vp-marker--2 {
    stroke-dasharray: 3 3;
  }
  .vp-marker--fvc { stroke: #9333ea; }   /* purple */
  .vp-marker--fcp { stroke: #16a34a; }   /* green  */
  .vp-marker--lcp { stroke: #ea580c; }   /* orange */
  .vp-marker--si  { stroke: #2563eb; }   /* blue   */

  .vp-marker-label {
    font-family: var(--font-sans);
    font-size: 10px;
    font-weight: var(--font-weight-semibold);
    paint-order: stroke;
    stroke: var(--color-surface-card);
    stroke-width: 3px;
    stroke-linejoin: round;
  }
  .vp-marker-label--2 { font-size: 9px; opacity: 0.85; }
  .vp-marker-label.vp-marker--fvc { fill: #9333ea; }
  .vp-marker-label.vp-marker--fcp { fill: #16a34a; }
  .vp-marker-label.vp-marker--lcp { fill: #ea580c; }
  .vp-marker-label.vp-marker--si  { fill: #2563eb; }
}

/* Thumbnail strips under the chart — absolute positioning lets us
   align each thumb's center to its time on the same axis as the SVG
   above, so the visual change at each milestone is easy to spot. */
.vp-thumb-row {
  display: grid;
  grid-template-columns: minmax(70px, 90px) 1fr;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
}

.vp-thumb-label {
  font-size: 0.85rem;
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-secondary);
  white-space: nowrap;
}

.vp-thumb-rail {
  position: relative;
  height: 104px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
}

.vp-thumb {
  position: absolute;
  top: 4px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;

  a {
    display: block;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--color-border);
    background: var(--color-surface-card);
    transition: border-color var(--motion-fast),
                box-shadow var(--motion-fast),
                transform var(--motion-fast);

    &:hover,
    &:focus-visible {
      border-color: var(--color-info-border);
      box-shadow: var(--shadow-md);
      transform: translate(-50%, -1px) translateX(50%);
    }
  }

  img {
    display: block;
    width: 120px;
    height: auto;
    max-height: 80px;
    object-fit: cover;
  }
}

.vp-thumb-time {
  font-size: 0.7rem;
  color: var(--color-text-secondary);
  font-variant-numeric: tabular-nums;
}

.resource-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin: 12px 0 0 0;
  padding: 0;
  font-size: 0.85rem;
  color: var(--color-text-secondary);

  li {
    display: inline-flex;
    align-items: center;

    &::before {
      content: '';
      width: 12px;
      height: 12px;
      margin-right: 6px;
      border-radius: var(--radius-pill);
    }
  }

  .legend-url1::before { background: var(--color-blue); }
  .legend-url2::before { background: var(--color-blue-dark); }
}

@media (max-width: 640px) {
  .vp-thumb-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  .vp-thumb img { width: 60px; max-height: 45px; }
  .vp-thumb-rail { height: 70px; }
}
