/* ==========================================================================
   Model Viewer — 360° product viewer
   Selectors and state classes (.hidden, .mv-action-selected, .mv360*,
   .mv-pack-progress, .mv-zoom-badge, .mv-hint) are wired to the template and
   JavaScript (mv360.js, m-viewer.js) — do not rename them.
   ========================================================================== */

.model-container {
  /* Theme tokens (scoped to the widget so they never leak into the theme) */
  --mv-radius: 16px;
  --mv-accent: #1d6fb8;
  --mv-accent-strong: #0f4c81;
  --mv-stage-top: #3d3d42;
  --mv-stage-bottom: #1d1d21;
  --mv-glass: rgba(24, 24, 28, 0.55);
  --mv-glass-hover: rgba(24, 24, 28, 0.78);
  --mv-glass-border: rgba(255, 255, 255, 0.14);
  --mv-control-icon: #ffffff;

  position: relative;
  margin: 0;
  padding: 0;
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: var(--mv-radius);
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(255, 255, 255, 0.07), transparent 60%),
    linear-gradient(170deg, var(--mv-stage-top), var(--mv-stage-bottom));
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.10);
  overflow: hidden;
}

/* The floor glow is baked into the renders now (radial pool low behind the
   model) - no CSS glow overlay on top of it. */

.model-container:fullscreen,
.model-container.mv-fake-fullscreen {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  /* Theme/page width caps on the shortcode wrapper must not survive into
     fullscreen. */
  max-width: none !important;
  max-height: none !important;
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  /* Continue the frames' baked backdrop (cool floor-glow radial, pool low
     behind the model) into the letterbox areas, aligned to the frame's own
     gradient so the seam disappears. Frames are 16:9; below, the contain-fit
     frame spans the screen WIDTH (letterbox above/below): frame height is
     56.25vw and the pool sits 22% up from the frame's bottom edge. Stops
     sampled from a rendered frame.
     Pool y = 50% + (56.25/2)vw - (0.22*56.25)vw = 50% + 15.75vw. */
  background: radial-gradient(ellipse 75vw 42.1875vw at 50% calc(50% + 15.75vw),
    #414550 0%, #3e424c 21%, #383d45 33%, #2e323a 50%, #282c33 60%, #111419 100%);
}

/* Screens at least as wide as 16:9: the frame spans the screen HEIGHT
   instead (letterbox left/right), so the same gradient is sized in vh.
   Pool y = 78% of the frame height = 78vh. */
@media (min-aspect-ratio: 16/9) {
  .model-container:fullscreen,
  .model-container.mv-fake-fullscreen {
    background: radial-gradient(ellipse 133.3333vh 75vh at 50% 78vh,
      #414550 0%, #3e424c 21%, #383d45 33%, #2e323a 50%, #282c33 60%, #111419 100%);
  }
}

/* iPhone Safari has no element Fullscreen API; m-viewer.js pins the viewer
   over the page with this class instead. */
.model-container.mv-fake-fullscreen {
  position: fixed;
  z-index: 999999;
}

.mv-noscroll {
  overflow: hidden;
}

/* Fullscreen must hand the whole screen to the canvas: override the stage's
   inline aspect-ratio lock (mv360 _resize), otherwise a portrait phone shows
   the model as a short letterboxed band and zoom/pan stay confined to it. */
.model-container:fullscreen .model-viewer,
.model-container.mv-fake-fullscreen .model-viewer {
  border: none !important;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  border-radius: 0;
}

.model-container:fullscreen .mv360,
.model-container.mv-fake-fullscreen .mv360 {
  height: 100%;
  min-height: 0;
  aspect-ratio: auto !important;
}

/* Preview state (before the model is loaded) ------------------------------- */

.mv-preview-container {
  position: relative;
}

.mv-preview {
  display: block;
  width: 100%;
  border-radius: var(--mv-radius);
  overflow: hidden;
}

/* The "spin" invite — the one signature element. A soft glass disc that
   breathes outward like a radar ping, pulling the eye toward the product. */
.mv-preview-action {
  position: absolute;
  top: auto;
  right: 0;
  bottom: 24px;
  left: 0;
  width: 112px;
  height: 112px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background-color: rgba(255, 255, 255, 0.32);
  -webkit-backdrop-filter: blur(8px) saturate(140%);
  backdrop-filter: blur(8px) saturate(140%);
  cursor: pointer;
  transition: transform 0.25s ease, background-color 0.25s ease, box-shadow 0.25s ease;
  animation: mv-pulsate 1600ms ease-in-out infinite alternate;
}

.mv-preview-action img {
  width: 96px;
  vertical-align: middle;
  pointer-events: none;
}

.mv-preview-action:hover {
  background-color: rgba(255, 255, 255, 0.85);
  box-shadow: 0 0 0 10px rgba(255, 255, 255, 0.16);
  transform: scale(1.06);
  animation: none;
}

@keyframes mv-pulsate {
  from {
    background-color: rgba(255, 255, 255, 0.26);
    box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.30);
  }
  to {
    background-color: rgba(255, 255, 255, 0.48);
    box-shadow: 0 0 0 18px rgba(255, 255, 255, 0);
  }
}

/* Loading progress ----------------------------------------------------------
   Glass pill with a real progress bar, shown over the preview while the
   frame pack downloads / frames decode (see updateLoadProgress). */

.mv-pack-progress {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 200px;
  max-width: 76%;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--mv-glass-border);
  background-color: var(--mv-glass);
  -webkit-backdrop-filter: blur(10px) saturate(140%);
  backdrop-filter: blur(10px) saturate(140%);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

.mv-progress-track {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background-color: rgba(255, 255, 255, 0.22);
  overflow: hidden;
}

.mv-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 2px;
  background: linear-gradient(90deg, #6db3e8, #ffffff);
  transition: width 0.15s ease;
}

.mv-progress-label {
  flex: none;
  min-width: 3.2em;
  text-align: right;
}

/* Load-failure state (see showLoadError) */
.mv-pack-progress.mv-load-error {
  background-color: rgba(122, 28, 28, 0.82);
  border-color: rgba(255, 120, 120, 0.35);
  font-weight: 500;
  letter-spacing: 0;
}

/* Viewer state (after the model is loaded) --------------------------------- */

.model-viewer {
  position: relative;
  width: 100%;
  border-radius: var(--mv-radius);
  overflow: hidden;
  cursor: grab;
}

.model-viewer:active {
  cursor: grabbing;
}

.mv360 {
  position: relative;
  width: 100%;
  min-height: 200px;
}

.mv360-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* Controls ------------------------------------------------------------------
   One segmented glass pill instead of separate floating circles. */

.button-container {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 100;
  display: flex;
  gap: 2px;
  padding: 4px;
  border-radius: 999px;
  border: 1px solid var(--mv-glass-border);
  background-color: var(--mv-glass);
  -webkit-backdrop-filter: blur(10px) saturate(140%);
  backdrop-filter: blur(10px) saturate(140%);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.22);
}

.mv-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background-color: transparent;
  color: var(--mv-control-icon);
  cursor: pointer;
  transition: background-color 0.18s ease, transform 0.12s ease;
}

.mv-action:hover {
  background-color: rgba(255, 255, 255, 0.16);
}

.mv-action:active {
  transform: scale(0.90);
}

.mv-action:focus-visible {
  outline: 2px solid #8ec2ee;
  outline-offset: 1px;
}

.mv-action-selected {
  background-color: var(--mv-accent-strong);
}

.mv-action-selected:hover {
  background-color: var(--mv-accent);
}

.mv-action svg {
  width: 18px;
  height: 18px;
  display: block;
}

.mv-action img {
  width: 24px;
}

/* Transient zoom-level badge (bottom-left, fades out after zooming) -------- */

.mv-zoom-badge {
  position: absolute;
  left: 14px;
  bottom: 14px;
  z-index: 100;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--mv-glass-border);
  background-color: var(--mv-glass);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.mv-zoom-badge.mv-visible {
  opacity: 1;
}

/* One-time interaction hint (fades after a few seconds / first drag) ------- */

.mv-hint {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 100;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--mv-glass-border);
  background-color: var(--mv-glass);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  color: rgba(255, 255, 255, 0.92);
  font-size: 12.5px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  animation: mv-hint-in 0.5s ease 0.6s forwards;
  transition: opacity 0.4s ease;
}

.mv-hint.mv-hint-out {
  opacity: 0 !important;
}

@keyframes mv-hint-in {
  to { opacity: 1; }
}

/* Utility ------------------------------------------------------------------ */

.hidden {
  display: none !important;
  visibility: hidden !important;
}

/* Tablets ------------------------------------------------------------------ */

@media only screen and (max-width: 768px) {
  .mv-preview-action {
    width: 92px;
    height: 92px;
  }

  .mv-preview-action img {
    width: 76px;
  }
}

/* Mobile ------------------------------------------------------------------- */

@media only screen and (max-width: 480px) {
  .mv-preview-action {
    width: 76px;
    height: 76px;
  }

  .mv-preview-action img {
    width: 60px;
  }

  .button-container {
    top: 8px;
    right: 8px;
  }

  .mv-action {
    width: 36px;
    height: 36px;
  }

  .mv-action svg {
    width: 16px;
    height: 16px;
  }

  .mv-hint {
    font-size: 11.5px;
  }
}

/* Respect users who prefer reduced motion --------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .mv-preview-action {
    animation: none;
    transition: none;
  }

  .mv-action,
  .mv-progress-fill,
  .mv-zoom-badge,
  .mv-hint {
    animation: none;
    transition: none;
  }

  .mv-hint {
    opacity: 1;
  }
}
