/*!
 * 123PhotoTool — shared parts of the colour tools.
 *
 *   .pt-cnow      a colour: its swatch (the system chooser lies over it) and
 *                 its codes, each typed in place and copied with one tap
 *   .pt-cslider   a channel slider with its number (--track paints the track)
 *   .pt-cseg      a segmented control: one of a few buttons, .active
 *   .pt-pick-*    picking from a photo (pt-pick.js): the photo, the ring on
 *                 the pick, the loupe, and the close button over the photo
 *   .pt-saved-*   the Saved Colors dialog (pt-saved.js keeps the list)
 */

/* ── A segmented control ───────────────────────────────────────────────── */
.pt-cseg { display: inline-flex; flex-wrap: wrap; padding: 3px; gap: 2px; border-radius: 10px; background: var(--pt-surface, #f6f8fb); border: 1px solid var(--pt-line, #e3e7ee); }
.pt-cseg button {
  min-height: 36px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--pt-muted, #6c757d);
  font-size: 0.7rem;
  font-weight: 600;
}
.pt-cseg button:hover { color: var(--pt-ink, #343f52); }
.pt-cseg button.active { background: #fff; color: var(--pt-ink, #343f52); box-shadow: 0 1px 3px rgba(30, 34, 40, 0.15); }
.pt-cseg button:focus-visible { outline: 3px solid var(--pt-accent, #3f78e0); outline-offset: 1px; }

/* ── A colour and its codes ────────────────────────────────────────────── */
.pt-cnow { display: flex; gap: 12px; align-items: stretch; }
.pt-cswatch {
  position: relative;
  flex: 0 0 104px;
  min-height: 104px;
  margin: 0;
  border-radius: var(--pt-radius-sm, 12px);
  border: 1px solid rgba(0, 0, 0, 0.12);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.35);
  cursor: pointer;
  overflow: hidden;
}
.pt-cswatch:focus-within { outline: 3px solid var(--pt-accent, #3f78e0); outline-offset: 2px; }
.pt-cnative { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; border: 0; opacity: 0; cursor: pointer; }
.pt-cswatch-edit {
  position: absolute;
  top: 6px;
  inset-inline-end: 6px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: var(--pt-ink, #343f52);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  pointer-events: none;
}
.pt-cswatch-edit svg { width: 14px; height: 14px; }
.pt-cvalues { flex: 1 1 auto; min-width: 0; display: grid; gap: 6px; }
.pt-cvalue {
  display: flex;
  align-items: stretch;
  height: 38px;
  border: 1px solid var(--pt-line, #e3e7ee);
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
}
.pt-cvalue:focus-within { border-color: var(--pt-accent, #3f78e0); box-shadow: 0 0 0 3px var(--pt-accent-soft, rgba(63, 120, 224, 0.15)); }
.pt-cvalue:has(.is-invalid) { border-color: #dc3545; }
.pt-cvalue-name {
  flex: 0 0 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-inline-end: 1px solid var(--pt-line, #e3e7ee);
  background: var(--pt-surface, #f6f8fb);
  color: var(--pt-muted, #6c757d);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.pt-cvalue input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  padding: 0 8px;
  background: transparent;
  color: var(--pt-ink, #343f52);
  font: 0.85rem/1 var(--bs-font-monospace, ui-monospace, Menlo, Consolas, monospace);
  text-overflow: ellipsis;
  outline: none;
  direction: ltr;
}
[dir="rtl"] .pt-cvalue input { text-align: right; }
.pt-cvalue input::placeholder { color: #b6bcc6; }
.pt-ccopy {
  flex: 0 0 40px;
  border: 0;
  border-inline-start: 1px solid var(--pt-line, #e3e7ee);
  background: transparent;
  color: var(--pt-muted, #6c757d);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.pt-ccopy:hover, .pt-ccopy:focus-visible { color: var(--pt-accent, #3f78e0); background: var(--pt-accent-soft, rgba(63, 120, 224, 0.06)); }
.pt-ccopy svg { width: 16px; height: 16px; }
.pt-ccopy .pt-ctick { display: none; }
.pt-cdone { color: #198754 !important; }
.pt-ccopy.pt-cdone .pt-cclip { display: none; }
.pt-ccopy.pt-cdone .pt-ctick { display: block; }
@media (min-width: 768px) and (max-width: 991.98px) {
  .pt-cswatch { flex-basis: 84px; min-height: 84px; }
}
@media (max-width: 575.98px) {
  .pt-cnow { flex-direction: column; }
  .pt-cswatch { flex: none; min-height: 56px; height: 56px; }
  .pt-cswatch-edit { top: 50%; transform: translateY(-50%); inset-inline-end: 12px; }
  .pt-cvalue { height: 44px; }
  .pt-cvalue input { font-size: 16px; } /* no iOS zoom on focus */
}

/* ── A channel slider: its name, its number, and a track that shows what
   moving it does to the colour (the page sets --track) ───────────────── */
.pt-cslider + .pt-cslider { margin-top: 12px; }
.pt-cslider-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 4px; }
.pt-cslider-head .form-label { font-size: 0.75rem; color: var(--pt-ink, #343f52); }
.pt-cslider-num { display: inline-flex; align-items: center; gap: 2px; direction: ltr; color: var(--pt-muted, #6c757d); font: 600 0.75rem/1 var(--bs-font-monospace, ui-monospace, Menlo, Consolas, monospace); }
.pt-cslider-num input {
  width: 3.6em;
  height: 32px;
  padding: 0 4px;
  border: 1px solid var(--pt-line, #e3e7ee);
  border-radius: 8px;
  background: #fff;
  color: var(--pt-ink, #343f52);
  font: inherit;
  text-align: center;
  -moz-appearance: textfield;
  appearance: textfield;
}
.pt-cslider-num input::-webkit-outer-spin-button, .pt-cslider-num input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.pt-cslider-num input:focus { outline: none; border-color: var(--pt-accent, #3f78e0); box-shadow: 0 0 0 3px var(--pt-accent-soft, rgba(63, 120, 224, 0.15)); }
.pt-crange { --track: #e3e7ee; display: block; height: 28px; }
[dir="rtl"] .pt-crange { direction: ltr; } /* a hue runs red to red left to right everywhere */
.pt-crange::-webkit-slider-runnable-track { height: 10px; border-radius: 5px; background: var(--track); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1); }
.pt-crange::-moz-range-track { height: 10px; border-radius: 5px; background: var(--track); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1); }
.pt-crange::-webkit-slider-thumb { width: 22px; height: 22px; margin-top: -6px; background: #fff; border: 2px solid var(--pt-ink, #343f52); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3); }
.pt-crange::-moz-range-thumb { width: 22px; height: 22px; background: #fff; border: 2px solid var(--pt-ink, #343f52); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3); }
@media (max-width: 575.98px) {
  .pt-cslider-num input { height: 36px; font-size: 16px; } /* no iOS zoom on focus */
  .pt-crange { height: 36px; }
}

/* ── Picking from a photo (pt-pick.js) ─────────────────────────────────── */
.pt-pick-box {
  position: absolute;
  display: none;
  cursor: crosshair;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  outline: none;
  border-radius: 4px;
}
.pt-pick-on > .pt-pick-box { display: block; }
.pt-pick-box:focus-visible { box-shadow: 0 0 0 3px var(--pt-accent, #3f78e0); }
.pt-pick-box > canvas { display: block; width: 100%; height: 100%; }
.pt-pick-marker {
  position: absolute;
  width: 28px;
  height: 28px;
  margin: -14px 0 0 -14px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1.5px rgba(0, 0, 0, 0.7), inset 0 0 0 1.5px rgba(0, 0, 0, 0.7);
  pointer-events: none;
}
.pt-pick-marker::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 4px;
  height: 4px;
  margin: -2px 0 0 -2px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.7);
}
.pt-pick-marker[hidden], .pt-picking > .pt-pick-marker { display: none; }
.pt-pick-loupe {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 7;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  will-change: transform;
}
.pt-pick-loupe.show { display: flex; }
.pt-pick-loupe > canvas {
  width: 132px;
  height: 132px;
  border-radius: 50%;
  border: 7px solid #fff;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.95), 0 0 0 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
  background: #9aa1ab;
}
.pt-pick-hex {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 4px;
  border-radius: 999px;
  background: rgba(17, 19, 23, 0.86);
  color: #fff;
  font: 600 0.78rem/1.4 var(--bs-font-monospace, ui-monospace, Menlo, Consolas, monospace);
  direction: ltr;
}
.pt-pick-hex > i { width: 16px; height: 16px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, 0.7); }
.pt-pick-remove {
  position: absolute;
  top: 10px;
  inset-inline-end: 10px;
  z-index: 6;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(17, 19, 23, 0.7);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pt-pick-remove[hidden] { display: none; }
.pt-pick-remove:hover, .pt-pick-remove:focus-visible { background: rgba(17, 19, 23, 0.9); }
.pt-pick-remove svg { width: 20px; height: 20px; }
/* The phone editor has its own close. */
.pt-app-open .pt-pick-remove, #pt-app .pt-pick-remove { display: none !important; }

/* ── Saved Colors (pt-saved.js): the list in its dialog ─────────────────── */
/* [dir="rtl"] too: style.css gives RTL lists padding-right: 2rem at (0,1,1), above a class. */
.pt-saved-list, [dir="rtl"] .pt-saved-list { margin: 0; padding: 0; list-style: none; }
.pt-saved-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--pt-line, #e3e7ee);
  border-radius: 12px;
  background: var(--pt-surface, #f6f8fb);
}
.pt-saved-item + .pt-saved-item { margin-top: 8px; }
.pt-saved-swatch {
  flex: 0 0 44px;
  height: 44px;
  padding: 0;
  border: 2px solid #fff;
  border-radius: 10px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12);
  cursor: pointer;
}
.pt-saved-swatch:hover, .pt-saved-swatch:focus-visible { box-shadow: 0 0 0 2px var(--pt-accent, #3f78e0); }
.pt-saved-meta { flex: 1 1 auto; min-width: 0; }
.pt-saved-hex { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font: 600 0.95rem/1.3 var(--bs-font-monospace, ui-monospace, Menlo, Consolas, monospace); color: var(--pt-ink, #343f52); }
.pt-saved-rgb { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font: 0.8rem/1.3 var(--bs-font-monospace, ui-monospace, Menlo, Consolas, monospace); color: var(--pt-muted, #6c757d); }
.pt-saved-tag {
  padding: 1px 8px;
  border-radius: 999px;
  background: rgba(63, 120, 224, 0.12);
  color: #2f5fb8;
  font: 600 0.68rem/1.5 var(--bs-body-font-family, system-ui, sans-serif);
}
.pt-saved-tag.pt-tag-palette { background: rgba(255, 193, 7, 0.22); color: #7a5a00; }
.pt-saved-btn { flex: none; width: 40px; height: 40px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.pt-saved-btn svg { width: 16px; height: 16px; }
.pt-saved-btn .pt-ctick { display: none; }
.pt-saved-btn.pt-cdone .pt-cclip { display: none; }
.pt-saved-btn.pt-cdone .pt-ctick { display: block; }
.pt-saved-modal .modal-header { padding: 20px 24px 12px; border-bottom: 1px solid var(--pt-line, #e3e7ee); }
.pt-saved-modal .modal-header .btn-close { position: static; margin: 0 0 0 auto; }
[dir="rtl"] .pt-saved-modal .modal-header .btn-close { margin: 0 auto 0 0; }
.pt-saved-modal .modal-body { min-height: 160px; padding: 16px 24px; }
.pt-saved-modal .modal-footer { padding: 12px 24px 20px; border-top: 1px solid var(--pt-line, #e3e7ee); gap: 8px; flex-wrap: wrap; }
.pt-saved-modal .modal-footer > .btn { margin: 0; }
.pt-saved-modal .pt-saved-empty[hidden] { display: none; }
@media (max-width: 575.98px) {
  .pt-saved-modal .modal-header, .pt-saved-modal .modal-body, .pt-saved-modal .modal-footer { padding-left: 16px; padding-right: 16px; }
  .pt-saved-modal .modal-footer > .btn { flex: 1 1 auto; min-height: 44px; }
}
