/* SWISH 3D & AR Viewer. Everything is prefixed .swish3d-.

   Theme-proof buttons: themes and page builders style every <button> (Elementor's default kit,
   for example, turns button:hover pink with `.elementor-kit-N button:hover`). So all plugin buttons
   are reset and styled through the modal's ID (#swish3d-modal / #swish3d-qr), which outranks those
   rules, and they share one neutral hover: a light grey tint over whatever their background is. */

.swish3d-actions[hidden],
.swish3d-viewer [hidden],
.swish3d-modal[hidden],
.swish3d-qr[hidden] { display: none !important; }

/* ---------- Button reset + the one shared hover/press/focus effect ---------- */

#swish3d-modal button,
#swish3d-qr button,
.swish3d-actions .swish3d-btn.swish3d-btn {
  all: unset;
  box-sizing: border-box;
  cursor: pointer;
  /* `all: unset` makes pointer-events inherit, and the viewer's bottom bar is pointer-events:none
     (so drags reach the 3D view): switch it back on or taps fall through to the canvas. */
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
  --swish3d-shadow: 0 0 0 0 transparent;
  /* Same two-shadow shape as :hover (with an invisible tint), so the hover animates smoothly. */
  box-shadow: var(--swish3d-shadow), inset 0 0 0 100px rgba(0, 0, 0, 0);
  transition: box-shadow .15s ease, background-color .15s ease, opacity .15s ease;
}
#swish3d-modal button:hover,
#swish3d-qr button:hover,
.swish3d-actions .swish3d-btn.swish3d-btn:hover {
  box-shadow: var(--swish3d-shadow), inset 0 0 0 100px rgba(0, 0, 0, .06);
}
#swish3d-modal button:active,
#swish3d-qr button:active,
.swish3d-actions .swish3d-btn.swish3d-btn:active {
  box-shadow: var(--swish3d-shadow), inset 0 0 0 100px rgba(0, 0, 0, .12);
}
#swish3d-modal button:focus,
#swish3d-qr button:focus,
.swish3d-actions .swish3d-btn.swish3d-btn:focus { outline: none; }
#swish3d-modal button:focus-visible,
#swish3d-qr button:focus-visible,
.swish3d-actions .swish3d-btn.swish3d-btn:focus-visible { outline: 2px solid #0058a3; outline-offset: 2px; }
@media (hover: none) {
  /* Touch screens keep :hover after a tap; only show the press tint. */
  #swish3d-modal button:hover:not(:active),
  #swish3d-qr button:hover:not(:active),
  .swish3d-actions .swish3d-btn.swish3d-btn:hover:not(:active) { box-shadow: var(--swish3d-shadow), inset 0 0 0 100px rgba(0, 0, 0, 0); }
}

/* ---------- Product page buttons ("View in 3D" / "View in your space") ---------- */

.swish3d-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}
.swish3d-actions--gallery {
  position: absolute;
  left: 16px;
  bottom: 16px;
  margin: 0;
  z-index: 9;
  flex-direction: column;
  align-items: flex-start;
}
.swish3d-actions .swish3d-btn.swish3d-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px 0 12px;
  border-radius: 999px;
  background: #fff;
  color: #111;
  font: 600 14px/1 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --swish3d-shadow: 0 1px 4px rgba(0, 0, 0, .18);
  white-space: nowrap;
}
.swish3d-btn__icon { width: 20px; height: 20px; flex: none; }

/* ---------- Modal ---------- */

html.swish3d-lock, html.swish3d-lock body { overflow: hidden !important; }

.swish3d-modal {
  position: fixed;
  inset: 0;
  z-index: 999999;
  background: rgba(17, 17, 17, .55);
  animation: swish3d-fade .2s ease;
}
.swish3d-modal__panel {
  position: absolute;
  inset: 24px;
  border-radius: 16px;
  overflow: hidden;
  background: #f5f5f5;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
}
.swish3d-modal__body { position: absolute; inset: 0; }
.swish3d-modal__title {
  position: absolute;
  top: 18px;
  left: 20px;
  right: 80px;
  z-index: 6;
  margin: 0;
  font: 700 17px/1.3 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: #111;
  pointer-events: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.swish3d-modal.is-dark .swish3d-modal__title { color: #f2f2f2; }

/* Close: a single cross (no circle); the shared hover tint shows a soft round highlight. */
#swish3d-modal .swish3d-close,
#swish3d-qr .swish3d-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 7;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: transparent;
  color: #111;
}
#swish3d-modal.is-dark .swish3d-close { color: #f2f2f2; }
#swish3d-modal.is-dark .swish3d-close:hover { box-shadow: inset 0 0 0 100px rgba(255, 255, 255, .12); }
.swish3d-close svg { width: 24px; height: 24px; }

@media (max-width: 768px) {
  .swish3d-modal__panel { inset: 0; border-radius: 0; }
  .swish3d-modal__title { font-size: 15px; top: 14px; left: 14px; }
  #swish3d-modal .swish3d-close { top: 4px; right: 4px; }
}
@keyframes swish3d-fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- QR dialog (desktop "View in your space") ---------- */

.swish3d-qr {
  position: fixed;
  inset: 0;
  z-index: 1000000;
  display: grid;
  place-items: center;
  background: rgba(17, 17, 17, .55);
  padding: 16px;
  animation: swish3d-fade .2s ease;
}
.swish3d-qr__card {
  position: relative;
  width: min(360px, 100%);
  padding: 32px 28px 28px;
  border-radius: 16px;
  background: #fff;
  color: #111;
  text-align: center;
  font: 400 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
}
.swish3d-qr__card h3 { margin: 0 0 16px; font-size: 19px; font-weight: 700; color: #111; }
.swish3d-qr__card p { margin: 16px 0 0; color: #484848; }
.swish3d-qr__code { width: 200px; height: 200px; margin: 0 auto; }
.swish3d-qr__code svg { display: block; width: 100%; height: 100%; }
#swish3d-qr .swish3d-close { top: 6px; right: 6px; width: 40px; height: 40px; }
#swish3d-qr .swish3d-close svg { width: 20px; height: 20px; }

/* ---------- Viewer ---------- */

.swish3d-viewer {
  --swish3d-stage: #f5f5f5;
  --swish3d-ink: #111;
  --swish3d-chip: #fff;
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: var(--swish3d-stage);
  color: var(--swish3d-ink);
  font: 400 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  outline: none;
  user-select: none;
  -webkit-user-select: none;
}
.swish3d-viewer.is-dark { --swish3d-ink: #f2f2f2; --swish3d-chip: #2c2f35; }
.swish3d-viewer:fullscreen { width: 100vw; height: 100vh; }
.swish3d-viewer *, .swish3d-viewer *::before, .swish3d-viewer *::after { box-sizing: border-box; }
.swish3d-viewer svg { display: block; }

.swish3d-stage, .swish3d-stage canvas { position: absolute; inset: 0; width: 100% !important; height: 100% !important; }
.swish3d-stage canvas { display: block; touch-action: none; cursor: grab; }
.swish3d-stage canvas:active { cursor: grabbing; }
.swish3d-labels { position: absolute !important; inset: 0; pointer-events: none; }
.swish3d-poster { position: absolute; inset: 15%; width: 70%; height: 70%; object-fit: contain; opacity: .25; filter: blur(2px); }

/* Centred overlays (loader, hint, toast, error, AR status) use left/right + auto margins and
   width:max-content instead of `left:50%; translateX(-50%)`: with the latter a box may only be half
   the screen wide, so on phones its text runs out of its background. */

/* Circular loader: ring = real progress, label underneath = current stage */
.swish3d-loader {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  margin: 0 auto;
  width: max-content;
  max-width: calc(100% - 32px);
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  z-index: 5;
  transition: opacity .4s ease;
}
.swish3d-loader.is-done { opacity: 0; }
.swish3d-loader__ring { position: relative; width: 96px; height: 96px; }
.swish3d-loader__ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.swish3d-loader__ring circle { fill: none; stroke-width: 6; }
.swish3d-loader__track { stroke: currentColor; opacity: .1; }
.swish3d-loader__value {
  stroke: currentColor;
  stroke-linecap: round;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  transition: stroke-dashoffset .3s ease;
}
.swish3d-loader__percent {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.swish3d-loader__label { font-size: 13px; opacity: .7; font-variant-numeric: tabular-nums; text-align: center; }
.swish3d-loader.is-indeterminate .swish3d-loader__value { stroke-dashoffset: 0; stroke-dasharray: 25 75; transition: none; }
.swish3d-loader.is-indeterminate svg { animation: swish3d-spin 1s linear infinite; }
@keyframes swish3d-spin { from { transform: rotate(-90deg); } to { transform: rotate(270deg); } }

/* W × D × H line under the modal title, only while dimensions are on */
.swish3d-dims { position: absolute; top: 44px; left: 20px; margin: 0; font-size: 13px; opacity: .75; z-index: 4; pointer-events: none; }

/* "Drag to rotate" hint, top centre (the bottom belongs to the AR button) */
.swish3d-hint {
  position: absolute;
  top: 64px;
  left: 0;
  right: 0;
  margin: 0 auto;
  width: max-content;
  max-width: calc(100% - 32px);
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px 6px 8px;
  border-radius: 18px;
  background: rgba(255, 255, 255, .92);
  color: #111;
  font-size: 13px;
  line-height: 1.35;
  pointer-events: none;
  opacity: 0;
  transition: opacity .4s ease;
}
.swish3d-hint img { flex: none; width: 22px; height: auto; animation: swish3d-sway 1.6s ease-in-out infinite alternate; }
.swish3d-viewer.is-loaded:not(.has-interacted) .swish3d-hint { opacity: 1; }
.swish3d-viewer.has-interacted .swish3d-hint { display: none; }
.swish3d-hint__touch { display: none; }
/* Touch wording on any touch screen (some Android phones also report hover support). */
@media (hover: none), (pointer: coarse) { .swish3d-hint__touch { display: inline; } .swish3d-hint__mouse { display: none; } }
@keyframes swish3d-sway { from { transform: translateX(-6px) rotate(-8deg); } to { transform: translateX(6px) rotate(8deg); } }

/* Right-hand tool column */
.swish3d-toolbar {
  position: absolute;
  top: 50%;
  right: 16px;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 4;
}
.swish3d-toolbar__sep { height: 1px; margin: 2px 8px; background: currentColor; opacity: .2; }
#swish3d-modal .swish3d-tool {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--swish3d-chip);
  color: var(--swish3d-ink);
  --swish3d-shadow: 0 1px 4px rgba(0, 0, 0, .15);
}
#swish3d-modal .swish3d-tool svg { width: 18px; height: 18px; }
#swish3d-modal .swish3d-tool.is-active { background: var(--swish3d-ink); color: var(--swish3d-stage); }
@media (hover: none), (pointer: coarse) { #swish3d-modal [data-mouse-only] { display: none; } }

/* Bottom row: variants, animation, AR */
.swish3d-foot {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 20px;
  bottom: max(20px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  z-index: 4;
  pointer-events: none;
}
.swish3d-foot > * { pointer-events: auto; }
.swish3d-variants { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
#swish3d-modal .swish3d-chip {
  border: 1px solid rgba(0, 0, 0, .15);
  background: var(--swish3d-chip);
  color: var(--swish3d-ink);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
}
#swish3d-modal .swish3d-chip.is-active { border-color: var(--swish3d-ink); --swish3d-shadow: inset 0 0 0 1px var(--swish3d-ink); font-weight: 700; }
.swish3d-anim { display: flex; gap: 6px; align-items: center; }
.swish3d-anim select { border-radius: 999px; border: 0; padding: 8px 12px; background: var(--swish3d-chip); color: var(--swish3d-ink); box-shadow: 0 1px 4px rgba(0, 0, 0, .15); }

#swish3d-modal .swish3d-ar-button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 44px;
  padding: 0 22px 0 16px;
  border-radius: 999px;
  background: #fff;
  color: #111;
  font: 600 15px/1 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --swish3d-shadow: 0 1px 6px rgba(0, 0, 0, .18);
}
#swish3d-modal .swish3d-ar-button svg { width: 22px; height: 22px; }
#swish3d-modal .swish3d-ar-button.is-busy { opacity: .55; cursor: progress; }
#swish3d-modal .swish3d-ar-button.is-attention { animation: swish3d-pulse 1.4s ease-in-out 4; }
@keyframes swish3d-pulse {
  0%, 100% { box-shadow: 0 1px 6px rgba(0, 0, 0, .18), 0 0 0 0 rgba(0, 88, 163, .45); }
  50% { box-shadow: 0 1px 6px rgba(0, 0, 0, .18), 0 0 0 10px rgba(0, 88, 163, 0); }
}

.swish3d-dim-label {
  background: var(--swish3d-ink, #111);
  color: var(--swish3d-stage, #fff);
  font: 700 12px/1.2 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.swish3d-toast {
  position: absolute;
  left: 0;
  right: 0;
  margin: 0 auto;
  width: max-content;
  bottom: 84px;
  transform: translateY(8px);
  background: #111;
  color: #fff;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
  z-index: 6;
  max-width: calc(100% - 32px);
  text-align: center;
}
.swish3d-toast.is-visible { opacity: 1; transform: translateY(0); }

.swish3d-error {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  margin: 0 auto;
  width: max-content;
  transform: translateY(-50%);
  max-width: calc(100% - 48px);
  padding: 14px 20px;
  border-radius: 10px;
  background: #fff;
  color: #b3261e;
  box-shadow: 0 1px 6px rgba(0, 0, 0, .15);
  text-align: center;
  z-index: 6;
}

@media (max-width: 768px) {
  #swish3d-modal .swish3d-ar-button { height: 48px; font-size: 16px; padding: 0 24px 0 18px; }
  .swish3d-hint { top: 56px; }
  .swish3d-dims { top: 38px; left: 14px; }
}
@media (max-width: 576px) {
  .swish3d-toolbar { right: 10px; gap: 6px; top: 45%; }
  #swish3d-modal .swish3d-tool { width: 36px; height: 36px; }
}

/* WebXR DOM overlay (becomes fullscreen during an AR session). The exit button keeps its dark
   circle: it sits on top of the live camera picture and must stay visible there. */
.swish3d-ar-overlay { position: fixed; inset: 0; z-index: 10; }
#swish3d-modal .swish3d-ar-exit {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, .55);
  color: #fff;
}
#swish3d-modal .swish3d-ar-exit svg { width: 22px; height: 22px; }
.swish3d-ar-status {
  position: absolute;
  top: 20px;
  left: 0;
  right: 0;
  margin: 0 auto;
  width: max-content;
  max-width: calc(100% - 136px); /* clear of the exit button in the top-right corner */
  background: rgba(0, 0, 0, .6);
  color: #fff;
  padding: 8px 16px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.35;
  text-align: center;
}
#swish3d-modal .swish3d-ar-scale {
  position: absolute;
  bottom: 32px;
  left: 0;
  right: 0;
  margin: 0 auto;
  width: max-content;
  border-radius: 999px;
  padding: 8px 18px;
  background: rgba(0, 0, 0, .6);
  color: #fff;
  font-weight: 700;
}
#swish3d-modal .swish3d-ar-scale.is-true-size { background: #fff; color: #111; }
.swish3d-ar-prompt {
  position: absolute;
  left: 50%;
  bottom: 60px;
  display: none;
  animation: swish3d-elongate 2s infinite ease-in-out alternate;
}
.swish3d-ar-prompt img { animation: swish3d-circle 4s linear infinite; }
@keyframes swish3d-circle {
  from { transform: translateX(-50%) rotate(0deg) translateX(50px) rotate(0deg); }
  to { transform: translateX(-50%) rotate(360deg) translateX(50px) rotate(-360deg); }
}
@keyframes swish3d-elongate { from { transform: translateX(100px); } to { transform: translateX(-100px); } }

@media (prefers-reduced-motion: reduce) {
  .swish3d-hint img, .swish3d-ar-prompt, .swish3d-ar-prompt img,
  #swish3d-modal .swish3d-ar-button.is-attention, .swish3d-modal, .swish3d-qr { animation: none; }
}
