/* ── Extract-from-image panel ─────────────────────────────────────────────
   Drop an image, pull dominant colors, use them as stops. Mirrors the layer
   panel's glass styling but centred (it is a focused task, not a side rail). */
.gs-extract {
  margin: auto;
  width: min(40rem, calc(100vw - 2rem));
  max-height: 90svh;
  overflow-y: auto;
  padding: 1rem;
  border-radius: 1.1rem;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(10, 14, 22, 0.74);
  -webkit-backdrop-filter: blur(26px) saturate(1.4);
  backdrop-filter: blur(26px) saturate(1.4);
  box-shadow: 0 2rem 5rem -1rem rgba(0, 0, 0, 0.7);
}
.gs-extract::backdrop {
  background: rgba(4, 6, 12, 0.62);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}
.gs-extract.is-busy { cursor: progress; }

.gs-extract__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.85rem;
}
.gs-extract__title {
  font-family: var(--font-secondary);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.72);
}
.gs-extract__close {
  appearance: none;
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border-radius: 0.6rem;
}
.gs-extract__close:hover { color: #fff; background: rgba(255, 255, 255, 0.1); }

/* Drop zone */
.gs-extract__drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1.7rem 1rem;
  text-align: center;
  color: rgba(255, 255, 255, 0.78);
  border: 1.5px dashed rgba(255, 255, 255, 0.28);
  border-radius: 0.9rem;
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}
.gs-extract__drop:hover { border-color: rgba(255, 255, 255, 0.5); background: rgba(255, 255, 255, 0.06); }
.gs-extract__drop:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.gs-extract__drop.is-over {
  border-color: #fff;
  border-style: solid;
  background: rgba(54, 201, 240, 0.14);
  transform: scale(1.02);
}
.gs-extract__drop.is-hidden { display: none; }
.gs-extract__drop svg { color: rgba(255, 255, 255, 0.7); }
.gs-extract__drop-text { font-size: 0.85rem; font-weight: 600; }
.gs-extract__hint { font-size: 0.7rem; color: rgba(255, 255, 255, 0.5); }

/* Result */
.gs-extract__result[hidden] { display: none; }

/* Interactive image stage: hosts the <img>, the sampling-dot overlay, the
   click/pan layer and the dots. The module positions the image absolutely. */
.gs-extract__stage {
  position: relative;
  width: 100%;
  height: min(52svh, 24rem);
  border-radius: 0.85rem;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.35);
  touch-action: none;
}
.gs-extract__stage img {
  display: block;
  /* The sampler sizes and offsets the image itself; the site's img max-width
     squashed it on a phone and left the dots outside the stage. */
  max-width: none;
  max-height: none;
  user-select: none;
  -webkit-user-drag: none;
}

.gs-extract__bar {
  margin: 0.7rem 0 0.55rem;
  min-height: 1.75rem;
}

.gs-extract__tip {
  margin: 0 0 0.85rem;
  font-size: 0.7rem;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.5);
}

/* ── Sampling dots (ported from Color Extractly) ─────────────────────────── */
.sampling-dots-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}
.sampling-dots-click-layer {
  position: absolute;
  inset: 0;
  pointer-events: auto;
  cursor: crosshair;
  z-index: 1;
}
.sampling-dot {
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--dot-border, #fff);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35), 0 2px 6px rgba(0, 0, 0, 0.3);
  transform: translate(-50%, -50%);
  cursor: grab;
  pointer-events: auto;
  transition: width .2s ease, height .2s ease, background-color .2s, box-shadow .2s, border-width .2s, border-color .2s,
              opacity .25s cubic-bezier(.4, 0, .2, 1), filter .25s cubic-bezier(.4, 0, .2, 1), transform .25s cubic-bezier(.4, 0, .2, 1);
  will-change: left, top;
  z-index: 3;
}
.sampling-dot:hover {
  width: 50px;
  height: 50px;
  background-color: transparent !important;
  border-width: 8px;
  border-color: var(--dot-color, #fff);
  box-shadow: 0 0 0 1.5px rgba(0, 0, 0, 0.4), inset 0 0 0 1px rgba(0, 0, 0, 0.2), 0 2px 10px rgba(0, 0, 0, 0.3);
}
.sampling-dot.dragging {
  width: 54px;
  height: 54px;
  cursor: grabbing;
  background-color: transparent !important;
  border-width: 8px;
  border-color: var(--dot-color, #fff);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(0, 0, 0, 0.25), 0 4px 14px rgba(0, 0, 0, 0.4);
  z-index: 4;
}
.sampling-dot.pulse { animation: dotPulse .6s ease-out; }
.sampling-dot.glow-bounce { animation: dotGlowBounce 1s ease-in-out; }
.sampling-dot.dot-faded {
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(.55);
  filter: blur(2px);
}
@keyframes dotPulse {
  0%   { transform: translate(-50%, -50%) scale(1); }
  40%  { transform: translate(-50%, -50%) scale(1.35); }
  100% { transform: translate(-50%, -50%) scale(1); }
}
@keyframes dotGlowBounce {
  0%   { transform: translate(-50%, -50%) scale(1);   box-shadow: 0 0 0 1px rgba(0, 0, 0, .35), 0 2px 6px rgba(0, 0, 0, .3); }
  20%  { transform: translate(-50%, -50%) scale(1.5); box-shadow: 0 0 12px 4px var(--dot-color, #fff), 0 0 0 1px rgba(0, 0, 0, .35); }
  50%  { transform: translate(-50%, -50%) scale(0.9); box-shadow: 0 0 6px 2px var(--dot-color, #fff), 0 0 0 1px rgba(0, 0, 0, .35); }
  75%  { transform: translate(-50%, -50%) scale(1.15); box-shadow: 0 0 8px 3px var(--dot-color, #fff), 0 0 0 1px rgba(0, 0, 0, .35); }
  100% { transform: translate(-50%, -50%) scale(1);   box-shadow: 0 0 0 1px rgba(0, 0, 0, .35), 0 2px 6px rgba(0, 0, 0, .3); }
}

/* Color bar: reorderable stripes, one per dot */
.sampling-color-bar {
  position: relative;
  display: flex;
  height: 28px;
  z-index: 5;
  pointer-events: auto;
  overflow: visible;
  border-radius: 0.5rem;
}
.sampling-color-bar__stripe {
  flex: 1;
  cursor: grab;
  position: relative;
  min-width: 18px;
  background: transparent;
  transition: background-color .25s, opacity .16s ease, transform .16s ease;
  will-change: transform;
}
.sampling-color-bar.reordering .sampling-color-bar__stripe { border-radius: 6px; }
.sampling-color-bar__stripe.dragging {
  cursor: grabbing;
  z-index: 6;
  animation: samplingChipWobble .68s ease-in-out infinite;
  transition: none;
}
.sampling-color-bar__stripe:first-child { border-radius: 0.5rem 0 0 0.5rem; }
.sampling-color-bar__stripe:last-child  { border-radius: 0 0.5rem 0.5rem 0; }
.sampling-color-bar__stripe::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 100%;
  background: var(--sampling-swatch-bg, transparent);
  transform: scaleY(1);
  transform-origin: bottom center;
  transition: transform .16s ease, border-radius .16s ease;
  border-radius: inherit;
}
.sampling-color-bar__stripe:hover::before {
  transform: scaleY(1.5);
  border-radius: 6px 6px 0 0;
}
.sampling-color-bar__hex {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, calc(-50% + 4px)) scale(.98);
  opacity: 0;
  pointer-events: none;
  z-index: 5;
  white-space: nowrap;
  font-size: 9px;
  line-height: 1;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: var(--sampling-hex-fg, #fff);
  transition: opacity .16s ease, transform .16s ease;
}
.sampling-color-bar__stripe:hover .sampling-color-bar__hex,
.sampling-color-bar__stripe:focus-visible .sampling-color-bar__hex,
.sampling-color-bar.reordering .sampling-color-bar__stripe .sampling-color-bar__hex {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}
.sampling-color-bar__drag-handle {
  position: absolute;
  inset: 0;
  cursor: grab;
  z-index: 6;
  background: transparent;
  touch-action: none;
}
.sampling-color-bar__stripe.dragging .sampling-color-bar__drag-handle { cursor: grabbing; }
@keyframes samplingChipWobble {
  0%, 100% { rotate: -.7deg; }
  50% { rotate: .7deg; }
}

.gs-extract__count {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.72);
  margin-bottom: 0.9rem;
}
.gs-extract__count input[type="range"] { flex: 1; }
.gs-extract__count output { min-width: 1.2rem; text-align: right; font-variant-numeric: tabular-nums; }

.gs-extract__actions {
  display: flex;
  gap: 0.6rem;
  justify-content: flex-end;
}
.gs-extract__actions .gs-btn[disabled] { opacity: 0.45; pointer-events: none; }

@media (prefers-reduced-motion: reduce) {
  .gs-extract__drop, .gs-extract__drop.is-over { transition: none; transform: none; }
}
