/* Buttons */

.button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: var(--control-h);
  padding: 0 24px;
  overflow: hidden;
  border-radius: var(--radius-m);
  font-size: var(--text-l);
  font-weight: 500;
  white-space: nowrap;
  transition: background-color 0.2s var(--ease), color 0.2s var(--ease), border-color 0.2s var(--ease), transform 0.25s var(--ease);
}

.button:active {
  transform: scale(0.98);
}

.button > span {
  position: relative;
  font-variant-numeric: tabular-nums;
}

.button-wide {
  width: 100%;
}

.button-well {
  background: var(--well);
}

.button-well:hover {
  background: var(--well-hover);
}

.button-soft {
  border-radius: 999px;
  background: var(--well);
  color: var(--ink);
}

.button-soft:hover {
  background: var(--well-hover);
}

.button-primary {
  --progress: 0;
  border-radius: 999px;
  background: var(--key);
  color: var(--key-ink);
  font-weight: 600;
}

.button-primary:hover {
  background: var(--key-hover);
}

.button-primary::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--key-hover);
  transform: scaleX(var(--progress));
  transform-origin: left;
  transition: transform 0.2s linear;
}

.button svg {
  position: relative;
}

.button.is-busy {
  cursor: progress;
}

/* The label keeps the width of its idle text; busy states show in its place without taking width. */

.button-label {
  display: grid;
}

.button-text,
.button-status {
  grid-area: 1 / 1;
  transition: opacity 0.2s var(--ease);
}

.button-status {
  display: flex;
  justify-content: center;
  justify-self: center;
  width: 0;
  white-space: nowrap;
  opacity: 0;
}

.button.is-busy .button-text {
  opacity: 0;
}

.button.is-busy .button-status {
  opacity: 1;
}

.dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 1em;
}

.dots i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  will-change: transform, opacity;
  animation: dot 1.2s ease-in-out infinite both;
}

.dots i:nth-child(2) {
  animation-delay: 0.16s;
}

.dots i:nth-child(3) {
  animation-delay: 0.32s;
}

@keyframes dot {
  0%,
  60%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }

  30% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

.icon-button {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  color: var(--ink-2);
  transition: background-color 0.2s var(--ease), color 0.2s var(--ease), opacity 0.2s var(--ease);
}

.icon-button:hover:not(:disabled) {
  background: var(--well-hover);
  color: var(--ink);
}

.icon-button:disabled {
  opacity: 0.35;
}

.icon-button-well {
  background: var(--well);
}

.chip {
  display: inline-grid;
  align-items: center;
  height: 46px;
  padding: 0 16px;
  border-radius: 999px;
  background: var(--well);
  color: var(--ink);
  font-size: var(--text-m);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  transition: background-color 0.2s var(--ease);
}

.chip:hover {
  background: var(--well-hover);
}

/* The chip is as wide as its widest preset (the hidden sizer row), so the buttons next to it never move;
   the live label and thumbnail sit together in the center. */

.chip-row {
  grid-area: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.chip-sizer {
  visibility: hidden;
}

.chip-frame {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
}

.chip-shape {
  border: 1.6px solid currentColor;
  border-radius: 4px;
  transition: width 0.35s var(--ease), height 0.35s var(--ease);
}

.text-button {
  align-self: flex-start;
  color: var(--ink-2);
  font-size: var(--text-l);
  text-decoration: underline;
  text-underline-offset: 5px;
  text-decoration-thickness: 1px;
  transition: color 0.2s var(--ease);
}

.text-button:hover {
  color: var(--ink);
}

/* Slider field */

.slider {
  --value: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--control-h);
  padding: 0 22px;
  overflow: hidden;
  border-radius: var(--radius-m);
  background: var(--well);
  cursor: ew-resize;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.slider-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: calc(var(--value) * 100%);
  background: rgba(255, 255, 255, 0.05);
}

.slider-fill::after {
  content: "";
  position: absolute;
  top: 17px;
  right: 0;
  bottom: 17px;
  width: 2px;
  border-radius: 2px;
  background: var(--ink-2);
  transition: background-color 0.2s var(--ease), top 0.2s var(--ease), bottom 0.2s var(--ease);
}

.slider:hover .slider-fill::after,
.slider.is-dragging .slider-fill::after {
  top: 12px;
  bottom: 12px;
  background: var(--ink);
}

.slider-label,
.slider-value {
  position: relative;
  pointer-events: none;
}

.slider-label {
  color: var(--ink-2);
  font-size: var(--text-l);
  transition: color 0.2s var(--ease);
}

.slider:hover .slider-label,
.slider.is-dragging .slider-label {
  color: var(--ink);
}

.slider-value {
  font-size: var(--text-m);
  font-variant-numeric: tabular-nums;
}

/* Segmented */

.segmented {
  position: relative;
  display: grid;
  grid-auto-columns: minmax(0, 1fr);
  grid-auto-flow: column;
  padding: 5px;
  border-radius: 20px;
  background: var(--well);
}

.segmented-indicator {
  position: absolute;
  top: 5px;
  bottom: 5px;
  left: 0;
  border-radius: 15px;
  background: var(--raised);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06), 0 2px 10px rgba(0, 0, 0, 0.3);
  transition: transform 0.4s var(--ease), width 0.4s var(--ease);
}

.segmented-indicator.is-instant {
  transition: none;
}

.segmented button {
  position: relative;
  height: 50px;
  border-radius: 15px;
  color: var(--ink-2);
  font-size: var(--text-l);
  font-weight: 500;
  transition: color 0.25s var(--ease);
}

.segmented button:hover,
.segmented button[aria-checked="true"] {
  color: var(--ink);
}

/* Swatches */

.swatches {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
}

.swatch,
.swatch-tool {
  width: 100%;
  aspect-ratio: 1;
  max-width: 100%;
  border-radius: 50%;
}

.swatch-item {
  position: relative;
  animation: swatch-in 0.35s var(--ease);
  transition: transform 0.18s ease-in, opacity 0.18s ease-in;
}

.swatch-item.is-leaving {
  opacity: 0;
  transform: scale(0.6);
  pointer-events: none;
}

@keyframes swatch-in {
  from {
    opacity: 0;
    transform: scale(0.6);
  }
}

.swatch {
  --swatch: transparent;
  display: block;
  background: var(--swatch);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
  transition: background-color 0.6s var(--ease), transform 0.3s var(--ease), box-shadow 0.25s var(--ease);
}

.swatch:hover {
  transform: scale(1.06);
}

.swatch[aria-expanded="true"] {
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1), 0 0 0 3px var(--rail), 0 0 0 5px var(--ink);
}

.swatch-remove {
  position: absolute;
  top: -5px;
  right: -5px;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--pop);
  color: var(--ink);
  box-shadow: 0 0 0 1px var(--line-strong), 0 4px 12px var(--shadow);
  opacity: 0;
  transform: scale(0.7);
  pointer-events: none;
  transition: opacity 0.18s var(--ease), transform 0.25s var(--ease), background-color 0.2s var(--ease);
}

.swatch-remove svg {
  width: 14px;
  height: 14px;
}

.swatch-remove:hover {
  background: var(--raised);
}

.swatch-item:hover .swatch-remove,
.swatch-remove:focus-visible {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

@media (hover: none) {
  .swatch-remove {
    display: none;
  }
}

.swatch-tool {
  display: grid;
  place-items: center;
  background: var(--well);
  color: var(--ink-2);
  transition: background-color 0.2s var(--ease), color 0.2s var(--ease), transform 0.3s var(--ease);
}

.swatch-tool:hover {
  background: var(--well-hover);
  color: var(--ink);
}

.swatch-tool:active {
  transform: rotate(-12deg) scale(0.94);
}

.swatch-add {
  background: transparent;
  box-shadow: inset 0 0 0 1.5px var(--line-strong);
}

/* Reference */

.reference-empty {
  display: flex;
  align-items: center;
  gap: 18px;
  width: 100%;
  min-height: 96px;
  padding: 16px 22px;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius-m);
  color: var(--ink-2);
  text-align: left;
  transition: border-color 0.2s var(--ease), background-color 0.2s var(--ease), color 0.2s var(--ease);
}

.reference-empty:hover,
.reference-empty.is-over {
  border-color: var(--ink-3);
  background: rgba(255, 255, 255, 0.02);
  color: var(--ink);
}

.reference-empty-icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--well);
}

.reference-empty-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: var(--text-m);
}

.reference-empty-text strong {
  color: var(--ink);
  font-size: var(--text-l);
  font-weight: 500;
}

.reference-card {
  display: grid;
  grid-template-columns: 80px minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 10px 8px 10px 10px;
  border-radius: var(--radius-m);
  background: var(--well);
  transition: box-shadow 0.2s var(--ease);
}

.reference-card.is-over {
  box-shadow: inset 0 0 0 1.5px var(--ink-3);
}

.reference-thumb {
  width: 80px;
  height: 80px;
  overflow: hidden;
  border-radius: 12px;
}

.reference-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.reference-meta {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.reference-name {
  overflow: hidden;
  color: var(--ink-2);
  font-size: var(--text-s);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.reference-dots {
  display: flex;
  gap: 5px;
}

.reference-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.reference-actions {
  display: flex;
  gap: 2px;
}
