/* Your avatar: stage, body scan, measurements, try-on and colours. Scoped to [data-screen="avatar"] and .av- classes. */

[data-screen="avatar"] .av-seg { margin-bottom: 14px; }

/* ---------- Stage ---------- */
[data-screen="avatar"] .av-studio { position: relative; }
.av-stage {
  position: relative;
  height: clamp(340px, 47vh, 440px);
  border-radius: var(--r-lg);
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(120% 70% at 50% 18%, rgba(255, 255, 255, 0.42), transparent 62%),
    linear-gradient(176deg, var(--olive-50) 0%, color-mix(in srgb, var(--olive-50) 52%, var(--surface-2)) 58%, var(--surface-2) 100%);
  box-shadow: inset 0 0 0 1px var(--line);
  transition: height 0.35s var(--ease);
}
.av-stage[data-mode="measure"] {
  position: sticky;
  top: calc(var(--safe-top) + 8px);
  z-index: 5;
  height: clamp(270px, 36vh, 340px);
  box-shadow: inset 0 0 0 1px var(--line), 0 10px 24px -14px rgba(58, 26, 51, 0.35);
}
.av-floor {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 13%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0.06));
  border-top: 1px solid rgba(86, 99, 63, 0.16);
  z-index: 0;
}
.av-layer { position: absolute; left: 0; right: 0; top: 30px; bottom: 6px; z-index: 1; --span: 368; }
.av-figure, .av-guide { position: absolute; inset: 0; pointer-events: none; }
/* The SVG is taller than the layer: viewBox y (432 - span)…432 fills it, soles near the bottom. */
.av-figure svg, .av-guide svg {
  position: absolute;
  left: 50%;
  bottom: calc(-100% * 8 / var(--span));
  height: calc(100% * 440 / var(--span));
  width: auto;
  max-width: none;
  transform: translateX(-50%);
}
.av-figure { transition: opacity 0.45s var(--ease), filter 0.45s var(--ease); }
.av-figure.reveal svg { animation: av-reveal 0.75s var(--ease) both; }
@keyframes av-reveal {
  from { opacity: 0; transform: translateX(-50%) translateY(10px) scale(0.97); filter: blur(3px); }
  to { opacity: 1; transform: translateX(-50%); filter: none; }
}

/* Ruler on the left, labelled vertically like the video */
.av-ruler {
  position: absolute;
  left: 24px;
  top: 21%;
  bottom: 4.6%;
  width: 1px;
  background: color-mix(in srgb, var(--ink-2) 55%, transparent);
  transition: top 0.3s var(--ease), opacity 0.3s;
}
.av-ruler::before, .av-ruler::after {
  content: '';
  position: absolute;
  left: -5px;
  width: 11px;
  height: 1px;
  background: inherit;
}
.av-ruler::before { top: 0; }
.av-ruler::after { bottom: 0; }
.av-ruler-label {
  position: absolute;
  left: 9px;
  top: 50%;
  transform: translateY(-50%) rotate(180deg);
  writing-mode: vertical-rl;
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--ink-2);
  opacity: 0.85;
  white-space: nowrap;
}
.av-ruler-value {
  position: absolute;
  top: -9px;
  left: 10px;
  padding: 2px 7px;
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--plum);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: var(--shadow-1);
  opacity: 0;
  transform: translateY(2px);
  transition: opacity 0.25s, transform 0.25s var(--ease);
}
.av-stage[data-mode="measure"] .av-ruler-value { opacity: 1; transform: none; }

/* Badge */
.av-badge {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 4;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: var(--r-pill);
  background: rgba(252, 249, 244, 0.9);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 500;
  box-shadow: var(--shadow-1);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.av-badge-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--olive);
  animation: av-pulse 1.1s ease-in-out infinite;
}
@keyframes av-pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.35; transform: scale(0.75); } }

/* Camera feed, guide, scanline, steps */
.av-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
  opacity: 0;
  z-index: 0;
  transition: opacity 0.4s;
  background: var(--plum-700);
}
.av-camtint {
  position: absolute;
  inset: 0;
  z-index: 0;
  opacity: 0;
  background: linear-gradient(180deg, rgba(58, 26, 51, 0.25), rgba(58, 26, 51, 0) 30%, rgba(58, 26, 51, 0) 70%, rgba(58, 26, 51, 0.35));
  transition: opacity 0.4s;
  pointer-events: none;
}
.av-guide { opacity: 0; transition: opacity 0.35s; }
.av-guide ellipse, .av-guide path {
  fill: rgba(255, 255, 255, 0.06);
  stroke: var(--olive-700);
  stroke-width: 1.4;
  stroke-dasharray: 5 4;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}
.av-stage .scanline { display: none; z-index: 3; }
.av-step {
  position: absolute;
  left: 50%;
  bottom: 22px;
  z-index: 4;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100% - 40px);
  padding: 8px 14px;
  border-radius: var(--r-pill);
  background: rgba(252, 249, 244, 0.94);
  color: var(--plum);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-2);
  transform: translate(-50%, 8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.3s var(--ease);
  white-space: nowrap;
}
.av-step > span:last-child { overflow: hidden; text-overflow: ellipsis; }
.av-step-dot {
  flex: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid var(--olive-100);
  border-top-color: var(--olive);
  animation: spin 0.8s linear infinite;
}
.av-progress {
  position: absolute;
  left: 20px; right: 20px; bottom: 11px;
  z-index: 4;
  height: 3px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.5);
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.25s;
}
.av-progress span { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--olive); transition: width 0ms linear; }

.av-stage:is([data-state="starting"], [data-state="framing"], [data-state="scanning"]) .av-step { opacity: 1; transform: translate(-50%, 0); }
.av-stage:is([data-state="framing"], [data-state="scanning"]) .av-guide { opacity: 1; }
.av-stage[data-state="scanning"] .scanline { display: block; }
.av-stage[data-state="scanning"] .av-progress { opacity: 1; }
/* No camera (or still asking): scan runs over a soft silhouette of the avatar */
.av-stage:is([data-state="starting"], [data-state="framing"], [data-state="scanning"]) .av-figure { opacity: 0.42; filter: grayscale(1) contrast(0.7) brightness(1.08); }
/* Live camera: show the mirrored feed, hide the figure, white guide */
.av-stage.has-camera .av-video, .av-stage.has-camera .av-camtint { opacity: 1; }
.av-stage.has-camera .av-figure, .av-stage.has-camera .av-floor, .av-stage.has-camera .av-ruler { opacity: 0; }
.av-stage.has-camera .av-guide ellipse, .av-stage.has-camera .av-guide path { stroke: #fff; fill: rgba(255, 255, 255, 0.04); }
.av-stage.has-camera .scanline { background: linear-gradient(90deg, transparent, #fff 20%, #fff 80%, transparent); box-shadow: 0 0 18px 6px rgba(255, 255, 255, 0.35); }

/* ---------- Panels under the stage ---------- */
.av-panel { margin-top: 14px; }
.av-scanpanel { display: flex; flex-direction: column; gap: 10px; }
.av-scanrow { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.av-scanrow .btn { min-height: 44px; }
.av-privacy {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 0;
  color: var(--ink-2);
  font-size: 12.5px;
  text-align: center;
}
.av-privacy svg { width: 14px; height: 14px; flex: none; color: var(--olive-700); }
.av-fine { margin: -4px 0 0; text-align: center; color: var(--muted); font-size: 12px; }
.av-fine .link-btn { font-size: 12px; padding: 0; min-height: 0; }
.av-note { align-items: flex-start; font-size: 13px; }
.av-note svg { margin-top: 1px; }
.av-note > span { flex: 1; }
.av-note .link-btn { flex: none; min-height: 32px; padding: 0 4px; }

/* Measurements */
.av-measure { display: flex; flex-direction: column; gap: 12px; }
.av-mcard {
  padding: 16px 16px 14px;
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-1);
}
.av-mhead { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }
.av-unit { font-size: 12px; color: var(--muted); }
.av-slider { padding: 8px 0 4px; }
.av-slider + .av-slider { border-top: 1px solid var(--line); }
.av-slider-head { display: flex; align-items: center; gap: 4px; }
.av-slider-head label { font-size: 14.5px; font-weight: 500; color: var(--ink); }
.av-val {
  min-width: 64px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-size: 15px;
  font-weight: 600;
  color: var(--plum);
}
.av-step-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin: -4px 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--olive-700);
  font-size: 22px;
  line-height: 1;
}
.av-step-btn:active { background: var(--olive-50); }
.av-range {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 32px;
  margin: 0;
  background: transparent;
  --p: 50%;
}
.av-range::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--olive) 0 var(--p), var(--surface-3) var(--p) 100%);
}
.av-range::-moz-range-track { height: 6px; border-radius: 6px; background: var(--surface-3); }
.av-range::-moz-range-progress { height: 6px; border-radius: 6px; background: var(--olive); }
.av-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 26px;
  height: 26px;
  margin-top: -10px;
  border-radius: 50%;
  background: var(--surface);
  border: 0;
  box-shadow: 0 1px 3px rgba(58, 26, 51, 0.22), 0 0 0 1px var(--line-strong);
}
.av-range::-moz-range-thumb {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--surface);
  border: 0;
  box-shadow: 0 1px 3px rgba(58, 26, 51, 0.22), 0 0 0 1px var(--line-strong);
}
.av-range:focus-visible { outline: none; }
.av-range:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px var(--olive-100), 0 0 0 1px var(--olive); }
.av-hint { display: flex; gap: 8px; margin: 10px 0 0; color: var(--muted); font-size: 12.5px; line-height: 1.4; }
.av-hint svg { width: 15px; height: 15px; flex: none; margin-top: 1px; color: var(--olive-700); }

.av-group + .av-group { margin-top: 16px; }
.av-glabel { display: block; margin-bottom: 10px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.av-swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.av-swatch {
  position: relative;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--sw);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
  transition: transform 0.15s var(--ease), box-shadow 0.15s;
}
.av-swatch:active { transform: scale(0.94); }
.av-swatch span { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: rgba(252, 249, 244, 0.92); color: var(--olive-700); opacity: 0; transform: scale(0.6); transition: opacity 0.15s, transform 0.2s var(--ease); }
.av-swatch span svg { width: 14px; height: 14px; }
.av-swatch[aria-pressed="true"] { box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12), 0 0 0 2px var(--bg), 0 0 0 4px var(--olive); }
.av-swatch[aria-pressed="true"] span { opacity: 1; transform: none; }
.av-measure .chips .chip { min-height: 40px; }
.av-savefoot { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.av-undo { min-height: 36px; }

/* ---------- Try-on ---------- */
.av-try {
  margin-top: 18px;
  padding: 16px 18px 16px;
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}
.av-try-head { display: flex; align-items: center; gap: 14px; }
.av-try-icon { display: grid; place-items: center; width: 34px; height: 34px; flex: none; color: var(--rose-ink); }
.av-try-icon svg { width: 30px; height: 30px; stroke-width: 1.4; }
.av-try-title { margin: 0; font-family: var(--font-sans); font-size: 16px; font-weight: 600; color: var(--ink); line-height: 1.25; }
.av-try-head p { margin: 2px 0 0; color: var(--ink-2); font-size: 13px; }
.av-try .av-chips { margin: 14px -18px 0; padding: 2px 18px; }
.av-strip {
  display: flex;
  gap: 10px;
  margin: 12px -18px 0;
  padding: 4px 18px 4px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scroll-padding-inline: 18px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.av-strip::-webkit-scrollbar { display: none; }
.av-strip > div { flex: none; scroll-snap-align: start; }
.av-thumb {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 78px;
  padding: 0;
  border: 0;
  background: none;
  text-align: center;
}
.av-thumb-img {
  position: relative;
  display: block;
  width: 78px;
  height: 88px;
  border-radius: 16px;
  overflow: hidden;
  background: color-mix(in srgb, var(--tint) 12%, var(--surface-2));
  transition: transform 0.15s var(--ease), box-shadow 0.18s;
}
.av-thumb-img img { width: 100%; height: 100%; object-fit: cover; }
.av-thumb:active .av-thumb-img { transform: scale(0.96); }
.av-thumb[aria-pressed="true"] .av-thumb-img { box-shadow: 0 0 0 2px var(--olive), 0 6px 14px -6px rgba(86, 99, 63, 0.6); }
.av-thumb-check {
  position: absolute;
  top: 6px; right: 6px;
  display: grid;
  place-items: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--olive);
  color: var(--on-olive);
  opacity: 0;
  transform: scale(0.5);
  transition: opacity 0.15s, transform 0.22s var(--ease);
}
.av-thumb-check svg { width: 14px; height: 14px; stroke-width: 2.2; }
.av-thumb[aria-pressed="true"] .av-thumb-check { opacity: 1; transform: none; }
.av-thumb-name {
  width: 100%;
  margin-top: 6px;
  font-size: 11.5px;
  line-height: 1.25;
  color: var(--ink-2);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  overflow-wrap: anywhere;
}
.av-thumb[aria-pressed="true"] .av-thumb-name { color: var(--plum); font-weight: 600; }
.av-try-actions { display: flex; gap: 6px; align-items: center; margin-top: 14px; }
.av-try-actions .btn.sm { min-height: 44px; }
.av-wearing { margin: 10px 0 0; font-size: 12.5px; color: var(--ink-2); line-height: 1.45; }
.av-wearing-label { font-weight: 600; color: var(--plum); }
.av-tip { margin-top: 12px; }
.av-try-foot { margin: 14px 0 0; padding-top: 12px; border-top: 1px solid var(--line); text-align: center; color: var(--muted); font-size: 12.5px; }

.av-try-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  padding: 20px 16px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  text-align: center;
}
.av-try-empty p { margin: 0; max-width: 280px; color: var(--ink-2); font-size: 13.5px; }
.av-try-empty .btn { min-height: 44px; }
.av-try-ghosts { display: flex; gap: 8px; }
.av-try-ghosts span {
  display: grid;
  place-items: center;
  width: 46px; height: 52px;
  border-radius: 14px;
  background: var(--surface);
  color: var(--khaki);
  border: 1.5px dashed var(--line-strong);
}
.av-try-ghosts svg { width: 24px; height: 24px; }

/* ---------- Colours that suit you ---------- */
.av-colours .section-head { align-items: center; }
.av-colours .link-btn { min-height: 44px; }
.av-quiz {
  padding: 18px;
  border-radius: var(--r-lg);
  background: var(--rose-50);
}
.av-quiz-top { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; }
.av-quiz-icon { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 50%; background: var(--surface); color: var(--rose-ink); }
.av-quiz-icon svg { width: 22px; height: 22px; }
.av-quiz-title { margin: 0; font-family: var(--font-serif); font-size: 21px; font-weight: 500; color: var(--plum); line-height: 1.15; }
.av-quiz-sub { margin: 2px 0 0; font-size: 13px; color: var(--ink-2); }
.av-q { padding: 12px 0; border-top: 1px solid rgba(176, 106, 147, 0.16); }
.av-q-text { display: flex; gap: 8px; margin: 0 0 10px; font-size: 14px; font-weight: 500; color: var(--ink); }
.av-q-num {
  display: grid;
  place-items: center;
  width: 20px; height: 20px;
  flex: none;
  border-radius: 50%;
  background: var(--surface);
  color: var(--rose-ink);
  font-size: 11.5px;
  font-weight: 600;
}
.av-quiz .chip { background: var(--surface); min-height: 40px; }
.av-quiz .chip[aria-pressed="true"] { background: var(--olive); }
.av-quiz > .btn { margin-top: 6px; }
.av-know { display: block; margin: 10px auto 0; min-height: 36px; }
.av-direct { margin-top: 8px; padding-top: 12px; border-top: 1px solid rgba(176, 106, 147, 0.16); }

.av-palette {
  padding: 18px;
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-1);
}
.av-pal-name { margin: 4px 0 0; font-family: var(--font-serif); font-size: 26px; font-weight: 500; color: var(--plum); line-height: 1.1; }
.av-pal-blurb { margin: 4px 0 0; color: var(--ink-2); font-size: 14px; }
.av-pal-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px 6px;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
}
.av-pal-grid li { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.av-pal-dot {
  width: 46px; height: 46px;
  border-radius: 50%;
  background: var(--sw);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1), 0 2px 6px -2px rgba(58, 26, 51, 0.25);
}
.av-pal-label { max-width: 100%; font-size: 11.5px; color: var(--ink-2); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.av-avoid { display: flex; gap: 8px; align-items: flex-start; margin: 16px 0 0; padding: 10px 12px; border-radius: var(--r-sm); background: var(--surface-2); font-size: 13px; color: var(--ink-2); }
.av-avoid svg { width: 15px; height: 15px; flex: none; margin-top: 1px; color: var(--muted); }
.av-avoid strong { color: var(--ink); font-weight: 600; }

.av-own { margin-top: 14px; padding: 14px; border-radius: var(--r-md); background: var(--olive-50); }
.av-own-title { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 14px; font-weight: 600; color: var(--plum); }
.av-own-check { display: grid; place-items: center; width: 20px; height: 20px; flex: none; border-radius: 50%; background: var(--olive); color: var(--on-olive); }
.av-own-check svg { width: 13px; height: 13px; stroke-width: 2.2; }
.av-own-sub { margin: 4px 0 0; font-size: 13px; color: var(--ink-2); }
.av-own-strip {
  display: flex;
  gap: 8px;
  margin: 12px -14px 0;
  padding: 2px 14px 2px;
  overflow-x: auto;
  scrollbar-width: none;
}
.av-own-strip::-webkit-scrollbar { display: none; }
.av-own-strip > div { flex: none; }
.av-own-item { position: relative; display: block; width: 58px; height: 64px; padding: 0; border: 0; background: none; }
.av-own-img {
  display: block;
  width: 100%; height: 100%;
  border-radius: 14px;
  overflow: hidden;
  background: color-mix(in srgb, var(--tint) 14%, var(--surface));
}
.av-own-img img { width: 100%; height: 100%; object-fit: cover; }
.av-own-item:active .av-own-img { transform: scale(0.95); }
.av-own-dot {
  position: absolute;
  right: -2px; bottom: -2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--sw);
  box-shadow: 0 0 0 2px var(--olive-50), inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}

.av-pair { display: flex; gap: 12px; align-items: center; margin-top: 12px; padding: 12px 14px; border-radius: var(--r-md); background: var(--rose-50); }
.av-pair-dots { position: relative; display: flex; flex: none; width: 46px; height: 30px; }
.av-pair-dots span {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--sw);
  box-shadow: 0 0 0 2px var(--rose-50), inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}
.av-pair-dots span + span { margin-left: -14px; }
.av-pair-title { margin: 0; font-size: 14px; font-weight: 600; color: var(--plum); }
.av-pair-body { margin: 2px 0 0; font-size: 13px; color: var(--ink-2); line-height: 1.4; }

/* ---------- Info sheet ---------- */
.av-info { display: flex; flex-direction: column; gap: 12px; }
.av-info-row { display: flex; gap: 12px; align-items: flex-start; padding: 4px 0; }
.av-info-icon { display: grid; place-items: center; width: 38px; height: 38px; flex: none; border-radius: 50%; background: var(--olive-50); color: var(--olive-700); }
.av-info-icon svg { width: 19px; height: 19px; }
.av-info-row strong { display: block; color: var(--plum); font-size: 15px; }
.av-info-row p { margin: 2px 0 0; color: var(--ink-2); font-size: 13.5px; }
.av-info .btn { margin-top: 2px; }
