/* Crop editor (js/ui/cropper.js). Only the three type tokens (.title / .body); no radii. */

.cropper {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  padding:
    calc(var(--sat) + var(--gap))
    calc(var(--sar) + var(--gap))
    calc(var(--sab) + var(--gap))
    calc(var(--sal) + var(--gap));
  background: var(--ink);
  color: var(--butter);
  font-size: var(--fs-body);
  overflow: hidden;
  overscroll-behavior: contain;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.cropper-head { text-align: center; flex: none; }
.cropper-hint { color: var(--butter-dim); }

/* The pan/zoom area. Everything outside the square frame is dimmed and clipped to this box. */
.cropper-stage {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  cursor: grab;
  outline-offset: -2px;
}
.cropper-stage.dragging { cursor: grabbing; }

/* Square viewport. The image is positioned inside it; the frame's ::after paints the dimming and
   the outline above the image. */
.cropper-frame {
  --crop: max(140px, min(88vw, 360px, calc(100dvh - 300px)));
  position: relative;
  flex: none;
  width: var(--crop);
  height: var(--crop);
  pointer-events: none;
}
.cropper-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  outline: 2px solid var(--butter);
  box-shadow: 0 0 0 100vmax rgba(27, 31, 59, .74);
  pointer-events: none;
}
.cropper-img {
  position: absolute;
  left: 0;
  top: 0;
  max-width: none;
  transform-origin: 0 0;
  will-change: transform;
  pointer-events: none;
}

/* Zoom slider: 48px tall hit area, square thumb. */
.cropper-zoom {
  flex: none;
  display: flex;
  align-items: center;
  gap: var(--gap);
  width: 100%;
  max-width: 360px;
  margin: 0 auto;
}
.cropper-range {
  flex: 1 1 auto;
  min-width: 0;
  height: var(--tap);
  margin: 0;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  touch-action: pan-x;
}
.cropper-range::-webkit-slider-runnable-track {
  height: 4px;
  background: var(--butter-dim);
  border: 0;
}
.cropper-range::-moz-range-track {
  height: 4px;
  background: var(--butter-dim);
  border: 0;
}
.cropper-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 32px;
  margin-top: -14px;
  background: var(--accent);
  border: 2px solid var(--ink);
}
.cropper-range::-moz-range-thumb {
  width: 20px;
  height: 28px;
  background: var(--accent);
  border: 2px solid var(--ink);
}
.cropper-range:focus-visible,
.cropper-stage:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.cropper-actions {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: var(--col);
  margin: 0 auto;
}
.cropper-row { display: flex; gap: 8px; }
.cropper-row .btn { flex: 1 1 0; min-width: 0; }

@supports not (height: 100dvh) {
  .cropper-frame { --crop: max(140px, min(88vw, 360px, calc(100vh - 300px))); }
}

/* Short screens (landscape phones): drop the hint and shrink the frame. */
@media (max-height: 640px) {
  .cropper-hint { display: none; }
}
@media (max-height: 480px) {
  .cropper-frame { --crop: max(120px, calc(100dvh - 200px)); }
}
