/*
 * Exhibits (2026-11-30): the Chart and Diagram blocks
 * (site/snippets/blocks/chart.php and diagram.php; docs/design/components.md,
 * "Exhibits: chart and diagram"). Linked only on pages whose markup uses an
 * exhibit class (peanut_scoped_css(), prefix exhibit). Layer: blocks. Tokens only.
 *
 * Both sit on a white panel with the 1px ink outline and --radius-sm corners,
 * the caption and the source line under them. The chart's marks are one SVG
 * stretched over the plot (strokes that do not scale); its words are HTML
 * placed by percentages over it, so they keep their size at every width.
 * One series: the ink line over a mint area, or mint bars outlined in ink;
 * faint ink gridlines; a marker is a dashed ink line with a butter label.
 * Nothing moves.
 */

@layer blocks {
  .exhibit {
    min-width: 0;
    margin: 0;
    padding: var(--space-3);
    border: var(--border);
    border-radius: var(--radius-sm);
    background: var(--color-white);
    color: var(--color-ink);
  }

  .exhibit__series,
  .exhibit__sourcelabel {
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: var(--tracking-caps);
    text-transform: uppercase;
  }

  .exhibit__series {
    margin: 0;
  }

  /* ---------- Chart ---------- */

  /* the top margin leaves room for a value or marker label above the highest point */
  .exhibit__plot {
    position: relative;
    height: clamp(11rem, 8rem + 12vw, 16rem);
    margin-top: var(--space-5);
  }

  /* the marks and their words, right of the gutter that holds the gridline values */
  .exhibit__marks {
    position: absolute;
    inset: 0 0 0 var(--exhibit-gutter, 2.75rem);
  }

  .exhibit__svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
  }

  .exhibit__area {
    fill: var(--color-brand);
  }

  .exhibit__line {
    fill: none;
    stroke: var(--color-ink);
    stroke-width: 2;
    stroke-linejoin: round;
    stroke-linecap: round;
  }

  .exhibit__bar {
    fill: var(--color-brand);
    stroke: var(--color-ink);
    stroke-width: 1;
  }

  /* gridlines over the marks, faint; the value sits just above its line at the left */
  .exhibit__tick {
    position: absolute;
    z-index: 1;
    right: 0;
    left: 0;
    border-top: 1px solid var(--color-ink-line-faint);
  }

  .exhibit__ticklabel {
    position: absolute;
    bottom: 0.2rem;
    left: 0;
    padding-inline-end: 0.25rem;
    background: var(--color-white);
    font-size: 0.6875rem;
    line-height: 1;
  }

  .exhibit__marker {
    position: absolute;
    z-index: 2;
    top: calc(-1 * var(--space-4));
    bottom: 0;
    border-left: 1px dashed var(--color-ink);
  }

  .exhibit__markerlabel {
    position: absolute;
    top: 0;
    left: 0.375rem;
    width: max-content;
    max-width: 9rem;
    padding: 0.2em 0.7em;
    border: var(--border);
    border-radius: var(--radius-pill);
    background: var(--color-butter);
    font-size: 0.6875rem;
    font-weight: 600;
    line-height: 1.3;
  }

  .exhibit__marker--end .exhibit__markerlabel {
    right: 0.375rem;
    left: auto;
  }

  .exhibit__marker--low .exhibit__markerlabel {
    top: 2rem;
  }

  .exhibit__dot {
    position: absolute;
    z-index: 3;
    width: 0.625rem;
    height: 0.625rem;
    border: 2px solid var(--color-ink);
    border-radius: 50%;
    background: var(--color-white);
    transform: translate(-50%, -50%);
  }

  .exhibit__value {
    position: absolute;
    z-index: 4;
    padding: 0 0.3em;
    border-radius: var(--radius-sm);
    background: var(--color-white);
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
    transform: translate(-50%, calc(-100% - 0.5rem));
  }

  .exhibit__labels {
    display: grid;
    grid-template-columns: repeat(var(--n), minmax(0, 1fr));
    margin: var(--space-1) 0 0;
    padding: 0 0 0 var(--exhibit-gutter, 2.75rem);
    border-top: var(--border);
    list-style: none;
  }

  .exhibit__label {
    padding-top: 0.35rem;
    font-size: 0.6875rem;
    line-height: 1.3;
    text-align: center;
    white-space: nowrap;
  }

  .exhibit__label--skip {
    visibility: hidden;
  }

  @media (max-width: 47.9375rem) {
    .exhibit__label--thin {
      visibility: hidden;
    }
  }

  .exhibit__data {
    margin-top: var(--space-2);
    font-size: var(--step--1);
  }

  .exhibit__summary {
    width: max-content;
    max-width: 100%;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 0.2em;
    cursor: pointer;
  }

  .exhibit__table {
    width: 100%;
    margin-top: var(--space-1);
    border-collapse: collapse;
  }

  .exhibit__table :is(th, td) {
    padding: 0.35rem 0.5rem 0.35rem 0;
    border-bottom: 1px solid var(--color-ink-line-faint);
    text-align: start;
    vertical-align: top;
  }

  .exhibit__table thead th {
    border-bottom: var(--border);
  }

  /* ---------- Diagram ---------- */

  .exhibit__frame {
    display: grid;
    place-items: center;
  }

  .exhibit__img {
    display: block;
    max-width: 100%;
    height: auto;
  }

  /* ---------- Caption and source ---------- */

  .exhibit__caption {
    display: grid;
    gap: 0.25rem;
    margin-top: var(--space-3);
    font-size: var(--step--1);
    line-height: 1.5;
  }

  .exhibit--chart .exhibit__caption {
    margin-top: var(--space-2);
  }
}
