/* ====================================================
   CropModal — interactive crop rectangle with handles
   ==================================================== */

.crop-modal {
  max-width: min(960px, 96vw);
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px 20px 16px;
}

.crop-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.crop-modal-head h2 {
  margin: 0;
  font-size: 16px;
  letter-spacing: -0.005em;
}
.crop-close {
  width: 30px; height: 30px;
  border-radius: 999px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-2);
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
}
.crop-close:hover { background: var(--surface-2); color: var(--text); }

/* Aspect ratio chip row */
.crop-ratios {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.crop-chip {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.14s var(--ease);
}
.crop-chip:hover { background: var(--surface-3); color: var(--text); }
.crop-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg, #0b1410);
}

/* Stage wrapper centers the image area inside the modal.
   font-size: 0 kills any inline-block whitespace that would otherwise
   give the stage a phantom strip alongside the image.
   overflow: visible so the crop handles (which sit a few px outside
   the rect for easier touch targets) aren't clipped when the rect is
   at the image's edge. */
.crop-stage-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-0, #06080a);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  min-height: 320px;
  max-height: 72vh;
  overflow: visible;
  font-size: 0;
}

/* Stage size is set inline once the image loads, exactly to the image's
   rendered dimensions (eliminates the phantom right/bottom strip).
   Until that measurement lands, the stage is shrink-to-fit so the
   image renders at its own constrained size. */
.crop-stage {
  position: relative;
  display: inline-block;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  line-height: 0;
  font-size: 0;
  vertical-align: top;  /* kill any baseline-induced descender space */
}
.crop-img {
  display: block;
  max-width: 100%;
  max-height: 64vh;
  width: auto;
  height: auto;
  pointer-events: none;
}

/* Dark overlay outside the rectangle — four positioned divs */
.crop-mask {
  position: absolute;
  background: rgba(0, 0, 0, 0.55);
  pointer-events: none;
}

/* The crop rectangle */
.crop-rect {
  position: absolute;
  border: 2px solid var(--accent);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4);
  cursor: move;
  box-sizing: border-box;
}

/* Rule-of-thirds guides */
.crop-thirds {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.crop-third-v, .crop-third-h {
  position: absolute;
  background: rgba(255, 255, 255, 0.25);
}
.crop-third-v { top: 0; bottom: 0; width: 1px; }
.crop-third-h { left: 0; right: 0; height: 1px; }

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

/* Bottom actions */
.crop-modal-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 4px;
}

/* Indicator on queue rows that have a per-image crop applied */
.ic-q-row.has-crop .ic-q-thumb {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  border-radius: 8px;
}
.ic-q-crop-badge {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 14px;
  height: 14px;
  border-radius: 4px;
  background: var(--accent);
  color: var(--accent-fg, #0b1410);
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.ic-q-crop-badge svg { width: 10px; height: 10px; }

/* Mobile tweaks */
@media (max-width: 720px) {
  .crop-modal { padding: 14px 14px 12px; gap: 10px; }
  .crop-modal-head h2 { font-size: 15px; }
  .crop-stage-wrap { padding: 8px; min-height: 240px; }
  .crop-chip { padding: 8px 12px; font-size: 13px; }   /* easier tap targets */
  .crop-handle { width: 18px; height: 18px; }
  .crop-handle.nw { top: -10px; left: -10px; }
  .crop-handle.ne { top: -10px; right: -10px; }
  .crop-handle.sw { bottom: -10px; left: -10px; }
  .crop-handle.se { bottom: -10px; right: -10px; }
  .crop-handle.n  { top: -10px; }
  .crop-handle.s  { bottom: -10px; }
  .crop-handle.w  { left: -10px; }
  .crop-handle.e  { right: -10px; }
}
