/* =========================================================================
   Filament colour swatches and personalisation field.
   Swatch colours are sampled from the supplier's own filament photography
   and stored in the td_filament_colors option.
   ========================================================================= */

.swatches { display: grid; gap: 10px; }

.swatches__legend {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-sm);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
}
.swatches__chosen {
  font-weight: 400;
  color: var(--accent);
}

.swatches__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
  gap: 8px;
}

.swatch {
  position: relative;
  display: block;
  cursor: pointer;
  line-height: 0;
}
.swatch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
}

.swatch__dot {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 999px;
  background: var(--sw, var(--panel));
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.14);
  transition: transform .18s cubic-bezier(.2,.7,.3,1), box-shadow .18s ease;
}
.swatch:hover .swatch__dot { transform: scale(1.12); }

.swatch input:checked + .swatch__dot {
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,0.2),
    0 0 0 2px var(--bg),
    0 0 0 4px var(--accent);
  transform: scale(1.08);
}
.swatch input:focus-visible + .swatch__dot {
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,0.2),
    0 0 0 2px var(--bg),
    0 0 0 4px var(--info);
}

/* The name is announced to assistive tech and shown on hover, not stacked
   under every dot, which would wreck the grid. */
.swatch__name {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  .swatch__dot { transition: none; }
  .swatch:hover .swatch__dot { transform: none; }
}

/* ---------- Field hints ---------- */
.field__hint {
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--muted);
  opacity: .8;
}

/* ---------- Buybox as a form ---------- */
form.buybox { gap: var(--space-sm); }
form.buybox .field label { font-size: 0.86rem; }
form.buybox .btn { width: 100%; }

/* ---------- Palette display on the printing page ---------- */
.palette {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: var(--space-sm);
}
.palette__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  transition: border-color .18s ease, transform .18s ease;
}
.palette__item:hover { border-color: var(--muted); transform: translateY(-2px); }
.palette__dot {
  width: 22px;
  height: 22px;
  flex: none;
  border-radius: 999px;
  background: var(--sw, var(--panel));
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.16);
}
.palette__label { font-size: 0.86rem; color: var(--muted); line-height: 1.3; }

@media (prefers-reduced-motion: reduce) {
  .palette__item { transition: border-color .18s ease; }
}

/* ---------- Silk finishes ----------
   Silk filament is directional: it reads as a lit band, a darker turn, and a
   second highlight, not as one flat colour. The swatch is banded to match,
   over the sampled base tone. */
.swatch__dot--silk,
.palette__dot--silk {
  position: relative;
  overflow: hidden;
  background-color: var(--sw);
  background-image: linear-gradient(
    135deg,
    rgba(255,255,255,0.60) 0%,
    rgba(255,255,255,0.12) 20%,
    rgba(0,0,0,0.24) 45%,
    rgba(255,255,255,0.44) 66%,
    rgba(255,255,255,0.04) 86%,
    rgba(0,0,0,0.16) 100%
  );
}

/* A single sheen travels across on hover, the way the highlight moves when
   you turn a silk print in the light. It runs once, it does not loop. */
.swatch__dot--silk::after,
.palette__dot--silk::after {
  content: "";
  position: absolute;
  inset: -45%;
  background: linear-gradient(115deg, transparent 42%, rgba(255,255,255,0.55) 50%, transparent 58%);
  transform: translateX(-130%);
  transition: transform .7s cubic-bezier(.2,.7,.3,1);
  pointer-events: none;
}
.swatch:hover .swatch__dot--silk::after,
.swatch input:focus-visible + .swatch__dot--silk::after,
.palette__item:hover .palette__dot--silk::after { transform: translateX(130%); }

/* Finish tag in the palette list. */
.palette__finish {
  display: inline-block;
  margin-left: 7px;
  padding: 1px 7px;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  font-size: 0.7rem;
  color: var(--muted);
  vertical-align: middle;
}

@media (prefers-reduced-motion: reduce) {
  .swatch__dot--silk::after,
  .palette__dot--silk::after { display: none; }
}
