/* Jewelry-safe 3D vitrine — scoped to .js3d-page only */

html:has(.js3d-page),
body:has(.js3d-page),
html:has(.products-3d),
body:has(.products-3d) {
  overflow-x: hidden;
  max-width: 100%;
}

.js3d-page {
  --js3d-header: calc(var(--header-h, 76px) + env(safe-area-inset-top, 0px));
  position: relative;
  min-height: calc(100dvh - var(--js3d-header));
  max-width: 100%;
  background:
    radial-gradient(900px 420px at 50% 8%, rgba(201, 162, 39, 0.07), transparent 55%),
    linear-gradient(180deg, #050506 0%, #0b0b0c 48%, #050506 100%);
  overflow: hidden;
}

.js3d-stage {
  position: relative;
  isolation: isolate;
  height: calc(100dvh - var(--js3d-header));
  min-height: 520px;
  max-width: 100%;
  overflow: hidden;
  cursor: grab;
  user-select: none;
  touch-action: none;
  background: #050506;
}

.js3d-stage.is-dragging,
.js3d-canvas.is-dragging {
  cursor: grabbing;
}

.js3d-canvas {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.js3d-status,
.js3d-fallback {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
  color: rgba(243, 239, 228, 0.82);
  background: rgba(5, 5, 6, 0.55);
  pointer-events: none;
}

.js3d-status[hidden],
.js3d-fallback[hidden] {
  display: none !important;
}

.js3d-status[data-state="READY"] {
  display: none;
}

.js3d-status[data-state="MODEL_LOAD_ERROR"],
.js3d-status[data-state="MODEL_PARSE_ERROR"],
.js3d-status[data-state="WEBGL_UNAVAILABLE"],
.js3d-status[data-state="UNKNOWN_ERROR"] {
  pointer-events: auto;
  background: rgba(5, 5, 6, 0.78);
}

.js3d-status-pulse {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--gold, #c9a227);
  box-shadow: 0 0 18px rgba(201, 162, 39, 0.55);
  animation: js3d-pulse 1.4s ease-in-out infinite;
}

.js3d-status[data-state="READY"] .js3d-status-pulse,
.js3d-status[data-state="MODEL_LOAD_ERROR"] .js3d-status-pulse,
.js3d-status[data-state="MODEL_PARSE_ERROR"] .js3d-status-pulse,
.js3d-status[data-state="WEBGL_UNAVAILABLE"] .js3d-status-pulse,
.js3d-status[data-state="UNKNOWN_ERROR"] .js3d-status-pulse {
  display: none;
}

@keyframes js3d-pulse {
  0%, 100% { opacity: 0.35; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1); }
}

.js3d-retry {
  pointer-events: auto;
  margin-top: 6px;
  padding: 8px 18px;
  border: 1px solid rgba(201, 162, 39, 0.45);
  background: transparent;
  color: var(--gold-light, #d4af37);
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
}

.js3d-fallback img {
  max-width: min(720px, 86vw);
  max-height: 46vh;
  object-fit: contain;
  border-radius: 12px;
}

.js3d-ui {
  position: absolute;
  z-index: 3;
  inset-inline: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(180deg, transparent, rgba(5, 5, 6, 0.88) 38%);
  pointer-events: none;
}

.js3d-intro {
  text-align: center;
  pointer-events: none;
}

.js3d-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--gold-light, #d4af37);
  font-size: 0.82rem;
  letter-spacing: 0.04em;
}

.js3d-intro h1 {
  margin: 6px 0 0;
  font-size: clamp(1.15rem, 2.4vw, 1.7rem);
  color: #f3efe4;
  font-weight: 600;
}

.js3d-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  pointer-events: auto;
  max-width: 100%;
}

.js3d-actions .btn {
  min-height: 42px;
}

.js3d-actions .btn[disabled] {
  opacity: 0.42;
  pointer-events: none;
}

.js3d-actions .btn.is-on {
  border-color: var(--gold, #c9a227);
  box-shadow: 0 0 16px rgba(201, 162, 39, 0.22);
}

.js3d-hint {
  margin: 0;
  color: rgba(229, 229, 229, 0.55);
  font-size: 0.8rem;
  pointer-events: none;
}

@media (max-width: 768px) {
  .js3d-stage {
    min-height: calc(100dvh - var(--js3d-header));
  }

  .js3d-actions {
    width: 100%;
    padding-inline: 4px;
  }

  .js3d-actions .btn {
    flex: 1 1 calc(50% - 8px);
    justify-content: center;
  }

  .js3d-intro h1 {
    padding-inline: 12px;
  }
}

/* —— /products 3D hero (background image + transparent canvas) —— */

.products-3d {
  --js3d-header: calc(var(--header-h, 76px) + env(safe-area-inset-top, 0px));
  --gold: #c9a227;
  --gold-light: #d4af37;
  position: relative;
  isolation: isolate;
  min-height: 680px;
  height: clamp(680px, calc(100dvh - var(--js3d-header)), 780px);
  max-width: 100%;
  overflow: hidden;
  background: #050506;
  color: #f3efe4;
}

.products-3d:fullscreen,
.products-3d:-webkit-full-screen {
  width: 100%;
  height: 100%;
  min-height: 100%;
  max-height: 100%;
}

.products-3d__bg,
.products-3d__bg img {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 0% 58%;
  pointer-events: none;
}

.products-3d__bg {
  margin: 0;
  display: block;
}

.products-3d__veil {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(5, 5, 6, 0.58) 0%, rgba(5, 5, 6, 0.42) 30%, rgba(5, 5, 6, 0.82) 52%, rgba(5, 5, 6, 0.96) 72%, #050506 100%),
    linear-gradient(180deg, rgba(5, 5, 6, 0.55) 0%, rgba(5, 5, 6, 0.12) 28%, rgba(5, 5, 6, 0.2) 62%, rgba(5, 5, 6, 0.72) 100%);
}

.products-3d__glow {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(ellipse 42% 52% at 70% 58%, rgba(201, 162, 39, 0.18), transparent 66%),
    radial-gradient(ellipse 80% 90% at 50% 50%, transparent 40%, rgba(0, 0, 0, 0.48) 100%);
}

.products-3d__layout {
  position: relative;
  z-index: 3;
  display: grid;
  grid-template-columns: minmax(280px, 0.4fr) minmax(340px, 0.6fr);
  gap: 8px 20px;
  width: min(1440px, calc(100% - 48px));
  height: 100%;
  margin: 0 auto;
  padding: 28px 8px 22px;
  direction: ltr;
  box-sizing: border-box;
}

.products-3d__copy {
  direction: rtl;
  text-align: right;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 22px;
  z-index: 4;
  min-width: 0;
  padding-inline: 8px 4px;
}

.products-3d__eyebrow {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid rgba(201, 162, 39, 0.38);
  background: rgba(12, 10, 8, 0.55);
  color: var(--gold-light);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.products-3d__intro h1 {
  margin: 14px 0 0;
  font-size: clamp(1.7rem, 3.4vw, 2.85rem);
  font-weight: 700;
  line-height: 1.28;
  color: #f7f3ea;
  letter-spacing: -0.02em;
}

.products-3d__intro h1 span {
  display: block;
  color: var(--gold-light);
}

.products-3d__lead {
  margin: 14px 0 0;
  max-width: 36rem;
  color: rgba(243, 239, 228, 0.72);
  font-size: 0.95rem;
  line-height: 1.85;
}

.products-3d__actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}

.products-3d__cta {
  max-width: 100%;
  white-space: normal;
  line-height: 1.4;
  text-align: center;
  padding-inline: 22px;
  box-shadow: 0 8px 28px rgba(201, 162, 39, 0.28);
}

.products-3d__cta:hover:not(:disabled) {
  transform: translateY(-2px) scale(1.015);
  box-shadow: 0 10px 32px rgba(201, 162, 39, 0.48);
  filter: brightness(1.06);
}

.products-3d__actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.products-3d__btn-close {
  background: rgba(12, 10, 8, 0.55);
}

.products-3d__btn-replay {
  background: transparent;
  color: rgba(243, 239, 228, 0.78);
  border: 1px solid rgba(201, 162, 39, 0.22);
  padding: 11px 18px;
}

.products-3d__btn-replay:hover:not(:disabled) {
  border-color: rgba(201, 162, 39, 0.55);
  color: var(--gold-light);
  background: rgba(201, 162, 39, 0.08);
}

.products-3d__actions .btn[disabled] {
  opacity: 0.42;
  pointer-events: none;
}

.products-3d__features {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
}

.products-3d__features li {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  color: rgba(243, 239, 228, 0.78);
  font-size: 0.74rem;
  line-height: 1.45;
}

.products-3d__ficon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(201, 162, 39, 0.42);
  color: var(--gold-light);
  background: rgba(12, 10, 8, 0.35);
  font-size: 0.92rem;
}

.products-3d__view {
  position: relative;
  min-width: 0;
  min-height: 0;
  height: 100%;
}

.products-3d .js3d-stage {
  position: relative;
  inset: auto;
  z-index: 2;
  width: 100%;
  height: 100%;
  min-height: 0;
  background: transparent;
}

.products-3d .js3d-canvas {
  background: transparent;
  z-index: 2;
}

.products-3d .js3d-status {
  background: rgba(5, 5, 6, 0.22);
  transition: opacity 0.45s ease;
}

.products-3d .js3d-status[data-state="READY"] {
  opacity: 0;
}

.products-3d .js3d-status-pulse {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: transparent;
  border: 2px solid rgba(201, 162, 39, 0.2);
  border-top-color: var(--gold-light);
  box-shadow: none;
  animation: js3d-spin 0.9s linear infinite;
}

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

.products-3d .js3d-fallback {
  background: transparent;
  color: rgba(243, 239, 228, 0.82);
}

.products-3d__tools {
  position: absolute;
  top: 50%;
  right: 10px;
  left: auto;
  transform: translateY(-50%);
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.products-3d__tool {
  width: 74px;
  min-height: 74px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 6px;
  border-radius: 16px;
  border: 1px solid rgba(201, 162, 39, 0.38);
  background: rgba(10, 9, 8, 0.62);
  color: rgba(243, 239, 228, 0.88);
  font: inherit;
  font-size: 0.68rem;
  line-height: 1.25;
  cursor: pointer;
  backdrop-filter: blur(10px);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.products-3d__tool i {
  color: var(--gold-light);
  font-size: 0.95rem;
}

.products-3d__tool:hover:not(:disabled),
.products-3d__tool.is-on {
  border-color: rgba(201, 162, 39, 0.78);
  box-shadow: 0 0 18px rgba(201, 162, 39, 0.22);
  color: #fff8e8;
}

.products-3d__tool:disabled {
  opacity: 0.38;
  cursor: default;
}

.products-3d__hint {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 0 12px;
  color: rgba(229, 229, 229, 0.42);
  font-size: 0.78rem;
  white-space: nowrap;
  pointer-events: none;
  direction: rtl;
}

.products-3d__mouse {
  width: 16px;
  height: 24px;
  border: 1.5px solid rgba(201, 162, 39, 0.45);
  border-radius: 10px;
  position: relative;
  flex: 0 0 auto;
}

.products-3d__mouse::after {
  content: "";
  position: absolute;
  top: 5px;
  left: 50%;
  width: 3px;
  height: 6px;
  margin-left: -1.5px;
  border-radius: 2px;
  background: rgba(201, 162, 39, 0.7);
  animation: js3d-mouse 1.4s ease-in-out infinite;
}

@keyframes js3d-mouse {
  0%, 100% { opacity: 0.35; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(4px); }
}

.products-3d__fs {
  position: absolute;
  left: 12px;
  right: auto;
  bottom: 14px;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid rgba(201, 162, 39, 0.28);
  border-radius: 999px;
  background: rgba(10, 9, 8, 0.45);
  color: rgba(243, 239, 228, 0.7);
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
  backdrop-filter: blur(8px);
  direction: rtl;
}

.products-3d__fs:hover {
  border-color: rgba(201, 162, 39, 0.6);
  color: var(--gold-light);
}

.products-3d.is-fullscreen .products-3d__fs i.fa-expand::before {
  content: "\f066";
}

@media (max-width: 1024px) {
  .products-3d__features {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    justify-items: start;
  }

  .products-3d__features li {
    flex-direction: row;
    text-align: right;
  }
}

@media (max-width: 860px) {
  .products-3d {
    height: auto;
    min-height: 0;
    overflow: hidden;
  }

  .products-3d__layout {
    grid-template-columns: 1fr;
    width: min(100%, calc(100% - 24px));
    height: auto;
    padding: 22px 0 28px;
    gap: 18px;
  }

  .products-3d__copy {
    display: contents;
  }

  .products-3d__intro {
    order: 1;
    direction: rtl;
    text-align: right;
    padding-inline: 4px;
  }

  .products-3d__view {
    order: 2;
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 0;
  }

  .products-3d .js3d-stage {
    height: min(48dvh, 380px);
    min-height: 280px;
    flex: 0 0 auto;
  }

  .products-3d__actions {
    order: 3;
    direction: rtl;
    padding-inline: 4px;
  }

  .products-3d__features {
    order: 4;
    direction: rtl;
    padding-inline: 4px;
  }

  .products-3d__cta {
    width: 100%;
  }

  .products-3d__actions-row {
    width: 100%;
  }

  .products-3d__actions-row .btn {
    flex: 1 1 auto;
    justify-content: center;
  }

  .products-3d__tools {
    position: relative;
    top: auto;
    bottom: auto;
    left: auto;
    right: auto;
    transform: none;
    flex-direction: row;
    justify-content: center;
    margin: 12px 0 4px;
  }

  .products-3d__tool {
    width: 68px;
    min-height: 62px;
    border-radius: 14px;
  }

  .products-3d__hint {
    position: relative;
    left: auto;
    bottom: auto;
    transform: none;
    white-space: normal;
    text-align: center;
    font-size: 0.72rem;
    justify-content: center;
    margin: 0 0 6px;
  }

  .products-3d__fs {
    top: 10px;
    bottom: auto;
    left: auto;
    right: 10px;
  }

  .products-3d__bg img,
  .products-3d__bg {
    object-position: 0% 58%;
  }

  .products-3d__veil {
    background:
      linear-gradient(180deg, rgba(5, 5, 6, 0.72) 0%, rgba(5, 5, 6, 0.28) 22%, rgba(5, 5, 6, 0.2) 55%, rgba(5, 5, 6, 0.7) 100%);
  }
}

@media (max-width: 480px) {
  .products-3d__intro h1 {
    font-size: 1.55rem;
  }

  .products-3d__features {
    grid-template-columns: 1fr 1fr;
  }

  .products-3d__hint {
    display: none;
  }
}
