/* Visualisation runtime — shared layout for interactive viz pages.
 * Two-pane: animation on the left, text + beat nav on the right.
 * Stacks vertically on narrow screens. */

/* Stacked layout: stage on top, panel below, single column at every viewport.
 * Phones and desktops get exactly the same shape; nothing about the page-
 * frame width changes when a viz is present, so navigating between viz and
 * non-viz pages is visually steady. */
.viz-app {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-sm, 1rem);
  align-items: start;
  margin: var(--space-md, 1.5rem) 0;
}

.viz-stage {
  background: var(--color-paper, #fff);
  border: 1px solid var(--color-border, #d9d4c0);
  border-radius: 4px;
  position: relative;
  width: 100%;
  aspect-ratio: 8 / 5;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.viz-stage > svg,
.viz-stage > canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.viz-panel {
  display: flex;
  flex-direction: column;
  background: var(--color-paper, #fff);
  border: 1px solid var(--color-border, #d9d4c0);
  border-radius: 4px;
  padding: var(--space-sm, 1rem) var(--space-md, 1.5rem);
  min-height: 0;              /* allow flex children (body) to control overflow */
  overflow: hidden;           /* clip if a beat is unusually long */
}

.viz-beat-counter {
  font-size: var(--text-sm, 0.875rem);
  color: var(--color-meta, #666);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin: 0 0 var(--space-2xs, 0.25rem) 0;
}

.viz-beat-title {
  font-family: 'Libre Baskerville', Georgia, serif;
  font-size: var(--text-lg, 1.25rem);
  color: var(--color-ink, #1a1a1a);
  margin: 0 0 var(--space-sm, 1rem) 0;
  border: none;
  padding: 0;
}

/* Body stack: every beat's body is rendered as a sibling inside this stack.
 * The grid-template-areas trick makes them all share a single cell, so the
 * cell sizes to the tallest beat. Only the active beat is visible; the
 * others stay invisible but still contribute to the cell's intrinsic height,
 * which is what locks the panel's overall size. */
.viz-beat-stack {
  display: grid;
  grid-template-areas: "stack";
  flex: 1 1 auto;
  min-height: 0;
}

.viz-beat-body {
  grid-area: stack;
  font-size: var(--text-base, 1rem);
  line-height: 1.6;
  color: var(--color-ink, #1a1a1a);
  margin: 0;
  visibility: hidden;         /* hidden but still measured */
  pointer-events: none;
}

.viz-beat-body.active {
  visibility: visible;
  pointer-events: auto;
}

.viz-beat-body p { margin: 0 0 var(--space-xs, 0.5rem) 0; }
.viz-beat-body p:last-child { margin-bottom: 0; }

.viz-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--space-sm, 1rem);
  padding-top: var(--space-sm, 1rem);
  border-top: 1px solid var(--color-border, #d9d4c0);
}

.viz-nav-btn {
  font-family: inherit;
  font-size: var(--text-sm, 0.875rem);
  background: transparent;
  border: 1px solid var(--color-border, #d9d4c0);
  color: var(--color-ink, #1a1a1a);
  padding: 0.4rem 0.9rem;
  cursor: pointer;
  border-radius: 3px;
  transition: background-color 0.15s ease;
}

.viz-nav-btn:hover:not(:disabled) {
  background: var(--color-bg-alt, #f5f2e8);
}

.viz-nav-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.viz-beat-dots {
  display: flex;
  gap: 0.35rem;
  align-items: center;
}

.viz-beat-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--color-border, #d9d4c0);
  border: none;
  padding: 0;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.15s ease;
}

.viz-beat-dot:hover {
  transform: scale(1.2);
}

.viz-beat-dot.active {
  background: var(--color-accent, #002147);
}

.viz-restart {
  font-family: inherit;
  font-size: var(--text-sm, 0.875rem);
  background: transparent;
  border: none;
  color: var(--color-meta, #666);
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.viz-restart:hover {
  color: var(--color-accent, #002147);
}
