/* ============================================================
   CAPELY: Try It On section
   Owned by Agent 3. Tokens only, per DESIGN-CONTRACT.md #2.
   ============================================================ */

.tryon-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 360px);
  gap: clamp(22px, 3vw, 40px);
  align-items: start;
  margin-top: clamp(36px, 4vw, 52px);
}
@media (max-width: 860px) {
  .tryon-panel { grid-template-columns: 1fr; }
}

.tryon-stage { min-width: 0; }

/* ---------- the 3D stage ----------
   .card (site.css) supplies the wash, hairline border and radius. This file
   only adds sizing and the state machine on top of it. */
.tryon-canvas-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 5;
  max-height: 560px;
  overflow: hidden;
}

.tryon-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: grab;
  -webkit-user-select: none;
  user-select: none;
  transition: opacity var(--t) var(--e-out);
}
.tryon-canvas-wrap[data-state="ready"] .tryon-canvas { opacity: 1; }
.tryon-canvas-wrap.is-dragging .tryon-canvas { cursor: grabbing; }

.tryon-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 32px;
  text-align: center;
  color: var(--text-mute);
  font-size: 14px;
  line-height: 1.65;
}
/* The class above sets display:flex on every .tryon-overlay regardless of
   the hidden attribute, and that author rule beats the UA stylesheet's own
   [hidden]{display:none} outright (origin wins before specificity is even
   compared). Without this line every overlay stacks and renders at once. */
.tryon-overlay[hidden] { display: none; }
.tryon-overlay-icon { width: 38px; height: 38px; color: var(--text-faint); }
.tryon-overlay[data-overlay="error"] .tryon-overlay-icon { color: var(--danger); }
.tryon-overlay[data-overlay="error"] p { color: var(--text-dim); }

/* rotating loader ring: transform only, killed under reduced motion rather
   than sped up, per DESIGN-CONTRACT.md #4 */
.tryon-spinner {
  width: 32px;
  height: 32px;
  border-radius: var(--r-pill);
  border: 3px solid var(--hairline-strong);
  border-top-color: var(--accent);
  animation: tryon-spin 0.8s linear infinite;
}
@keyframes tryon-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .tryon-spinner { animation: none; border-top-color: var(--hairline-strong); }
}

/* ---------- cape switcher ---------- */
.tryon-cape-switch {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 18px;
}
.tryon-arrow {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  color: var(--text-dim);
  transition: color var(--t-fast), border-color var(--t-fast), background var(--t-fast);
}
.tryon-arrow svg { width: 18px; height: 18px; }
.tryon-arrow:hover { color: var(--text); border-color: var(--hairline-strong); background: var(--surface-3); }
.tryon-arrow[disabled] { opacity: 0.4; pointer-events: none; }

.tryon-cape-name {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 220px;
  overflow-wrap: anywhere;
  text-align: center;
  font-family: 'Outfit', sans-serif;
  font-size: 15.5px;
  font-weight: 600;
  color: var(--text);
}

/* ---------- controls column ---------- */
.tryon-controls { display: flex; flex-direction: column; gap: 18px; min-width: 0; }

.tryon-label {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
}

.tryon-input-row { display: flex; gap: 10px; }

.tryon-input {
  flex: 1 1 auto;
  min-width: 0;
  height: 44px;
  padding: 0 14px;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: 14.5px;
  transition: border-color var(--t-fast), background var(--t-fast);
}
.tryon-input::placeholder { color: var(--text-faint); }
.tryon-input:hover { border-color: var(--hairline-strong); }
.tryon-input:focus { background: var(--surface-3); }
.tryon-input.is-invalid { border-color: var(--danger); }
.tryon-input[disabled] { opacity: 0.6; }

.tryon-input-row .btn { flex: 0 0 auto; position: relative; }

.tryon-spinner-btn {
  width: 15px;
  height: 15px;
  border-radius: var(--r-pill);
  /* --on-accent at partial strength, derived rather than a hand-picked rgba
     (DESIGN-CONTRACT.md #2: no invented colour values in section CSS). */
  border: 2px solid color-mix(in srgb, var(--on-accent) 35%, transparent);
  border-top-color: var(--on-accent);
  animation: tryon-spin 0.7s linear infinite;
}
@media (prefers-reduced-motion: reduce) {
  .tryon-spinner-btn { animation: none; }
}

.tryon-hint {
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--text-mute);
}

/* ---------- cape info + buy card ---------- */
.tryon-cape-info { padding: 18px; }
.tryon-cape-info-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.tryon-cape-rarity {
  font-family: 'Outfit', sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}
.tryon-cape-price {
  font-family: 'Outfit', sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}
.tryon-cape-blurb {
  color: var(--text-dim);
  font-size: 13.5px;
  line-height: 1.65;
  margin-bottom: 16px;
}
.tryon-buy { width: 100%; }

@media (max-width: 480px) {
  .tryon-canvas-wrap { aspect-ratio: 3 / 4; }
}
