.clip-swatch {
  background: none;
  border: 0;
  bottom: 0;
  cursor: pointer;
  font-size: 0;
  left: 0;
  padding: 0;
  position: absolute;
  top: 0;
  transition: background 150ms ease;
  width: 0.75rem;
  z-index: 2;
}

.clip-swatch:hover,
.clip-swatch:focus-visible {
  background: color-mix(in srgb, var(--clip-color) 45%, transparent);
}

.color-dialog {
  background: linear-gradient(var(--surface-raised), var(--surface));
  border: 1px solid var(--edge);
  border-radius: var(--radius-lg);
  box-shadow: var(--lip);
  color: var(--ink);
  padding: 1.5rem;
}

.color-dialog::backdrop {
  background: rgba(0, 0, 0, 0.7);
}

.color-dialog form {
  background: none;
  border: 0;
  box-shadow: none;
  padding: 0;
  width: 15rem;
}

.color-marker {
  box-sizing: border-box;
  display: block;
  height: 1.1rem;
  padding: 0;
  pointer-events: none;
  position: absolute;
  transform: translate(-50%, -50%);
  width: 1.1rem;
}

.color-marker::before,
.color-marker::after {
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6);
  content: "";
  left: 50%;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
}

.color-marker::before {
  height: 2px;
  width: 100%;
}

.color-marker::after {
  height: 100%;
  width: 2px;
}

.color-preview {
  align-items: center;
  border: 1px solid var(--edge);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  height: 2rem;
  justify-content: center;
  margin: 1rem 0 0;
}

.color-heading {
  border-top: 1px solid var(--edge);
  color: var(--ink);
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.22em;
  margin: 0.9rem 0 0.4rem;
  padding-top: 0.75rem;
  text-align: center;
  text-transform: uppercase;
}

/* Wears the copied color, so it stays legible only while it means something */
.color-copied {
  display: block;
  font-size: var(--label);
  letter-spacing: 0.16em;
  line-height: 1.2;
  margin-top: 0.2rem;
  opacity: 0;
  text-align: right;
  text-transform: uppercase;
}

.color-copied.is-copied {
  animation: copied 1800ms ease-out;
}

/* The copied line already holds a gap under the preview */
.color-copied + .color-heading {
  margin-top: 0.5rem;
}

@keyframes copied {
  0%,
  45% {
    opacity: 1;
  }

  100% {
    opacity: 0;
  }
}

/* A dark chip keeps the code readable whatever color sits behind it */
.color-chip,
.color-hex[type="text"] {
  background: rgba(0, 0, 0, 0.55);
  border-radius: var(--radius-sm);
  color: #fff;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  line-height: 1.4;
  padding: 0.1rem 0.4rem;
  text-transform: uppercase;
}

.color-hex[type="text"] {
  border: 0;
  box-sizing: content-box;
  text-align: center;
  width: 6rem;
}

.color-hex[type="text"]:hover {
  border: 0;
}

/* The default selection washes out against the chip */
.color-hex[type="text"]::selection {
  background: #fff;
  color: #101016;
}

.color-hint {
  color: var(--muted);
  font-size: 0.6rem;
  letter-spacing: 0.12em;
  margin: 0 0 0.6rem;
  text-align: center;
  text-transform: uppercase;
}

.color-preset {
  aspect-ratio: 1;
  background: var(--bg);
  border: 1px solid var(--edge);
  border-radius: var(--radius-sm);
  color: var(--muted);
  cursor: pointer;
  display: block;
  font-size: 0.75rem;
  line-height: 1;
  outline: 2px solid transparent;
  outline-offset: 2px;
  padding: 0;
}

.color-preset.is-found {
  animation: preset-found 900ms ease-out;
}

@keyframes preset-found {
  0%,
  100% {
    outline-color: transparent;
  }

  20%,
  60% {
    outline-color: var(--ink);
  }
}

.color-presets {
  display: grid;
  gap: 0.35rem;
  grid-template-columns: repeat(8, 1fr);
  margin: 0 0 0.9rem;
}

/* One click stages the color the film wore before */
.color-previous {
  align-items: center;
  border: 1px solid var(--edge);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  height: 2rem;
  justify-content: center;
  padding: 0;
  width: 100%;
}

.color-wheel {
  aspect-ratio: 1;
  background:
    radial-gradient(circle closest-side, #fff, transparent),
    conic-gradient(
      from 90deg,
      hsl(0 100% 55%),
      hsl(60 100% 55%),
      hsl(120 100% 55%),
      hsl(180 100% 55%),
      hsl(240 100% 55%),
      hsl(300 100% 55%),
      hsl(360 100% 55%)
    );
  border-radius: 50%;
  cursor: crosshair;
  position: relative;
  touch-action: none;
  width: 100%;
}
