/* ===== model color control and picker (js/color-picker.js); theme tokens only ===== */

/* the row in the sidebar (the holder reserves its height so nothing jumps when the script adds it) */
.cc-holder{ min-height:60px; }
.cc{ margin-top:var(--space-3); min-height:48px; }
.cc-row{ display:flex; align-items:center; gap:var(--space-2); min-height:36px; }
.cc-label{ flex:0 0 auto; font-size:var(--text-sm); color:var(--text-soft); margin-right:2px; }
.cc-swatch{
  flex:0 0 auto; width:34px; height:34px; border-radius:var(--radius-md); cursor:pointer; padding:0;
  background:var(--sw, #fff); border:1px solid var(--field-border);
  box-shadow:inset 0 0 0 2px var(--panel-bg);
  transition:transform 140ms var(--ease-out), border-color 140ms ease;
}
.cc-swatch:hover{ border-color:var(--accent); }
.cc-swatch:active{ transform:scale(0.95); }
.cc-hex{
  flex:1 1 auto; min-width:0; width:88px; background:var(--input-bg); border:1px solid var(--field-border);
  border-radius:var(--radius-sm); padding:7px 9px; font-size:var(--text-sm); font-variant-numeric:tabular-nums; letter-spacing:.02em;
  text-transform:uppercase;
}
.cc-hex:focus-visible, .cp-hex:focus-visible{ border-color:var(--accent); outline:none; box-shadow:var(--focus-ring); }
.cc-hex[aria-invalid="true"], .cp-hex[aria-invalid="true"]{ border-color:var(--danger); box-shadow:0 0 0 3px rgba(var(--danger-rgb),0.2); }
.cc-pick{
  flex:0 0 auto; width:34px; height:34px; display:inline-flex; align-items:center; justify-content:center; padding:0; cursor:pointer;
  border-radius:var(--radius-md); background:transparent; border:1px solid var(--field-border); color:var(--text-muted);
  transition:border-color 140ms ease, color 140ms ease, transform 140ms var(--ease-out);
}
.cc-pick:hover{ border-color:var(--accent); color:var(--accent); }
.cc-pick:active{ transform:scale(0.95); }
.cc-reset{
  flex:0 0 auto; background:none; border:none; color:var(--text-muted); font-size:var(--text-xs); text-decoration:underline;
  text-underline-offset:2px; cursor:pointer; padding:8px 4px;
}
.cc-reset:hover{ color:var(--accent); }
.cc-native{ position:absolute; width:1px; height:1px; opacity:0; pointer-events:none; }
.cc-msg{ min-height:16px; margin-top:4px; font-size:var(--text-xs); color:var(--danger); line-height:1.35; }

/* the picker: a popover next to the swatch, a bottom sheet on phones */
.cp-backdrop{ position:fixed; inset:0; z-index:120; }
.cp{
  position:fixed; width:264px; max-width:calc(100vw - 16px); padding:12px; z-index:121;
  background:var(--panel-bg); border:1px solid var(--border-strong); border-radius:var(--radius-lg); box-shadow:var(--shadow);
  animation:cp-in 150ms var(--ease-out) both; outline:none;
}
@keyframes cp-in{ from{ opacity:0; transform:translateY(4px) scale(0.98); } to{ opacity:1; transform:none; } }
@keyframes cp-sheet{ from{ transform:translateY(100%); } to{ transform:none; } }
.cp-head{ display:flex; align-items:center; justify-content:space-between; margin-bottom:8px; }
.cp-title{ font-size:var(--text-sm); font-weight:700; }
.cp-close{
  width:32px; height:32px; display:inline-flex; align-items:center; justify-content:center; border-radius:50%; cursor:pointer;
  background:transparent; border:1px solid transparent; color:var(--text-muted);
}
.cp-close:hover{ background:var(--accent-soft); color:var(--text); }

.cp-sv{
  position:relative; width:100%; height:150px; border-radius:var(--radius-md); cursor:crosshair; touch-action:none; outline:none;
  background:linear-gradient(to top, #000, rgba(0,0,0,0)), linear-gradient(to right, #fff, var(--hue, red));
  border:1px solid var(--border-strong);
}
.cp-sv:focus-visible{ outline:2px solid var(--accent); outline-offset:2px; }
/* Both handles are outline-only rings: a clear center, a thin white edge and a subtle dark outer and inner edge,
   so the color underneath stays visible and the ring reads on white, black and everything between. */
.cp-handle{
  position:absolute; width:22px; height:22px; margin:-11px 0 0 -11px; border-radius:50%; pointer-events:none;
  background:transparent; border:2px solid #fff;
  box-shadow:0 0 0 1px rgba(0,0,0,0.55), inset 0 0 0 1px rgba(0,0,0,0.35);
}
.cp-sv:focus-visible .cp-handle{ box-shadow:0 0 0 1px rgba(0,0,0,0.55), inset 0 0 0 1px rgba(0,0,0,0.35), 0 0 0 4px var(--accent); }

/* The hue bar: the full rainbow across its whole width. The selectors are written to out-rank the global slider
   rules in styles.css, which would otherwise paint a dark track over the gradient. */
input.cp-hue[type="range"]{
  -webkit-appearance:none; appearance:none; display:block; width:100%; height:16px; margin:14px 0 0; padding:0; cursor:pointer;
  border-radius:var(--radius-pill); border:1px solid var(--border-strong); touch-action:none;
  background:linear-gradient(to right, #ff0000 0%, #ffff00 16.667%, #00ff00 33.333%, #00ffff 50%, #0000ff 66.667%, #ff00ff 83.333%, #ff0000 100%);
}
input.cp-hue[type="range"]::-webkit-slider-runnable-track{ -webkit-appearance:none; background:transparent; height:14px; border:none; border-radius:var(--radius-pill); }
input.cp-hue[type="range"]::-moz-range-track{ background:transparent; height:14px; border:none; border-radius:var(--radius-pill); }
input.cp-hue[type="range"]::-moz-range-progress{ background:transparent; }
input.cp-hue[type="range"]::-webkit-slider-thumb{
  -webkit-appearance:none; appearance:none; width:22px; height:22px; margin-top:-5px; border-radius:50%; cursor:grab;
  background:transparent; border:2px solid #fff; transform:none;
  box-shadow:0 0 0 1px rgba(0,0,0,0.55), inset 0 0 0 1px rgba(0,0,0,0.35);
}
input.cp-hue[type="range"]::-moz-range-thumb{
  width:18px; height:18px; border-radius:50%; cursor:grab; background:transparent; border:2px solid #fff; transform:none;
  box-shadow:0 0 0 1px rgba(0,0,0,0.55), inset 0 0 0 1px rgba(0,0,0,0.35);
}
input.cp-hue[type="range"]:hover::-webkit-slider-thumb, input.cp-hue[type="range"]:active::-webkit-slider-thumb{ transform:none; }
input.cp-hue[type="range"]:hover::-moz-range-thumb, input.cp-hue[type="range"]:active::-moz-range-thumb{ transform:none; }
input.cp-hue[type="range"]:focus-visible{ outline:none; }
input.cp-hue[type="range"]:focus-visible::-webkit-slider-thumb{ box-shadow:0 0 0 1px rgba(0,0,0,0.55), inset 0 0 0 1px rgba(0,0,0,0.35), 0 0 0 4px var(--accent); }
input.cp-hue[type="range"]:focus-visible::-moz-range-thumb{ box-shadow:0 0 0 1px rgba(0,0,0,0.55), inset 0 0 0 1px rgba(0,0,0,0.35), 0 0 0 4px var(--accent); }

.cp-row{ display:flex; align-items:center; gap:8px; margin-top:10px; }
.cp-hex-label{ font-size:var(--text-xs); color:var(--text-muted); }
.cp-hex{
  flex:1 1 auto; min-width:0; background:var(--input-bg); border:1px solid var(--field-border); border-radius:var(--radius-sm);
  padding:7px 9px; font-size:var(--text-sm); text-transform:uppercase; font-variant-numeric:tabular-nums;
}
.cp-compare{ display:flex; flex:0 0 auto; border-radius:var(--radius-sm); overflow:hidden; border:1px solid var(--field-border); }
.cp-cur, .cp-prev{ display:block; width:28px; height:30px; padding:0; border:none; }
.cp-prev{ cursor:pointer; }
.cp-prev:focus-visible{ outline:2px solid var(--accent); outline-offset:-2px; }
.cp-msg{ min-height:15px; margin-top:4px; font-size:var(--text-xs); color:var(--danger); line-height:1.3; }

.cp-swatches{ display:flex; flex-wrap:wrap; gap:6px; margin-top:6px; }
.cp-sw{
  width:26px; height:26px; padding:0; cursor:pointer; border-radius:50%; background:var(--sw);
  border:1px solid var(--border-strong); transition:transform 120ms var(--ease-out);
}
.cp-sw:hover{ transform:scale(1.12); }
.cp-sw:focus-visible{ outline:2px solid var(--accent); outline-offset:2px; }
.cp-sub{ margin-top:8px; font-size:10.5px; letter-spacing:.06em; text-transform:uppercase; color:var(--text-muted); }
.cp-recent[hidden]{ display:none; }
.cp-actions{ display:flex; flex-wrap:wrap; gap:8px; margin-top:10px; }
.cp-btn{ display:inline-flex; align-items:center; gap:6px; }
.cp-live{ position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; }

@media (max-width: 560px){
  .cp-backdrop.sheet{ background:rgba(var(--scrim-rgb),0.35); }
  .cp-backdrop.sheet .cp{
    left:0; right:0; bottom:0; top:auto; width:auto; max-width:none; max-height:88dvh; overflow-y:auto;
    border-radius:var(--radius-lg) var(--radius-lg) 0 0; border-bottom:none; padding:14px 16px calc(16px + env(safe-area-inset-bottom));
    animation:cp-sheet 220ms var(--ease-out) both;
  }
  .cp-sv{ height:180px; }
  .cp-handle{ width:30px; height:30px; margin:-15px 0 0 -15px; }
  input.cp-hue[type="range"]{ height:24px; margin-top:16px; }
  input.cp-hue[type="range"]::-webkit-slider-runnable-track{ height:22px; }
  input.cp-hue[type="range"]::-moz-range-track{ height:22px; }
  input.cp-hue[type="range"]::-webkit-slider-thumb{ width:32px; height:32px; margin-top:-5px; }
  input.cp-hue[type="range"]::-moz-range-thumb{ width:28px; height:28px; }
  .cp-sw{ width:34px; height:34px; }
  .cp-close{ width:40px; height:40px; }
  .cp-btn{ min-height:40px; }
  .cc-swatch, .cc-pick{ width:40px; height:40px; }
  .cc-hex{ padding:10px; }
}
@media (prefers-reduced-motion: reduce){ .cp, .cp-backdrop.sheet .cp{ animation:none; } }
