/* FurnitureView shopper widget — CSS-isolated (.fv- prefix).
   From the FurnitureView design system: Evergreen accent, warm gallery
   neutrals, hairline-first. Self-contained: assumes hostile host CSS.
   All tokens are scoped to .fv-overlay so nothing leaks in or out.
   ALWAYS LIGHT — the widget matches the storefront, not the OS theme.
   Performance rules: animate transform/opacity only; no full-screen
   backdrop-filter; 16px inputs so iOS never zooms.
   (Production hardening: move the modal into an <iframe> for total isolation.) */
@import url("https://api.fontshare.com/v2/css?f[]=general-sans@400,500,600,700&display=swap");

.fv-overlay, .fv-overlay *, .fv-overlay *::before, .fv-overlay *::after,
.fv-btn, .fv-btn * { box-sizing: border-box; }

.fv-overlay {
  --fv-canvas:#FAFAF8; --fv-surface:#FFFFFF; --fv-surface-2:#F2F2EF; --fv-surface-3:#ECECE7;
  --fv-ink:#16171B; --fv-ink-2:#3A3D44; --fv-muted:#6B6F76; --fv-faint:#9A9EA6;
  --fv-hairline:#E9E9E4; --fv-hairline-2:#DEDED8;
  --fv-accent:#1F6F5C; --fv-accent-hover:#1B6151; --fv-accent-press:#175344;
  --fv-accent-ink:#FFFFFF; --fv-accent-soft:#E7F0EC; --fv-ring:rgba(31,111,92,.32);
  --fv-danger:#C1362B; --fv-danger-soft:#FBE9E7;
  --fv-shadow-lg:0 24px 60px rgba(16,17,21,.18), 0 4px 14px rgba(16,17,21,.08);
  --fv-font:"General Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --fv-mono:ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --fv-r:16px; --fv-ease:cubic-bezier(.2,0,0,1);

  position: fixed; inset: 0; z-index: 2147483000;
  display: flex; align-items: center; justify-content: center; padding: 16px;
  background: rgba(16,17,21,.52); /* plain scrim — no backdrop blur, it janks phones */
  font-family: var(--fv-font); color: var(--fv-ink);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  line-height: 1.5; font-size: 15px;
  -webkit-tap-highlight-color: transparent;
  animation: fvfade .18s var(--fv-ease);
}
.fv-overlay[hidden] { display: none; }
@keyframes fvfade { from { opacity: 0; } to { opacity: 1; } }

.fv-overlay h1, .fv-overlay h2, .fv-overlay h3, .fv-overlay p { margin: 0; font-weight: inherit; }
/* :where() keeps this reset at zero specificity so .fv-primary/.fv-ghost etc.
   can win with a single class — otherwise every button loses its background. */
.fv-overlay :where(button) { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; font-size: inherit; touch-action: manipulation; }
.fv-overlay :focus-visible { outline: 2px solid var(--fv-accent); outline-offset: 2px; border-radius: 6px; }
.fv-overlay img { display: block; max-width: 100%; border: none; }

/* ---------- Modal shell ---------- */
.fv-modal {
  background: var(--fv-canvas);
  width: 100%; max-width: 480px; max-height: 92vh;
  border-radius: 20px; box-shadow: var(--fv-shadow-lg);
  display: flex; flex-direction: column; overflow: hidden;
  animation: fvpop .24s var(--fv-ease);
}
@keyframes fvpop { from { opacity: 0; transform: scale(.96) translateY(10px); } to { opacity: 1; transform: none; } }
@media (max-width: 520px) {
  .fv-overlay { align-items: flex-end; padding: 0; }
  .fv-modal { max-width: none; max-height: 96vh; border-radius: 20px 20px 0 0; }
}

/* ---------- Header ---------- */
.fv-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid var(--fv-hairline);
  background: var(--fv-surface); flex: 0 0 auto;
}
.fv-product { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; }
.fv-product img {
  width: 50px; height: 50px; border-radius: 12px; object-fit: cover; flex: 0 0 auto;
  background: var(--fv-surface-3); box-shadow: inset 0 0 0 1px rgba(22,23,27,.08);
}
.fv-eyebrow {
  display: block; font-size: 10.5px; font-weight: 600; letter-spacing: .07em;
  text-transform: uppercase; color: var(--fv-accent);
}
.fv-product b {
  display: block; font-size: 15px; font-weight: 600; letter-spacing: -.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.fv-product span { display: block; font-size: 12px; color: var(--fv-muted); }
.fv-x {
  width: 36px; height: 36px; border-radius: 999px; flex: 0 0 auto;
  display: grid; place-items: center; color: var(--fv-muted);
  font-size: 22px; line-height: 1;
  transition: background .13s var(--fv-ease), color .13s var(--fv-ease);
}
.fv-x:hover { background: var(--fv-surface-2); color: var(--fv-ink); }

/* ---------- Body / steps ---------- */
.fv-body {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain; /* scrolling here must never scroll the store behind */
  position: relative; min-height: 300px;
}
.fv-step { padding: 22px 18px; animation: fvstep .24s var(--fv-ease); }
@keyframes fvstep { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

/* Step title + sub */
.fv-title { font-size: 21px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; }
.fv-sub { color: var(--fv-muted); font-size: 13.5px; margin-top: 5px; }

/* ---------- Dropzone ---------- */
.fv-drop {
  display: block; margin-top: 18px;
  border: 1.5px dashed var(--fv-hairline-2); border-radius: var(--fv-r);
  background: var(--fv-surface); padding: 32px 20px; text-align: center; cursor: pointer;
  transition: border-color .15s var(--fv-ease), background .15s var(--fv-ease), transform .15s var(--fv-ease), box-shadow .15s var(--fv-ease);
}
.fv-drop:hover { border-color: var(--fv-accent); transform: translateY(-1px); box-shadow: 0 6px 20px rgba(16,17,21,.06); }
.fv-drop.fv-drag { border-color: var(--fv-accent); background: var(--fv-accent-soft); border-style: solid; }
.fv-drop > svg {
  width: 56px; height: 56px; padding: 15px; margin: 0 auto 14px; border-radius: 999px;
  display: block; background: var(--fv-accent-soft); color: var(--fv-accent);
}
.fv-drop.fv-drag > svg { background: var(--fv-surface); }
.fv-drop b { display: block; font-size: 15px; font-weight: 600; }
.fv-drop small { display: block; font-size: 12.5px; color: var(--fv-muted); margin-top: 6px; max-width: 34ch; margin-left: auto; margin-right: auto; }
.fv-preview {
  width: 100%; border-radius: 12px; object-fit: cover; max-height: 280px;
  box-shadow: inset 0 0 0 1px rgba(22,23,27,.08); background: var(--fv-surface-3);
}
.fv-hint { display: flex; gap: 8px; align-items: flex-start; margin-top: 14px; color: var(--fv-muted); font-size: 12.5px; }

/* ---------- Details form ---------- */
.fv-form { margin-top: 20px; display: flex; flex-direction: column; gap: 10px; }
.fv-form-title { font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.fv-input {
  height: 48px; padding: 0 15px; width: 100%;
  border: 1px solid var(--fv-hairline-2); border-radius: 12px;
  background: var(--fv-surface); color: var(--fv-ink);
  font-family: var(--fv-font);
  font-size: 16px; /* NEVER below 16px — iOS zooms the page on focus otherwise */
  transition: border-color .13s var(--fv-ease), box-shadow .13s var(--fv-ease);
}
.fv-input::placeholder { color: var(--fv-faint); }
.fv-input:focus { outline: none; border-color: var(--fv-accent); box-shadow: 0 0 0 3px var(--fv-ring); }
.fv-consent { display: flex; gap: 10px; align-items: flex-start; font-size: 12.5px; color: var(--fv-muted); cursor: pointer; }
.fv-consent input { width: 17px; height: 17px; margin-top: 1px; accent-color: var(--fv-accent); flex: 0 0 auto; cursor: pointer; }
.fv-form-msg { font-size: 13px; color: var(--fv-danger); min-height: 16px; }

/* ---------- Buttons ---------- */
.fv-primary, .fv-ghost {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  height: 50px; border-radius: 14px; font-size: 16px; font-weight: 600; letter-spacing: -.01em;
  transition: background .13s var(--fv-ease), transform .13s var(--fv-ease), box-shadow .13s var(--fv-ease), opacity .13s var(--fv-ease);
}
.fv-primary {
  background: var(--fv-accent); color: var(--fv-accent-ink);
  box-shadow: 0 6px 18px rgba(31,111,92,.28);
}
.fv-primary:hover { background: var(--fv-accent-hover); }
.fv-primary:active { background: var(--fv-accent-press); transform: translateY(1px); box-shadow: 0 3px 10px rgba(31,111,92,.24); }
.fv-primary[disabled] { opacity: .4; pointer-events: none; box-shadow: none; }
.fv-ghost { background: var(--fv-surface); color: var(--fv-ink); box-shadow: inset 0 0 0 1px var(--fv-hairline-2); }
.fv-ghost:hover { background: var(--fv-surface-2); }
.fv-ghost:active { transform: translateY(1px); }
.fv-primary svg, .fv-ghost svg { width: 18px; height: 18px; flex: 0 0 auto; }
.fv-actions { display: flex; gap: 10px; margin-top: 16px; }
.fv-actions .fv-primary, .fv-actions .fv-ghost { flex: 1; }

/* ---------- Generating — the cinematic wait (kept dark on purpose:
     the shopper's own photo is the stage; the veil makes the captions readable) ---------- */
.fv-gen { position: relative; border-radius: var(--fv-r); overflow: hidden; aspect-ratio: 4/3; background: #101113; }
.fv-gen > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; filter: brightness(.42) saturate(.85); transform: scale(1.04); }
.fv-gen-veil { position: absolute; inset: 0; background: radial-gradient(120% 90% at 50% 20%, rgba(8,9,11,.15) 40%, rgba(8,9,11,.68) 100%); }
.fv-gen-sweep {
  position: absolute; top: 0; bottom: 0; width: 46%;
  background: linear-gradient(90deg, transparent, rgba(46,145,121,0) 10%, rgba(120,220,190,.20) 50%, rgba(46,145,121,0) 90%, transparent);
  mix-blend-mode: screen; /* no blur filter — it's expensive on phones */
  animation: fvsweep 2.6s var(--fv-ease) infinite;
  will-change: transform; left: 0; transform: translateX(-110%);
}
.fv-gen-line {
  position: absolute; top: 0; bottom: 0; width: 2px; left: -2%;
  background: linear-gradient(180deg, transparent, rgba(180,240,215,.9), transparent);
  box-shadow: 0 0 16px 2px rgba(46,145,121,.7);
  animation: fvline 2.6s var(--fv-ease) infinite;
}
/* the wide sweep moves by transform (its own width ≈ half the stage → GPU-composited) */
@keyframes fvsweep { 0% { transform: translateX(-110%); } 100% { transform: translateX(240%); } }
@keyframes fvline { 0% { left: -2%; opacity: 0; } 8% { opacity: 1; } 92% { opacity: 1; } 100% { left: 100%; opacity: 0; } }
.fv-gen-grain { position: absolute; inset: 0; opacity: .45; mix-blend-mode: overlay;
  background-image: radial-gradient(rgba(255,255,255,.12) 0.5px, transparent 0.6px); background-size: 3px 3px; }
.fv-gen-caption { position: absolute; left: 0; right: 0; bottom: 64px; text-align: center; padding: 0 24px; color: #fff; }
.fv-gen-badge {
  display: inline-flex; align-items: center; gap: 7px; font-size: 11px; font-weight: 600;
  letter-spacing: .04em; text-transform: uppercase; color: rgba(255,255,255,.72); margin-bottom: 10px;
}
.fv-pulse { width: 7px; height: 7px; border-radius: 999px; background: #56d6ae; box-shadow: 0 0 10px 1px rgba(86,214,174,.9); animation: fvpulse 1.3s var(--fv-ease) infinite; }
@keyframes fvpulse { 50% { opacity: .3; transform: scale(.7); } }
.fv-gen-status { font-size: 17px; font-weight: 600; letter-spacing: -.02em; min-height: 24px; transition: opacity .4s var(--fv-ease); }
.fv-gen-bar-wrap { position: absolute; left: 20px; right: 20px; bottom: 38px; height: 4px; border-radius: 999px; background: rgba(255,255,255,.16); overflow: hidden; }
.fv-gen-bar { height: 100%; width: 0%; border-radius: 999px; background: linear-gradient(90deg,#1f6f5c,#56d6ae); box-shadow: 0 0 12px rgba(86,214,174,.7); transition: width .4s var(--fv-ease); position: relative; }
.fv-gen-bar::after { content:""; position:absolute; right:0; top:-3px; bottom:-3px; width:14px; background: radial-gradient(circle, rgba(200,255,235,.9), transparent 70%); }
.fv-gen-pct { position: absolute; left: 20px; right: 20px; bottom: 14px; text-align: center; font-family: var(--fv-mono); font-size: 11.5px; color: rgba(255,255,255,.55); font-variant-numeric: tabular-nums; }
.fv-gen-sub { text-align: center; font-size: 12.5px; color: var(--fv-muted); margin-top: 12px; }

/* ---------- Result — the hero ---------- */
.fv-result b { letter-spacing: -.02em; }
.fv-reveal {
  position: relative; border-radius: var(--fv-r); overflow: hidden; aspect-ratio: 4/3;
  background: var(--fv-surface-3); cursor: ew-resize; user-select: none; -webkit-user-select: none;
  box-shadow: inset 0 0 0 1px rgba(22,23,27,.08), 0 10px 30px rgba(16,17,21,.10);
  touch-action: none;
}
.fv-reveal img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.fv-reveal .fv-after { clip-path: inset(0 0 0 var(--fv-pos,50%)); }
.fv-rlabel {
  position: absolute; bottom: 12px; padding: 4px 12px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; color: #fff; background: rgba(0,0,0,.55);
  pointer-events: none;
}
.fv-rlabel.b { left: 12px; }
.fv-rlabel.a { right: 12px; }
.fv-handle {
  position: absolute; top: 0; bottom: 0; left: var(--fv-pos,50%); width: 2px;
  background: #fff; transform: translateX(-1px); pointer-events: none; box-shadow: 0 0 0 1px rgba(0,0,0,.08);
}
.fv-handle::after {
  content:""; position: absolute; top: 50%; left: 50%; width: 40px; height: 40px;
  transform: translate(-50%,-50%); border-radius: 999px; background: #fff;
  box-shadow: 0 4px 16px rgba(16,17,21,.25);
}
.fv-handle svg {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
  z-index: 1; color: #16171B; width: 18px; height: 18px;
}
.fv-single { width: 100%; border-radius: var(--fv-r); box-shadow: inset 0 0 0 1px rgba(22,23,27,.08); }

/* ---------- Error ---------- */
.fv-error { text-align: center; padding: 12px 8px 0; color: var(--fv-ink); font-size: 14px; }
.fv-error::before {
  content: "!"; display: grid; place-items: center;
  width: 54px; height: 54px; margin: 8px auto 14px; border-radius: 999px;
  background: var(--fv-danger-soft); color: var(--fv-danger);
  font-size: 24px; font-weight: 700;
}

/* ---------- Loading (product lookup / fallback) ---------- */
.fv-loading { text-align: center; padding: 40px 20px; }
.fv-loading b { display: block; font-size: 17px; font-weight: 600; letter-spacing: -.02em; margin-top: 16px; }
.fv-loading small { display: block; color: var(--fv-muted); font-size: 12.5px; margin-top: 4px; }
.fv-spinner {
  width: 34px; height: 34px; margin: 0 auto; border-radius: 999px;
  border: 3px solid var(--fv-accent-soft); border-top-color: var(--fv-accent);
  animation: fvspin .9s linear infinite;
}
@keyframes fvspin { to { transform: rotate(360deg); } }

/* ---------- Footer: sticky CTA + powered-by ---------- */
.fv-foot {
  flex: 0 0 auto;
  padding: 12px 18px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--fv-hairline); background: var(--fv-surface);
}
.fv-cta-row { margin-bottom: 8px; }
.fv-cta-row .fv-actions { margin-top: 0; }
.fv-powered { text-align: center; font-size: 11px; color: var(--fv-faint); }

/* ---------- Auto-inserted product page button ---------- */
.fv-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 22px; border: none; border-radius: 14px; cursor: pointer;
  background: #1F6F5C; color: #fff;
  font-family: "General Sans", ui-sans-serif, system-ui, sans-serif;
  font-size: 15px; font-weight: 600; letter-spacing: -.01em;
  box-shadow: 0 6px 18px rgba(31,111,92,.28);
  transition: background .13s ease, transform .13s ease, box-shadow .13s ease;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.fv-btn:hover { background: #1B6151; }
.fv-btn:active { transform: translateY(1px); background: #175344; box-shadow: 0 3px 10px rgba(31,111,92,.24); }
.fv-btn svg { width: 18px; height: 18px; }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .fv-overlay *, .fv-overlay *::before, .fv-overlay *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; }
  .fv-gen-sweep, .fv-gen-line { display: none; }
  .fv-step, .fv-modal, .fv-overlay { animation: none; }
}

/* ---------- RTL ---------- */
.fv-overlay[dir="rtl"] .fv-rlabel.b { left: auto; right: 12px; }
.fv-overlay[dir="rtl"] .fv-rlabel.a { right: auto; left: 12px; }
