/* The diagram.
   Plain CSS because almost all of it is SVG child selectors. Colour lives here and nowhere
   else on the page: pale highlighter washes under black halftone screens. */

.ampo-venn {
  display: block;
  width: 100%;
  height: auto;
  max-width: 34rem;
  margin-inline: auto;
  overflow: visible;
  touch-action: manipulation;
}

/* Multiply is what makes this read as highlighter rather than as stacked paint: two
   overlapping washes deepen instead of one hiding the other, which is exactly the
   relationship the region represents. */
.ampo-venn__wash {
  mix-blend-mode: multiply;
  pointer-events: none;
  transform-box: fill-box;
  transform-origin: center;
}

/* The screen sits as tone over the wash rather than as solid ink. At full opacity a 50%
   halftone reads as near-black and kills the colour underneath it, which loses the
   penetration reading the density is there to carry. */
.ampo-venn__fill {
  opacity: 0.3;
  pointer-events: none;
}

.ampo-venn__circle {
  stroke: #0a0a0b;
  stroke-width: 2;
  cursor: pointer;
  transition: stroke-width 150ms ease;
}

.ampo-venn__circle.is-core {
  stroke-width: 4;
}

.ampo-venn__circle.is-active {
  stroke-width: 5;
}

.ampo-venn__overlap {
  fill: transparent;
  stroke: none;
  cursor: pointer;
}

.ampo-venn__overlap.is-active {
  fill: #0a0a0b;
  fill-opacity: 0.1;
}

.ampo-venn__label {
  fill: #0a0a0b;
  font-family: inherit;
  font-weight: 600;
  letter-spacing: -0.02em;
  paint-order: stroke fill;
  stroke: #fff;
  stroke-width: 6;
  stroke-linejoin: round;
  pointer-events: none;
}

.ampo-venn__leader {
  stroke: #71717a;
  stroke-width: 1.5;
}

.ampo-venn__chord {
  stroke: #0a0a0b;
  stroke-linecap: round;
  opacity: 0.35;
}

.ampo-venn__watermark {
  fill: #71717a;
  font-family: inherit;
  font-weight: 500;
  letter-spacing: 0.12em;
  pointer-events: none;
  text-transform: uppercase;
}

/* The one authored moment: circles settle into place, staggered, with their washes
   arriving after the outline. */
@media (prefers-reduced-motion: no-preference) {
  .ampo-venn__wash,
  .ampo-venn__fill {
    animation: ampo-settle 520ms cubic-bezier(0.16, 1, 0.3, 1) both;
    animation-delay: calc(var(--i, 0) * 60ms);
  }

  @keyframes ampo-settle {
    from { opacity: 0; transform: scale(0.96); }
    to   { opacity: 1; transform: scale(1); }
  }
}

/* The readout. Replaces a tooltip, which cannot be reached by keyboard, has nowhere to live
   on a phone, and disappears exactly when someone wants to think about what it said. */
.ampo-readout {
  background: #fafafa;
  border-radius: 14px;
  margin-top: 1.5rem;
  min-height: 7.5rem;
  padding: 1.1rem 1.25rem;
}

.ampo-readout__kind {
  color: #71717a;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.ampo-readout__title {
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin-top: 0.4rem;
}

.ampo-readout__body {
  color: #52525b;
  font-size: 0.9375rem;
  line-height: 1.55;
  margin-top: 0.4rem;
  max-width: 62ch;
}

.ampo-readout__figures {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.75rem;
  margin-top: 0.9rem;
}

.ampo-readout__figures div {
  color: #71717a;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.ampo-readout__figures b {
  color: #0a0a0b;
  display: block;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  margin-top: 0.15rem;
}

/* Tables carry every figure the diagram approximates, so they are never visually demoted. */
.ampo-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
  margin-block: 1.5rem;
}

.ampo-table caption {
  color: #52525b;
  font-size: 0.875rem;
  line-height: 1.55;
  margin-bottom: 1rem;
  max-width: 70ch;
  text-align: left;
}

.ampo-table th,
.ampo-table td {
  border-bottom: 1px solid #e4e4e7;
  padding: 0.7rem 1rem 0.7rem 0;
  text-align: left;
  vertical-align: top;
}

.ampo-table thead th {
  color: #71717a;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.ampo-table tbody th {
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.ampo-table td {
  color: #52525b;
  font-variant-numeric: tabular-nums;
}

.ampo-core-tag,
.ampo-method {
  border-radius: 999px;
  display: inline-block;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  padding: 0.1rem 0.5rem;
  white-space: nowrap;
}

.ampo-core-tag {
  background: #0a0a0b;
  color: #fff;
}

/* A modelled figure must never carry the weight of a counted one. */
.ampo-method {
  border: 1px solid #e4e4e7;
  color: #71717a;
}

.ampo-method[data-method="official"] {
  border-color: #0a0a0b;
  color: #0a0a0b;
}

.ampo-method[data-method="modelled"] {
  border-style: dashed;
}

.ampo-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1.5rem;
  list-style: none;
  margin: 1.25rem 0 0;
  padding: 0;
}

.ampo-legend li {
  align-items: center;
  color: #52525b;
  display: flex;
  font-size: 0.8125rem;
  gap: 0.5rem;
}

.ampo-legend .swatch {
  background-color: #fff;
  background-repeat: repeat;
  border: 1px solid #d4d4d8;
  border-radius: 4px;
  display: inline-block;
  flex: 0 0 auto;
  height: 1rem;
  width: 1rem;
}

/* The same three screen densities the diagram uses, so the legend is made of the
   material it describes rather than an approximation of it. */
.ampo-legend .swatch[data-density="sparse"] {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='8' height='8'><rect x='0' y='0' width='2' height='2'/><rect x='4' y='4' width='2' height='2'/></svg>");
}

.ampo-legend .swatch[data-density="light"] {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='8' height='8'><rect x='0' y='0' width='2' height='2'/><rect x='4' y='4' width='2' height='2'/><rect x='4' y='0' width='2' height='2'/><rect x='0' y='4' width='2' height='2'/></svg>");
}

.ampo-legend .swatch[data-density="dense"] {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='8' height='8'><rect x='0' y='0' width='2' height='2'/><rect x='2' y='2' width='2' height='2'/><rect x='4' y='4' width='2' height='2'/><rect x='6' y='6' width='2' height='2'/><rect x='4' y='0' width='2' height='2'/><rect x='6' y='2' width='2' height='2'/><rect x='0' y='4' width='2' height='2'/><rect x='2' y='6' width='2' height='2'/></svg>");
}

.ampo-fit-note {
  border-left: 2px solid #e4e4e7;
  color: #52525b;
  font-size: 0.875rem;
  line-height: 1.6;
  margin-top: 1.25rem;
  max-width: 68ch;
  padding-left: 1rem;
}

/* Below this width a seven-column table can only be read by dragging it sideways, which on
   the viewport most of this traffic arrives on means it does not get read. */
@media (max-width: 40rem) {
  .ampo-table,
  .ampo-table caption,
  .ampo-table thead,
  .ampo-table tbody,
  .ampo-table tr,
  .ampo-table th,
  .ampo-table td {
    display: block;
  }

  .ampo-table thead {
    clip-path: inset(50%);
    height: 1px;
    overflow: hidden;
    position: absolute;
    white-space: nowrap;
    width: 1px;
  }

  .ampo-table tr {
    border: 1px solid #e4e4e7;
    border-radius: 14px;
    margin-bottom: 1rem;
    padding: 1rem 1.1rem;
  }

  .ampo-table th,
  .ampo-table td {
    border-bottom: 0;
    padding: 0;
    white-space: normal;
  }

  .ampo-table th[scope="row"] {
    font-size: 1.0625rem;
    margin-bottom: 0.6rem;
  }

  .ampo-table td {
    align-items: baseline;
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    padding-block: 0.45rem;
    text-align: right;
  }

  .ampo-table td + td {
    border-top: 1px solid #f4f4f5;
  }

  .ampo-table td::before {
    color: #71717a;
    content: attr(data-label);
    flex: 0 0 auto;
    font-family: var(--font-mono, ui-monospace, monospace);
    font-size: 0.75rem;
    text-align: left;
  }

  .ampo-table td .ampo-method {
    align-self: center;
    flex: 0 0 auto;
  }
}
