/*!
 * 123PhotoTool — Image Color Extractor (color-extractor.php).
 *
 * The page uses the shared tool layout (pt-ui.css) and, on a phone, the
 * full-screen editor (pt-app.css). This file is only what the extractor
 * adds: the moods, the colour list, the photo with its numbered handles,
 * and the editor's colour bar.
 */

/* ── Panel ─────────────────────────────────────────────────────────────── */
/* Three to a row, each at least as wide as its label (equal thirds cut
   "Gedämpft" short); a row too narrow wraps. */
.ce-moods { display: flex; flex-wrap: wrap; gap: 6px; }
.ce-moods .btn {
  flex: 1 1 calc(33.333% - 4px);
  min-height: 36px;
  padding: 6px 10px;
  font-size: 13.6px;
  font-weight: 600;
  white-space: nowrap;
  /* The theme lifts outline buttons on hover; a choice stays put. */
  transform: none !important;
}

.ce-count { display: flex; align-items: center; gap: 12px; }
.ce-count .form-label { white-space: nowrap; }
.ce-count .form-range { flex: 1 1 auto; min-width: 0; }

/* [dir="rtl"] too: style.css gives RTL lists padding-right: 2rem at (0,1,1), above a class. */
.ce-list, [dir="rtl"] .ce-list { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.ce-row {
  display: flex;
  align-items: stretch;
  height: 48px;
  border: 1px solid var(--pt-line, #e3e7ee);
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.ce-row.ce-active { border-color: var(--pt-accent, #0f70e6); box-shadow: 0 0 0 2px var(--pt-accent-soft, rgba(15, 112, 230, 0.18)); }
.ce-row > button, .ce-codes > button { border: 0; background: transparent; padding: 0; color: inherit; }
.ce-pick { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; padding: 0 0 0 10px !important; cursor: pointer; }
[dir="rtl"] .ce-pick { padding: 0 10px 0 0 !important; }
.ce-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--pt-surface, #f1f4f8);
  color: var(--pt-muted, #6c757d);
  font: 700 0.72rem/22px var(--bs-body-font-family, system-ui, sans-serif);
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.ce-row.ce-active .ce-num { background: var(--pt-accent, #0f70e6); color: #fff; }
.ce-swatch {
  width: 52px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.12);
}
/* No colour yet: a blank, striped. */
.ce-row.ce-empty .ce-swatch { background: repeating-linear-gradient(45deg, #f1f3f6 0 6px, #e6e9ee 6px 12px); }
.ce-codes { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 4px; padding: 0 8px; }
.ce-code {
  min-width: 0;
  height: 32px;
  padding: 0 6px !important;
  border-radius: 6px;
  font: 0.82rem/32px var(--bs-font-monospace, ui-monospace, Menlo, Consolas, monospace);
  color: var(--pt-ink, #343f52) !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: copy;
  direction: ltr;
}
.ce-hex { flex: 0 0 auto; font-weight: 700; }
.ce-rgb { flex: 0 1 auto; color: var(--pt-muted, #6c757d) !important; }
.ce-code:hover:not(:disabled), .ce-code:focus-visible { background: var(--pt-accent-soft, rgba(15, 112, 230, 0.08)) !important; }
.ce-copy {
  flex: 0 0 44px;
  border-inline-start: 1px solid var(--pt-line, #e3e7ee) !important;
  color: var(--pt-muted, #6c757d) !important;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ce-copy:hover:not(:disabled), .ce-copy:focus-visible { color: var(--pt-accent, #0f70e6) !important; background: var(--pt-accent-soft, rgba(15, 112, 230, 0.06)) !important; }
.ce-copy svg { width: 16px; height: 16px; }
.ce-copy .ce-tick, .ce-bar-copy .ce-tick { display: none; }
.ce-done { color: #198754 !important; }
.ce-copy.ce-done .ce-clip { display: none; }
.ce-copy.ce-done .ce-tick { display: block; }
.ce-row.ce-empty .ce-code, .ce-row.ce-empty .ce-copy, .ce-row.ce-empty .ce-pick { cursor: default; }
.ce-row.ce-empty .ce-hex { color: var(--pt-muted, #6c757d) !important; font-weight: 400; }
.ce-row.ce-empty .ce-copy { opacity: 0.45; }
@media (min-width: 768px) and (max-width: 991.98px) {
  .ce-rgb { display: none; }
}
/* 0.82rem was 16.4px on this site's 20px root. In the desktop's 360px
   panel the RGB code sat beside the HEX and was cut to "rgb(113,…": it goes
   under it, in the same 48px row. */
@media (min-width: 768px) {
  .ce-code { font-size: 13px; }
}
@media (min-width: 992px) {
  .ce-codes { flex-direction: column; align-items: flex-start; justify-content: center; gap: 0; }
  .ce-code { height: 20px; line-height: 20px; }
  .ce-rgb { font-size: 12px; }
}

.ce-format-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.ce-format-row .form-select { flex: 1 1 auto; min-width: 0; }
.ce-save #ce-copy-all { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.ce-save #ce-copy-all svg { flex: none; }

/* ── The photo box ─────────────────────────────────────────────────────── */
#ce-viewport { overflow: hidden; }
#ce-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  text-align: center;
}
.ce-has-photo #ce-empty { display: none; }
#ce-empty .sample-thumbnails { display: flex; justify-content: center; gap: 12px; margin: 10px 0; flex-wrap: wrap; }
#ce-empty .sample-thumbnail {
  cursor: pointer;
  border: 2px solid #dee2e6;
  border-radius: 10px;
  overflow: hidden;
  width: 110px;
  height: 110px;
  padding: 0;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
#ce-empty .sample-thumbnail:hover { border-color: var(--pt-accent, #0f70e6); box-shadow: 0 4px 12px rgba(15, 112, 230, 0.25); }
#ce-empty .sample-thumbnail img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 0 !important; }
@media (max-width: 768px) { #ce-empty .sample-thumbnail { width: 90px; height: 90px; } }
@media (max-width: 576px) { #ce-empty .sample-thumbnail { width: 72px; height: 72px; } }

/* The photo, fitted and centred by color-extractor.js. */
#ce-image-box {
  position: absolute;
  display: none;
  cursor: crosshair;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.ce-has-photo #ce-image-box { display: block; }
#extractorCanvas { display: block; width: 100%; height: 100%; border-radius: 4px; }

/* A handle: the colour, its number, ringed to read on light and dark. */
.ce-handle {
  position: absolute;
  width: 30px;
  height: 30px;
  margin: -15px 0 0 -15px;
  padding: 0;
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45), 0 2px 6px rgba(0, 0, 0, 0.35);
  color: #fff;
  font: 700 0.75rem/24px var(--bs-body-font-family, system-ui, sans-serif);
  text-align: center;
  text-shadow: 0 0 2px rgba(0, 0, 0, 0.8);
  cursor: grab;
  touch-action: none;
  transition: transform 0.12s, box-shadow 0.12s;
}
.ce-handle.ce-on-light { color: #1e2228; text-shadow: 0 0 2px rgba(255, 255, 255, 0.9); }
.ce-handle[hidden] { display: none; }
.ce-handle.ce-active {
  z-index: 2;
  transform: scale(1.2);
  box-shadow: 0 0 0 2px var(--pt-accent, #0f70e6), 0 0 0 4px #fff, 0 3px 10px rgba(0, 0, 0, 0.4);
}
.ce-handle:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--pt-accent, #0f70e6), 0 0 0 5px #fff, 0 0 0 7px var(--pt-accent, #0f70e6); }
.ce-dragging, .ce-dragging .ce-handle { cursor: grabbing; }
/* Touch handles are bigger: a fingertip, not a cursor. */
@media (pointer: coarse) {
  .ce-handle { width: 36px; height: 36px; margin: -18px 0 0 -18px; line-height: 30px; font-size: 0.85rem; }
}

/* The loupe: the spot under the finger, enlarged, ringed in its colour. */
#ce-loupe {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 7;
  display: none;
  pointer-events: none;
  will-change: transform;
}
#ce-loupe.show { display: block; }
#ce-loupe-canvas {
  display: block;
  width: 120px;
  height: 120px;
  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;
}

/* ── In the phone editor ───────────────────────────────────────────────── */
/* Colors: the colours (a tap selects one), then the selected one's codes. */
.ce-bar { padding: 2px 4px; }
.pt-app-panels > #ce-colors-bar.pt-app-panel-on { display: flex !important; flex-direction: column; gap: 8px; }
.ce-bar-swatches {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding: 4px 2px;
}
.ce-bar-swatches::-webkit-scrollbar { display: none; }
/* #id: pt-app.css sets .pt-app-strip > * { flex: none } and loads later. */
#ce-colors-bar .ce-bar-swatch {
  flex: 1 0 48px;
  max-width: 80px;
  height: 44px;
  padding: 0;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-radius: 12px;
  color: #fff;
  font: 700 0.8rem/1 var(--bs-body-font-family, system-ui, sans-serif);
  text-shadow: 0 0 2px rgba(0, 0, 0, 0.8);
}
#ce-colors-bar .ce-bar-swatch.ce-on-light { color: #1e2228; text-shadow: 0 0 2px rgba(255, 255, 255, 0.9); }
#ce-colors-bar .ce-bar-swatch.ce-active { border-color: #fff; box-shadow: 0 0 0 2px var(--pt-accent, #0f70e6); }
.ce-bar-line { display: flex; align-items: center; gap: 12px; padding: 0 4px; }
.ce-bar-text { flex: 1 1 auto; min-width: 0; display: flex; align-items: baseline; gap: 10px; line-height: 1.3; direction: ltr; }
[dir="rtl"] .ce-bar-text { justify-content: flex-end; }
.ce-bar-hex { font: 700 1.05rem/1.3 var(--bs-font-monospace, ui-monospace, Menlo, Consolas, monospace); color: var(--pt-app-fg, #fff); }
.ce-bar-rgb { min-width: 0; font: 0.8rem/1.3 var(--bs-font-monospace, ui-monospace, Menlo, Consolas, monospace); color: var(--pt-app-muted, #c2c8d0); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ce-bar-copy {
  flex: none;
  min-width: 44px;
  height: 44px;
  padding: 0 16px;
  border: 1px solid var(--pt-app-line, rgba(255, 255, 255, 0.1));
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--pt-app-fg, #fff);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 600;
}
.ce-bar-copy .uil { font-size: 1.1rem; line-height: 1; }
.ce-bar-copy.ce-done { border-color: #198754; }

/* In the sheet: the colour list is the Colors bar and Save is in the top
   bar, so neither is repeated there. */
.pt-app-sheet .ce-save { border-top: 0; padding-top: 0; margin-top: 0; }
.pt-app-sheet .ce-save .pt-tool-savebar > .btn { flex: 1 1 auto; }
