/* Repete box — 3D figure. Tokens come from site.css (:root); every var() carries a fallback. */

.box3d {
  --box3d-coral: var(--rp-coral, #F8685A);
  --box3d-ink: var(--rp-ink, #342C2C);
  --box3d-paper: var(--rp-paper, #EFEBE7);
  margin: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.25rem;
  color: var(--box3d-ink);
}

/* Stage: same 4:3 box as the poster, so swapping in the viewer never shifts the layout. */
.box3d-stage {
  position: relative;
  aspect-ratio: 4 / 3;
  width: 100%;
}
.box3d-poster {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  transition: opacity 0.45s ease;
}
.box3d-stage > .box3d-poster { position: absolute; inset: 0; height: 100%; }

.box3d-mv {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: transparent;
  opacity: 0;
  transition: opacity 0.45s ease;
  --poster-color: transparent;
  --progress-bar-height: 0;
}
.box3d-mv:focus-visible { outline: 3px solid var(--box3d-ink); outline-offset: 2px; }
.box3d.is-live .box3d-mv { opacity: 1; }
.box3d.is-live .box3d-poster { opacity: 0; visibility: hidden; transition: opacity 0.45s ease, visibility 0s 0.45s; }

/* Hotspots */
.box3d-hotspot {
  --size: 1.75rem;
  display: grid;
  place-items: center;
  width: var(--size);
  height: var(--size);
  padding: 0;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--box3d-ink);
  color: #fff;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  transition: opacity 0.25s ease, visibility 0.25s, transform 0.2s ease, background-color 0.2s ease;
}
.box3d-hotspot:not([data-visible]) { opacity: 0; visibility: hidden; } /* facing away: reach it from the list */
.box3d.is-closed .box3d-hotspot[slot="hotspot-message"] { opacity: 0; visibility: hidden; } /* inside the closed box */
.box3d-hotspot:hover { transform: scale(1.08); }
.box3d-hotspot.is-active { background: var(--box3d-coral); transform: scale(1.15); opacity: 1; }
.box3d-hotspot:focus-visible { outline: 3px solid var(--box3d-ink); outline-offset: 2px; }
.box3d.is-moving .box3d-hotspot { opacity: 0; pointer-events: none; }
.box3d:not([data-box3d-state="ready"]) .box3d-hotspot { opacity: 0; visibility: hidden; }

/* Controls over the stage */
.box3d-controls {
  position: absolute;
  left: 50%;
  bottom: 0.75rem;
  transform: translateX(-50%);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  width: max-content;
  max-width: calc(100% - 1.5rem);
  opacity: 0;
  transition: opacity 0.3s ease;
}
.box3d[data-box3d-state="ready"] .box3d-controls { opacity: 1; }
.box3d-btn {
  min-height: 2.75rem;
  padding: 0.5rem 1.1rem;
  border: 1.5px solid var(--box3d-ink);
  border-radius: 999px;
  background: var(--box3d-paper);
  color: var(--box3d-ink);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}
.box3d-btn:hover { background: var(--box3d-ink); color: var(--box3d-paper); }
.box3d-btn:focus-visible { outline: 3px solid var(--box3d-coral); outline-offset: 2px; }
.box3d-btn--ar { background: var(--box3d-coral); border-color: var(--box3d-coral); color: #fff; }
.box3d-btn--ar:hover { background: var(--box3d-ink); border-color: var(--box3d-ink); }
.box3d-btn[hidden] { display: none; }

.box3d-hint {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  margin: 0;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--box3d-ink);
  font-size: 0.8125rem;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease;
}
.box3d[data-box3d-state="ready"]:not(.has-interacted) .box3d-hint { opacity: 1; }

/* Facts legend — visible, numbered text (the no-JS content too). */
.box3d-facts {
  list-style: none;
  counter-reset: box3d;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.25rem;
}
.box3d-facts > li {
  counter-increment: box3d;
  position: relative;
  padding: 0.6rem 0.75rem 0.6rem 2.9rem;
  border-radius: 0.75rem;
  line-height: 1.4;
  transition: background-color 0.2s ease;
}
.box3d-facts > li::before {
  content: counter(box3d);
  position: absolute;
  left: 0.75rem;
  top: 0.6rem;
  display: grid;
  place-items: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: var(--box3d-ink);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1;
}
.box3d-facts strong { display: block; font-weight: 600; }
.box3d-facts span { display: block; opacity: 0.8; font-size: 0.9375em; }
.box3d-facts > li.is-interactive { padding: 0; }
.box3d-facts > li.is-interactive::before { left: 0.75rem; top: 0.6rem; pointer-events: none; }
.box3d-fact {
  display: block;
  width: 100%;
  padding: 0.6rem 0.75rem 0.6rem 2.9rem;
  border: 0;
  border-radius: inherit;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.box3d-fact:hover { background: rgba(52, 44, 44, 0.05); }
.box3d-fact:focus-visible { outline: 3px solid var(--box3d-ink); outline-offset: -3px; }
.box3d-facts > li.is-active { background: color-mix(in srgb, var(--box3d-coral) 14%, transparent); }
.box3d-facts > li.is-active::before { background: var(--box3d-coral); }

@media (max-width: 599px) {
  .box3d-controls { bottom: 0.25rem; gap: 0.375rem; }
  .box3d-btn { min-height: 2.25rem; padding: 0.35rem 0.85rem; font-size: 0.8125rem; }
  .box3d-hint { top: 0.25rem; left: 0.25rem; font-size: 0.75rem; }
  .box3d-hotspot { --size: 1.5rem; }
}

@media (min-width: 960px) {
  .box3d { grid-template-columns: minmax(0, 1.7fr) minmax(16rem, 1fr); align-items: center; gap: 2rem; }
}

@media (prefers-reduced-motion: reduce) {
  .box3d-poster, .box3d-mv, .box3d-hotspot, .box3d-controls, .box3d-hint, .box3d-facts > li { transition: none; }
}
