/* Shared by the Astro, React and Vanilla ColorInput variants. */

.exo-color-input {
  --exo-color-input-swatch: var(--exo-size-swatch-md, 32px);
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  gap: var(--exo-space-2, 6px);
  min-width: 0;
  font-family: var(--exo-font-family-sans, system-ui, sans-serif);
  line-height: var(--exo-font-line-height-snug, 1.25);
  color: var(--exo-color-text, #333333);
  cursor: pointer;
}

/* Sizes: the swatch matches the height of a Button of the same size. */
.exo-color-input--md {
  font-size: var(--exo-font-size-sm, 14px);
}

.exo-color-input--sm {
  --exo-color-input-swatch: var(--exo-size-swatch-sm, 24px);
  font-size: var(--exo-font-size-xs, 12px);
}

/* The native color input, drawn as a square swatch of its value. Clicking it (or the label) opens the color picker. */
.exo-color-input__swatch {
  -webkit-appearance: none;
  appearance: none;
  box-sizing: border-box;
  flex: none;
  width: var(--exo-color-input-swatch);
  height: var(--exo-color-input-swatch);
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: none;
  border: var(--exo-border-width-1, 1px) solid var(--exo-color-border-strong, #cccccc);
  border-radius: var(--exo-radius-3, 6px);
  cursor: inherit;
}

.exo-color-input__swatch::-webkit-color-swatch-wrapper {
  padding: 0;
}

.exo-color-input__swatch::-webkit-color-swatch {
  border: none;
  border-radius: 0;
}

.exo-color-input__swatch::-moz-color-swatch {
  border: none;
  border-radius: 0;
}

.exo-color-input__text {
  display: flex;
  flex-direction: column;
  gap: var(--exo-space-0-5, 2px);
  min-width: 0;
}

/* The hex code, under the label. */
.exo-color-input__value {
  font-family: var(--exo-font-family-mono, ui-monospace, monospace);
  font-size: var(--exo-font-size-xs, 12px);
  color: var(--exo-color-text-muted, #666666);
}

/* States */
.exo-color-input:hover .exo-color-input__swatch:not(:disabled, :focus-visible) {
  border-color: var(--exo-color-text-muted, #666666);
}

.exo-color-input__swatch:focus-visible {
  outline: var(--exo-border-width-2, 2px) solid var(--exo-color-accent, #2f5fdb);
  outline-offset: var(--exo-border-width-2, 2px);
}

.exo-color-input:has(.exo-color-input__swatch:disabled) {
  opacity: 0.5;
  cursor: not-allowed;
}
