/* Virtual Try-on: the demo's own workspace only (media frames, face oval, scarf tiles, the 360).
   Everything else is the shell's (demo_shell/web/shell.css). Shell tokens only, no new colours,
   except the white oval and hint pill drawn over a live photo, where the photo is the background. */

/* ---------- the workspace ----------
   Photo, scarf, result. Three columns from 1360px, so the whole task (and the scarves) sits on one
   1080p screen; two columns with the scarves underneath on a tablet; one column on a phone, in the
   order the task runs. */
.tryon-work { display: grid; gap: 24px; align-items: start; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) {
  .tryon-work { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-areas: "you result" "picker picker"; }
  .tryon-you { grid-area: you; }
  .tryon-result { grid-area: result; }
  .tryon-picker { grid-area: picker; }
}
@media (min-width: 1360px) {
  .tryon-work { grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-areas: "you picker result"; align-items: stretch; }
}

/* ---------- the photo frames ---------- */
.tryon-frame {
  position: relative;
  aspect-ratio: 3 / 4;
  /* As wide as the card allows, but never taller than most of the screen. */
  width: min(100%, calc(min(640px, 72vh) * 3 / 4));
  margin-inline: auto;
  overflow: hidden;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  /* clear of the sticky header when the try-on scrolls the frame into view */
  scroll-margin: 84px 0 16px;
}
/* three columns: short enough that the Try button is on a 1080p screen without scrolling */
@media (min-width: 1360px) { .tryon-frame { width: min(100%, calc(clamp(420px, 100vh - 560px, 640px) * 3 / 4)); } }
.tryon-frame > video,
.tryon-frame > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
#cam { transform: scaleX(-1); }
/* Anything the frame starts showing (photo, render, video, the 360) settles in rather than snapping.
   Restarts on every hidden -> shown, so a tab switch gets it too. */
.tryon-frame > img, .tryon-frame > video, .tryon-frame > canvas { animation: tryon-in 0.45s var(--ease) both; }
#cam { animation-name: tryon-in-mirror; }
@keyframes tryon-in { from { opacity: 0; transform: scale(1.02); } }
@keyframes tryon-in-mirror { from { opacity: 0; transform: scaleX(-1) scale(1.02); } }
#resultVid { object-fit: contain; background: var(--surface-2); }

.tryon-blank { position: absolute; inset: 0; align-content: end; padding-bottom: 8%; }
.tryon-blank p { max-width: 24ch; font-size: 0.9375rem; }

/* Framing an upload: same oval, same 3:4, same result as the camera path. */
#crop, #spin { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
/* The 360 only turns sideways, so a vertical swipe over it still scrolls the page: on a phone it fills the screen. */
#spin { touch-action: pan-y; }
#crop { cursor: grab; }
#crop:active { cursor: grabbing; }
#spin { cursor: ew-resize; object-fit: cover; }
#spin:focus-visible { outline-offset: -4px; }

.tryon-zoom { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.tryon-zoom input { flex: 1; min-height: 44px; accent-color: var(--primary); }

/* The face oval: the demo's own motif. White over a live picture, which is the background there;
   on the empty frame it is drawn in the control edge colour so the frame says what it wants. */
.tryon-guide { position: absolute; inset: 0; pointer-events: none; }
.tryon-guide span {
  position: absolute; left: 50%; top: 41%; transform: translate(-50%, -50%);
  width: 47%; aspect-ratio: 3 / 4; border-radius: 50%;
  border: 1.5px dashed rgb(255 255 255 / 0.8);
}
.tryon-guide--idle span { border-color: var(--border-strong); }
.tryon-frame:has(#youImg:not([hidden])) .tryon-guide--idle,
.tryon-frame:has(#cam:not([hidden])) .tryon-guide--idle,
.tryon-frame:has(#crop:not([hidden])) .tryon-guide--idle { display: none; }

/* The chosen cloth fills the result frame until the render replaces it: the same macro the picker
   shows, so the two read as one fabric. (Zoomed into the flat lay it looked unrelated to the
   picker; the flat lay is a scale reference for the model, not a picture for people.) */
.tryon-cloth {
  position: absolute; inset: 0; pointer-events: none;
  background-size: cover; background-position: center;
  transition: opacity 0.5s var(--ease);
}

.tryon-spinhint {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
  padding: 6px 14px; border-radius: 999px;
  background: rgb(13 23 48 / 0.72); color: #ffffff;
  font-size: 0.875rem; font-weight: 700; white-space: nowrap; pointer-events: none; transition: opacity 0.3s;
}

/* Invitations and the busy state sit over the frame. */
.tryon-overlay {
  position: absolute; inset: 0; align-content: center; padding: 24px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
}
.tryon-overlay p { max-width: 28ch; }
.tryon-overlay .ds-btn { margin-top: 6px; }

/* The wait: steps (360 only), a bar against the measured time, the estimate and the count. */
.tryon-busy { gap: 12px; }
.tryon-bar { width: min(240px, 80%); height: 6px; border-radius: 6px; overflow: hidden; background: var(--border); }
.tryon-bar span {
  display: block; height: 100%; border-radius: inherit; transform-origin: left; transform: scaleX(0);
  background: linear-gradient(90deg, var(--btn-from), var(--btn-to));
  transition: transform 1s linear;
}
.tryon-busy__time { font-size: 0.875rem; font-variant-numeric: tabular-nums; }
.tryon-phases { display: grid; gap: 6px; margin: 2px 0; padding: 0; list-style: none; text-align: left; font-size: 0.875rem; }
.tryon-phases li { display: flex; align-items: center; gap: 8px; color: var(--text-muted); }
.tryon-phases li::before {
  content: ""; flex: none; width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--border-strong); box-sizing: border-box;
}
.tryon-phases li[data-state="now"] { color: var(--text); font-weight: 700; }
.tryon-phases li[data-state="now"]::before { border-color: var(--primary); border-right-color: transparent; animation: ds-spin 0.8s linear infinite; }
/* a check cut out of a green disc, so it reads on either theme's surface */
.tryon-phases li[data-state="done"]::before {
  border: 0; background: var(--success);
  -webkit-mask: var(--tryon-check) center / contain no-repeat; mask: var(--tryon-check) center / contain no-repeat;
}
.tryon-phases { --tryon-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cmask id='m'%3E%3Crect width='16' height='16' fill='white'/%3E%3Cpath d='M4.5 8.2 7 10.5l4.5-5' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/mask%3E%3Ccircle cx='8' cy='8' r='8' mask='url(%23m)'/%3E%3C/svg%3E"); }
/* the 360's step list says it already */
@media (min-height: 501px) { .tryon-busy:has(.tryon-phases:not([hidden])) > .ds-spinner { display: none; } }
/* A phone on its side: the frame is under 300px tall, too short for the step list, which was cut off at
   both ends. The title, bar and time stay, and the spinner keeps its place. */
@media (max-height: 500px) {
  .tryon-overlay { padding: 12px; }
  .tryon-busy .tryon-phases { display: none; }
}

.tryon-tabs { margin-bottom: 14px; }
.tryon-acts { margin-top: 14px; }
.tryon-msg { margin-top: 12px; }
.tryon-meta { margin-top: 12px; min-height: 1.4em; }
.tryon-notes { --stack: 6px; margin-top: 16px; }
/* the privacy note and the result line are read, not skimmed: no smaller than 14px */
.tryon-notes .ds-hint, .tryon-meta { font-size: 0.875rem; }

/* ---------- the scarves ---------- */
.tryon-how { margin-top: 24px; }
.tryon-swatches { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.tryon-swatch {
  flex-direction: column; align-items: stretch; gap: 0; padding: 0; overflow: hidden;
}
.tryon-swatch__cloth {
  width: 100%; height: auto; aspect-ratio: 1; object-fit: cover; background: var(--surface-2);
  transition: transform 0.35s var(--ease);
}
.tryon-swatch:hover:not(:disabled) .tryon-swatch__cloth { transform: scale(1.05); }
.tryon-swatch__name { padding: 10px 12px 2px; font-size: 0.875rem; font-weight: 700; line-height: 1.3; }
.tryon-swatch__price { padding: 0 12px 12px; color: var(--text-muted); font-size: 0.875rem; }
.tryon-swatch:disabled, .tryon-styles .ds-option:disabled { cursor: not-allowed; opacity: 0.6; }

.tryon-styles__title { margin: 20px 0 10px; font-size: 1rem; }
.tryon-styles { display: flex; flex-wrap: wrap; gap: 8px; }
.tryon-styles .ds-option { width: auto; font-weight: 600; font-size: 0.9375rem; }

/* full width under the two frames on a tablet: one row of six */
@media (min-width: 900px) and (max-width: 1359px) { .tryon-swatches { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
/* phone: one swipeable row running to the card's edges, the next tile peeking in, instead of a
   grid three screens tall between the photo and the result */
@media (max-width: 599px) {
  .tryon-swatches {
    grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: 42%;
    overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x mandatory; scrollbar-width: none;
    margin-inline: -16px; padding: 2px 16px 4px; scroll-padding-inline: 16px;
  }
  .tryon-swatches::-webkit-scrollbar { display: none; }
  .tryon-swatch { scroll-snap-align: start; }
}

/* ---------- how it works ---------- */
.tryon-how__lede { max-width: 60ch; margin-top: -4px; }
.tryon-steps {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px;
  margin: 20px 0 0; padding: 0; list-style: none; counter-reset: step;
}
.tryon-steps li { counter-increment: step; }
.tryon-steps li::before {
  content: counter(step); display: inline-grid; place-items: center; width: 28px; height: 28px; margin-bottom: 10px;
  border-radius: 50%; background: var(--accent-soft); color: var(--brand-ink); font-weight: 800; font-size: 0.875rem;
}
.tryon-steps p { margin-top: 6px; font-size: 0.9375rem; }
.tryon-steps .tryon-steps__facts { color: var(--text); font-size: 0.875rem; font-weight: 600; }
.tryon-notes-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 24px; }
.tryon-notes-grid .ds-well { padding: 16px; }
.tryon-notes-grid p { margin-top: 6px; font-size: 0.9375rem; }

@media (max-width: 899px) {
  .tryon-steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tryon-notes-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 599px) { .tryon-steps { grid-template-columns: minmax(0, 1fr); } }
