/* Colour picker: picking from a photo (tools/color/photo.js). The rest of the picker lives in /style.css. */

.color-photo {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(15rem, 1fr);
  gap: 1.5rem;
  align-items: start;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}

.color-photo-frame { position: relative; justify-self: center; width: fit-content; max-width: 100%; }
.color-img {
  display: block;
  max-width: 100%;
  max-height: 72vh;
  border-radius: 12px;
  box-shadow: var(--shadow);
  cursor: crosshair;
  touch-action: none; /* drag to aim on touch screens instead of scrolling */
}
.color-img:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

/* Magnifier: 11×11 photo pixels, the middle one outlined, ringed in the colour under it. */
.color-loupe {
  --dx: 1rem;
  --dy: calc(-100% - 1rem);
  position: absolute;
  z-index: 2;
  width: 8.25rem;
  height: 8.25rem;
  border: 5px solid var(--card);
  border-radius: 50%;
  background: var(--card);
  box-shadow: 0 0 0 2px var(--card), 0 18px 40px -12px rgb(0 0 0 / 0.45);
  image-rendering: pixelated;
  pointer-events: none;
  transform: translate(var(--dx), var(--dy));
}
.color-loupe.is-left { --dx: calc(-100% - 1rem); }
.color-loupe.is-below { --dy: 1rem; }

.color-pins { position: absolute; inset: 0; pointer-events: none; }
.color-pin {
  position: absolute;
  width: 1rem;
  height: 1rem;
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgb(0 0 0 / 0.35), 0 2px 6px rgb(0 0 0 / 0.35);
  transform: translate(-50%, -50%);
  animation: pin-drop 260ms var(--ease-out-expo) both;
}
@keyframes pin-drop { from { opacity: 0; transform: translate(-50%, -90%) scale(0.6); } }

.color-photo-side { position: sticky; top: 1rem; display: grid; gap: 1rem; }
.color-live {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--field);
}
.color-live-swatch {
  flex: none;
  width: 3.5rem;
  height: 3.5rem;
  border: 1px solid color-mix(in srgb, var(--ink) 14%, transparent);
  border-radius: 10px;
  background: repeating-conic-gradient(var(--line) 0 25%, transparent 0 50%) 0 0 / 0.75rem 0.75rem; /* "nothing yet" */
  transition: background var(--duration-fast);
}
.color-live b { display: block; font: 600 1.1rem var(--font-mono); }
.color-live small { color: var(--ink-2); font-size: 0.85rem; }
.color-photo-help { margin: 0; color: var(--ink-2); font: 0.78rem/1.5 var(--font-mono); }
.color-photo-side .palette-row .chips { flex-wrap: wrap; }
.color-photo-side .chip { flex: 1 1 22%; min-height: 3rem; }
#color-photo-clear { justify-self: start; margin-left: 0; }

@media (max-width: 760px) {
  .color-photo { grid-template-columns: 1fr; }
  .color-photo-side { position: static; }
  .color-loupe { width: 6.5rem; height: 6.5rem; }
}
