/* Blog interactives (scripts/blog-interactives/, website/blog/interactives/).
   Linked only from pages that contain a <figure class="blog-interactive">, so it
   never touches the rest of the site. Uses the palette from /styles.css. */
.blog-interactive {
  --bi-mint: #34c79a;
  --bi-sky: #5aa9f5;
  margin: 2em 0;
  padding: 0;
}

/* Stage: fixed aspect ratio (inline style from the JSON), so nothing below it
   moves while the poster, the canvas or the loading state swap. */
.bi-stage {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--grad-soft);
  box-shadow: var(--shadow);
}
.bi-poster {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.45s ease;
}
.bi-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 0.45s ease;
}
.blog-interactive[data-state="ready"] .bi-canvas { opacity: 1; }
.blog-interactive[data-state="ready"] .bi-poster { opacity: 0; }
.blog-interactive[data-state="loading"] .bi-stage::after {
  content: "";
  position: absolute;
  top: 14px;
  right: 14px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 3px solid rgba(124, 92, 255, 0.22);
  border-top-color: var(--purple);
  animation: bi-spin 0.9s linear infinite;
}
@keyframes bi-spin { to { transform: rotate(360deg); } }
.bi-load {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  min-height: 44px;
  padding: 10px 20px;
  border: 2px solid #e6ddff;
  border-radius: 999px;
  background: #fff;
  color: var(--purple);
  font: 600 0.95rem "Fredoka", "Nunito", sans-serif;
  box-shadow: var(--shadow);
  cursor: pointer;
  white-space: nowrap;
}
.bi-load:hover { border-color: var(--purple); }

/* Controls: server-rendered (disabled) so they exist before any script runs. */
.bi-panel { margin-top: 16px; }
.bi-choices { min-width: 0; margin: 0; padding: 0; border: 0; }
.bi-legend {
  padding: 0;
  margin-bottom: 10px;
  font: 600 1.02rem/1.3 "Fredoka", "Nunito", sans-serif;
  color: var(--ink);
}
.bi-options { display: flex; flex-wrap: wrap; gap: 10px; }
.bi-option {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 48px;
  padding: 7px 18px 7px 36px;
  border: 2px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  color: var(--ink);
  line-height: 1.25;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.bi-option::before {
  content: "";
  position: absolute;
  left: 14px;
  top: 50%;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--bi-swatch, var(--pink));
  box-shadow: 0 0 0 3px #fff, 0 0 0 4px rgba(59, 42, 82, 0.12);
  transform: translateY(-50%);
}
/* The radio stays in the accessibility tree and keyboard order (arrow keys move
   between conditions); the whole pill is its label. */
.bi-option input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: inherit;
}
.bi-option-label { font-weight: 800; font-size: 0.95rem; }
.bi-option-value { font-size: 0.86rem; color: var(--ink-soft); }
.bi-option:has(input:checked) {
  border-color: var(--purple);
  background: #f3e8ff;
  box-shadow: 0 3px 0 rgba(124, 92, 255, 0.22);
}
.blog-interactive[data-state="ready"] .bi-option { cursor: pointer; }
.blog-interactive[data-state="ready"] .bi-option:hover { border-color: #c4b5fd; }
.bi-option:has(input:focus-visible) { outline: 3px solid var(--purple); outline-offset: 3px; }
@supports not selector(:has(*)) {
  .bi-option:focus-within { outline: 3px solid var(--purple); outline-offset: 3px; }
}

.bi-readout-row { display: flex; align-items: flex-start; gap: 14px; margin-top: 14px; }
.bi-readout { flex: 1 1 auto; min-width: 0; margin: 0; }
.bi-readout-label {
  display: block;
  font-weight: 800;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--violet);
}
.bi-readout-value {
  display: block;
  font: 600 1.4rem/1.25 "Fredoka", "Nunito", sans-serif;
  color: var(--ink);
}
.bi-readout-note { display: block; color: var(--ink-soft); font-size: 0.97rem; }
.bi-replay {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 9px 18px;
  border: 2px solid #e6ddff;
  border-radius: 999px;
  background: #fff;
  color: var(--purple);
  font: 600 0.95rem "Fredoka", "Nunito", sans-serif;
  cursor: pointer;
  visibility: hidden;
}
.blog-interactive[data-state="ready"] .bi-replay { visibility: visible; }
.bi-replay:hover { border-color: var(--purple); }
.bi-replay:focus-visible, .bi-load:focus-visible { outline: 3px solid var(--purple); outline-offset: 3px; }
.bi-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.bi-caption { margin-top: 14px; font-size: 0.95rem; line-height: 1.6; color: var(--ink-soft); }
.bi-title { color: var(--ink); font-family: "Fredoka", "Nunito", sans-serif; font-weight: 600; font-size: 1.02rem; }
.bi-title::after { content: "."; }
.bi-source { display: block; margin-top: 6px; font-size: 0.86rem; }
.bi-badge {
  display: inline-block;
  margin-right: 4px;
  padding: 2px 10px;
  border-radius: 999px;
  background: #fff3c4;
  color: #7a4f00;
  font-weight: 800;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

@media (max-width: 600px) {
  .bi-options { display: grid; grid-template-columns: 1fr; }
  .bi-readout-row { flex-direction: column; gap: 10px; }
  .bi-readout-value { font-size: 1.25rem; }
}
@media (prefers-reduced-motion: reduce) {
  .bi-poster, .bi-canvas, .bi-option { transition: none; }
  .blog-interactive[data-state="loading"] .bi-stage::after { animation: none; }
}
