/*
  Kurumi colour picker styles (pairs with kurumi-colorpicker.js).
  Gothic-luxe: midnight panel, gold hairlines, crimson glow, round gold thumbs.
*/

/* The real input stays in the DOM (forms, scripts) but is visually hidden. */
.kcp-native {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  border: 0 !important;
  opacity: 0 !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  pointer-events: none !important;
}

/* ---------- trigger ---------- */
.kcp-trigger {
  --kcp-color: #9a1b12;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  height: 2.5rem;
  min-width: 3rem;
  padding: 0 0.7rem 0 0.5rem;
  color: var(--ka-ivory, #efe3d2);
  font: 600 0.78rem/1 ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  letter-spacing: 0.04em;
  background: linear-gradient(180deg, #1a1320, #120d17);
  border: 1px solid rgba(176, 138, 62, 0.42);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.12s ease;
}
.kcp-trigger:hover:not(:disabled) {
  border-color: rgba(233, 196, 106, 0.8);
  box-shadow: 0 0 0 3px rgba(224, 30, 55, 0.12), 0 6px 18px rgba(0, 0, 0, 0.45);
}
.kcp-trigger:active:not(:disabled) { transform: translateY(1px); }
.kcp-trigger:focus-visible {
  outline: 2px solid var(--ka-focus, #e9c46a);
  outline-offset: 2px;
}
.kcp-trigger:disabled { opacity: 0.5; cursor: not-allowed; }
.kcp-trigger__sw {
  flex: 0 0 auto;
  width: 1.55rem;
  height: 1.55rem;
  border-radius: 7px;
  background: var(--kcp-color);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35), 0 0 0 1px rgba(0, 0, 0, 0.6), 0 0 14px -2px var(--kcp-color);
}
.kcp-trigger--compact { padding: 0 0.5rem; justify-content: center; }
.kcp-trigger--compact .kcp-trigger__hex { display: none; }

/* ---------- popover ---------- */
.kcp-panel {
  --kcp-hue: hsl(0, 100%, 50%);
  --kcp-current: #9a1b12;
  position: fixed;
  z-index: 3000;
  box-sizing: border-box;
  width: min(264px, calc(100vw - 16px));
  padding: 14px;
  color: var(--ka-ivory, #efe3d2);
  background:
    radial-gradient(120% 90% at 100% 0%, rgba(173, 26, 45, 0.18), transparent 60%),
    linear-gradient(180deg, #1f1726, #140e1a);
  border: 1px solid rgba(176, 138, 62, 0.5);
  border-radius: 16px;
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(224, 30, 55, 0.1), inset 0 1px 0 rgba(255, 233, 180, 0.08);
  opacity: 0;
  transform: translateY(-4px) scale(0.98);
  transform-origin: top left;
  transition: opacity 0.16s ease, transform 0.16s ease;
}
.kcp-panel[hidden] { display: none; }
.kcp-panel.is-open { opacity: 1; transform: none; }

.kcp-sv {
  position: relative;
  height: 150px;
  border-radius: 10px;
  background:
    linear-gradient(to top, #000, rgba(0, 0, 0, 0)),
    linear-gradient(to right, #fff, rgba(255, 255, 255, 0)),
    var(--kcp-hue);
  box-shadow: inset 0 0 0 1px rgba(176, 138, 62, 0.35);
  cursor: crosshair;
  touch-action: none;
  outline: none;
}
.kcp-sv:focus-visible { box-shadow: inset 0 0 0 1px rgba(176, 138, 62, 0.35), 0 0 0 2px var(--ka-focus, #e9c46a); }
.kcp-sv__thumb {
  position: absolute;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border-radius: 50%;
  background: var(--kcp-current);
  border: 2px solid #fff;
  box-shadow: 0 0 0 1.5px rgba(0, 0, 0, 0.75), 0 2px 8px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}

.kcp-row { margin-top: 12px; }
.kcp-hue {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 12px;
  margin: 0;
  padding: 0;
  border-radius: 999px;
  background: linear-gradient(to right, #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%);
  box-shadow: inset 0 0 0 1px rgba(176, 138, 62, 0.35);
  outline: none;
  cursor: pointer;
}
.kcp-hue::-webkit-slider-runnable-track { height: 12px; background: transparent; border: 0; }
.kcp-hue::-moz-range-track { height: 12px; background: transparent; border: 0; }
.kcp-hue::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -3px;
  border-radius: 50%;
  background: var(--kcp-hue);
  border: 2px solid #f3dfa0;
  box-shadow: 0 0 0 1.5px rgba(0, 0, 0, 0.75), 0 2px 8px rgba(0, 0, 0, 0.6);
}
.kcp-hue::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--kcp-hue);
  border: 2px solid #f3dfa0;
  box-shadow: 0 0 0 1.5px rgba(0, 0, 0, 0.75), 0 2px 8px rgba(0, 0, 0, 0.6);
}
.kcp-hue:focus-visible { box-shadow: inset 0 0 0 1px rgba(176, 138, 62, 0.35), 0 0 0 2px var(--ka-focus, #e9c46a); }

.kcp-hexrow { display: flex; align-items: center; gap: 8px; }
.kcp-preview {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--kcp-current);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.3), 0 0 0 1px rgba(0, 0, 0, 0.6), 0 0 16px -4px var(--kcp-current);
}
.kcp-hex {
  flex: 1 1 auto;
  min-width: 0;
  height: 34px;
  padding: 0 10px;
  box-sizing: border-box;
  color: var(--ka-ivory, #efe3d2);
  font: 600 0.85rem/1 ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: #0f0a14;
  border: 1px solid rgba(176, 138, 62, 0.4);
  border-radius: 9px;
}
.kcp-hex:focus { outline: none; border-color: #e9c46a; box-shadow: 0 0 0 3px rgba(233, 196, 106, 0.18); }
.kcp-eye {
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  color: #e9c46a;
  background: #0f0a14;
  border: 1px solid rgba(176, 138, 62, 0.4);
  border-radius: 9px;
  cursor: pointer;
}
.kcp-eye[hidden] { display: none; }
.kcp-eye svg { width: 18px; height: 18px; fill: currentColor; }
.kcp-eye:hover { border-color: #e9c46a; box-shadow: 0 0 0 3px rgba(233, 196, 106, 0.14); }
.kcp-eye:focus-visible { outline: 2px solid var(--ka-focus, #e9c46a); outline-offset: 2px; }

.kcp-swatches {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 7px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(176, 138, 62, 0.22);
}
.kcp-swatch {
  aspect-ratio: 1;
  min-width: 0;
  padding: 0;
  border-radius: 50%;
  background: var(--kcp-sw);
  border: 0;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25), 0 0 0 1px rgba(0, 0, 0, 0.6);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.kcp-swatch:hover { transform: scale(1.15); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.4), 0 0 0 2px #e9c46a; }
.kcp-swatch:focus-visible { outline: 2px solid var(--ka-focus, #e9c46a); outline-offset: 2px; }
.kcp-swatch.is-active { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.4), 0 0 0 2px #14101a, 0 0 0 4px #e9c46a; }

@media (prefers-reduced-motion: reduce) {
  .kcp-trigger, .kcp-panel, .kcp-swatch { transition: none !important; }
  .kcp-panel { transform: none !important; }
}
html[data-ka-motion="off"] .kcp-trigger,
html[data-ka-motion="off"] .kcp-panel,
html[data-ka-motion="off"] .kcp-swatch { transition: none !important; }
