/* ==========================================================================
   OstuGrupp — Variation swatches
   Colour circles for colour-like attributes, pill buttons for the rest.
   Uses the design tokens from main.css. Scoped to .ostu-swatches-field so it
   never touches the rest of the variations table.
   ========================================================================== */

/* Hide the native <select> once JS has taken over — but only then, so the form
   stays usable with JS disabled (progressive enhancement). */
.ostu-swatches-ready .ostu-swatches-field select {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Until JS is ready, hide our swatch buttons so there is no double control. */
.ostu-swatches-field .ostu-swatches { display: none; }
.ostu-swatches-ready .ostu-swatches-field .ostu-swatches { display: flex; }

.ostu-swatches {
  flex-wrap: wrap;
  gap: 10px;
  margin: 4px 0 2px;
  padding: 0;
}

/* ---- Shared swatch button ---- */
.ostu-swatch {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border: 1.5px solid var(--border);
  color: var(--slate);
  cursor: pointer;
  transition: border-color .18s ease, box-shadow .18s ease, color .18s ease, background .18s ease, transform .18s ease;
  font-family: var(--font-body);
}
.ostu-swatch:hover { border-color: rgba(5,150,105,.55); transform: translateY(-1px); }
.ostu-swatch:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

/* ---- Pill swatches (size / material / other) ---- */
.ostu-swatch--pill {
  min-height: 44px;
  min-width: 48px;
  padding: 0 16px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
}
.ostu-swatch--pill.is-selected {
  border-color: var(--green);
  background: rgba(5,150,105,.08);
  color: var(--green-dark);
  box-shadow: var(--shadow-green);
}

/* ---- Colour swatches (circles) ---- */
.ostu-swatch--colour {
  width: 44px;
  height: 44px;
  padding: 3px;
  border-radius: 50%;
}
.ostu-swatch--colour .ostu-swatch__chip {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: inherit; /* set inline; chip mirrors via parent style below */
  box-shadow: inset 0 0 0 1px rgba(15,23,42,.10);
}
/* The inline style sets the background ON the button; paint the chip from it. */
.ostu-swatch--colour { background-clip: padding-box; }
.ostu-swatch--colour .ostu-swatch__chip {
  background: inherit;
}
.ostu-swatch--colour.is-selected {
  border-color: var(--green);
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--green);
}
.ostu-swatch--colour.is-selected .ostu-swatch__chip {
  box-shadow: inset 0 0 0 1px rgba(15,23,42,.12);
}

/* Selected check mark for colour swatches (legible on any colour). */
.ostu-swatch--colour.is-selected::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 11px;
  height: 6px;
  border-left: 2.5px solid #fff;
  border-bottom: 2.5px solid #fff;
  transform: translate(-50%, -65%) rotate(-45deg);
  filter: drop-shadow(0 0 1px rgba(15,23,42,.45));
  pointer-events: none;
}

/* ---- Unavailable (incompatible with current selection) ---- */
.ostu-swatch.is-unavailable {
  cursor: not-allowed;
  opacity: .45;
}
.ostu-swatch.is-unavailable:hover {
  border-color: var(--border);
  transform: none;
}
/* Diagonal strike for unavailable colours/pills. */
.ostu-swatch.is-unavailable::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top right, transparent calc(50% - 1px), rgba(100,116,139,.7) 50%, transparent calc(50% + 1px));
  border-radius: inherit;
  pointer-events: none;
}

/* Tidy the WooCommerce variations table spacing around our control. */
.ostu-swatches-scope .variations td.value,
.ostu-swatches-scope .variations th.label { padding-block: 10px; }
.ostu-swatches-scope .variations th.label label { font-weight: 600; color: var(--slate-dark); }

/* Hide WooCommerce's "Clear" link clutter — swatch re-click clears instead. */
.ostu-swatches-ready .variations .reset_variations { font-size: 13px; color: var(--slate-500); }
.ostu-swatches-ready .variations .reset_variations:hover { color: var(--green); }
