/* ui.image-crop (public/js/ui-image-crop.js): crop frame over an image. The area outside the frame is
   dimmed by the frame's outer shadow, so the root clips it. Handles sit inside the frame's corners, so
   they stay reachable when the frame fills the image; their hit area is larger than the drawn square. */
.ui-image-crop {
  position: relative;
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  line-height: 0;
  border: 1px solid var(--surface-border, var(--bs-border-color));
  border-radius: var(--radius-sm, 0.3125rem);
  /* Checkerboard behind transparent pixels, readable in both modes. */
  background-color: light-dark(#ffffff, #1d2422);
  background-image:
    linear-gradient(45deg, light-dark(#e6ebe9, #2a3331) 25%, transparent 25%),
    linear-gradient(-45deg, light-dark(#e6ebe9, #2a3331) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, light-dark(#e6ebe9, #2a3331) 75%),
    linear-gradient(-45deg, transparent 75%, light-dark(#e6ebe9, #2a3331) 75%);
  background-position:
    0 0,
    0 0.5rem,
    0.5rem -0.5rem,
    -0.5rem 0;
  background-size: 1rem 1rem;
  user-select: none;
  -webkit-user-select: none;
}

.ui-image-crop__image {
  display: block;
  max-width: 100%;
  max-height: 28rem;
  width: auto;
  height: auto;
  pointer-events: none;
}

.ui-image-crop__frame {
  position: absolute;
  box-sizing: border-box;
  border: 2px solid #ffffff;
  outline: 1px solid rgb(0 0 0 / 0.6);
  box-shadow: 0 0 0 100vmax rgb(0 0 0 / 0.5);
  cursor: move;
  touch-action: none;
}

.ui-image-crop__frame:focus-visible {
  outline: 3px solid var(--color-brand);
  outline-offset: 0;
}

.ui-image-crop__handle {
  position: absolute;
  width: 0.875rem;
  height: 0.875rem;
  border: 2px solid var(--color-brand);
  border-radius: 2px;
  background: #ffffff;
  touch-action: none;
}

.ui-image-crop__handle::before {
  content: "";
  position: absolute;
  inset: -0.9375rem;
}

.ui-image-crop__handle:focus-visible {
  outline: 3px solid var(--color-brand);
  outline-offset: 2px;
}

.ui-image-crop__handle--nw {
  top: -2px;
  left: -2px;
  cursor: nwse-resize;
}

.ui-image-crop__handle--ne {
  top: -2px;
  right: -2px;
  cursor: nesw-resize;
}

.ui-image-crop__handle--sw {
  bottom: -2px;
  left: -2px;
  cursor: nesw-resize;
}

.ui-image-crop__handle--se {
  right: -2px;
  bottom: -2px;
  cursor: nwse-resize;
}

/* Live preview of a crop (canvas), sized by its width/height attributes. */
.ui-image-crop-preview {
  display: block;
  max-width: 100%;
  height: auto;
}

@media (pointer: coarse) {
  .ui-image-crop__handle {
    width: 1.25rem;
    height: 1.25rem;
  }
}
