/* ==========================================================================
   Product theater — centrepiece on a light drafting sheet.

   Hero already spends the charcoal budget; this section stays light.
   position: sticky fails if any ancestor sets overflow ≠ visible.
   ========================================================================== */

.theater {
  background: var(--tr-white);
  color: var(--color-text);
  padding-block: var(--section-pad);
}

.theater__head h2 { max-inline-size: 22ch; }

.theater__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  gap: clamp(2rem, 6vw, 5rem);
  align-items: start;
}

/* --------------------------------------------------------------------------
   The sticky stage
   -------------------------------------------------------------------------- */

.theater__stage {
  position: sticky;
  inset-block-start: calc(var(--header-h) + 3.5rem);
  aspect-ratio: 1 / 0.92;
  border: 1px solid var(--color-border);
  background: var(--tr-off-white);
  display: grid;
  place-items: center;
  padding: 2rem;
}

/* Opacity crossfade only — no second transform motion on top of SLD. */
.theater__fig {
  grid-area: 1 / 1;
  margin: 0;
  inline-size: 100%;
  opacity: 0;
  transition: opacity 520ms var(--ease-out);
  pointer-events: none;
}

.theater__fig.is-on {
  opacity: 1;
}

.theater__fig img {
  inline-size: 100%;
  block-size: auto;
  object-fit: contain;
}

.theater .sld [data-draw] { stroke: var(--sld-color); }
.theater .sld__node { fill: var(--sld-color); }
.theater .sld__label { fill: var(--sld-dim); }

/*
 * Per-family companion figure. Exists in the DOM at every width, but only
 * shown below the .theater__stage breakpoint — see the mobile section further
 * down. Hidden here so desktop never renders four extra copies of the SLD.
 */
.fam__fig {
  display: none;
}

/* --------------------------------------------------------------------------
   The scrolling families
   -------------------------------------------------------------------------- */

.theater__families {
  display: flex;
  flex-direction: column;
  gap: clamp(2rem, 5vw, 3.5rem);
}

.fam {
  padding-block: clamp(1.5rem, 3vw, 2.5rem);
  border-block-start: 1px solid var(--color-border);
  opacity: 0.28;
  transition: opacity 460ms var(--ease-out);
}

.fam.is-on { opacity: 1; }

.fam__class {
  display: inline-block;
  margin-block-end: 0.9rem;
  padding: 0.2rem 0.55rem;
  border: 1px solid var(--color-border);
  font-family: var(--font-mono);
  font-size: var(--readout-size);
  letter-spacing: 0.1em;
  color: var(--color-heading);
}

.fam.is-on .fam__class {
  border-color: rgba(0, 179, 154, 0.45);
  color: var(--tr-teal-700);
}

.fam__title {
  color: var(--color-heading);
  font-size: clamp(1.25rem, 2.2vw, 1.6rem);
  margin-block-end: 0.7rem;
}

.fam__body {
  font-size: 0.9375rem;
  max-inline-size: 46ch;
  margin-block-end: var(--space-lg);
}

.fam__specs { margin-block-end: var(--space-lg); }

.fam__link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--tr-teal-700);
  text-decoration: none;
  font-size: var(--fs-small);
  font-weight: var(--fw-semibold);
}

.fam__link:hover {
  text-decoration: underline;
  text-underline-offset: 4px;
}

@media (max-width: 900px) {
  .theater__grid { grid-template-columns: 1fr; }

  /*
   * The sticky-stage-plus-scrolling-blocks pairing is a desktop device: it
   * works because the stage stays put while blocks scroll past it. Stacked
   * single-column, that same stage becomes one giant diagram a phone has to
   * scroll past before reaching ANY of the four descriptions — exactly the
   * "diagram with no visible caption" problem. Below this width the shared
   * stage drops out entirely and each family carries its own inline figure
   * instead (.fam__fig), sized to sit beside its own text.
   */
  .theater__stage {
    display: none;
  }

  .fam { opacity: 1; }

  .fam__fig {
    display: grid;
    place-items: center;
    aspect-ratio: 4 / 3;
    margin: 0 0 var(--space-lg);
    padding: 1.5rem;
    border: 1px solid var(--color-border);
    background: var(--tr-off-white);
  }

  .fam__fig .sld,
  .fam__fig img {
    inline-size: 100%;
    block-size: auto;
    max-block-size: 100%;
    object-fit: contain;
  }
}

@media (prefers-reduced-motion: reduce) {
  .fam { opacity: 1; }
}
