/* Labelled exploded view (partials/exploded-view.njk + assets/js/exploded.js).
   Mobile first: numbered markers on the image and a numbered list below.
   Wide screens with JS (.is-leaders): labels in two columns with leader lines. */

.exploded { position: relative; }
.exploded__fig { position: relative; margin: 0 auto; max-width: 26rem; }
.exploded__fig img { display: block; width: 100%; height: auto; }

.exploded__marker,
.exploded__num {
  display: grid;
  place-items: center;
  width: 1.375rem;
  height: 1.375rem;
  border-radius: 50%;
  background: var(--color-accent-primary);
  color: var(--color-text-on-accent);
  font: 500 var(--font-size-xs) / 1 var(--font-family-mono);
}
.exploded__marker {
  position: absolute;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 3px var(--color-bg-primary);
}

ol.exploded__parts {
  list-style: none;
  margin: var(--space-6) 0 0;
  padding: 0;
  border-top: 1px solid var(--color-border-primary);
}
.exploded__part {
  display: grid;
  grid-template-columns: 2rem 1fr;
  column-gap: var(--space-3);
  align-items: center;
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--color-border-primary);
}
.exploded__num { grid-row: span 2; }
.exploded__name { font-weight: 700; line-height: 1.3; }
.exploded__note {
  grid-column: 2;
  color: var(--color-text-secondary);
  font: 400 var(--font-size-sm) / 1.4 var(--font-family-mono);
}

.exploded__leaders { display: none; }

@media (min-width: 960px) {
  .exploded__fig { max-width: 27.5rem; }

  /* exploded.js adds .is-leaders once it has measured and placed the labels */
  .exploded.is-leaders ol.exploded__parts {
    position: absolute;
    inset: 0;
    margin: 0;
    border: 0;
    pointer-events: none;
  }
  .exploded.is-leaders .exploded__part {
    position: absolute;
    /* What's left beside the figure (27.5rem) minus exploded.js's 24px GAP, up to 15rem:
       about 12rem at 960px, so both columns stay inside the container. */
    width: min(15rem, (100% - 27.5rem) / 2 - 24px);
    display: block;
    padding: 0;
    border: 0;
    margin-top: -1.4em;           /* centre the name on the leader line (no transform: see reveal rule) */
  }
  .exploded.is-leaders .exploded__part--left { text-align: right; }
  .exploded.is-leaders .exploded__num { display: none; }
  .exploded.is-leaders .exploded__name,
  .exploded.is-leaders .exploded__note { display: block; }
  .exploded.is-leaders .exploded__name { font-size: var(--font-size-base); }
  .exploded.is-leaders .exploded__marker {
    width: 0.625rem;
    height: 0.625rem;
    font-size: 0;
  }
  .exploded.is-leaders .exploded__leaders {
    display: block;
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
    pointer-events: none;
  }
  .exploded__leaders path { fill: none; stroke: var(--color-text-tertiary); stroke-width: 1; }
}
