/* Tool-specific: Image Cropper */

/* Drop zone */
.drop-zone {
  border: 2px dashed var(--color-border);
  border-radius: 4px;
  padding: 32px 24px;
  text-align: center;
  background-color: var(--color-surface-subtle);
  color: var(--color-text-muted);
  cursor: pointer;
  margin-bottom: 16px;
  position: relative;
  transition: border-color 0.2s, background-color 0.2s;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--color-signal);
  background-color: var(--color-surface-muted);
  color: var(--color-text);
}

.drop-zone input[type="file"] {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.drop-zone__hint {
  display: inline-block;
  font-size: var(--fs-sm);
}

/* Aspect ratio chips */
.aspect-ratios {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.option-radio--chip {
  position: relative;
}

.option-radio--chip input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.option-radio--chip span {
  display: inline-block;
  padding: 4px 12px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-size: var(--fs-sm);
  cursor: pointer;
  transition: border-color 0.2s, background-color 0.2s;
}

.option-radio--chip input[type="radio"]:checked + span {
  border-color: var(--color-signal);
  background-color: var(--color-signal-soft);
  color: var(--color-signal);
}

.option-radio--chip span:hover {
  border-color: var(--color-signal);
}

/* Crop options row */
.crop-options {
  margin-bottom: 16px;
}

/* Crop viewport */
.crop-viewport {
  position: relative;
  max-width: 100%;
  overflow: hidden;
  background-color: var(--color-surface-muted);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  margin-bottom: 12px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.crop-viewport img {
  display: block;
  max-width: 100%;
  height: auto;
}

/* Overlay with darkened border areas */
.crop-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
}

.crop-overlay::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

/* Crop selection rectangle */
.crop-selection {
  position: absolute;
  border: 2px solid #fff;
  outline: 1px solid rgba(0, 0, 0, 0.25);
  pointer-events: auto;
  cursor: move;
  box-sizing: border-box;
}

/* Corner and edge handles */
.crop-handle {
  position: absolute;
  width: 14px;
  height: 14px;
  background: #fff;
  border: 2px solid var(--color-signal);
  border-radius: 2px;
  z-index: 2;
}

.crop-handle--nw {
  top: -7px;
  left: -7px;
  cursor: nw-resize;
}

.crop-handle--n {
  top: -7px;
  left: 50%;
  margin-left: -7px;
  cursor: n-resize;
}

.crop-handle--ne {
  top: -7px;
  right: -7px;
  cursor: ne-resize;
}

.crop-handle--e {
  top: 50%;
  margin-top: -7px;
  right: -7px;
  cursor: e-resize;
}

.crop-handle--se {
  bottom: -7px;
  right: -7px;
  cursor: se-resize;
}

.crop-handle--s {
  bottom: -7px;
  left: 50%;
  margin-left: -7px;
  cursor: s-resize;
}

.crop-handle--sw {
  bottom: -7px;
  left: -7px;
  cursor: sw-resize;
}

.crop-handle--w {
  top: 50%;
  margin-top: -7px;
  left: -7px;
  cursor: w-resize;
}

/* Touch-friendly larger hit area for handles */
@media (pointer: coarse) {
  .crop-handle {
    width: 28px;
    height: 28px;
  }

  .crop-handle--nw,
  .crop-handle--n,
  .crop-handle--ne {
    top: -14px;
  }

  .crop-handle--sw,
  .crop-handle--s,
  .crop-handle--se {
    bottom: -14px;
  }

  .crop-handle--w,
  .crop-handle--e {
    margin-top: -14px;
  }

  .crop-handle--n,
  .crop-handle--s {
    margin-left: -14px;
  }

  .crop-handle--nw,
  .crop-handle--ne,
  .crop-handle--sw,
  .crop-handle--se {
    width: 32px;
    height: 32px;
  }

  .crop-handle--nw,
  .crop-handle--sw {
    left: -16px;
  }

  .crop-handle--ne,
  .crop-handle--se {
    right: -16px;
  }
}

/* Live readout */
.crop-readout {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 8px 12px;
  background: var(--color-surface-subtle);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  margin-bottom: 12px;
  font-size: var(--fs-sm);
  font-family: var(--font-mono);
}

.crop-readout__item {
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
}

.crop-readout__label {
  color: var(--color-text-muted);
}

.crop-readout__unit {
  color: var(--color-text-muted);
  margin-left: 1px;
}

/* Privacy note */
.crop-privacy-note {
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
  margin-bottom: 12px;
  font-style: italic;
}

/* Hidden state - use display:none via class instead of inline style */
.crop-selection[hidden] {
  display: none !important;
}

.crop-overlay[hidden] {
  display: none !important;
}
