/* ==========================================================================
   FRONTBIT AI — EARRINGS CUSTOMIZER
   Follows the ring builder's visual language; all rules are scoped to .ec-*
   ========================================================================== */

@font-face {
  font-family: 'Figtree';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url('/assets/fonts/figtree.woff2') format('woff2');
}

:root {
  --ec-ink: #1B1B1B;
  --ec-text: #2B2B2B;
  --ec-muted: #6B6F76;
  --ec-line: #DCDCDC;
  --ec-line-soft: #ECECEC;
  --ec-surface: #FFFFFF;
  --ec-stage: #EFEFEF;
  --ec-nav: #F7F6F4;
  --ec-primary: #2F4FD8;
  --ec-primary-soft: #E9EFFD;
  --ec-radius: 4px;
  --ec-bar-height: 76px;
  --ec-font: 'Figtree', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--ec-font);
  color: var(--ec-text);
  background: var(--ec-surface);
  -webkit-font-smoothing: antialiased;
  padding-bottom: var(--ec-bar-height);
}

button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--ec-primary); outline-offset: 2px; }

/* ---------- header ---------- */

.ec-header { border-bottom: 1px solid var(--ec-line-soft); }
.ec-header-top {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  max-width: 1680px;
  margin: 0 auto;
  padding: 12px 32px;
}
.ec-header-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-self: start;
  color: var(--ec-text);
  text-decoration: none;
  font-size: 14px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.ec-header-link:hover { color: var(--ec-primary); }
.ec-logo img { display: block; height: 38px; width: auto; }
.ec-nav {
  display: flex;
  justify-content: center;
  gap: 48px;
  padding: 0 16px;
  background: var(--ec-nav);
}
.ec-nav a {
  padding: 20px 0 18px;
  border-bottom: 2px solid transparent;
  color: var(--ec-text);
  text-decoration: none;
  font-size: 15px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}
.ec-nav a:hover { color: var(--ec-ink); border-bottom-color: var(--ec-line); }
.ec-nav a.active { color: var(--ec-ink); border-bottom-color: var(--ec-ink); font-weight: 600; }
.ec-nav { gap: 40px; }
@media (max-width: 1480px) {
  .ec-nav { gap: 26px; }
  .ec-nav a { font-size: 14px; letter-spacing: 0.04em; }
}
@media (max-width: 1200px) {
  .ec-nav { gap: 20px; }
  .ec-nav a { font-size: 13px; letter-spacing: 0.02em; }
}

/* ---------- page ---------- */

.ec-main { max-width: 1880px; margin: 0 auto; padding: 0 20px 28px; }

.ec-breadcrumb {
  display: flex;
  align-items: center;
  padding: 20px 104px 16px;
  font-size: 14px;
  font-weight: 500;
}
.ec-breadcrumb a { color: #535555; text-decoration: none; padding-right: 14px; margin-right: 14px; border-right: 1px solid #535555; line-height: 1; }
.ec-breadcrumb a:hover { color: var(--ec-ink); }
.ec-breadcrumb span { color: var(--ec-ink); }

.ec-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.72fr) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

/* ---------- 3D stage ---------- */

.ec-stage { position: sticky; top: 12px; }
.ec-viewer {
  position: relative;
  height: min(68vh, 720px);
  min-height: 440px;
  overflow: hidden;
  background: radial-gradient(120% 90% at 50% 38%, #F8F8F7 0%, var(--ec-stage) 62%, #E4E4E3 100%);
  touch-action: none;
}
.earring-canvas { display: block; width: 100%; height: 100%; cursor: grab; opacity: 0; transition: opacity 0.6s ease; }
.earring-canvas:active { cursor: grabbing; }
.ec-ready .earring-canvas { opacity: 1; }

.ec-reset {
  position: absolute;
  top: 12px;
  right: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 8px;
  border: 0;
  background: none;
  font-size: 14px;
  font-weight: 600;
  color: var(--ec-ink);
}
.ec-reset svg { transition: transform 0.5s ease; }
.ec-reset:hover svg { transform: rotate(-200deg); }

.ec-views {
  position: absolute;
  top: 14px;
  left: 14px;
  display: flex;
  padding: 3px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.08);
  backdrop-filter: blur(6px);
}
.ec-views button {
  padding: 7px 14px;
  border: 0;
  border-radius: 20px;
  background: none;
  font-size: 13px;
  font-weight: 500;
  transition: background-color 0.2s ease, color 0.2s ease;
}
.ec-views button.active { background: var(--ec-ink); color: #fff; }

.ec-hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 12px;
  text-align: center;
  font-size: 12px;
  color: #8A8A8A;
  pointer-events: none;
}

.ec-loading {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  font-size: 13px;
  color: var(--ec-muted);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.ec-loading.active { opacity: 1; }
.ec-ready .ec-loading { justify-content: flex-end; padding-bottom: 38px; }
.ec-ready .ec-loading .ec-loading-text { display: none; }
.ec-loading.error { padding: 0 32px; text-align: center; }
.ec-loading.error .ec-spinner { display: none; }
.ec-spinner {
  width: 30px;
  height: 30px;
  border: 2px solid rgba(0, 0, 0, 0.12);
  border-top-color: var(--ec-ink);
  border-radius: 50%;
  animation: ec-spin 0.8s linear infinite;
}
@keyframes ec-spin { to { transform: rotate(360deg); } }

.ec-credit { padding: 6px 12px 0; text-align: center; font-size: 11px; color: #9A9A9A; }
.ec-credit:empty { display: none; }
.ec-caption { padding: 16px 12px 0; text-align: center; font-size: 18px; font-weight: 700; letter-spacing: 0.02em; color: var(--ec-ink); }

/* ---------- controls panel ---------- */

.ec-panel {
  min-height: min(68vh, 720px);
  padding: 22px 24px 8px 18px;
  border: 1px solid var(--ec-line);
  border-radius: 6px;
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.05);
}

.ec-row {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 20px 0;
  border-bottom: 1px solid var(--ec-line);
  animation: ec-rise 0.3s ease both;
}
.ec-row:last-of-type { border-bottom: 0; }
.ec-row-style { align-items: start; padding-top: 6px; }
.ec-row-inner { display: block; padding: 10px 0 0; border: 0; animation: none; }
.ec-row-inner > .ec-row-label { display: none; }
@keyframes ec-rise { from { opacity: 0; transform: translateY(6px); } }

.ec-row-label { position: relative; padding-left: 16px; }
.ec-row-style > .ec-row-label { padding-top: 34px; }
.ec-row-label::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.45em;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #B9B9B9;
}
.ec-row-style > .ec-row-label::before { top: calc(34px + 0.45em); }
.ec-row-label span { font-size: 15px; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase; color: var(--ec-ink); }
.ec-row-label small { display: block; margin-top: 4px; font-size: 13px; color: var(--ec-muted); }

.ec-row-body { display: flex; align-items: center; gap: 6px; min-width: 0; }
.ec-scroll {
  display: flex;
  flex: 1;
  gap: 8px;
  min-width: 0;
  padding: 2px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
}
.ec-scroll::-webkit-scrollbar { display: none; }

.ec-arrow {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ec-ink);
  transition: opacity 0.2s ease;
}
.ec-arrow:disabled { opacity: 0.25; cursor: default; }
.ec-arrow[hidden] { display: none; }

.ec-tabs { display: flex; gap: 0; overflow-x: auto; background: #FAFAFA; scrollbar-width: none; scroll-snap-type: x proximity; }
.ec-tabs::-webkit-scrollbar { display: none; }
.ec-tab {
  position: relative;
  flex: 1 0 auto;
  padding: 12px 16px;
  scroll-snap-align: start;
  border: 1px solid transparent;
  border-radius: var(--ec-radius);
  background: none;
  font-size: 14px;
  white-space: nowrap;
}
.ec-tab:hover { background: #F1F1F1; }
.ec-tab.active { border-color: var(--ec-ink); background: #fff; font-weight: 700; }

.ec-choice {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 112px;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: var(--ec-radius);
  background: none;
  font-size: 14px;
  scroll-snap-align: start;
  transition: border-color 0.18s ease, background-color 0.18s ease, transform 0.18s ease;
}
.ec-choice:hover { background: #F7F7F7; }
.ec-choice:active { transform: scale(0.97); }
.ec-choice.active { border-color: var(--ec-ink); background: #fff; font-weight: 700; }
.ec-choice img { display: block; }

.ec-design { width: 176px; padding: 12px 10px; }
.ec-design img { width: 96px; height: 60px; object-fit: contain; }
.ec-shape { min-width: 104px; }
.ec-shape img { width: 46px; height: 46px; }
.ec-setting img { width: 40px; height: 40px; }
.ec-text { min-width: 104px; min-height: 40px; }
.ec-metal { min-width: 78px; }

.ec-swatch {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.85), rgba(255, 255, 255, 0) 55%),
    var(--swatch);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}
.ec-swatch-skin { background: radial-gradient(circle at 34% 30%, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0) 60%), var(--swatch); }

.ec-note { margin: 16px 0 12px 16px; font-size: 14px; line-height: 1.5; color: var(--ec-muted); }
.ec-note-box { margin: 24px 16px; padding: 18px 20px; border: 1px dashed var(--ec-line); border-radius: 6px; }

.ec-summary { margin: 18px 0 16px 16px; padding: 20px 22px; border-radius: 6px; background: #F8F8F7; }
.ec-summary h2 { margin: 0 0 6px; font-size: 13px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ec-muted); }
.ec-summary p { margin: 0 0 14px; font-size: 17px; font-weight: 600; line-height: 1.5; color: var(--ec-ink); }
.ec-summary p span { font-size: 14px; font-weight: 400; color: var(--ec-muted); }
.ec-summary dl { margin: 0; }
.ec-summary dl div { display: flex; justify-content: space-between; padding: 7px 0; font-size: 14px; }
.ec-summary dd { margin: 0; font-variant-numeric: tabular-nums; }
.ec-summary .ec-total { margin-top: 6px; padding-top: 12px; border-top: 1px solid var(--ec-line); font-size: 16px; font-weight: 700; color: var(--ec-ink); }
.ec-saved { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; padding: 12px 14px; border-radius: 6px; background: var(--ec-primary-soft); font-size: 14px; color: var(--ec-primary); }
.ec-link { padding: 0; border: 0; background: none; font-weight: 600; color: var(--ec-primary); text-decoration: underline; }

.ec-skeleton-row {
  height: 96px;
  margin-bottom: 18px;
  border-radius: 6px;
  background: linear-gradient(90deg, #F2F2F2 25%, #FAFAFA 45%, #F2F2F2 65%);
  background-size: 200% 100%;
  animation: ec-shimmer 1.4s linear infinite;
}
@keyframes ec-shimmer { to { background-position: -200% 0; } }

/* ---------- bottom bar ---------- */

.ec-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: var(--ec-bar-height);
  padding: 12px 32px;
  background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid var(--ec-line-soft);
  box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.06);
  backdrop-filter: blur(8px);
}
.ec-bar:empty { display: none; }
.ec-bar-info { flex: 1; min-width: 0; }
.ec-bar-title { font-size: 16px; font-weight: 700; color: var(--ec-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ec-bar-meta { margin-top: 2px; font-size: 13px; color: var(--ec-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ec-bar-price { font-size: 22px; font-weight: 700; color: var(--ec-ink); font-variant-numeric: tabular-nums; }
.ec-bar-actions { display: flex; gap: 10px; }

.ec-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 26px;
  border: 1px solid var(--ec-ink);
  border-radius: 30px;
  background: var(--ec-ink);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  transition: background-color 0.2s ease, transform 0.2s ease;
}
.ec-btn:hover { background: #000; }
.ec-btn:active { transform: scale(0.98); }
.ec-btn-ghost { background: #fff; color: var(--ec-ink); }
.ec-btn-ghost:hover { background: #F4F4F4; }

.ec-toasts { position: fixed; left: 50%; bottom: calc(var(--ec-bar-height) + 16px); z-index: 30; display: flex; flex-direction: column; gap: 8px; transform: translateX(-50%); width: min(92vw, 460px); pointer-events: none; }
.ec-toast { padding: 12px 18px; border-radius: 8px; background: var(--ec-ink); color: #fff; font-size: 14px; line-height: 1.4; text-align: center; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18); animation: ec-rise 0.3s ease both; transition: opacity 0.3s ease, transform 0.3s ease; }
.ec-toast.leaving { opacity: 0; transform: translateY(8px); }

/* ---------- embedded preview (admin) ---------- */

.ec-embed { padding: 0; }
.ec-embed .ec-header, .ec-embed .ec-breadcrumb, .ec-embed .ec-credit, .ec-embed .ec-panel, .ec-embed .ec-bar,
.ec-embed .ec-caption, .ec-embed .ec-reset, .ec-embed .ec-hint, .ec-embed .ec-views { display: none; }
.ec-embed .ec-main { padding: 0; }
.ec-embed .ec-layout { display: block; }
.ec-embed .ec-stage { position: static; }
.ec-embed .ec-viewer { height: 100vh; min-height: 0; }

/* ---------- responsive ---------- */

@media (max-width: 1280px) {
  .ec-breadcrumb { padding-left: 12px; padding-right: 12px; }
  .ec-row { grid-template-columns: 150px minmax(0, 1fr); }
  .ec-design { width: 150px; }
}

@media (max-width: 960px) {
  :root { --ec-bar-height: 118px; }
  .ec-header-top { padding: 10px 16px; }
  .ec-header-link span { display: none; }
  .ec-logo img { height: 30px; }
  .ec-nav { justify-content: flex-start; gap: 24px; overflow-x: auto; scrollbar-width: none; }
  .ec-nav a { padding: 14px 0 12px; font-size: 13px; }
  .ec-main { padding: 0 0 20px; }
  .ec-breadcrumb { padding: 12px 16px; font-size: 13px; }

  /* The viewer stays in sight while the controls scroll beneath it */
  .ec-layout { display: block; }
  .ec-stage { top: 0; z-index: 5; background: var(--ec-surface); }
  .ec-viewer { height: 44vh; min-height: 280px; }
  .ec-caption { padding: 8px 12px; font-size: 15px; border-bottom: 1px solid var(--ec-line-soft); }
  .ec-hint { display: none; }
  .ec-views button { padding: 6px 11px; font-size: 12px; }

  .ec-panel { min-height: 0; padding: 4px 12px; border: 0; box-shadow: none; }
  .ec-row { display: block; padding: 14px 0; }
  .ec-row-label { margin-bottom: 8px; }
  .ec-row-style > .ec-row-label { padding-top: 0; }
  .ec-row-style > .ec-row-label::before { top: 0.45em; }
  .ec-row-label small { display: inline; margin-left: 8px; }
  .ec-arrow { display: none; }
  .ec-choice { min-width: 92px; }
  .ec-design { width: 138px; }
  .ec-tab { min-width: 0; padding: 10px 14px; }
  .ec-note, .ec-summary { margin-left: 0; }

  .ec-bar { flex-wrap: wrap; gap: 6px 12px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); }
  .ec-bar-price { font-size: 19px; }
  .ec-bar-actions { width: 100%; }
  .ec-bar-actions .ec-btn { flex: 1; min-height: 44px; padding: 0 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------- single-window refinements ---------- */

.ec-views[hidden] { display: none; }
.ec-row-style > .ec-row-label small { max-width: 190px; line-height: 1.45; }
.ec-setting { min-width: 112px; }

@media (max-width: 960px) {
  /* Controls slide over the lower part of the page like a drawer under the fixed viewer */
  .ec-panel { position: relative; margin-top: -10px; padding-top: 14px; border-radius: 16px 16px 0 0; background: var(--ec-surface); box-shadow: 0 -8px 20px rgba(0, 0, 0, 0.06); }
  .ec-panel::before { content: ''; position: absolute; top: 6px; left: 50%; width: 40px; height: 4px; margin-left: -20px; border-radius: 2px; background: #D9D9D9; }
  .ec-row-style > .ec-row-label small { display: block; max-width: none; margin: 4px 0 0; }
  .ec-credit { padding-bottom: 14px; }
}

/* Necklace: let the chest fall away softly at the foot of the frame, like a studio crop */
.ec-necklace .ec-viewer::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 16%;
  background: linear-gradient(to bottom, rgba(236, 236, 235, 0), #ECECEB 88%);
  pointer-events: none;
}
.ec-necklace .ec-hint { z-index: 1; }

/* Bracelet: the forearm leaves the frame softly on the right, like a studio crop */
.ec-bracelet .ec-viewer::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 14%;
  background: linear-gradient(to right, rgba(236, 236, 235, 0), #ECECEB 90%);
  pointer-events: none;
}
.ec-bracelet .ec-zoom { z-index: 3; }

/* Anklet: the leg leaves the frame softly at the top */
.ec-anklet .ec-viewer::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 14%;
  background: linear-gradient(to top, rgba(244, 244, 243, 0), #F4F4F3 90%);
  pointer-events: none;
}
.ec-anklet .ec-reset { z-index: 3; }

/* ---------- zoom controls ---------- */

.ec-zoom {
  position: absolute;
  right: 14px;
  bottom: 14px;
  z-index: 2;
  display: flex;
  flex-direction: column;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(6px);
  overflow: hidden;
}
.ec-zoom button {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ec-ink);
  transition: background-color 0.2s ease;
}
.ec-zoom button + button { border-top: 1px solid var(--ec-line-soft); }
.ec-zoom button:hover { background: #F2F2F2; }
.ec-zoom button:active { background: #E6E6E6; }
.ec-embed .ec-zoom { display: none; }

/* ---------- skin tone slider ---------- */

.ec-row-stack { min-width: 0; }
.ec-shade { display: flex; align-items: center; gap: 14px; margin: 10px 6px 2px; font-size: 13px; color: var(--ec-muted); }
.ec-shade span { flex: none; }
.ec-shade input {
  flex: 1;
  min-width: 0;
  height: 28px;
  margin: 0;
  background: none;
  -webkit-appearance: none;
  appearance: none;
  cursor: grab;
}
.ec-shade input:active { cursor: grabbing; }
.ec-shade input::-webkit-slider-runnable-track { height: 10px; border-radius: 6px; background: var(--shade-gradient); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08); }
.ec-shade input::-moz-range-track { height: 10px; border-radius: 6px; background: var(--shade-gradient); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08); }
.ec-shade input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 26px;
  height: 26px;
  margin-top: -8px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--shade-thumb);
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.3);
}
.ec-shade input::-moz-range-thumb { width: 20px; height: 20px; border: 3px solid #fff; border-radius: 50%; background: var(--shade-thumb); box-shadow: 0 1px 6px rgba(0, 0, 0, 0.3); }
.ec-shade input:focus-visible { outline: 2px solid var(--ec-primary); outline-offset: 4px; border-radius: 6px; }

@media (max-width: 960px) {
  .ec-zoom { right: 10px; bottom: 10px; }
  .ec-zoom button { width: 36px; height: 36px; }
  .ec-shade { margin: 10px 2px 0; }
}
