@layer components {
  /* Pronunciation Trend Widget
   * CSS-only bar chart for pronunciation scores over time.
   * Bar height driven by --score custom property (0-100).
   */

  .pronunciation-trend {
    padding: var(--block-space-l) var(--inline-space-l);
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
  }

  .pronunciation-trend__summary {
    padding-block-start: var(--block-space);
    border-block-start: 1px solid var(--color-border);
  }

  /* Chart container */
  .trend-chart {
    display: flex;
    gap: var(--inline-space);
    height: 10rem;
  }

  .trend-chart__y-axis {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--color-ink-muted);
    padding-block-end: 1.25rem;
    min-width: 3ch;
    text-align: right;
  }

  .trend-chart__bars {
    flex: 1;
    display: flex;
    align-items: flex-end;
    gap: 2px;
    border-block-end: 1px solid var(--color-border);
    padding-block-end: 1.25rem;
    position: relative;
    overflow-x: auto;
  }

  .trend-chart__bar-group {
    flex: 1;
    min-width: 1rem;
    max-width: 3rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    justify-content: flex-end;
  }

  .trend-chart__bar {
    width: 100%;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    height: calc(var(--score) * 1%);
    min-height: 2px;
    transition: height 300ms ease;

    &.score--good { background: var(--color-positive); }
    &.score--fair { background: var(--color-warning); }
    &.score--weak { background: var(--color-negative); }
    &.score--none { background: var(--color-border); }

    &:hover {
      filter: brightness(1.15);
    }
  }

  .trend-chart__label {
    font-size: 0.625rem;
    color: var(--color-ink-muted);
    margin-block-start: 0.25rem;
    white-space: nowrap;
    position: absolute;
    bottom: 0;
    transform: translateY(100%);
  }

  /* Only show every Nth label to avoid crowding */
  .trend-chart__bar-group:not(:first-child):not(:last-child):not(:nth-child(5n)) .trend-chart__label {
    visibility: hidden;
  }

}
