/* Remove Image Background: styles for this tool only. Shared styles live in /tools/shared/tools.css. */

/* The dropzone shows its own file card; this tool shows the editor instead once an image is added */
.rb-has-file .dropzone-root {
  display: none;
}

.rb-editor {
  display: none;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: var(--stage-pad);
}
.rb-has-file .rb-editor {
  display: flex;
}
.rb-area {
  position: relative;
  padding: 8px;
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 0;
}

/* The picture. Original underneath, the cut-out on top, clipped from the divider to the right edge. */
.rb-frame {
  --rb-pos: 50%;
  position: relative;
  flex: none;
  border-radius: var(--radius-md);
  overflow: hidden;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}
.rb-frame[data-view="compare"] {
  cursor: ew-resize;
}
.rb-frame canvas {
  display: block;
  width: 100%;
  height: 100%;
}
.rb-before {
  position: absolute;
  inset: 0;
}
.rb-after-wrap {
  position: absolute;
  inset: 0;
  clip-path: inset(0 0 0 var(--rb-pos));
  /* checkerboard so a transparent background is visible */
  background-color: var(--color-field);
  background-image:
    linear-gradient(45deg, rgba(128, 128, 128, 0.22) 25%, transparent 25%, transparent 75%, rgba(128, 128, 128, 0.22) 75%),
    linear-gradient(45deg, rgba(128, 128, 128, 0.22) 25%, transparent 25%, transparent 75%, rgba(128, 128, 128, 0.22) 75%);
  background-size: 20px 20px;
  background-position: 0 0, 10px 10px;
}
.rb-frame[data-bg="color"] .rb-after-wrap {
  background-image: none;
}
.rb-frame[data-view="before"] .rb-after-wrap {
  display: none;
}
.rb-frame[data-view="after"] .rb-after-wrap {
  clip-path: none;
}
.rb-frame[data-view="after"] .rb-before {
  visibility: hidden;
}

/* The corner labels sit on the photo, so they stay light-on-dark in both themes */
.rb-tag {
  position: absolute;
  top: var(--space-2);
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: var(--text-xs);
  pointer-events: none;
}
.rb-tag-before {
  left: var(--space-2);
}
.rb-tag-after {
  right: var(--space-2);
}
.rb-frame[data-view="after"] .rb-tag-before,
.rb-frame[data-view="before"] .rb-tag-after {
  display: none;
}

/* The divider */
.rb-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--rb-pos);
  width: 2px;
  margin-left: -1px;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25);
  outline: none;
  cursor: ew-resize;
}
.rb-handle[hidden] {
  display: none;
}
/* A wider invisible target for fingers */
.rb-handle::before {
  content: "";
  position: absolute;
  inset: 0 -14px;
}
.rb-grip {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 2.25rem;
  height: 2.25rem;
  margin: -1.125rem 0 0 -1.125rem;
  display: grid;
  place-items: center;
  border-radius: var(--radius-full);
  background: #fff;
  color: #2f2f2f;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.4);
  transition: transform var(--duration) ease-out;
}
.rb-grip .icon {
  transform: rotate(90deg);
}
.rb-handle:hover .rb-grip {
  transform: scale(1.1);
}
.rb-handle:active .rb-grip {
  transform: scale(0.92);
}
.rb-handle:focus-visible .rb-grip {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* Progress while the model downloads or runs */
.rb-status {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: var(--space-4);
  pointer-events: none;
}
.rb-status[hidden] {
  display: none;
}
.rb-card {
  width: min(22rem, 100%);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  border-radius: var(--radius-xl);
  background: var(--color-surface);
  box-shadow: var(--shadow-float);
}
.rb-status-title {
  font-weight: var(--weight-bold);
  color: var(--color-ink);
}
.rb-status-note {
  min-height: 1.2em;
}
/* No percentage to show yet: a short bar slides along the track */
.rb-card .progress {
  position: relative;
}
.rb-card .progress.is-indeterminate > div {
  position: absolute;
  width: 35%;
  transition: none;
  animation: rb-slide 1.1s ease-in-out infinite;
}
@keyframes rb-slide {
  from {
    left: -35%;
  }
  to {
    left: 100%;
  }
}

/* Panel */
.rb-hint {
  margin-top: calc(-1 * var(--space-1));
  line-height: 1.4;
}
.rb-color {
  margin-top: var(--space-1);
}
.panel-foot .info-note {
  justify-content: center;
}

@media (max-width: 860px) {
  /* The picture comes first and the settings follow it, instead of a sheet covering the picture */
  body.panel-open .panel {
    position: static;
    box-shadow: none;
  }
  .panel-body {
    max-height: none;
  }
  .rb-area {
    min-height: 55vh;
  }
}

@media (prefers-reduced-motion: reduce) {
  .rb-grip {
    transition: none;
  }
  .rb-handle:hover .rb-grip,
  .rb-handle:active .rb-grip {
    transform: none;
  }
  .rb-card .progress.is-indeterminate > div {
    animation: none;
    left: 0;
    width: 100%;
    opacity: 0.5;
  }
}
