/* ============================================
   265 — IMMERSIVE RING VIEWER (fullscreen overlay)
   Inspirert av rene jewelry e-commerce viewere.
   Tre modi: STILL, 360°, PÅ HÅNDEN
   ============================================ */

/* ===== TRIGGER — cursor on main image ===== */
.gallery .stage .slide.active {
  cursor: zoom-in;
}
.gallery .stage .slide.active::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border: 1px solid transparent;
  transition: border-color 0.3s;
}
.gallery .stage .slide.active:hover::after {
  border-color: rgba(201, 169, 110, 0.25);
}

.viewer-trigger-hint {
  position: absolute;
  top: 18px;
  left: 18px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 14px 9px 12px;
  background: rgba(10, 10, 10, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(245, 240, 232, 0.12);
  border-radius: 100px;
  font-size: 9px;
  letter-spacing: 0.36em;
  text-transform: uppercase;
  color: var(--ink-mute);
  pointer-events: none;
  z-index: 6;
  opacity: 0;
  transition: opacity 0.4s ease;
}
.gallery .stage:hover .viewer-trigger-hint { opacity: 1; }
.viewer-trigger-hint svg {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: var(--gold);
  stroke-width: 1.4;
}

/* ===== OVERLAY ROOT ===== */
.ring-viewer {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: #050505;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.42s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
}
.ring-viewer.open {
  opacity: 1;
  pointer-events: auto;
}
/* When closed, NOTHING inside can intercept clicks — even if children have pointer-events:auto */
.ring-viewer:not(.open),
.ring-viewer:not(.open) * {
  pointer-events: none !important;
}
.ring-viewer:not(.open) {
  visibility: hidden;
  transition: opacity 0.42s cubic-bezier(0.4, 0, 0.2, 1), visibility 0s linear 0.42s;
}
.ring-viewer.open {
  visibility: visible;
  transition: opacity 0.42s cubic-bezier(0.4, 0, 0.2, 1), visibility 0s linear 0s;
}
html.viewer-locked,
html.viewer-locked body {
  overflow: hidden;
}

/* Subtle background gradient — same DNA as 360 viewer */
.ring-viewer::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 50% 40%, rgba(201, 169, 110, 0.05) 0%, transparent 55%),
    linear-gradient(180deg, #0a0a0a 0%, #050505 100%);
  pointer-events: none;
}

/* ===== TOP BAR ===== */
.viewer-topbar {
  position: relative;
  z-index: 4;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 24px 36px;
  border-bottom: 1px solid rgba(245, 240, 232, 0.06);
}

.viewer-eyebrow {
  font-size: 10px;
  letter-spacing: 0.45em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.viewer-eyebrow em {
  font-style: normal;
  color: var(--gold);
}

.viewer-title {
  text-align: center;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 300;
  font-size: 19px;
  letter-spacing: 0.08em;
  color: var(--ink);
}
.viewer-title em {
  font-style: italic;
  color: var(--gold);
  margin: 0 4px;
}

.viewer-close {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: 1px solid rgba(245, 240, 232, 0.14);
  color: var(--ink-mute);
  padding: 10px 16px 10px 14px;
  font-family: inherit;
  font-size: 10px;
  letter-spacing: 0.36em;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: 100px;
  transition: all 0.25s;
}
.viewer-close:hover {
  border-color: var(--gold);
  color: var(--gold);
}
.viewer-close svg {
  width: 11px;
  height: 11px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
}

/* ===== STAGE (mode container) ===== */
.viewer-stage {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  overflow: hidden;
}

/* Corner ornaments — same DNA as 360 viewer */
.viewer-stage > .corner {
  position: absolute;
  width: 22px;
  height: 22px;
  border: 1px solid var(--gold);
  opacity: 0.4;
  pointer-events: none;
  z-index: 3;
}
.viewer-stage > .corner.tl { top: 28px; left: 28px; border-right: none; border-bottom: none; }
.viewer-stage > .corner.tr { top: 28px; right: 28px; border-left: none; border-bottom: none; }
.viewer-stage > .corner.bl { bottom: 28px; left: 28px; border-right: none; border-top: none; }
.viewer-stage > .corner.br { bottom: 28px; right: 28px; border-left: none; border-top: none; }

/* ===== PANELS (one per mode) ===== */
.viewer-panel {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.viewer-panel.active {
  opacity: 1;
  pointer-events: auto;
}

/* ----- PANEL: STILL ----- */
.viewer-panel.still {
  padding: 60px;
}
.viewer-panel.still .still-image {
  max-width: min(900px, 80%);
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 30px 60px rgba(0, 0, 0, 0.6));
  user-select: none;
  -webkit-user-drag: none;
}
.viewer-panel.still .still-meta {
  position: absolute;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 28px;
  align-items: center;
  font-size: 10px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.viewer-panel.still .still-meta .dot {
  width: 4px;
  height: 4px;
  background: var(--gold);
  border-radius: 50%;
  opacity: 0.5;
}

/* ----- PANEL: 360 ----- */
.viewer-panel.spin {
  padding: 40px;
}
.viewer-panel.spin .spin-stage {
  width: 100%;
  height: 100%;
  max-width: 1200px;
  max-height: 100%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.viewer-panel.spin canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  cursor: grab;
}
.viewer-panel.spin canvas.dragging { cursor: grabbing; }

.spin-overlay {
  position: absolute;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 11px 20px;
  background: rgba(10, 10, 10, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(245, 240, 232, 0.12);
  border-radius: 100px;
  font-size: 10px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--ink-mute);
  pointer-events: none;
  opacity: 0;
  animation: viewerFadeIn 0.6s ease 0.4s forwards;
}
.spin-overlay svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: var(--gold);
  stroke-width: 1.5;
  animation: dragHint 2.4s ease-in-out infinite;
}
.spin-readout {
  font-family: "Inter", monospace;
  font-feature-settings: "tnum";
  letter-spacing: 0.25em;
  color: var(--gold);
}
@keyframes viewerFadeIn {
  to { opacity: 1; }
}

/* ----- PANEL: TRY-ON ----- */
/* Honest preview — no fake hand. Two design-side-by-side cards: a skin-tone
   swatch and a ring-on-skin scale preview. Both respond to the controls. */
.viewer-panel.tryon {
  display: grid;
  grid-template-columns: 1fr;
  padding: 40px 40px 220px;
}
.tryon-stage {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 32px;
  background:
    radial-gradient(ellipse at 50% 38%, rgba(255, 240, 220, 0.05) 0%, transparent 55%),
    linear-gradient(180deg, #0e0c0a 0%, #060606 100%);
  border-radius: 4px;
}

.tryon-preview {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  width: min(820px, 88%);
  max-width: 100%;
}

.tryon-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 36px 24px 28px;
  border: 1px solid rgba(245, 240, 232, 0.08);
  border-radius: 4px;
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0));
  min-height: 320px;
}

.tryon-card-label {
  position: absolute;
  top: 18px;
  left: 22px;
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 9px;
  letter-spacing: 0.45em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.tryon-card-label .num {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-style: italic;
  letter-spacing: 0;
  color: var(--gold);
  font-size: 13px;
}

.tryon-card-caption {
  margin-top: auto;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-style: italic;
  font-size: 22px;
  color: var(--gold);
  letter-spacing: 0.02em;
  padding-top: 24px;
}

/* Skin-tone disc — large flat disc showing chosen tone */
.tryon-tone-disc {
  width: min(180px, 60%);
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  margin: auto 0;
  background:
    radial-gradient(circle at 32% 30%, rgba(255,255,255,0.22) 0%, transparent 38%),
    radial-gradient(circle at 70% 78%, rgba(0,0,0,0.18) 0%, transparent 55%),
    var(--hand-tone, #c9a07a);
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,0.06),
    0 20px 40px rgba(0,0,0,0.5),
    0 6px 14px rgba(0,0,0,0.35);
  transition: background-color 0.55s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Ring stage — ring shape drawn on a skin-tone backdrop, scaled to carat */
.tryon-ring-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  max-width: 240px;
  margin: auto 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tryon-ring-backdrop {
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 30%, rgba(255,255,255,0.18) 0%, transparent 40%),
    radial-gradient(circle at 70% 80%, rgba(0,0,0,0.20) 0%, transparent 55%),
    var(--hand-tone, #c9a07a);
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,0.06),
    0 20px 40px rgba(0,0,0,0.5);
  transition: background-color 0.55s cubic-bezier(0.4, 0, 0.2, 1);
}

/* The ring shape itself — drawn with CSS only.
   A gold band (ring) + a gemstone-colored stone on top. Stone shape varies per ring.id. */
.tryon-ring-shape {
  position: relative;
  z-index: 2;
  width: 56%;
  height: 56%;
  transform: scale(var(--ring-scale, 1));
  transition: transform 0.55s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  filter:
    drop-shadow(0 4px 8px rgba(0,0,0,0.45))
    drop-shadow(0 1px 2px rgba(0,0,0,0.35));
}
/* Band — gold ellipse (top-down view of a ring) */
.tryon-ring-shape::before {
  content: "";
  position: absolute;
  inset: 28% 0 28% 0;
  border-radius: 50%;
  border: 4px solid;
  border-color:
    rgba(247, 220, 160, 0.95)
    rgba(220, 188, 130, 0.95)
    rgba(180, 148, 92, 0.95)
    rgba(220, 188, 130, 0.95);
  background: transparent;
  box-shadow:
    inset 0 1px 2px rgba(255,240,200,0.4),
    inset 0 -1px 2px rgba(120,90,40,0.4);
}
/* Stone — sits center-top on the band */
.tryon-ring-shape::after {
  content: "";
  position: absolute;
  top: 10%;
  left: 50%;
  transform: translateX(-50%);
  width: 38%;
  height: 50%;
  background:
    radial-gradient(ellipse at 35% 25%, rgba(255,255,255,0.85) 0%, rgba(255,255,255,0) 35%),
    radial-gradient(ellipse at 65% 70%, rgba(180,210,255,0.4) 0%, transparent 55%),
    linear-gradient(160deg, #f4f8ff 0%, #c8d8ec 60%, #9bb0c8 100%);
  box-shadow:
    0 2px 4px rgba(0,0,0,0.35),
    inset 0 1px 2px rgba(255,255,255,0.7);
}

/* Stone shape per ring — set via [data-ring-shape] on the viewer root */
.ring-viewer[data-ring-shape="round"] .tryon-ring-shape::after {
  border-radius: 50%;
  width: 36%;
  height: 36%;
  top: 18%;
}
.ring-viewer[data-ring-shape="oval"] .tryon-ring-shape::after {
  border-radius: 50%;
  width: 32%;
  height: 46%;
  top: 12%;
}
.ring-viewer[data-ring-shape="pear"] .tryon-ring-shape::after {
  width: 34%;
  height: 50%;
  top: 10%;
  border-radius: 50% 50% 50% 50% / 70% 70% 35% 35%;
  clip-path: polygon(50% 0%, 78% 28%, 88% 60%, 70% 92%, 50% 100%, 30% 92%, 12% 60%, 22% 28%);
}

.tryon-footnote {
  width: min(720px, 88%);
  text-align: center;
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-faint);
  line-height: 1.8;
}

/* Placeholder note — we don't have real hand photos yet */
.tryon-placeholder-note {
  position: absolute;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px 8px 12px;
  background: rgba(201, 169, 110, 0.08);
  border: 1px solid rgba(201, 169, 110, 0.32);
  border-radius: 100px;
  font-size: 9px;
  letter-spacing: 0.36em;
  text-transform: uppercase;
  color: var(--gold);
  z-index: 5;
}
.tryon-placeholder-note::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold);
  animation: pulse 2s ease-in-out infinite;
}

/* Try-on controls — anchored to bottom */
.tryon-controls {
  position: absolute;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 48px;
  align-items: flex-start;
  padding: 22px 36px;
  background: rgba(10, 10, 10, 0.7);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(245, 240, 232, 0.1);
  border-radius: 4px;
  z-index: 4;
}
.tryon-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}
.tryon-group .label {
  font-size: 9px;
  letter-spacing: 0.45em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.tryon-group .value {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 14px;
  color: var(--gold);
  font-style: italic;
  margin-top: -6px;
  height: 18px;
  display: flex;
  align-items: center;
  letter-spacing: 0.04em;
}

/* Skin tone swatches */
.skin-swatches {
  display: flex;
  gap: 12px;
}
.skin-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid rgba(245, 240, 232, 0.15);
  cursor: pointer;
  padding: 0;
  position: relative;
  transition: transform 0.25s, border-color 0.25s;
}
.skin-swatch::after {
  content: "";
  position: absolute;
  inset: -5px;
  border: 1px solid var(--gold);
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.25s;
}
.skin-swatch:hover { transform: scale(1.08); }
.skin-swatch.active::after { opacity: 1; }
.skin-swatch.active { border-color: rgba(201, 169, 110, 0.5); }

/* Carat pills */
.carat-pills {
  display: flex;
  gap: 8px;
}
.carat-pill {
  background: transparent;
  border: 1px solid rgba(245, 240, 232, 0.14);
  color: var(--ink-mute);
  padding: 9px 14px;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 14px;
  font-style: italic;
  letter-spacing: 0.02em;
  cursor: pointer;
  border-radius: 2px;
  transition: all 0.25s;
  min-width: 56px;
}
.carat-pill:hover {
  border-color: rgba(201, 169, 110, 0.4);
  color: var(--ink);
}
.carat-pill.active {
  background: var(--gold);
  border-color: var(--gold);
  color: #0A0A0A;
}

/* ===== BOTTOM TAB BAR ===== */
.viewer-tabs {
  position: relative;
  z-index: 5;
  display: flex;
  justify-content: center;
  gap: 4px;
  padding: 22px 24px 28px;
  border-top: 1px solid rgba(245, 240, 232, 0.06);
}
.viewer-tab {
  background: transparent;
  border: 1px solid transparent;
  color: var(--ink-mute);
  padding: 14px 28px;
  font-family: inherit;
  font-size: 10px;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: 2px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
}
.viewer-tab .num {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 13px;
  font-style: italic;
  letter-spacing: 0;
  color: var(--ink-faint);
  transition: color 0.3s;
}
.viewer-tab:hover {
  color: var(--ink);
  border-color: rgba(245, 240, 232, 0.1);
}
.viewer-tab:hover .num {
  color: var(--gold);
}
.viewer-tab.active {
  color: var(--gold);
  border-color: var(--gold);
}
.viewer-tab.active .num {
  color: var(--gold);
}

/* ===== LOADING STATE ===== */
.viewer-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--ink-mute);
  pointer-events: none;
  z-index: 6;
  opacity: 0;
  transition: opacity 0.3s;
}
.viewer-loading.visible { opacity: 1; }
.viewer-loading::after {
  content: "";
  width: 60px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  margin-left: 18px;
  animation: shimmer 1.6s ease-in-out infinite;
}

/* ===== MOBILE ===== */
@media (max-width: 900px) {
  .viewer-topbar {
    padding: 16px 18px;
    grid-template-columns: 1fr auto;
  }
  .viewer-eyebrow { display: none; }
  .viewer-title { font-size: 15px; text-align: left; }
  .viewer-close {
    padding: 8px 12px;
    font-size: 9px;
    letter-spacing: 0.28em;
  }
  .viewer-stage > .corner { width: 16px; height: 16px; }
  .viewer-stage > .corner.tl { top: 16px; left: 16px; }
  .viewer-stage > .corner.tr { top: 16px; right: 16px; }
  .viewer-stage > .corner.bl { bottom: 16px; left: 16px; }
  .viewer-stage > .corner.br { bottom: 16px; right: 16px; }

  .viewer-panel.still { padding: 30px; }
  .viewer-panel.still .still-image { max-width: 92%; }
  .viewer-panel.spin { padding: 20px; }
  .viewer-panel.tryon { padding: 20px 20px 260px; }

  .tryon-preview {
    grid-template-columns: 1fr;
    gap: 18px;
    width: 92%;
  }
  .tryon-card { min-height: 220px; padding: 30px 20px 22px; }
  .tryon-tone-disc { width: 130px; }
  .tryon-ring-stage { max-width: 180px; }
  .tryon-footnote { width: 92%; font-size: 9px; }
  .tryon-controls {
    bottom: 20px;
    flex-direction: column;
    gap: 22px;
    padding: 18px 22px;
    width: calc(100% - 36px);
    max-width: 360px;
  }

  .viewer-tabs {
    padding: 14px 12px 18px;
    gap: 2px;
  }
  .viewer-tab {
    padding: 11px 14px;
    font-size: 8.5px;
    letter-spacing: 0.3em;
    gap: 8px;
  }
  .viewer-tab .num { font-size: 11px; }
}

@media (max-width: 520px) {
  .viewer-tab .label-long { display: none; }
}
