/* ══════════════════════════════════════════════════════════════════
 *  Virtual Try-On — Custom UI
 *  Every control on this page belongs to the host page. The only
 *  iJewel3D UI left on screen is the loading screen and hand prompt
 *  drawn by TryonUIPlugin during a session.
 * ══════════════════════════════════════════════════════════════════ */


/* ──────────────────────────────────────────────────────────────────
 *  TOKENS
 * ────────────────────────────────────────────────────────────────── */

:root {
  --accent:      #8b6f3a;
  --accent-soft: #f3ecdd;
  --ink:         #1a1a1a;
  --muted:       #7a7470;
  --line:        #e4dfd8;
  --bg:          #faf9f6;
  --bg-card:     #ffffff;
  --shadow-md:   0 4px 20px rgba(0, 0, 0, 0.06);
  --radius-sm:   6px;
  --radius-md:   10px;
  --radius-lg:   16px;

  --status-idle: #b9b3aa;
  --status-go:   #4caf50;
  --status-err:  #d84141;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
}

body {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
}


/* ──────────────────────────────────────────────────────────────────
 *  HEADER
 * ────────────────────────────────────────────────────────────────── */

#topbar {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  background: var(--bg-card);
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.brand-mark em {
  font-style: normal;
  color: var(--accent);
}

.brand-sub {
  font-size: 0.8rem;
  color: var(--muted);
}

.status-area {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
  font-size: 0.8rem;
  color: var(--muted);
}

.status-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--status-idle);
}

.status-dot[data-state='go']  { background: var(--status-go); }
.status-dot[data-state='err'] { background: var(--status-err); }


/* ──────────────────────────────────────────────────────────────────
 *  LAYOUT — viewer left, product details right
 * ────────────────────────────────────────────────────────────────── */

#app {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 22rem;
  gap: 1.5rem;
  padding: 1.5rem;
  align-items: start;
}

#stage {
  position: relative;
  height: clamp(22rem, calc(100vh - 11rem), 46rem);
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

#viewer {
  width: 100%;
  height: 100%;
}


/* ──────────────────────────────────────────────────────────────────
 *  IN-SESSION CONTROLS — float over the viewer while running
 * ────────────────────────────────────────────────────────────────── */

#session-controls {
  position: absolute;
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  z-index: 5;
}

#session-controls[hidden] { display: none; }

.pill {
  padding: 0.5rem 1rem;
  font: inherit;
  font-size: 0.8rem;
  color: #fff;
  background: rgba(26, 26, 26, 0.72);
  backdrop-filter: blur(6px);
  border: 0;
  border-radius: 999px;
  cursor: pointer;
}

.pill:hover { background: rgba(26, 26, 26, 0.88); }

.finger-picker {
  display: flex;
  gap: 0.25rem;
  padding: 0.25rem;
  background: rgba(26, 26, 26, 0.72);
  backdrop-filter: blur(6px);
  border-radius: 999px;
}

.finger {
  padding: 0.4rem 0.8rem;
  font: inherit;
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.75);
  background: transparent;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
}

.finger:hover { color: #fff; }

.finger.active {
  color: var(--ink);
  background: #fff;
  font-weight: 600;
}


/* ──────────────────────────────────────────────────────────────────
 *  PRODUCT DETAILS
 * ────────────────────────────────────────────────────────────────── */

#details {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 1.5rem;
}

.eyebrow {
  margin: 0 0 0.35rem;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

.product-name {
  margin: 0;
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.9rem;
  font-weight: 500;
}

.price {
  margin: 0.35rem 0 1rem;
  font-size: 1.1rem;
  font-weight: 600;
}

.copy {
  margin: 0 0 1.25rem;
  color: var(--muted);
  line-height: 1.6;
}


/* ──────────────────────────────────────────────────────────────────
 *  THE TRY-ON ENTRY POINT
 * ────────────────────────────────────────────────────────────────── */

.tryon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.85rem 1rem;
  font: inherit;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.tryon-btn:hover:not(:disabled) {
  color: #fff;
  background: var(--accent);
}

.tryon-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.tryon-btn[hidden] { display: none; }

.tryon-icon { font-size: 1.1em; }

.hint {
  margin: 0.6rem 0 1.25rem;
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--muted);
  text-align: center;
}

.cart-btn {
  width: 100%;
  padding: 0.8rem 1rem;
  font: inherit;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #fff;
  background: var(--ink);
  border: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.cart-btn:hover { background: var(--accent); }


/* ──────────────────────────────────────────────────────────────────
 *  EXPLANATORY NOTE — remove this block in a real storefront
 * ────────────────────────────────────────────────────────────────── */

.note {
  margin-top: 1.5rem;
  padding: 1rem;
  background: var(--accent-soft);
  border-radius: var(--radius-md);
}

.note-title {
  margin: 0 0 0.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.note-list {
  margin: 0;
  padding-left: 1.1rem;
  line-height: 1.6;
}

.note-list li + li { margin-top: 0.35rem; }

.note-list code,
#footnote code {
  padding: 0.1rem 0.3rem;
  background: var(--bg-card);
  border-radius: 3px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9em;
}


/* ──────────────────────────────────────────────────────────────────
 *  FOOTER
 * ────────────────────────────────────────────────────────────────── */

#footnote {
  padding: 0.9rem 1.5rem;
  font-size: 0.8rem;
  color: var(--muted);
  background: var(--bg-card);
  border-top: 1px solid var(--line);
}


/* ──────────────────────────────────────────────────────────────────
 *  RESPONSIVE
 * ────────────────────────────────────────────────────────────────── */

@media (max-width: 860px) {
  #app {
    grid-template-columns: 1fr;
    padding: 1rem;
    gap: 1rem;
  }

  #stage {
    height: 62vh;
  }

  .status-area { display: none; }
}
