/*!
 * 123PhotoTool — Image Splitter (image-splitter.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 splitter adds:
 * the photo with the split area over it, and the pieces after a save.
 */

/* ── The photo box ─────────────────────────────────────────────────────── */
#split-viewport { overflow: hidden; }

/* Empty: one Upload button and three samples, centred. */
#split-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  text-align: center;
}
#split-viewport.split-has-photo #split-empty { display: none; }
.sample-thumbnails { display: flex; justify-content: center; gap: 12px; margin: 10px 0; flex-wrap: wrap; }
.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;
}
.sample-thumbnail:hover { border-color: var(--pt-accent, #0f70e6); box-shadow: 0 4px 12px rgba(15, 112, 230, 0.25); }
.sample-thumbnail img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 0 !important; }
@media (max-width: 768px) { .sample-thumbnail { width: 90px; height: 90px; } }
@media (max-width: 576px) { .sample-thumbnail { width: 72px; height: 72px; } }

/* The photo, fitted and centred by image-splitter.js. The box is the photo's
   own size, so the split area is positioned in the photo's coordinates. */
#split-image-box {
  position: absolute;
  display: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
#split-viewport.split-has-photo #split-image-box { display: block; }
#split-canvas { display: block; width: 100%; height: 100%; }

/* Outside the split area is dimmed: a hole with a wide shadow, clipped to
   the photo. The area itself sits in a layer that is not clipped, so its
   handles stay whole at the photo's edges. */
#split-dim { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
#split-dim-hole { position: absolute; box-shadow: 0 0 0 9999px rgba(15, 18, 24, 0.5); }

#split-crop-box {
  position: absolute;
  cursor: move;
  outline: 2px solid var(--pt-accent, #0f70e6);
  outline-offset: -1px;
  touch-action: none;
}
#split-grid-lines { position: absolute; inset: 0; pointer-events: none; }
.split-line { position: absolute; background: rgba(255, 255, 255, 0.9); box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25); }
.split-line-v { top: 0; bottom: 0; width: 1px; }
.split-line-h { left: 0; right: 0; height: 1px; }

/* Handles: a small dot drawn, a finger-sized target around it. */
.split-handle {
  position: absolute;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--pt-accent, #0f70e6);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  z-index: 1;
}
.split-handle::before { content: ""; position: absolute; inset: -14px; }
.split-handle[data-dir="nw"] { left: 0; top: 0; cursor: nwse-resize; }
.split-handle[data-dir="n"]  { left: 50%; top: 0; cursor: ns-resize; }
.split-handle[data-dir="ne"] { left: 100%; top: 0; cursor: nesw-resize; }
.split-handle[data-dir="e"]  { left: 100%; top: 50%; cursor: ew-resize; }
.split-handle[data-dir="se"] { left: 100%; top: 100%; cursor: nwse-resize; }
.split-handle[data-dir="s"]  { left: 50%; top: 100%; cursor: ns-resize; }
.split-handle[data-dir="sw"] { left: 0; top: 100%; cursor: nesw-resize; }
.split-handle[data-dir="w"]  { left: 0; top: 50%; cursor: ew-resize; }
@media (pointer: coarse) {
  .split-handle { width: 18px; height: 18px; margin: -9px 0 0 -9px; }
  /* The side handles would crowd the corners of a small area. */
  .split-handle[data-dir="n"], .split-handle[data-dir="s"],
  .split-handle[data-dir="e"], .split-handle[data-dir="w"] { display: none; }
}
#split-crop-box.split-dragging { outline-color: #fff; }

/* ── The pieces ────────────────────────────────────────────────────────── */
#split-results-grid { display: grid; gap: 6px; }
.split-piece {
  position: relative;
  display: block;
  padding: 0;
  border: 0;
  border-radius: 6px;
  overflow: hidden;
  background: #eef1f5;
  cursor: pointer;
}
.split-piece img { display: block; width: 100%; height: auto; }
.split-piece span {
  position: absolute;
  left: 4px;
  top: 4px;
  min-width: 20px;
  padding: 0 5px;
  border-radius: 10px;
  background: rgba(15, 18, 24, 0.7);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 20px;
  text-align: center;
}
.split-piece:hover { outline: 2px solid var(--pt-accent, #0f70e6); outline-offset: -2px; }
.split-piece:focus-visible { outline: 3px solid var(--pt-accent, #0f70e6); outline-offset: -3px; }

/* ── In the phone editor ───────────────────────────────────────────────── */
/* Grid: Columns and Rows as two rows of chips. */
.split-grid-panel { padding: 2px 4px; }
.split-grid-row { display: flex; align-items: center; gap: 8px; }
.split-grid-row + .split-grid-row { margin-top: 8px; }
.split-grid-row > span {
  flex: 0 0 auto;
  min-width: 64px;
  max-width: 34%;
  color: var(--pt-app-muted, rgba(255, 255, 255, 0.7));
  font-size: 0.8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.split-grid-row > .pt-app-chiprow { display: flex !important; gap: 6px; flex: 1 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.split-grid-row > .pt-app-chiprow::-webkit-scrollbar { display: none; }
.split-grid-row .pt-app-chip { flex: 1 0 40px; min-width: 40px; padding-left: 0; padding-right: 0; justify-content: center; }
.pt-app-panels > .split-shape-strip.pt-app-panel-on,
.pt-app-panels > #split-layout-strip.pt-app-panel-on { justify-content: center; }

/* Save: the format row, its label as wide as on the other tools. */
.split-format-label { width: 90px; text-align: start; }
/* In the phone editor's sheet the save section is all there is, so it
   needs no rule or gap above it. */
.pt-app-sheet .split-save { border-top: 0; padding-top: 0; margin-top: 0; }
