/* InstantPalette - photo recolor (layer 5, this page only)
   Load order: tokens.css -> base.css -> site.css -> tools.css -> photo-recolor.css

   Only what this tool needs: the compare stage, the sample buttons, the look tiles, the palette chips per role and
   the export row. Panels, buttons, sliders and segmented controls come from tools.css. */

/* ================= Image and compare stage ================= */
.pr-image { container: primg / inline-size; }
.pr-cmp { --ar: 1.5; --tall: 56vh; width: min(100%, max(180px, var(--tall) * var(--ar))); margin: 0 auto; }
@container tpage (min-width: 690px) { .pr-cmp { --tall: 40vh; } }
.pr-tags { display: flex; justify-content: space-between; gap: 12px; margin: 0 0 6px; font: 500 13px/1.3 var(--f-sans); }
.pr-stage {
  --split: 50%;
  position: relative;
  aspect-ratio: var(--ar);
  border-radius: var(--r);
  background: var(--sunken);
  box-shadow: 0 0 0 1px var(--line-2);
  cursor: ew-resize; touch-action: pan-y;
  -webkit-user-select: none; user-select: none;
}
.pr-layer { position: absolute; inset: 0; border-radius: var(--r); overflow: hidden; pointer-events: none; }
.pr-layer > canvas { display: block; width: 100%; height: 100%; object-fit: contain; }
/* An opaque ground, so the recolored copy never shows through a transparent original */
.pr-over { clip-path: inset(0 calc(100% - var(--split)) 0 0); background: var(--sunken); }
/* The handle: a 2px line with a white-on-black rim, and a 44px grip */
.pr-split {
  position: absolute; top: 0; bottom: 0; left: var(--split); width: 44px;
  transform: translateX(-50%);
  display: grid; place-items: center;
}
.pr-split::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: 2px; transform: translateX(-50%);
  background: #FFF; box-shadow: 0 0 0 1px #000;
}
.pr-grip {
  position: relative; width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--raised); color: var(--ink-1);
  box-shadow: 0 0 0 2px var(--ink-1), 0 0 0 4px var(--raised);
}
.pr-grip .i { width: 22px; height: 22px; }
.pr-split:focus-visible { outline: none; }
.pr-split:focus-visible .pr-grip { box-shadow: 0 0 0 2px var(--ink-1), 0 0 0 4px var(--raised), 0 0 0 7px var(--ink-1), 0 0 0 9px var(--raised); }
.pr-drop {
  position: absolute; inset: 0; z-index: 1;
  display: grid; place-items: center; padding: 20px;
  border: 2px solid var(--ink-1); border-radius: var(--r);
  background: var(--raised); text-align: center; font: 600 17px/1.3 var(--f-sans);
}
.pr-name { min-width: 0; }
.pr-name .field-hint { overflow-wrap: anywhere; }
.pr-image .tpanel-hd .btn-o { min-height: 44px; flex: none; }
.pr-image .tpanel-bd { gap: 12px; }
.pr-samples { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.pr-samples .field-l { flex: none; }
.pr-samples .field-hint { flex: 1 0 60%; }
/* A finger can neither drop nor paste a file */
@media (hover: none), (pointer: coarse) {
  .pr-samples .field-l { flex: 1 0 100%; }
  .pr-samples .field-hint { display: none; }
}
.pr-sample {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 4px 12px 4px 4px;
  border: 1px solid var(--line-2); border-radius: var(--r);
  background: var(--raised); color: var(--ink-1);
  font: 500 13px/1.1 var(--f-sans); white-space: nowrap;
}
.pr-sample canvas { display: block; width: 46px; height: 34px; border-radius: var(--r-xs); }
.pr-sample[aria-pressed="true"] { border-color: var(--ink-1); box-shadow: inset 0 0 0 1px var(--ink-1); }
@media (hover: hover) and (pointer: fine) { .pr-sample:hover { border-color: var(--ink-1); } }
/* A wide panel: the samples stand beside the picture */
@container primg (min-width: 680px) {
  .pr-image .tpanel-bd { display: grid; grid-template-columns: minmax(0, 1fr) 152px; gap: 0 18px; align-items: start; }
  .pr-image .pr-cmp { --tall: 43vh; }
  .pr-image .pr-samples { flex-direction: column; align-items: stretch; flex-wrap: nowrap; }
  .pr-samples .field-l { flex: none; line-height: 17px; margin-bottom: -2px; }
  .pr-samples .field-hint { order: 9; flex: none; margin: 0; }
}

/* ================= Look ================= */
.pr-looks { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.pr-look {
  display: flex; flex-direction: column; gap: 5px; min-width: 0; padding: 4px 4px 6px;
  border: 1px solid var(--line-2); border-radius: var(--r);
  color: var(--ink-1); text-align: center; font: 500 13px/1.2 var(--f-sans);
}
.pr-look canvas { display: block; width: 100%; aspect-ratio: 168 / 108; border-radius: var(--r-xs); background: var(--sunken); }
.pr-look[aria-checked="true"] { background: var(--sunken); border-color: var(--ink-1); box-shadow: inset 0 0 0 1px var(--ink-1); font-weight: 600; }
@media (hover: hover) and (pointer: fine) { .pr-look:hover { border-color: var(--ink-1); } }

/* The two-column workspace at its narrowest: every look name stays on one line */
@container tpage (min-width: 690px) and (max-width: 879.98px) { .pr-look { font-size: 12px; letter-spacing: -.03em; padding-inline: 3px; } }

.pr-colors { display: flex; flex-direction: column; gap: 10px; }
.pr-picks { display: grid; gap: 8px; }
.pr-role { display: grid; grid-template-columns: 66px minmax(0, 1fr); align-items: center; gap: 6px; }
.pr-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.pr-chip {
  width: 44px; height: 44px; display: grid; place-items: center;
  border: 1px solid var(--ink-3); border-radius: var(--r);
  background: var(--sw, var(--sunken)); color: var(--ink, #000);
}
.pr-chip .i { opacity: 0; stroke-width: 2.4; }
.pr-chip[aria-checked="true"] { box-shadow: 0 0 0 2px var(--raised), 0 0 0 4px var(--ink-1); }
.pr-chip[aria-checked="true"] .i { opacity: 1; }
.pr-chip:focus-visible { outline: 2px solid var(--ink-1); outline-offset: 5px; }
/* A mouse can hit a narrower chip, so eight colors stay on one line */
@media (hover: hover) and (pointer: fine) {
  .pr-chips { flex-wrap: nowrap; }
  .pr-chip { flex: 0 1 44px; min-width: 24px; }
  .pr-chip:hover { border-color: var(--ink-1); }
}
.pr-ramp { display: block; width: 100%; height: 16px; border-radius: var(--r-xs); image-rendering: pixelated; box-shadow: 0 0 0 1px var(--line-2); }
.pr-two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 20px; }
.pr-two > .wide { grid-column: 1 / -1; }
#pr-bm button { flex: 1 1 auto; padding: 0 9px; text-align: center; }
.pr-tgs { display: flex; flex-wrap: wrap; gap: 8px; }
.pr-tg { min-height: 44px; flex: 1 1 130px; }
.pr-tg .i { display: none; stroke-width: 2.4; }
.pr-tg[aria-pressed="true"] { border-color: var(--ink-1); background: var(--sunken); box-shadow: inset 0 0 0 1px var(--ink-1); }
.pr-tg[aria-pressed="true"] .i { display: block; }

/* ================= Export ================= */
.pr-exp .tpanel-bd { gap: 12px; }
.pr-fmt { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.pr-fmt .tprimary { flex: 1 0 190px; }
.pr-acts { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; }
.pr-acts .tslider { flex: 1 1 100%; }
.pr-acts .btn-o { min-height: 44px; flex: 1 1 auto; }
.pr-acts [aria-disabled="true"] { cursor: progress; }

@media (max-width: 520px) {
  .pr-fmt .tseg { flex: 1 1 100%; }
  .pr-fmt .tseg button { flex: 1 1 0; text-align: center; }
  .pr-sample { flex: 1 1 auto; justify-content: center; }
}
/* Landscape phones: the stage gives the handle and the panel head room */
@media (orientation: landscape) and (max-height: 500px) { .pr-cmp { width: min(100%, max(180px, 64vh * var(--ar))); } }
