/*!
 * 123PhotoTool — Color Palette Generator (color-palette.php).
 *
 * The page uses the shared tool layout (pt-ui.css), the shared colour parts
 * (pt-color.css) and, with a photo on a phone, the full-screen editor
 * (pt-app.css). This file is what the tool adds: the palette bars, the chips
 * under the photo, the sliders, the type buttons and the palette rows.
 */

/* ── The selected colour ───────────────────────────────────────────────── */
.pl-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  border-radius: 12px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15);
  font-size: 0.78rem;
  font-weight: 700;
}
.pl-base-tag {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--pt-surface, #f6f8fb);
  color: var(--pt-muted, #6c757d);
  font-size: 0.72rem;
  font-weight: 600;
}
.pl-base-tag[hidden] { display: none; }
.pl-color-tools { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.pl-tool-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; flex: 1 1 auto; }
.pl-tool-btn svg { flex: none; width: 14px; height: 14px; }
.pl-tool-btn .badge { font-size: 0.68rem; }
.pl-tool-btn.pl-locked { background: var(--pt-ink, #343f52); border-color: var(--pt-ink, #343f52); color: #fff; }
.pl-tool-btn.pt-cdone { border-color: #198754; }
/* A lock shows shut or open. */
.pl-lock-on { display: none; }
.pl-locked .pl-lock-on { display: block; }
.pl-locked .pl-lock-off { display: none; }

/* ── Sliders: each track shows what it does to the colour ──────────────── */
.pl-slider + .pl-slider { margin-top: 10px; }
.pl-slider-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.pl-slider-head output { font: 600 0.8rem/1 var(--bs-font-monospace, ui-monospace, Menlo, Consolas, monospace); color: var(--pt-muted, #6c757d); direction: ltr; }
.pl-slider-ends { display: flex; justify-content: space-between; color: var(--pt-muted, #6c757d); margin-top: -2px; }
.pl-range { --pl-track: #e3e7ee; }
.pl-range-hue { --pl-track: linear-gradient(to right, #f00, #ff0 16.67%, #0f0 33.33%, #0ff 50%, #00f 66.67%, #f0f 83.33%, #f00); }
.pl-range-sat { --pl-track: var(--pl-sat-track, linear-gradient(to right, #8c8c8c, #3b82f6)); }
.pl-range-light { --pl-track: var(--pl-light-track, linear-gradient(to right, #000, #3b82f6, #fff)); }
[dir="rtl"] .pl-range { direction: ltr; }
.pl-range::-webkit-slider-runnable-track { height: 10px; border-radius: 5px; background: var(--pl-track); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1); }
.pl-range::-moz-range-track { height: 10px; border-radius: 5px; background: var(--pl-track); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1); }
.pl-range::-webkit-slider-thumb { width: 20px; height: 20px; margin-top: -5px; background: #fff; border: 2px solid var(--pt-ink, #343f52); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3); }
.pl-range::-moz-range-thumb { width: 20px; height: 20px; background: #fff; border: 2px solid var(--pt-ink, #343f52); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3); }

/* ── Palette types ─────────────────────────────────────────────────────── */
/* Two to a row; a label whose longest word needs more takes the row
   (a fixed two-column grid chopped "Monochromatic" mid-word). */
.pl-types { display: flex; flex-wrap: wrap; gap: 6px; }
.pl-tbtn {
  flex: 1 1 calc(50% - 3px);
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 6px 10px;
  border: 1px solid var(--pt-line, #e3e7ee);
  border-radius: 10px;
  background: #fff;
  color: var(--pt-ink, #343f52);
  font-size: 13.6px;
  font-weight: 600;
  line-height: 1.2;
  text-align: start;
}
.pl-tbtn[hidden] { display: none; }
.pl-tbtn svg { flex: none; width: 22px; height: 22px; }
.pl-tbtn span { min-width: 0; }
.pl-tbtn:hover { border-color: var(--pt-accent, #0f70e6); }
.pl-tbtn:focus-visible { outline: 3px solid var(--pt-accent, #0f70e6); outline-offset: 1px; }
.pl-tbtn.active { border-color: var(--pt-accent, #0f70e6); background: var(--pt-accent-soft, rgba(15, 112, 230, 0.1)); color: var(--pt-accent, #0f70e6); }
/* The 320px panel: the icon over the label leaves a half-width tile room
   for "Monochromatic". */
@media (min-width: 768px) and (max-width: 991.98px) {
  .pl-tbtn { flex-direction: column; justify-content: center; gap: 4px; padding: 8px 6px; text-align: center; }
}
.pl-desc { margin-top: 8px; color: var(--pt-muted, #6c757d); font-size: 13.6px; line-height: 1.45; }
.pl-hint { margin-top: 8px; color: var(--pt-muted, #6c757d); font-size: 13px; line-height: 1.4; }
.pl-random { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; }
.pl-random svg { flex: none; width: 18px; height: 18px; }

/* ── The palette rows ──────────────────────────────────────────────────── */
.pl-list-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.pl-codes .btn { padding: 2px 10px; font-size: 0.78rem; }
/* [dir="rtl"] too: style.css gives RTL lists padding-right: 2rem at (0,1,1), above a class. */
.pl-list, [dir="rtl"] .pl-list { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.pl-row {
  display: flex;
  align-items: stretch;
  min-height: 50px;
  border: 1px solid var(--pt-line, #e3e7ee);
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
}
.pl-row[hidden] { display: none; }
.pl-row.pl-active { border-color: var(--pt-accent, #0f70e6); box-shadow: 0 0 0 2px var(--pt-accent-soft, rgba(15, 112, 230, 0.15)); }
.pl-row-pick {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border: 0;
  background: transparent;
  color: var(--pt-ink, #343f52);
  text-align: start;
}
.pl-row-num {
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--pt-surface, #eef1f5);
  color: var(--pt-muted, #6c757d);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  line-height: 1; /* an Arabic line box overflowed the 22px circle */
}
.pl-active .pl-row-num { background: var(--pt-accent, #0f70e6); color: #fff; }
.pl-row-swatch {
  flex: 0 0 48px;
  height: 36px;
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 700;
}
/* The code over its contrast pill. A long code (rgb, hsl) wraps at its
   spaces rather than being cut to "#…". */
.pl-row-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 3px; }
.pl-row-code { max-width: 100%; font: 600 13px/1.25 var(--bs-font-monospace, ui-monospace, Menlo, Consolas, monospace); direction: ltr; }
.pl-row-ratio {
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.4;
  white-space: nowrap;
  direction: ltr;
  cursor: help;
}
.pl-row-ratio.pl-ok { background: rgba(25, 135, 84, 0.12); color: #146c43; }
.pl-row-ratio.pl-large { background: rgba(250, 183, 88, 0.2); color: #8a5a10; }
.pl-row-ratio.pl-low { background: rgba(220, 53, 69, 0.1); color: #b02a37; }
.pl-row-lock {
  flex: 0 0 40px;
  border: 0;
  border-inline-start: 1px solid var(--pt-line, #e3e7ee);
  background: transparent;
  color: #a5acb8;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.pl-row-lock svg { width: 15px; height: 15px; }
.pl-row-lock:hover, .pl-row-lock:focus-visible { color: var(--pt-accent, #0f70e6); background: var(--pt-accent-soft, rgba(15, 112, 230, 0.06)); }
.pl-row.pl-locked .pl-row-lock { color: var(--pt-ink, #343f52); background: var(--pt-surface, #f6f8fb); }
.pl-row .pt-ccopy { flex: 0 0 44px; }
.pl-format-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
#pl-copy-all { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
@media (max-width: 380px) {
  .pl-row-swatch { flex-basis: 38px; }
  .pl-row-pick { gap: 8px; padding: 6px 8px; }
  .pl-row-ratio { padding: 2px 6px; }
  .pl-row-lock { flex-basis: 36px; }
  .pl-row .pt-ccopy { flex-basis: 38px; }
}

/* ── The workspace: the bars (or the photo), the chips, the upload ─────── */
#pl-viewport { display: flex; flex-direction: column; overflow: hidden; }
.pl-main { position: relative; flex: 1 1 auto; min-height: 0; display: flex; align-items: stretch; justify-content: center; }
/* A bar per colour: side by side here, one above the other on a phone. */
.pl-bars {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  margin: 12px;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.06), 0 8px 28px rgba(30, 34, 40, 0.12);
}
.pl-bar { position: relative; flex: 1 1 0; min-width: 0; min-height: 0; display: flex; transition: flex-grow 0.18s ease; }
.pl-bar[hidden] { display: none; }
.pl-bar.pl-active { flex-grow: 1.35; }
.pl-bar-pick {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  padding: 14px 4px 18px;
  border: 0;
  background: transparent;
  color: inherit;
}
.pl-bar-pick:focus-visible { outline: 3px solid currentColor; outline-offset: -6px; }
.pl-bar-num { font-size: 0.8rem; font-weight: 700; opacity: 0.7; line-height: 1; }
.pl-bar-base { font-size: 0.68rem; font-weight: 600; opacity: 0.8; line-height: 1.2; text-align: center; overflow-wrap: anywhere; }
.pl-bar-base:empty { display: none; }
.pl-bar-code { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 700 0.95rem/1.2 var(--bs-font-monospace, ui-monospace, Menlo, Consolas, monospace); direction: ltr; }
/* The selected bar: a ring inside it, in its own text colour. */
.pl-bar.pl-active::after { content: ""; position: absolute; inset: 6px; border: 3px solid currentColor; border-radius: 10px; opacity: 0.85; pointer-events: none; }
.pl-bar.pt-cdone::after { border-color: #198754; opacity: 1; }
.pl-bar-lock {
  position: absolute;
  top: 12px;
  left: 50%;
  width: 36px;
  height: 36px;
  margin-left: -18px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  color: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s, background-color 0.15s;
  z-index: 1;
}
.pl-bar-lock svg { width: 16px; height: 16px; }
.pl-bar:hover .pl-bar-lock, .pl-bar.pl-active .pl-bar-lock, .pl-bar-lock:focus-visible, .pl-bar.pl-locked .pl-bar-lock { opacity: 1; }
.pl-bar-lock:hover { background: rgba(255, 255, 255, 0.38); }
.pl-bar.pl-locked .pl-bar-lock { background: rgba(0, 0, 0, 0.28); color: #fff; }
.pl-bar-lock:focus-visible { outline: 3px solid currentColor; outline-offset: 2px; }
@media (hover: none) { .pl-bar-lock { opacity: 0.75; } }
/* Narrow columns (many colours): the code on its side. */
.pl-bars.pl-narrow .pl-bar-code { writing-mode: vertical-rl; transform: rotate(180deg); max-width: none; max-height: 100%; font-size: 0.85rem; }
.pl-bars.pl-narrow .pl-bar-base { display: none; }
.pl-bars.pl-narrow .pl-bar-lock { width: 30px; height: 30px; margin-left: -15px; }

/* The photo instead of the bars; the chips under it. */
.pl-main.pl-photo-view > .pl-bars { display: none; }
.pl-main:not(.pl-photo-view) > .pt-pick-box, .pl-main:not(.pl-photo-view) > .pt-pick-loupe { display: none !important; }
.pl-strip { flex: none; display: none; grid-template-columns: repeat(var(--pl-n, 5), minmax(0, 1fr)); gap: 6px; padding: 4px 12px 12px; }
.pl-photo-on .pl-strip { display: grid; }
.pl-chip {
  position: relative;
  min-width: 0;
  height: 56px;
  padding: 0 2px;
  border: 0;
  border-radius: 12px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  transition: transform 0.12s, box-shadow 0.12s;
}
.pl-chip[hidden] { display: none; }
.pl-chip-num { font-size: 0.7rem; font-weight: 700; line-height: 1; opacity: 0.75; }
.pl-chip-code { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 600 0.72rem/1.2 var(--bs-font-monospace, ui-monospace, Menlo, Consolas, monospace); direction: ltr; }
.pl-chip.pl-locked::after { content: ""; position: absolute; top: 4px; inset-inline-end: 4px; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: 0.8; }
.pl-chip.pl-active { transform: translateY(-2px); box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--pt-accent, #0f70e6); }
.pl-chip:focus-visible { outline: 3px solid var(--pt-accent, #0f70e6); outline-offset: 3px; }
.pl-chip.pt-cdone { box-shadow: 0 0 0 3px #fff, 0 0 0 5px #198754; }
.pl-views {
  position: absolute;
  top: 10px;
  inset-inline-start: 10px;
  z-index: 6;
  display: flex;
  padding: 3px;
  border-radius: 999px;
  background: rgba(17, 19, 23, 0.72);
}
.pl-views[hidden] { display: none; }
.pl-views button { border: 0; border-radius: 999px; padding: 5px 12px; background: transparent; color: #fff; font-size: 0.8rem; font-weight: 600; }
.pl-views button[aria-pressed="true"] { background: #fff; color: var(--pt-ink, #343f52); }
/* With a photo, the bars leave a strip above them for the switch, clear of
   the codes and the locks. */
.pl-has-photo .pl-main:not(.pl-photo-view) > .pl-bars { margin-top: 54px; }

.pl-foot {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  margin: 0 12px 12px;
  padding: 10px 12px;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 2px 10px rgba(30, 34, 40, 0.06);
}
.pl-has-photo .pl-foot { display: none; }
.pl-foot .sample-thumbnails { display: flex; justify-content: center; gap: 8px; }
.pl-foot .sample-thumbnail {
  width: 52px;
  height: 52px;
  padding: 0;
  border: 2px solid #dee2e6;
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  cursor: pointer;
}
.pl-foot .sample-thumbnail:hover { border-color: var(--pt-accent, #0f70e6); }
.pl-foot .sample-thumbnail img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 0 !important; }

/* ── Phone: one bar above the other ────────────────────────────────────── */
@media (max-width: 767.98px) {
  .pl-bars { flex-direction: column; margin: 10px; }
  .pl-bar.pl-active { flex-grow: 1.25; }
  .pl-bar-pick { flex-direction: row; justify-content: flex-start; gap: 10px; padding: 8px 64px 8px 16px; }
  [dir="rtl"] .pl-bar-pick { padding: 8px 16px 8px 64px; }
  .pl-bar-num { order: 0; }
  .pl-bar-code { order: 1; font-size: 0.95rem; }
  .pl-bar-base { order: 2; text-align: start; }
  .pl-bar-lock { top: 50%; left: auto; right: 10px; margin: -18px 0 0; opacity: 0.75; }
  [dir="rtl"] .pl-bar-lock { right: auto; left: 10px; }
  .pl-bar.pl-active::after { inset: 4px; border-radius: 9px; }
  .pl-bars.pl-short .pl-bar-pick { padding-top: 2px; padding-bottom: 2px; }
  .pl-bars.pl-short .pl-bar-lock { width: 30px; height: 30px; margin-top: -15px; }
  /* On the page (no photo) each bar is a row of its own height. */
  #pl-viewport:not(.pl-has-photo):not(.pt-app-viewport) { height: auto !important; min-height: 0 !important; }
  #pl-viewport:not(.pl-has-photo):not(.pt-app-viewport) .pl-main { flex: none; }
  #pl-viewport:not(.pl-has-photo):not(.pt-app-viewport) .pl-bar { flex: none; min-height: 50px; }
  #pl-viewport:not(.pl-has-photo):not(.pt-app-viewport) .pl-bar.pl-active { min-height: 64px; }
  .pl-chip { height: 50px; }
  .pl-chip-code { font-size: 0.64rem; }
}
/* On the phone page a photo is not a work surface (a tap opens the editor),
   so its own buttons would only be in the way. */
html.pt-phone:not(.pt-app-open) #pl-views, html.pt-phone:not(.pt-app-open) #pl-remove-photo { display: none !important; }

/* ── In the phone editor ───────────────────────────────────────────────── */
#pt-app #pl-views, #pt-app .pl-foot { display: none !important; }
#pt-app .pl-strip { padding: 8px 4px 0; gap: 4px; }
#pt-app .pl-chip.pl-active { box-shadow: 0 0 0 2px #15181d, 0 0 0 4px #fff; }
#pt-app .pl-bars { margin: 4px 0; box-shadow: none; }
.pt-app-sheet .pl-save .pt-tool-savebar > .btn { flex: 1 1 auto; }
