/* The 3D viewer, shared by the store and the admin panel. */
/* 3D view: the "View in 3D" button on the product photo, the 3D badge on cards, and the viewer dialog
   (a dark stage so a light print reads clearly; the dialog is the native modal, so focus stays in it
   and Escape closes it). */
.gallery-main { position: relative; }
.view3d-btn {
  position: absolute; right: var(--s-4); top: var(--s-4); z-index: 1;
  display: inline-flex; align-items: center; gap: var(--s-2); min-height: 44px; padding: 0 var(--s-4) 0 var(--s-3);
  border: 1px solid color-mix(in oklab, var(--ink) 14%, transparent); border-radius: 999px;
  background: color-mix(in oklab, var(--bg) 92%, transparent); color: var(--ink);
  font: 500 var(--t-small)/1 var(--font-text); cursor: pointer;
  box-shadow: 0 6px 20px rgb(0 0 0 / .08); backdrop-filter: blur(6px);
  transition: background-color 160ms var(--ease), border-color 160ms var(--ease), transform 160ms var(--ease);
}
.view3d-btn svg { flex: none; }
.view3d-btn:hover { background: var(--bg); border-color: var(--ink); }
.view3d-btn:active { transform: scale(.97); }
.view3d-btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }

.badge3d {
  position: absolute; right: var(--s-3); bottom: var(--s-3); display: inline-flex; align-items: center; gap: 4px;
  height: 24px; padding: 0 var(--s-2); border-radius: var(--r-sm); background: var(--bg); color: var(--ink);
  font-size: var(--t-label); font-weight: 600; letter-spacing: .02em;
}

.model-dialog {
  width: min(960px, calc(100vw - 32px)); max-width: none; max-height: calc(100dvh - 32px); padding: 0; border: 0;
  border-radius: var(--r-lg); background: #161817; color: #f2f3f1; overflow: hidden;
}
.model-dialog::backdrop { background: rgb(10 12 11 / .62); backdrop-filter: blur(2px); }
.model-dialog[open] { animation: model-in 220ms var(--ease) both; }
@keyframes model-in { from { opacity: 0; transform: translateY(8px) scale(.985); } }
.model-dialog__panel { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; height: min(720px, calc(100dvh - 32px)); }
.model-dialog__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); padding: var(--s-3) var(--s-3) var(--s-3) var(--s-5); }
.model-dialog__head h2 { display: flex; align-items: center; gap: var(--s-2); margin: 0; font-size: var(--t-body); font-weight: 500; color: inherit; }
.model-dialog__close {
  display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 999px;
  background: transparent; color: inherit; cursor: pointer;
}
.model-dialog__close:hover { background: rgb(255 255 255 / .08); }
.model-dialog__close:focus-visible, .model-dialog__canvas:focus-visible { outline: 2px solid #a1ffcb; outline-offset: -2px; }
.model-dialog__stage {
  position: relative; min-height: 0;
  background: radial-gradient(120% 90% at 50% 38%, #2b2f2d 0%, #1b1d1c 55%, #121413 100%);
}
.model-dialog__canvas {
  display: block; width: 100%; height: 100%; touch-action: none; cursor: grab;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
.model-dialog__canvas:active { cursor: grabbing; }
.model-dialog__status {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: var(--s-3);
  margin: 0; padding: var(--s-5); text-align: center; color: #d9dbd8; font-size: var(--t-small);
}
.model-dialog__status--error { color: #ffd2cc; }
.model-dialog__spinner {
  width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgb(255 255 255 / .2); border-top-color: #a1ffcb;
  animation: model-spin 800ms linear infinite;
}
@keyframes model-spin { to { transform: rotate(360deg); } }
.model-dialog__foot {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); padding: var(--s-3) var(--s-5);
  border-top: 1px solid rgb(255 255 255 / .08);
}
.model-dialog__hint { margin: 0; color: #b9bdb8; font-size: var(--t-small); }
html .model-dialog .model-dialog__foot .btn--secondary, html[data-buttons] .admin-shell .model-dialog .model-dialog__foot .btn--secondary {
  --ink: #f2f3f1; flex: none; height: 44px; padding: 0 var(--s-5); border: 1px solid rgb(255 255 255 / .38); border-radius: var(--r-btn);
  background: transparent; color: #f2f3f1; text-decoration: none;
}
.model-dialog .model-dialog__foot .btn--secondary:hover:not(:disabled) { border-color: #f2f3f1; background: rgb(255 255 255 / .06); }
.model-dialog .model-dialog__foot .btn--secondary:focus-visible { outline: 2px solid #a1ffcb; outline-offset: 2px; }
.model-dialog .model-dialog__foot .btn--secondary:disabled { opacity: .45; }
@media (max-width: 639px) {
  .view3d-btn { right: var(--s-3); top: var(--s-3); }
  .model-dialog { width: 100vw; max-height: 100dvh; height: 100dvh; border-radius: 0; }
  .model-dialog__panel { height: 100dvh; }
  .model-dialog__foot { flex-direction: column; align-items: stretch; }
  .model-dialog__foot .btn { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .model-dialog[open] { animation: none; }
  .model-dialog__spinner { animation-duration: 2.4s; }
  .view3d-btn { transition: none; }
}
