/* ============================================================
   Rosetta component shell (placeholders mounted by index.js).
   Component-specific styles go in <name>.css, scoped under
   .rv-figure[data-component="<name>"].
   ============================================================ */

.rv-figure {
  margin-top: 3em;
  margin-bottom: 3.25em;
  position: relative;
}

.rv-figure > .rv-stage {
  position: relative;
  width: 100%;
}

.rv-figure .rv-stage svg,
.rv-figure .rv-stage canvas {
  display: block;
  max-width: 100%;
}

/* Fallback text: visible without JS / on error; after mount it stays in the
   accessibility tree as the figure's text description, but is not shown. */
.rv-figure.rv-mounted > .rv-fallback {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.rv-figure > .rv-fallback {
  font-size: 0.9rem;
  color: var(--viz-ink-2, var(--meta-color));
  line-height: 1.55;
  border-left: 2px solid var(--border-medium);
  padding-left: 0.9em;
}

/* While the component loads, the stage reserves its height and the fallback
   stays in the accessibility tree only (no flash of text, no layout jump). */
.rv-figure.rv-loading > .rv-fallback {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Failure (set by index.js showFailure): the stage collapses, a one-line
   notice comes first, then the fallback text, then the caption. */
.rv-figure.rv-error > .rv-stage { display: none; }
.rv-figure > .rv-error-note {
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--viz-ink-2, var(--meta-color));
  margin: 0 0 0.5em 0;
}

.rv-figure > .rv-caption {
  font-size: 0.95rem;
  /* boxy captions: justified, hyphenated so word gaps stay even, no lone last word */
  text-align: justify;
  hyphens: auto;
  -webkit-hyphens: auto;
  text-wrap: pretty;
  line-height: 1.5em;
  color: var(--viz-ink-2, var(--meta-color));
  margin-top: 0.75em;
}
.rv-figure > .rv-caption p { margin: 0 0 0.5em 0; }
.rv-figure > .rv-caption p:last-child { margin-bottom: 0; }

/* Minimal control row. Prefer viz-theme.css classes (.viz-controls,
   .viz-range, .viz-readout, .viz-btn, .viz-seg); these are a fallback. */
.rv-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5em 1em;
  font-size: 0.85rem;
  color: var(--viz-ink-2, var(--meta-color));
  margin: 0.5em 0;
}
.rv-controls label { display: inline-flex; align-items: center; gap: 0.5em; }
.rv-controls input[type="range"] {
  flex: 1 1 160px;
  min-width: 120px;
  accent-color: var(--viz-ink, var(--accent-color));
}
.rv-controls output,
.rv-readout {
  font-variant-numeric: tabular-nums;
  min-width: 3.5em;
}

@media (prefers-reduced-motion: reduce) {
  .rv-figure *, .rv-figure *::before, .rv-figure *::after {
    transition-duration: 0s !important;
    animation-duration: 0s !important;
    animation-iteration-count: 1 !important;
  }
}
