/* ============================================================
 * Utilities Bunker — Color Palette From Image (v2.1)
 * File: /assets/css/modules/colors/palette-from-image.v2.1.css
 * Purpose:
 * - Tool-only layout + dropzone + palette swatches + preview
 * Notes:
 * - No changes to ub-toolkit.v2.1.css
 * - Mobile-first, 44x44 targets, clamp typography
 * ============================================================ */

/* ============================== Local tokens (tool-scoped) ============================== */
:root{
  --pfi-radius: 16px;
  --pfi-gap: 14px;
  --pfi-soft: rgba(0,0,0,.06);
}

/* ============================== Tool hero layout ============================== */
.ub-hero{
  display:grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: var(--pfi-gap);
}
@media (max-width: 980px){
  .ub-hero{ grid-template-columns: 1fr; }
}

/* ============================== Lab panel ============================== */
.ub-lab{
  background: var(--ub-surface-2);
  border: 1px solid var(--ub-border);
  border-radius: var(--pfi-radius);
  padding: 12px;
}
.ub-lab-top{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap: 10px;
  flex-wrap:wrap;
  margin-bottom: 10px;
}
.ub-lab-title{
  font-size: clamp(13px, 1.2vw, 14px);
  font-weight: 950;
  letter-spacing: .01em;
}
.ub-lab-sub{
  font-size: 12px;
  color: var(--ub-muted);
  margin-top: 2px;
}

/* ============================== KPI tiles ============================== */
.ub-kpis{
  display:flex;
  flex-wrap:wrap;
  gap: 8px;
  justify-content:flex-end;
}
.ub-kpi{
  min-width: 112px;
  padding: 8px 10px;
  border-radius: 14px;
  border: 1px solid var(--ub-border);
  background: var(--ub-card-bg);
}
.ub-kpi .k{
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ub-muted);
}
.ub-kpi .v{
  font-family: var(--ub-mono);
  font-weight: 950;
  font-size: 14px;
  margin-top: 2px;
}
@media (max-width: 520px){
  .ub-kpi{ min-width: 98px; }
}

/* ============================== Format chips (tool wheel) ============================== */
.ub-wheel{
  display:grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 10px;
}
.ub-wheel .ub-chip{
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 999px;
  border: 1px solid var(--ub-border);
  background: var(--ub-chip-bg);
  color: var(--ub-chip-text);
  font-weight: 900;
  cursor: pointer;
  user-select:none;
}
.ub-wheel .ub-chip:hover{ background: var(--ub-chip-hover); }
.ub-wheel .ub-chip[aria-pressed="true"]{
  border-color: rgba(249,58,19,.55);
  box-shadow: 0 0 0 4px rgba(249,58,19,.12);
}

/* ============================== Dropzone ============================== */
.ub-drop{
  border-radius: var(--pfi-radius);
  border: 2px dashed rgba(0,0,0,.18);
  background: var(--ub-card-bg);
  padding: 14px;
  min-height: 120px;
  display:flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  user-select:none;
  transition: transform .15s ease, background .15s ease, border-color .15s ease;
}
html.ub-theme-dark .ub-drop{ border-color: rgba(255,255,255,.18); }

.ub-drop:hover{ background: var(--ub-surface-1); }
.ub-drop:active{ transform: translateY(1px); }
.ub-drop:focus{
  outline: none;
  box-shadow: 0 0 0 4px var(--ub-focus);
}
.ub-drop--over{
  border-color: rgba(249,58,19,.55);
  box-shadow: 0 0 0 4px rgba(249,58,19,.12);
  background: var(--ub-surface-2);
}

.ub-drop-inner{ text-align:center; }
.ub-drop-title{
  font-size: var(--ub-fs-3);
  font-weight: 950;
  letter-spacing: -0.01em;
}
.ub-drop-sub{
  margin-top: 6px;
  font-size: 12px;
  color: var(--ub-muted);
}

/* ============================== Preview ============================== */
.ub-preview{
  margin-top: 12px;
  border-radius: var(--pfi-radius);
  border: 1px solid var(--ub-border);
  background: var(--ub-card-bg);
  overflow:hidden;
}
.ub-preview-img{
  display:none; /* shown by JS when loaded */
  width: 100%;
  height: auto;
  max-height: 360px;
  object-fit: contain;
  background: linear-gradient(180deg, var(--ub-surface-2), var(--ub-surface-1));
}
.ub-preview-canvas{
  display:none;
}

/* ============================== Palette section ============================== */
.ub-palette{
  margin-top: 12px;
}
.ub-palette-head{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap: 10px;
  flex-wrap:wrap;
  margin-bottom: 10px;
}

.ub-palette-grid{
  display:grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
@media (max-width: 560px){
  .ub-palette-grid{ grid-template-columns: 1fr; }
}

/* ============================== Swatches ============================== */
.ub-swatch{
  position: relative;
  width: 100%;
  border: 1px solid var(--ub-border);
  border-radius: var(--pfi-radius);
  background: var(--ub-card-bg);
  padding: 10px;
  min-height: 92px;
  cursor: pointer;
  text-align:left;
}
.ub-swatch:focus{
  outline: none;
  box-shadow: 0 0 0 4px var(--ub-focus);
}
.ub-swatch[aria-pressed="true"]{
  border-color: rgba(249,58,19,.55);
  box-shadow: 0 0 0 4px rgba(249,58,19,.12);
}

/* color chip bar */
.ub-swatch::before{
  content:"";
  position:absolute;
  left: 10px;
  right: 10px;
  top: 10px;
  height: 18px;
  border-radius: 999px;
  background: var(--sw, #cccccc);
  border: 1px solid rgba(0,0,0,.10);
}
html.ub-theme-dark .ub-swatch::before{
  border-color: rgba(255,255,255,.10);
}

.ub-swatch-meta{
  margin-top: 30px;
}
.ub-swatch-top{
  display:flex;
  align-items:baseline;
  justify-content:space-between;
  gap: 10px;
}
.ub-swatch-code{
  font-family: var(--ub-mono);
  font-weight: 950;
  font-size: 13px;
  overflow-wrap:anywhere;
}
.ub-swatch-pct{
  font-family: var(--ub-mono);
  font-weight: 950;
  font-size: 12px;
  color: var(--ub-muted);
  white-space:nowrap;
}
.ub-swatch-bar{
  margin-top: 8px;
  height: 10px;
  border-radius: 999px;
  background: var(--ub-surface-3);
  border: 1px solid var(--ub-border);
  overflow:hidden;
}
.ub-swatch-fill{
  height: 100%;
  width: 0%;
  background: linear-gradient(92deg, var(--ub-btn-grad-a), var(--ub-btn-grad-b));
}

/* ============================== Work/details monospace ============================== */
.ub-work{
  font-family: var(--ub-mono);
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap:anywhere;
}

/* ============================== Collapsible summary polish ============================== */
.ub-collapsible summary{
  cursor:pointer;
  font-weight: 950;
  min-height: 44px;
  display:flex;
  align-items:center;
}
.ub-collapsible summary:focus{
  outline: none;
  box-shadow: 0 0 0 4px var(--ub-focus);
  border-radius: 12px;
}

/* ============================== Rail button helper (tool-only safe) ============================== */
.ub-btn--block{ width:100%; }
