/* The background keyer (inc/bgkey-tool.inc.php): the samples, the mode and
   colour buttons and the preview backdrops. The layout is pt-ui.css's, the
   phone editor pt-app.css's. */

/* ── Empty state: the samples ─────────────────────────────────────────── */
.bgkey-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. */
#bgk-empty.hidden { display: none; }
.bgkey-editor .sample-thumbnails { display: flex; justify-content: center; gap: 12px; margin: 10px 0; flex-wrap: wrap; }
.bgkey-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;
}
.bgkey-editor .sample-thumbnail:hover,
.bgkey-editor .sample-thumbnail:focus-visible { border-color: #3f78e0; box-shadow: 0 4px 12px rgba(63, 120, 224, 0.25); }
.bgkey-editor .sample-thumbnail img { width: 100%; height: 100%; object-fit: cover; display: block; }
@media (max-width: 767px) { .bgkey-editor .sample-thumbnail { width: 84px; height: 84px; } }

/* ── The photo ────────────────────────────────────────────────────────── */
/* The photo centred in its box, as on the other tools (by id: in the phone
   editor the box is in the stage, out of the card). */
#bgk-viewport { display: flex; align-items: center; justify-content: center; padding: 12px; overflow: hidden; }
#bgk-canvas { display: block; max-width: 100%; max-height: 100%; border-radius: 6px; }
#bgk-canvas[hidden] { display: none; }
#bgk-canvas.bgk-picking { cursor: crosshair; }
/* What shows through: squares (transparent), white or dark, to check the
   edges against both. */
.bgk-checker,
.bgk-bd-squares #bgk-canvas {
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #d5d9df 25%, transparent 25%),
    linear-gradient(-45deg, #d5d9df 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #d5d9df 75%),
    linear-gradient(-45deg, transparent 75%, #d5d9df 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}
.bgk-bd-white #bgk-canvas { background: #fff; box-shadow: 0 0 0 1px #dee2e6; }
.bgk-bd-dark #bgk-canvas { background: #1f2937; }
.bgk-backdrops {
  position: absolute;
  bottom: 10px;
  inset-inline-end: 10px;
  z-index: 6;
  display: flex;
  gap: 4px;
  padding: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.18);
}
.bgk-backdrops[hidden] { display: none; }
.bgk-bd-btn {
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid transparent;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18);
  cursor: pointer;
}
.bgk-bd-btn[data-bd="squares"] { background-size: 10px 10px; background-position: 0 0, 0 5px, 5px -5px, -5px 0; }
.bgk-bd-btn[data-bd="white"] { background: #fff; }
.bgk-bd-btn[data-bd="dark"] { background: #1f2937; }
.bgk-bd-btn[aria-pressed="true"] { border-color: #3f78e0; }
.bgk-bd-btn:focus-visible { outline: 3px solid rgba(63, 120, 224, 0.45); outline-offset: 1px; }

/* ── Controls ─────────────────────────────────────────────────────────── */
.bgk-seg { display: flex; flex-wrap: wrap; gap: 6px; }
.bgk-pill {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 3px 14px;
  font-size: 0.85rem;
  border-radius: 20px;
  border: 1px solid #dee2e6;
  background: transparent;
  color: #555;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.bgk-pill[aria-pressed="true"] { background: #3f78e0; border-color: #3f78e0; color: #fff; }
.bgk-pill:hover:not([aria-pressed="true"]):not(:disabled) { background: #f0f4ff; border-color: #3f78e0; color: #3f78e0; }
.bgk-pill:focus-visible, .bgk-swatch:focus-visible { outline: 3px solid rgba(63, 120, 224, 0.45); outline-offset: 2px; }
.bgk-dot { width: 16px; height: 16px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.25); flex: none; }
.bgk-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 4px 2px; }
.bgk-swatch {
  flex: none;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid #dee2e6;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #444;
  background: #fff;
  transition: border-color 0.15s, transform 0.15s;
}
.bgk-swatch svg { width: 18px; height: 18px; }
.bgk-swatch[aria-pressed="true"], .bgk-swatch:hover:not(:disabled) { border-color: #3f78e0; transform: scale(1.1); }
.bgk-hint { font-size: 0.7rem; line-height: 1.45; color: #6c757d; margin: 2px 0 10px; }

/* ── Phone editor: the rows lifted into the bottom bar ────────────────── */
/* They are strips (pt-app.css): one row that scrolls sideways. */
.pt-app-panels #bgk-key-row,
.pt-app-panels #bgk-ink-row { align-items: center; gap: 10px; padding: 5px 4px; }
.pt-app-panels .bgk-pill { border-color: rgba(255, 255, 255, 0.22); color: rgba(255, 255, 255, 0.85); }
.pt-app-panels .bgk-pill[aria-pressed="true"] { background: var(--pt-app-accent-soft, rgba(63, 120, 224, 0.35)); border-color: transparent; color: #fff; }
.pt-app-panels .bgk-swatch { border-color: rgba(255, 255, 255, 0.3); }
/* A ring outside a dark gap: shows on the white swatch and the black one. */
.pt-app-panels .bgk-swatch[aria-pressed="true"] { border-color: #1f2937; box-shadow: 0 0 0 2px #fff; transform: none; }
