/*
 * SORKISTx — 3D Viewer Styles  (assets/css/3d-viewer.css)
 * Enqueued only on jewel-showcase template pages.
 *
 * Covers:
 *  - .viewer-wrap          outer container
 *  - .viewer-loading       cinematic loading screen (gold shimmer)
 *  - .viewer-mat-switcher  floating material/color switcher overlay
 *  - .viewer-controls-bar  bottom toolbar (auto-rotate, screenshot)
 */

/* ─── Viewer wrapper ────────────────────────────────────────────────────────── */

.viewer-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--radius-xl);
  overflow: hidden;
  background: #0a0a0f;
}

.viewer-wrap canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

/* ─── Loading screen ────────────────────────────────────────────────────────── */

.viewer-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-5);
  background: #0a0a0f;
  z-index: 10;
  transition: opacity 0.6s ease;
}

.viewer-loading[hidden] {
  display: none;
}

/* Gold shimmer ring */
.viewer-loading__ring {
  position: relative;
  width: 72px;
  height: 72px;
}

.viewer-loading__ring::before,
.viewer-loading__ring::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
}

.viewer-loading__ring::before {
  border: 3px solid rgba(196, 163, 90, 0.15);
}

.viewer-loading__ring::after {
  border: 3px solid transparent;
  border-top-color: #C4A35A;
  border-right-color: rgba(196, 163, 90, 0.5);
  animation: viewer-spin 1.1s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes viewer-spin {
  to { transform: rotate(360deg); }
}

/* Gold shimmer text */
.viewer-loading__label {
  font-family: var(--font-heading, 'Playfair Display', serif);
  font-size: var(--font-size-sm);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  background: linear-gradient(90deg, #8a6c30 0%, #C4A35A 40%, #e8c97a 60%, #C4A35A 75%, #8a6c30 100%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: viewer-shimmer 2.4s linear infinite;
}

@keyframes viewer-shimmer {
  to { background-position: 200% center; }
}

/* Progress bar */
.viewer-loading__progress {
  width: 160px;
  height: 2px;
  background: rgba(196, 163, 90, 0.15);
  border-radius: 99px;
  overflow: hidden;
}

.viewer-loading__bar-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #8a6c30, #C4A35A, #e8c97a);
  transition: width 0.3s ease;
  border-radius: 99px;
}

.viewer-loading__pct {
  font-size: var(--font-size-xs);
  color: rgba(196, 163, 90, 0.5);
  font-variant-numeric: tabular-nums;
}

/* ─── Material / colour switcher ────────────────────────────────────────────── */

.viewer-mat-switcher {
  position: absolute;
  inset-block-end: var(--space-4);
  inset-inline-end: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  z-index: 5;
}

.viewer-mat-swatch {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  background: none;
  padding: 0;
  transition: transform var(--transition-fast), border-color var(--transition-fast);
  position: relative;
}

.viewer-mat-swatch:hover { transform: scale(1.15); }

.viewer-mat-swatch.is-active {
  border-color: #C4A35A;
  box-shadow: 0 0 0 3px rgba(196, 163, 90, 0.3);
}

.viewer-mat-swatch__dot {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.3), inset 0 -1px 2px rgba(255,255,255,0.2);
}

/* Tooltip */
.viewer-mat-swatch::after {
  content: attr(data-label);
  position: absolute;
  inset-inline-end: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0,0,0,0.8);
  color: #e2e8f0;
  font-size: 11px;
  white-space: nowrap;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.viewer-mat-swatch:hover::after { opacity: 1; }

/* Custom colour input */
.viewer-color-input-wrap {
  position: relative;
  width: 36px;
  height: 36px;
}

.viewer-color-input {
  opacity: 0;
  position: absolute;
  inset: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.viewer-color-dot {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px dashed rgba(196, 163, 90, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(196, 163, 90, 0.08);
  pointer-events: none;
  transition: border-color var(--transition-fast);
}

.viewer-color-input-wrap:hover .viewer-color-dot {
  border-color: #C4A35A;
}

.viewer-color-dot svg { width: 14px; height: 14px; stroke: #C4A35A; }

/* ─── Controls bar (bottom) ────────────────────────────────────────────────── */

.viewer-controls-bar {
  position: absolute;
  inset-block-end: var(--space-4);
  inset-inline-start: var(--space-4);
  display: flex;
  gap: var(--space-2);
  z-index: 5;
}

.viewer-ctrl-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: rgba(0,0,0,0.55);
  border: 1px solid rgba(196, 163, 90, 0.2);
  color: rgba(196, 163, 90, 0.7);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast), color var(--transition-fast);
  backdrop-filter: blur(8px);
}

.viewer-ctrl-btn:hover {
  background: rgba(196, 163, 90, 0.15);
  color: #C4A35A;
}

.viewer-ctrl-btn.is-active {
  background: rgba(196, 163, 90, 0.2);
  color: #C4A35A;
}

.viewer-ctrl-btn svg { width: 16px; height: 16px; }
