/*
 * Jewellery Virtual Try-On styles.
 * Theme it by overriding these variables on :root (or any ancestor) in your site CSS.
 */
:root {
  --tryon-font: inherit;
  --tryon-heading-font: inherit;
  --tryon-text: #1f1b17;
  --tryon-muted: #6d655c;
  --tryon-bg: #ffffff;
  --tryon-border: #e3ddd4;
  --tryon-accent: #1f1b17;
  --tryon-accent-text: #ffffff;
  --tryon-radius: 4px;
  --tryon-stage-bg: #171412;
  --tryon-focus: #9a7b4f;
}

html.tryon-open {
  overflow: hidden;
}

/* ---------- Entry point on the product page ---------- */
.tryon-entry {
  margin-top: 12px;
}
.tryon-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 48px;
  padding: 12px 20px;
  font: inherit;
  font-family: var(--tryon-font);
  letter-spacing: 0.04em;
  color: var(--tryon-text);
  background: transparent;
  border: 1px solid var(--tryon-text);
  border-radius: var(--tryon-radius);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.tryon-trigger:hover {
  background: var(--tryon-text);
  color: var(--tryon-bg);
}
.tryon-trigger:focus-visible,
.tryon button:focus-visible,
.tryon input:focus-visible {
  outline: 2px solid var(--tryon-focus);
  outline-offset: 2px;
}
.tryon-trigger__icon svg {
  width: 18px;
  height: 18px;
  display: block;
}
.tryon-entry__hint,
.tryon-entry__note {
  margin: 8px 0 0;
  font-size: 0.8125rem;
  color: var(--tryon-muted);
  text-align: center;
}
.tryon-entry__note {
  text-align: left;
}

/* ---------- Dialog ---------- */
.tryon {
  padding: 0;
  border: 0;
  margin: auto;
  width: min(960px, calc(100vw - 48px));
  max-height: calc(100dvh - 48px);
  color: var(--tryon-text);
  background: var(--tryon-bg);
  border-radius: calc(var(--tryon-radius) * 2);
  font-family: var(--tryon-font);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}
.tryon::backdrop {
  background: rgba(15, 12, 10, 0.6);
}
.tryon__panel {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(260px, 1fr);
  grid-template-rows: auto 1fr auto;
  grid-template-areas:
    'stage header'
    'stage controls'
    'stage privacy';
  max-height: calc(100dvh - 48px);
}
.tryon__header {
  grid-area: header;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 20px 8px;
}
.tryon__eyebrow {
  margin: 0 0 4px;
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--tryon-muted);
}
.tryon__title {
  margin: 0;
  font-family: var(--tryon-heading-font);
  font-size: 1.25rem;
  font-weight: 500;
  line-height: 1.25;
}
.tryon__close {
  flex: none;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  color: inherit;
  background: transparent;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}
.tryon__close:hover {
  background: rgba(0, 0, 0, 0.06);
}
.tryon__close svg,
.tryon__tool svg {
  width: 20px;
  height: 20px;
  display: block;
}

/* ---------- Stage ---------- */
.tryon__stage {
  grid-area: stage;
  position: relative;
  width: 100%;
  min-width: 0;
  aspect-ratio: 4 / 3;
  max-height: calc(100dvh - 48px);
  background: var(--tryon-stage-bg);
  overflow: hidden;
}
.tryon__video {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.tryon__canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  touch-action: none;
}
.tryon__canvas.is-mirrored {
  transform: scaleX(-1);
}
.tryon__stage.is-photo .tryon__canvas {
  object-fit: contain;
}
.tryon__stage[data-state='live'] .tryon__canvas,
.tryon__stage[data-state='photo'] .tryon__canvas {
  cursor: grab;
}
.tryon__stage[data-state='live'] .tryon__canvas:active,
.tryon__stage[data-state='photo'] .tryon__canvas:active {
  cursor: grabbing;
}
.tryon__status {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--tryon-stage-bg);
}
.tryon__status[hidden] {
  display: none;
}
.tryon__card {
  max-width: 360px;
  text-align: center;
  color: #f4efe8;
}
.tryon__preview {
  display: block;
  width: 96px;
  height: 96px;
  margin: 0 auto 16px;
  object-fit: contain;
}
.tryon__card-title {
  margin: 0 0 8px;
  font-family: var(--tryon-heading-font);
  font-size: 1.125rem;
}
.tryon__card-msg {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.5;
  color: rgba(244, 239, 232, 0.78);
}
.tryon__actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
}
.tryon__hint {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 8px 14px;
  font-size: 0.8125rem;
  color: #fff;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 999px;
  text-align: center;
  pointer-events: none;
}
.tryon__hint[hidden] {
  display: none;
}
.tryon__spinner {
  width: 32px;
  height: 32px;
  margin: 0 auto 16px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: tryon-spin 0.9s linear infinite;
}
@keyframes tryon-spin {
  to {
    transform: rotate(360deg);
  }
}
@media (prefers-reduced-motion: reduce) {
  .tryon__spinner {
    animation-duration: 3s;
  }
}

/* ---------- Buttons ---------- */
.tryon__primary,
.tryon__secondary {
  min-height: 46px;
  padding: 12px 20px;
  font: inherit;
  font-size: 0.9375rem;
  letter-spacing: 0.03em;
  border-radius: var(--tryon-radius);
  cursor: pointer;
}
.tryon__primary {
  color: var(--tryon-accent-text);
  background: var(--tryon-accent);
  border: 1px solid var(--tryon-accent);
}
.tryon__status .tryon__primary {
  color: var(--tryon-stage-bg);
  background: #f4efe8;
  border-color: #f4efe8;
}
.tryon__secondary {
  color: #f4efe8;
  background: transparent;
  border: 1px solid rgba(244, 239, 232, 0.5);
}

/* ---------- Controls ---------- */
.tryon__controls {
  grid-area: controls;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 12px 20px;
  overflow-y: auto;
}
.tryon__variants {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.tryon__variant {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 6px 12px;
  font: inherit;
  font-size: 0.875rem;
  color: inherit;
  background: transparent;
  border: 1px solid var(--tryon-border);
  border-radius: 999px;
  cursor: pointer;
}
.tryon__variant[aria-checked='true'] {
  border-color: var(--tryon-text);
}
.tryon__swatch {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15);
}
.tryon__adjust {
  display: grid;
  gap: 12px;
}
.tryon__field {
  display: grid;
  grid-template-columns: 52px 1fr;
  align-items: center;
  gap: 12px;
  font-size: 0.875rem;
  color: var(--tryon-muted);
}
.tryon__field[hidden] {
  display: none;
}
.tryon__field input[type='range'] {
  width: 100%;
  accent-color: var(--tryon-accent);
}
.tryon__tools {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.tryon__tool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 10px;
  font: inherit;
  font-size: 0.8125rem;
  color: inherit;
  background: transparent;
  border: 1px solid var(--tryon-border);
  border-radius: var(--tryon-radius);
  cursor: pointer;
}
.tryon__tool[hidden] {
  display: none;
}
.tryon__tool:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.tryon__tool:not(:disabled):hover {
  border-color: var(--tryon-text);
}
.tryon__cart {
  width: 100%;
  margin-top: auto;
}
.tryon__privacy {
  grid-area: privacy;
  margin: 0;
  padding: 8px 20px 20px;
  font-size: 0.75rem;
  line-height: 1.5;
  color: var(--tryon-muted);
}
.tryon__file {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* ---------- Mobile: full-screen sheet ---------- */
@media (max-width: 860px) {
  .tryon {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }
  .tryon__panel {
    height: 100dvh;
    max-height: 100dvh;
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr) auto auto;
    grid-template-areas:
      'header'
      'stage'
      'controls'
      'privacy';
  }
  .tryon__header {
    padding: max(12px, env(safe-area-inset-top)) 12px 8px 16px;
  }
  .tryon__title {
    font-size: 1.0625rem;
  }
  .tryon__stage {
    min-height: 0;
    max-height: none;
    aspect-ratio: auto;
  }
  .tryon__controls {
    gap: 12px;
    padding: 12px 16px;
    overflow: visible;
  }
  .tryon__privacy {
    padding: 0 16px max(12px, env(safe-area-inset-bottom));
  }
}

/* ---------- Tracking status + finger picker ---------- */
.tryon__badge {
  position: absolute;
  top: 12px;
  left: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px 5px 8px;
  font-size: 0.75rem;
  color: #fff;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 999px;
  pointer-events: none;
}
.tryon__badge::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e0b341;
  box-shadow: 0 0 0 0 rgba(224, 179, 65, 0.6);
  animation: tryon-pulse 1.4s ease-out infinite;
}
.tryon__badge.is-found::before {
  background: #4cc38a;
  animation: none;
}
.tryon__badge[hidden] {
  display: none;
}
@keyframes tryon-pulse {
  to {
    box-shadow: 0 0 0 6px rgba(224, 179, 65, 0);
  }
}
@media (prefers-reduced-motion: reduce) {
  .tryon__badge::before {
    animation: none;
  }
}
.tryon__group {
  display: grid;
  gap: 8px;
}
.tryon__group-label {
  font-size: 0.875rem;
  color: var(--tryon-muted);
}
.tryon__tool[aria-pressed='true'] {
  border-color: var(--tryon-text);
  background: rgba(0, 0, 0, 0.04);
}
