/**
 * Preview backdrops — the look of each tone chosen by
 * static/js/preview-backdrop.js (see that file for how tones are picked).
 *
 * Luminances here are mirrored in CANDIDATES in the script; change both
 * together or "auto" will choose against colours that aren't on screen.
 *
 * Tones win over the theme deliberately: the backdrop exists to make the
 * design legible, so a white design gets a dark backdrop in light mode too.
 */

/* --- Checkerboard (transparency) boxes ---------------------------------- */

/* Low-contrast squares: the pattern only has to say "transparent", and a
   strong pattern fights pale and grey artwork for attention. */
.checkerboard-bg[data-backdrop-tone] {
  background-image:
    linear-gradient(45deg, var(--pb-check-b) 25%, transparent 25%),
    linear-gradient(-45deg, var(--pb-check-b) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--pb-check-b) 75%),
    linear-gradient(-45deg, transparent 75%, var(--pb-check-b) 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
  background-color: var(--pb-check-a);
  transition: background-color 0.2s ease;
}

.checkerboard-bg[data-backdrop-tone="light"] {
  --pb-check-a: #ffffff;
  --pb-check-b: #f0f0f0;
}

.checkerboard-bg[data-backdrop-tone="mid"] {
  --pb-check-a: #959595;
  --pb-check-b: #838383;
}

.checkerboard-bg[data-backdrop-tone="dark"] {
  --pb-check-a: #383b40;
  --pb-check-b: #2c2f33;
}

/* --- Solid ("fabric") boxes -------------------------------------------- */

/* !important because the download step's box carries Bootstrap's
   .bg-light, and digitize.css forces a dark-mode colour with !important. */
[data-preview-backdrop][data-backdrop-tone="light"] {
  background-color: #eef0f2 !important;
}

[data-preview-backdrop][data-backdrop-tone="mid"] {
  background-color: #8e949c !important;
}

[data-preview-backdrop][data-backdrop-tone="dark"] {
  background-color: #2a2d33 !important;
}

[data-preview-backdrop][data-backdrop-tone] {
  transition: background-color 0.2s ease;
}

/* The stitch simulator draws over the same box; let it share the backdrop
   instead of its fixed light grey. */
[data-backdrop-tone="mid"] .stitch-sim-stage {
  background: #8e949c;
}

[data-backdrop-tone="dark"] .stitch-sim-stage {
  background: #2a2d33;
}

/* --- Toggle button ------------------------------------------------------ */

.preview-backdrop-toggle {
  position: absolute;
  left: 0.5rem;
  bottom: 0.5rem;
  z-index: 6;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.55rem;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.4;
  cursor: pointer;
  opacity: 0.85;
  transition: opacity 0.15s ease;
}

.preview-backdrop-toggle:hover,
.preview-backdrop-toggle:focus-visible {
  opacity: 1;
}

.preview-backdrop-toggle:focus-visible {
  outline: 2px solid #0d6efd;
  outline-offset: 2px;
}

/* The editor canvas keeps its zoom badge (.scale-indicator) in the bottom-left
   corner, so the toggle stacks just above it there. */
#svg-preview > .preview-backdrop-toggle {
  left: 10px;
  bottom: 44px;
}

/* The simulator's transport controls own the bottom of the box while open. */
.stitch-sim-open > .preview-backdrop-toggle {
  display: none;
}

@media (max-width: 767.98px) {
  /* Below the mobile sticky footer (z-index 40), like the other in-canvas
     overlays in digitize.css. */
  .preview-backdrop-toggle {
    z-index: 30;
  }
}
