/* Non-destructive photo crop (DEB-4186, inc/image-crop.php + assets/image-crop.js). Loaded on block pages, in the
   editor canvas and in the editor itself (the crop dialog). */

/* ---- the page: the rectangle's numbers are inline on .gh-crop and its <img> ---- */
.wp-block-gallery.has-nested-images figure.wp-block-image .gh-crop { width: 100% !important; }
/* core's album rule caps the photo at 100% with !important; the photo behind the crop is wider than its frame */
.wp-block-gallery.has-nested-images figure.wp-block-image:not(#individual-image) img.gh-crop__img {
  max-width: none !important; width: var(--gh-crop-w, auto); flex: none;
}
/* core places the lightbox button from the <img>'s size, which is the whole photo here: keep it in the frame's corner */
figure.gh-has-crop .lightbox-trigger { top: 16px !important; right: auto !important; left: calc(min(var(--gh-crop-box, 100%), 100%) - 36px) !important; }
.wp-block-gallery figure.gh-has-crop .lightbox-trigger { top: 14px !important; left: auto !important; right: 14px !important; }

/* ---- the editor canvas: custom properties on the block's <figure> (assets/image-crop.js, useCropStyle) ---- */
.editor-styles-wrapper figure.gh-has-crop.wp-block-image img {
  display: block; width: var(--gh-crop-box) !important; max-width: 100% !important; height: auto !important; margin: 0 !important;
  aspect-ratio: var(--gh-crop-a) !important; object-fit: cover !important; object-position: var(--gh-crop-pos) !important;
  transform-origin: var(--gh-crop-pos); transform: scale(var(--gh-crop-z)); clip-path: var(--gh-crop-clip); flex: none !important;
}
.editor-styles-wrapper .wp-block-gallery figure.gh-has-crop.wp-block-image img { width: 100% !important; }
/* a selected photo sits in core's resize box, sized for the whole photo: let it follow the frame, no resize handles */
.editor-styles-wrapper figure.gh-has-crop .components-resizable-box__container { width: auto !important; height: auto !important; max-width: 100%; }
.editor-styles-wrapper figure.gh-has-crop .components-resizable-box__handle { display: none; }

/* ---- the crop dialog (editor, outside the canvas) ---- */
.gh-cropper .components-modal__content { display: flex; flex-direction: column; gap: 12px; }
.gh-cropper__help { margin: 0; max-width: 90ch; }
.gh-cropper__ratios { display: flex; flex-wrap: wrap; gap: 6px; }
.gh-cropper__wrap { display: flex; justify-content: center; background: #1e1e1e; padding: 12px; border-radius: 2px; }
.gh-cropper__stage { position: relative; display: inline-block; line-height: 0; overflow: hidden; touch-action: none; user-select: none; }
.gh-cropper__img { display: block; max-width: min(84vw, 1000px); max-height: max(200px, calc(100vh - 500px)); width: auto; height: auto; pointer-events: none; }
.gh-cropper__rect {
  position: absolute; box-sizing: border-box; cursor: move; outline: 2px solid #fff; outline-offset: -1px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, .58);
  background-image: linear-gradient(rgba(255,255,255,.35) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.35) 1px, transparent 1px);
  background-size: 33.333% 33.333%; background-position: -1px -1px;
}
.gh-cropper__rect:focus-visible { outline: 3px solid var(--wp-admin-theme-color, #3858e9); }
.gh-cropper__handle { position: absolute; width: 18px; height: 18px; background: #fff; border: 2px solid #1e1e1e; border-radius: 2px; touch-action: none; }
.gh-cropper__handle--nw { left: -2px; top: -2px; cursor: nwse-resize; }
.gh-cropper__handle--ne { right: -2px; top: -2px; cursor: nesw-resize; }
.gh-cropper__handle--sw { left: -2px; bottom: -2px; cursor: nesw-resize; }
.gh-cropper__handle--se { right: -2px; bottom: -2px; cursor: nwse-resize; }
.gh-cropper__size { margin: 0; color: #757575; font-size: 12px; }
.gh-cropper__actions { display: flex; gap: 8px; align-items: center; }
