/* Crop PDF: a large page preview with a draggable frame on the left, options on the right.
   Uses stamp.css for the shared form bits. Colours come from style.css variables only. */

.crop-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(240px, 300px); gap: 24px; align-items: start; }
.crop-preview { margin: 0; min-width: 0; }
.crop-opts { min-width: 0; }

/* The stage leaves room around the page so handles on the page edge stay easy to grab. */
.crop-stage { display: grid; place-items: center; min-height: 320px; padding: 22px; border-radius: 12px; background: var(--soft); overflow: hidden; }
.crop-page { position: relative; max-width: 100%; background: var(--card); box-shadow: var(--shadow); user-select: none; -webkit-user-select: none; cursor: crosshair; }
.crop-shot { position: absolute; inset: 0; display: grid; place-items: center; }
.crop-shot canvas { display: block; width: 100%; height: 100%; }
.crop-blank { width: 100%; height: 100%; background: var(--card); }

/* Outside the frame fades into the stage colour: what will be cut away. */
.crop-shade { position: absolute; background: color-mix(in srgb, var(--soft) 82%, transparent); pointer-events: none; }

.crop-box { position: absolute; outline: 2px solid var(--accent); outline-offset: 0; cursor: move; touch-action: none; border-radius: 0; }
.crop-box::before { content: ''; position: absolute; inset: 0; border: 1px dashed color-mix(in srgb, var(--card) 70%, transparent); pointer-events: none; }
.crop-box:focus-visible { outline: 3px solid var(--accent); outline-offset: 0; box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 25%, transparent); }

/* Handles: a small visible dot with a large invisible hit area for fingers. */
.crop-h { position: absolute; width: 14px; height: 14px; margin: 0; padding: 0; border: 2px solid var(--accent); border-radius: 4px; background: var(--card); touch-action: none; z-index: 1; }
.crop-h::before { content: ''; position: absolute; inset: -13px; }
.crop-h:focus-visible { outline: none; background: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 30%, transparent); }
.crop-h-nw { left: -8px; top: -8px; cursor: nwse-resize; }
.crop-h-ne { right: -8px; top: -8px; cursor: nesw-resize; }
.crop-h-se { right: -8px; bottom: -8px; cursor: nwse-resize; }
.crop-h-sw { left: -8px; bottom: -8px; cursor: nesw-resize; }
.crop-h-n, .crop-h-s { left: calc(50% - 12px); width: 24px; height: 10px; border-radius: 5px; cursor: ns-resize; }
.crop-h-n { top: -6px; }
.crop-h-s { bottom: -6px; }
.crop-h-e, .crop-h-w { top: calc(50% - 12px); width: 10px; height: 24px; border-radius: 5px; cursor: ew-resize; }
.crop-h-e { right: -6px; }
.crop-h-w { left: -6px; }

/* A page outside the chosen range: the frame is only a guide here. */
.crop-page.is-off .crop-box { outline-style: dashed; outline-color: var(--muted); }
.crop-page.is-off .crop-h { border-color: var(--muted); }
.crop-page.is-off .crop-shade { background: color-mix(in srgb, var(--soft) 35%, transparent); }

.crop-nav { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 10px; }
.crop-pageno { min-width: 9ch; text-align: center; font-size: 14px; font-variant-numeric: tabular-nums; }
.crop-note { margin-top: 6px; text-align: center; min-height: 1.4em; }

.crop-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.crop-auto { border-color: var(--accent); color: var(--accent); }
.crop-auto:hover { background: var(--accent-soft); border-color: var(--accent); }
.crop-auto[aria-busy=true] { cursor: progress; }
.crop-size { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.crop-scope label { white-space: normal; text-align: center; }

@media (max-width: 860px) {
  .crop-grid { grid-template-columns: 1fr; gap: 18px; }
  .crop-stage { padding: 16px; min-height: 240px; }
}
