/* STL Spawn — storefront configurator widget styles.
 * Everything is scoped under #stlspawn-widget / .stlspawn so nothing leaks
 * into the WooCommerce theme. Neutral palette, reads well on a light store.
 */

/* Variables + base typography apply to ANY mount host: the combined #stlspawn-widget OR the
 * split #stlspawn-preview / #stlspawn-controls (both get the .stlspawn class from the JS). */
.stlspawn {
  --sp-accent: #7d54c0;
  --sp-accent-press: #6a45ab;
  --sp-accent-glow: rgba(125, 84, 192, .4);   /* selected-bead glow; theme may re-point */
  --sp-ink: #2b2440;
  --sp-muted: #8a82a0;
  --sp-line: #e7e3f0;
  --sp-bg: #f6f4fb;
  --sp-stage-bg: #efeaf8;
  --sp-card: #ffffff;
  --sp-radius: 14px;

  box-sizing: border-box;
  width: 100%;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: var(--sp-ink);
  line-height: 1.45;
}

/* Combined mount: the widget lays itself out as two columns (preview | controls).
 * In SPLIT mode the theme owns placement, so no grid is imposed on the hosts. */
#stlspawn-widget.stlspawn {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
  align-items: start;
}

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

.stlspawn [hidden] { display: none !important; }

/* ---------------------------------------------------------------- stage/3D */
.stlspawn .stlspawn-stage {
  position: relative;
  width: 100%;
  min-height: 380px;
  aspect-ratio: 1 / 1;
  background: radial-gradient(120% 120% at 50% 20%, #ffffff 0%, var(--sp-stage-bg) 100%);
  border: 1px solid var(--sp-line);
  border-radius: var(--sp-radius);
  overflow: hidden;
}
.stlspawn .stlspawn-canvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
  touch-action: none;
}
/* floating dimension labels overlaid on the 3D preview (W / H / D) */
.stlspawn .stlspawn-dim-label {
  position: absolute;
  top: 0; left: 0;
  pointer-events: none;
  background: rgba(43, 36, 64, 0.82);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .3px;
  line-height: 1;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
  z-index: 4;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
}
.stlspawn .stlspawn-hint {
  position: absolute;
  bottom: 12px; left: 50%;
  transform: translateX(-50%);
  font-size: 11.5px;
  color: #6f6890;
  background: rgba(255, 255, 255, 0.72);
  padding: 4px 12px;
  border-radius: 999px;
  pointer-events: none;
  white-space: nowrap;
}

/* spinner */
.stlspawn .stlspawn-spinner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(246, 244, 251, 0.45);
  pointer-events: none;
}
.stlspawn .stlspawn-spinner span {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--sp-accent);
  animation: stlspawn-bounce 1s infinite ease-in-out;
}
.stlspawn .stlspawn-spinner span:nth-child(2) { animation-delay: .16s; background: #e86a82; }
.stlspawn .stlspawn-spinner span:nth-child(3) { animation-delay: .32s; }
@keyframes stlspawn-bounce {
  0%, 80%, 100% { transform: scale(.4); opacity: .5; }
  40% { transform: scale(1); opacity: 1; }
}

/* ---------------------------------------------------------------- controls */
.stlspawn .stlspawn-controls {
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--sp-card);
  border: 1px solid var(--sp-line);
  border-radius: var(--sp-radius);
  padding: 20px;
}
.stlspawn .stlspawn-field { display: flex; flex-direction: column; gap: 8px; }
.stlspawn .stlspawn-label {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--sp-muted);
}
.stlspawn .stlspawn-size-val { color: var(--sp-accent); font-weight: 800; }

.stlspawn .stlspawn-name {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--sp-line);
  border-radius: 10px;
  font-size: 20px;
  font-weight: 700;
  color: var(--sp-ink);
  background: #fff;
}
.stlspawn .stlspawn-name:focus {
  outline: none;
  border-color: var(--sp-accent);
  box-shadow: 0 0 0 3px rgba(125, 84, 192, 0.14);
}

/* swatches — glossy filament "beads" (single-colour, picked from the library) */
.stlspawn .stlspawn-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}
.stlspawn .stlspawn-swatch {
  position: relative;
  width: 54px; height: 54px;
  padding: 0;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  overflow: hidden;   /* keeps the sheen inside the bead; the outset rings are shadows, unclipped */
  /* solid filament colour + a soft top-left sheen so it reads as a glossy printed bead */
  background:
    radial-gradient(circle at 33% 27%, rgba(255, 255, 255, .6), rgba(255, 255, 255, 0) 45%),
    var(--sw-body, #ccc);
  box-shadow:
    inset 0 -4px 7px rgba(0, 0, 0, .22),
    inset 0 3px 6px rgba(255, 255, 255, .35),
    0 3px 8px rgba(70, 45, 20, .18);
  transition: transform .18s cubic-bezier(.34, 1.56, .64, 1), box-shadow .18s ease;
}
.stlspawn .stlspawn-swatch:hover { transform: translateY(-2px) rotate(-3deg); }
.stlspawn .stlspawn-swatch.is-active,
.stlspawn .stlspawn-swatch.is-active:hover {
  transform: scale(1.1) translateY(-2px);
  box-shadow:
    inset 0 -4px 7px rgba(0, 0, 0, .22),
    inset 0 3px 6px rgba(255, 255, 255, .4),
    0 0 0 3px var(--sp-card),
    0 0 0 5px var(--sp-accent),
    0 6px 16px var(--sp-accent-glow, rgba(125, 84, 192, .4));
}
/* out-of-stock: greyed, struck through, not clickable */
.stlspawn .stlspawn-swatch.is-oos {
  cursor: not-allowed;
  opacity: 0.4;
  filter: grayscale(0.5);
}
.stlspawn .stlspawn-swatch.is-oos::after {
  content: '';
  position: absolute;
  left: 6px; right: 6px; top: 50%;
  height: 2px;
  background: rgba(0, 0, 0, 0.55);
  transform: rotate(-45deg);
}
.stlspawn .stlspawn-swatch.is-oos:hover { transform: none; }

/* custom free-picker chip — an <input type=color> sized like a bead */
.stlspawn .stlspawn-swatch-customwrap {
  padding: 0;
  background:
    radial-gradient(circle at 33% 27%, rgba(255, 255, 255, .55), rgba(255, 255, 255, 0) 45%),
    conic-gradient(from 0deg, #e86a82, #f4c430, #57c785, #4aa3df, #7d54c0, #e86a82);
}
.stlspawn .stlspawn-swatch-custominput {
  -webkit-appearance: none;
  appearance: none;
  width: 100%; height: 100%;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}
.stlspawn .stlspawn-swatch-custominput::-webkit-color-swatch-wrapper { padding: 0; }
.stlspawn .stlspawn-swatch-custominput::-webkit-color-swatch { border: none; border-radius: 50%; }

@media (prefers-reduced-motion: reduce) {
  .stlspawn .stlspawn-swatch,
  .stlspawn .stlspawn-swatch:hover,
  .stlspawn .stlspawn-swatch.is-active { transition: none; }
}

/* dropdowns (font picker, per-letter colour) */
.stlspawn .stlspawn-select,
.stlspawn .stlspawn-letter-select {
  border: 1px solid var(--sp-line);
  border-radius: 8px;
  background: #fff;
  color: var(--sp-ink);
  font-weight: 600;
  cursor: pointer;
}
.stlspawn .stlspawn-select { width: 100%; padding: 10px 12px; font-size: 14px; }
.stlspawn .stlspawn-letter-select { padding: 4px 4px; font-size: 12px; max-width: 74px; }

/* per-letter multicolour */
.stlspawn .stlspawn-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--sp-ink);
  cursor: pointer;
}
.stlspawn .stlspawn-check input[type="checkbox"] { accent-color: var(--sp-accent); width: 16px; height: 16px; }
.stlspawn .stlspawn-letters-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}
.stlspawn .stlspawn-letter-cell {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.stlspawn .stlspawn-letter-cell input[type="color"] { width: 30px; height: 26px; }
.stlspawn .stlspawn-letter-ch {
  font-size: 12px;
  font-weight: 700;
  color: var(--sp-muted);
}

/* admin-only diagnostics, never rendered for a customer */
.stlspawn .stlspawn-admin-note {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-left: 3px solid #b32d2e;
  background: #fff5f5;
  font-size: 12px;
  line-height: 1.5;
  color: #6b2b2b;
}

/* size + base sliders
 *
 * Built from scratch rather than left native. WooCommerce themes style bare
 * `input` selectors freely -- a 44px height, a border, a background, a padding
 * -- and every one of those lands on a range input too, which turns the slider
 * into what looks like an empty text box with no handle. A range that a theme
 * can dress is a range that eventually stops looking draggable, so nothing here
 * is inherited: appearance, track and thumb are all declared, in both engines.
 */
.stlspawn input[type="range"].stlspawn-size,
.stlspawn input[type="range"].stlspawn-base {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 22px;               /* the hit area, not the track */
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  outline: none;
  accent-color: var(--sp-accent);
  cursor: pointer;
  touch-action: pan-y;        /* let a finger drag the handle, not the page */
  min-height: 0;              /* themes love a min-height on form controls */
  line-height: normal;
}
.stlspawn input[type="range"].stlspawn-size:focus-visible,
.stlspawn input[type="range"].stlspawn-base:focus-visible {
  outline: 2px solid var(--sp-accent);
  outline-offset: 3px;
}
/* WebKit / Blink */
.stlspawn input[type="range"].stlspawn-size::-webkit-slider-runnable-track,
.stlspawn input[type="range"].stlspawn-base::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: #e4dff0;
  border: 0;
}
.stlspawn input[type="range"].stlspawn-size::-webkit-slider-thumb,
.stlspawn input[type="range"].stlspawn-base::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -6px;           /* centre the 18px thumb on the 6px track */
  border-radius: 50%;
  background: var(--sp-accent);
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .28);
  cursor: pointer;
}
/* Firefox */
.stlspawn input[type="range"].stlspawn-size::-moz-range-track,
.stlspawn input[type="range"].stlspawn-base::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: #e4dff0;
  border: 0;
}
.stlspawn input[type="range"].stlspawn-size::-moz-range-thumb,
.stlspawn input[type="range"].stlspawn-base::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--sp-accent);
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .28);
  cursor: pointer;
}
.stlspawn .stlspawn-base-val { color: var(--sp-accent); font-weight: 800; }

/* price */
.stlspawn .stlspawn-price {
  display: flex;
  align-items: baseline;
  gap: 10px;
  background: linear-gradient(90deg, #f3eeff, #fbf0f3);
  border: 1px solid var(--sp-line);
  border-radius: 12px;
  padding: 12px 14px;
  min-height: 52px;
}
.stlspawn .stlspawn-price-amt {
  font-size: 26px;
  font-weight: 800;
  color: var(--sp-accent);
  letter-spacing: .3px;
}
.stlspawn .stlspawn-price-amt:empty::before {
  content: '—';
  color: var(--sp-muted);
  font-weight: 700;
}
.stlspawn .stlspawn-price-sub {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--sp-muted);
}

/* finished dimensions (W × H × D) */
.stlspawn .stlspawn-dims {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px 10px;
  font-size: 12.5px;
  color: var(--sp-ink);
}
.stlspawn .stlspawn-dims-label {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--sp-muted);
}
.stlspawn .stlspawn-dims-val { font-weight: 800; color: var(--sp-accent); }
.stlspawn .stlspawn-dims-axes { font-size: 11px; color: var(--sp-muted); }

/* message line */
.stlspawn .stlspawn-msg {
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.5;
  color: var(--sp-muted);
  background: #faf8ff;
  border: 1px solid var(--sp-line);
  border-radius: 10px;
  padding: 9px 12px;
}
.stlspawn .stlspawn-msg.is-error {
  color: #b23a52;
  background: #fdf0f3;
  border-color: #f3d5dd;
}

/* add to cart */
.stlspawn .stlspawn-cart {
  width: 100%;
  padding: 15px;
  border: none;
  border-radius: 12px;
  background: var(--sp-accent);
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: .4px;
  cursor: pointer;
  transition: transform .08s ease, background .2s ease, opacity .2s ease;
}
.stlspawn .stlspawn-cart:hover { background: var(--sp-accent-press); }
.stlspawn .stlspawn-cart:active { transform: translateY(1px); }
.stlspawn .stlspawn-cart:disabled { opacity: .55; cursor: default; }
/* "Match my theme" mode sets the button's colours as INLINE styles (which outrank the
 * :hover rule above), so hover feedback comes from a filter instead. */
.stlspawn .stlspawn-cart.is-theme-matched:hover { filter: brightness(.92); }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 820px) {
  #stlspawn-widget.stlspawn {
    grid-template-columns: 1fr;
  }
  .stlspawn .stlspawn-stage {
    min-height: 320px;
    aspect-ratio: 4 / 3;
  }
}
