/*
 * image-cropper.css — per-tool styles: drop zone, crop stage, crop box and
 * resize handles. Tokens only; positions/sizes for the crop box are set via
 * element.style in JS (CSP: style-src 'self', no inline <style> attributes).
 */

/* ---- Drop zone (label wrapping a visually-hidden file input) ------------- */
.ic-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-6) var(--space-4);
  text-align: center;
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  background: var(--neutral-50);
  cursor: pointer;
  transition: border-color .15s ease, background-color .15s ease;
}
.ic-dropzone:hover { border-color: var(--blue-600); background: var(--blue-50); }
.ic-dropzone.is-dragover { border-color: var(--blue-600); background: var(--blue-100); }
.ic-dropzone:focus-within { outline: 2px solid var(--blue-600); outline-offset: 2px; }
.ic-dropzone-icon { color: var(--text-muted); }
.ic-dropzone-title { font: 600 15px/1.4 var(--font-sans); color: var(--text-primary); }
.ic-dropzone-hint { font: 400 13px/1.4 var(--font-sans); color: var(--text-secondary); }

.ic-file-input {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---- Controls ----------------------------------------------------------- */
.ic-controls {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  margin: var(--space-4) 0;
}
.ic-control { flex: 1 1 180px; margin: 0; }
.ic-quality-row { display: flex; align-items: center; gap: var(--space-3); }
.ic-quality-range { flex: 1 1 auto; accent-color: var(--blue-600); }
.ic-quality-val { min-width: 3.5ch; color: var(--text-secondary); }

/* ---- Crop stage --------------------------------------------------------- */
.ic-stage-wrap {
  display: flex;
  justify-content: center;
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background-color: var(--neutral-50);
  background-image:
    linear-gradient(45deg, var(--neutral-100) 25%, transparent 25%),
    linear-gradient(-45deg, var(--neutral-100) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--neutral-100) 75%),
    linear-gradient(-45deg, transparent 75%, var(--neutral-100) 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  overflow: auto;
}

/* Sized to the rendered image; clips the crop mask's giant box-shadow. */
.ic-stage {
  position: relative;
  display: inline-block;
  line-height: 0;
  overflow: hidden;
  max-width: 100%;
  touch-action: none;   /* let the crop box own touch gestures */
}
.ic-image {
  display: block;
  max-width: 100%;
  max-height: 60vh;
  height: auto;
  width: auto;
  user-select: none;
  -webkit-user-drag: none;
}

/* ---- Crop box ----------------------------------------------------------- */
.ic-cropbox {
  position: absolute;
  top: 0; left: 0;
  box-sizing: border-box;
  border: 1px solid rgba(255, 255, 255, .9);
  outline: 1px solid rgba(0, 0, 0, .5);
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .45);
  cursor: move;
  touch-action: none;
}
.ic-cropbox:focus-visible {
  outline: 2px solid var(--blue-600);
  outline-offset: 0;
}
/* Rule-of-thirds guides. */
.ic-cropbox::before,
.ic-cropbox::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.ic-cropbox::before {
  border-left: 1px solid rgba(255, 255, 255, .4);
  border-right: 1px solid rgba(255, 255, 255, .4);
  margin: 0 33.333%;
}
.ic-cropbox::after {
  border-top: 1px solid rgba(255, 255, 255, .4);
  border-bottom: 1px solid rgba(255, 255, 255, .4);
  margin: 33.333% 0;
}

/* ---- Resize handles ----------------------------------------------------- */
.ic-handle {
  position: absolute;
  width: 12px; height: 12px;
  background: var(--blue-600);
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 2px rgba(0, 0, 0, .6);
  touch-action: none;
  z-index: 1;
}
.ic-handle-nw { top: -7px; left: -7px; cursor: nwse-resize; }
.ic-handle-n  { top: -7px; left: 50%; transform: translateX(-50%); cursor: ns-resize; }
.ic-handle-ne { top: -7px; right: -7px; cursor: nesw-resize; }
.ic-handle-e  { top: 50%; right: -7px; transform: translateY(-50%); cursor: ew-resize; }
.ic-handle-se { bottom: -7px; right: -7px; cursor: nwse-resize; }
.ic-handle-s  { bottom: -7px; left: 50%; transform: translateX(-50%); cursor: ns-resize; }
.ic-handle-sw { bottom: -7px; left: -7px; cursor: nesw-resize; }
.ic-handle-w  { top: 50%; left: -7px; transform: translateY(-50%); cursor: ew-resize; }

/* Larger touch targets on coarse pointers. */
@media (pointer: coarse) {
  .ic-handle { width: 18px; height: 18px; }
  .ic-handle-nw { top: -10px; left: -10px; }
  .ic-handle-n  { top: -10px; }
  .ic-handle-ne { top: -10px; right: -10px; }
  .ic-handle-e  { right: -10px; }
  .ic-handle-se { bottom: -10px; right: -10px; }
  .ic-handle-s  { bottom: -10px; }
  .ic-handle-sw { bottom: -10px; left: -10px; }
  .ic-handle-w  { left: -10px; }
}

.ic-instructions { margin-top: var(--space-3); }
.ic-stats { margin-top: var(--space-4); }
