/* The three small utilities of inc/ut-page.inc.php: Sprite Sheet Cutter
   (ss-), Placeholder Image Generator (ph-) and Image Analyzer (ia-). The
   layout is pt-ui.css's, the phone editor pt-app.css's, the sliders, fields
   and buttons take pt-theme.css's look. */

/* ── Empty state: the samples ─────────────────────────────────────────── */
.ut-editor .sample-thumbnails-container {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
  text-align: center;
  /* Without a width it shrinks to half the box (left: 50%). */
  width: 90%;
}
/* By id: in the phone editor the photo box is out of the card. */
#ss-empty.hidden, #ia-empty.hidden { display: none; }
.ut-editor .sample-thumbnails { display: flex; justify-content: center; gap: 12px; margin: 10px 0; flex-wrap: wrap; }
.ut-editor .sample-thumbnail {
  flex-shrink: 0;
  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;
}
.ut-editor .sample-thumbnail:hover,
.ut-editor .sample-thumbnail:focus-visible { border-color: var(--pt-accent, #0f70e6); box-shadow: 0 4px 12px rgba(15, 112, 230, 0.25); }
.ut-editor .sample-thumbnail img { width: 100%; height: 100%; object-fit: cover; display: block; }
@media (max-width: 767px) { .ut-editor .sample-thumbnail { width: 84px; height: 84px; } }

/* ── The picture ──────────────────────────────────────────────────────── */
.ut-viewport { position: relative; display: flex; align-items: center; justify-content: center; padding: 12px; overflow: hidden; }
.ut-viewport canvas { display: block; max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 4px; }
.ut-viewport canvas[hidden] { display: none; }
/* See-through parts: the checkerboard behind them. */
.ut-checker {
  background-color: #fff;
  background-image: linear-gradient(45deg, #e3e3e3 25%, transparent 25%), linear-gradient(-45deg, #e3e3e3 25%, transparent 25%),
                    linear-gradient(45deg, transparent 75%, #e3e3e3 75%), linear-gradient(-45deg, transparent 75%, #e3e3e3 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}
/* Small frames made bigger: one square per pixel. */
.ut-pixels { image-rendering: pixelated; }

/* ── Panel bits ───────────────────────────────────────────────────────── */
.ut-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.ut-link {
  border: 0;
  background: none;
  padding: 2px 4px;
  font-size: 13px;
  font-weight: 600;
  color: var(--pt-accent, #0f70e6);
  cursor: pointer;
  text-align: end;
}
.ut-link:hover { text-decoration: underline; }
.ut-link:disabled { color: #9aa1aa; cursor: default; text-decoration: none; }
.ut-count { font-size: 13px; color: var(--cb-muted, #626973); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ut-note { font-size: 12.5px; line-height: 1.45; color: var(--cb-muted, #626973); }
/* Two fields side by side. */
.ut-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 10px; }
.ut-field { min-width: 0; }
.ut-field .form-label { font-size: 13px; margin-bottom: 4px; overflow-wrap: anywhere; hyphens: auto; }
.ut-num { position: relative; }
.ut-num .form-control { padding-inline-end: 30px; font-variant-numeric: tabular-nums; }
.ut-unit {
  position: absolute;
  inset-inline-end: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  color: var(--cb-muted, #626973);
  pointer-events: none;
}
.ut-editor .pt-cseg button { min-width: 0; overflow-wrap: anywhere; hyphens: auto; }

/* ── Sprite Sheet Cutter ──────────────────────────────────────────────── */
#ss-sheet { cursor: pointer; }
#ss-anim { cursor: pointer; }
.ss-frames {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
  gap: 6px;
  max-height: 232px;
  overflow-y: auto;
  padding: 3px;
  margin: -3px;
}
.ss-frame {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  background-color: #fff;
  background-image: linear-gradient(45deg, #ececec 25%, transparent 25%), linear-gradient(-45deg, #ececec 25%, transparent 25%),
                    linear-gradient(45deg, transparent 75%, #ececec 75%), linear-gradient(-45deg, transparent 75%, #ececec 75%);
  background-size: 10px 10px;
  background-position: 0 0, 0 5px, 5px -5px, -5px 0;
  box-shadow: inset 0 0 0 1px var(--cb-line, #e4e1dc);
}
.ss-frame canvas { display: block; width: 100%; height: 100%; }
.ss-num {
  position: absolute;
  inset-inline-start: 3px;
  bottom: 3px;
  min-width: 18px;
  padding: 0 4px;
  border-radius: 999px;
  background: rgba(22, 24, 29, 0.72);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.ss-frame[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--pt-accent, #0f70e6); }
.ss-frame.off canvas { opacity: 0.25; }
.ss-frame.off::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top right, transparent calc(50% - 1px), #626973 calc(50% - 1px), #626973 calc(50% + 1px), transparent calc(50% + 1px));
}
.ss-frame:focus-visible { outline: 2px solid var(--pt-accent, #0f70e6); outline-offset: 2px; }
fieldset:disabled .ss-frame { cursor: default; }
/* The view buttons in the dark bar under the picture. */
@media (min-width: 768px) {
  .pt-tool .pt-tool-deskbar .ss-view .btn.active { background: #fff; color: var(--cb-ink, #16181d); }
}
.ss-view .btn.active { background: var(--cb-ink, #16181d); color: #fff; border-color: var(--cb-ink, #16181d); }

/* ── Phone editor ─────────────────────────────────────────────────────── */
/* The grid's fields in the bottom bar: compact, and scrolled if need be. */
.pt-app-panels #ss-grid { padding: 4px 4px 2px; max-height: 40vh; overflow-y: auto; }
.pt-app-panels #ss-grid .form-label { color: var(--pt-app-fg); }
.pt-app-panels #ss-grid .ut-fields { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 8px; }
/* The frames as one row that scrolls sideways. */
.pt-app-panels .ss-frames { display: flex; gap: 8px; max-height: none; margin: 0; padding: 6px 4px; }
.pt-app-panels .ss-frame { flex: 0 0 56px; width: 56px; }

/* ── Placeholder Image Generator ──────────────────────────────────────── */
.ph-presets { display: flex; flex-wrap: wrap; gap: 6px; }
.ph-chip {
  padding: 4px 11px;
  border: 0;
  border-radius: 999px;
  background: var(--cb-bg, #f5f4f2);
  color: var(--cb-text, #3d434b);
  font-size: 12.8px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.ph-chip:hover { background: #ebe8e3; }
.ph-chip[aria-pressed="true"] { background: var(--cb-ink, #16181d); color: #fff; }
.ph-chip:focus-visible { outline: 2px solid var(--pt-accent, #0f70e6); outline-offset: 2px; }
.ph-swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.ph-swatch {
  position: relative;
  flex: none;
  width: 32px;
  height: 32px;
  padding: 0;
  margin: 0;
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 50%;
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.ph-swatch:hover { transform: scale(1.06); }
.ph-swatch:focus-visible, .ph-swatch-pick:focus-within { outline: none; box-shadow: 0 0 0 2px #fff, 0 0 0 4px rgba(15, 112, 230, 0.6); }
.ph-swatch[aria-pressed="true"],
.ph-swatch-pick.on { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--cb-ink, #16181d); }
/* A colour of your own: the colour wheel, the picker over it. */
.ph-swatch-pick { display: block; background: conic-gradient(#ff4757, #ffd32a, #00c389, #00c6ff, #4782dc, #764ba2, #ff4757); }
.ph-swatch-pick input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0; }
#ph-canvas { box-shadow: 0 8px 24px -12px rgba(0, 0, 0, 0.5); border-radius: 2px; }
/* No photo to wait for: a light stage, not the dark one. */
.ph-editor .pt-tool-viewport { background: var(--cb-bg, #f5f4f2); }
#ph-savebar > .btn { flex: 1 1 auto; }

/* ── Image Analyzer ───────────────────────────────────────────────────── */
.ia-box + .ia-box { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--cb-line, #e4e1dc); }
.ia-title {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--cb-muted, #626973);
}
.ia-facts { margin: 0; }
.ia-fact { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); gap: 10px; padding: 4px 0; font-size: 13.6px; line-height: 1.4; }
.ia-fact + .ia-fact { border-top: 1px dashed #ece9e4; }
.ia-fact dt { font-weight: 600; color: var(--cb-text, #3d434b); overflow-wrap: anywhere; hyphens: auto; }
.ia-fact dd { margin: 0; color: var(--cb-ink, #16181d); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; text-align: end; }
.ia-fact[data-k="name"] dd { word-break: break-all; }
.ia-fact dd .ia-color { margin-inline-start: auto; }
.ia-hist { display: block; width: 100%; height: 110px; border-radius: 10px; background: #f7f6f4; box-shadow: inset 0 0 0 1px var(--cb-line, #e4e1dc); }
.ia-mini { flex: none; }
.ia-editor .ia-mini button { min-height: 28px; padding: 2px 10px; font-size: 12px; }
.ia-main { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.ia-color {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 4px 8px 4px 4px;
  border: 1px solid var(--cb-line, #e4e1dc);
  border-radius: 999px;
  background: #fff;
  color: var(--cb-ink, #16181d);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.ia-color:hover { border-color: #cfcac3; }
.ia-color:focus-visible { outline: 2px solid var(--pt-accent, #0f70e6); outline-offset: 2px; }
.ia-chip { flex: none; width: 20px; height: 20px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15); }
.ia-hex { font-family: ui-monospace, Consolas, monospace; font-size: 11.5px; }
.ia-share { margin-inline-start: auto; color: var(--cb-muted, #626973); font-weight: 600; }
/* A main colour: the colour as a block, its code and share under it. */
.ia-main .ia-color { flex-direction: column; align-items: stretch; gap: 2px; padding: 4px 4px 5px; border-radius: 12px; }
.ia-main .ia-chip { width: 100%; height: 28px; border-radius: 8px; }
.ia-main .ia-hex, .ia-main .ia-share { margin: 0; text-align: center; line-height: 1.3; }
.ia-main .ia-share { font-size: 11.5px; }
.ia-legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 16px; margin-top: 10px; font-size: 13px; color: var(--cb-text, #3d434b); }
.ia-legend[hidden] { display: none; }
.ia-key { display: inline-flex; align-items: center; gap: 6px; }
.ia-key-chip { display: inline-block; width: 14px; height: 14px; border-radius: 4px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15); }
.ia-key-clear { background: repeating-conic-gradient(#cfd4da 0 25%, #fff 0 50%) 0 0 / 8px 8px; }
#ia-show-alpha-row[hidden] { display: none; }
#ia-scaled[hidden] { display: none; }

/* Phone editor: each part of the findings in the bottom bar, scrolled. */
.pt-app-panels .ia-box { max-height: 42vh; overflow-y: auto; overscroll-behavior: contain; padding: 4px 10px 8px; margin: 0; border: 0; }
.pt-app-panels .ia-fact { color: var(--pt-app-fg); }
.pt-app-panels .ia-fact dt, .pt-app-panels .ia-fact dd { color: inherit; }
.pt-app-panels .ia-fact + .ia-fact { border-top-color: var(--pt-app-line, rgba(255, 255, 255, 0.12)); }
.pt-app-panels .form-label, .pt-app-panels .ut-note { color: var(--pt-app-fg); }
