/* MV_PhotoCropper — optional crop step when adding a photo (#56).
   Lives under .photo-cropper per the COMPONENT RULE. The stage is sized in JS
   to the displayed image (no letterboxing) so the crop→source mapping stays a
   single scale. */

.photo-cropper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
}

/* ---- aspect presets ---- */

.photo-cropper__presets {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-xs);
}

.photo-cropper__preset {
  appearance: none;
  border: 1px solid var(--color-border-strong);
  background: var(--color-surface);
  color: var(--color-text-muted);
  font: inherit;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast),
    border-color var(--transition-fast);
}

.photo-cropper__preset:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.photo-cropper__preset:focus-visible {
  outline: none;
  box-shadow: var(--shadow-glow);
}

.photo-cropper__preset--active {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #fff;
}

.photo-cropper__preset--active:hover {
  background: var(--color-accent-hover);
  border-color: var(--color-accent-hover);
  color: #fff;
}

/* ---- crop stage ---- */

.photo-cropper__stage-host {
  width: 100%;
  display: flex;
  justify-content: center;
}

.photo-cropper__stage {
  position: relative;
  max-width: 100%;
  background: var(--color-bg-tint);
  border-radius: var(--radius-sm);
  overflow: hidden;
  touch-action: none; /* drags should crop, not pan/zoom the page */
  user-select: none;
}

.photo-cropper__image {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

/* The crop rectangle. The huge spread box-shadow dims everything outside it
   without a second overlay element. */
.photo-cropper__rect {
  position: absolute;
  box-sizing: border-box;
  border: 2px solid #fff;
  box-shadow: 0 0 0 9999px rgba(20, 20, 18, 0.5);
  cursor: move;
  touch-action: none;
}

/* Rule-of-thirds guides for nicer composition. */
.photo-cropper__rect::before,
.photo-cropper__rect::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.5;
}

.photo-cropper__rect::before {
  border-left: 1px solid rgba(255, 255, 255, 0.6);
  border-right: 1px solid rgba(255, 255, 255, 0.6);
  left: 33.33%;
  right: 33.33%;
}

.photo-cropper__rect::after {
  border-top: 1px solid rgba(255, 255, 255, 0.6);
  border-bottom: 1px solid rgba(255, 255, 255, 0.6);
  top: 33.33%;
  bottom: 33.33%;
}

.photo-cropper__handle {
  position: absolute;
  width: 14px;
  height: 14px;
  background: #fff;
  border: 2px solid var(--color-accent);
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
  touch-action: none;
}

.photo-cropper__handle--nw { top: -8px; left: -8px; cursor: nwse-resize; }
.photo-cropper__handle--ne { top: -8px; right: -8px; cursor: nesw-resize; }
.photo-cropper__handle--sw { bottom: -8px; left: -8px; cursor: nesw-resize; }
.photo-cropper__handle--se { bottom: -8px; right: -8px; cursor: nwse-resize; }

.photo-cropper__hint {
  margin: 0;
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  text-align: center;
}

/* ---- touch: bigger handles, easier to grab (MOBILE/TOUCH PARITY RULE) ---- */
@media (hover: none) and (pointer: coarse) {
  .photo-cropper__handle {
    width: 22px;
    height: 22px;
  }
  .photo-cropper__handle--nw { top: -12px; left: -12px; }
  .photo-cropper__handle--ne { top: -12px; right: -12px; }
  .photo-cropper__handle--sw { bottom: -12px; left: -12px; }
  .photo-cropper__handle--se { bottom: -12px; right: -12px; }
}
