/* CropFrame template (templates/cropFrame.js): the photo under a frame of the chosen shape, the shape buttons and Cancel / Done below. */
.crop {
  position: absolute; /* over the whole app (.app is the positioned box) */
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  padding: var(--top-gap) 0 54px;
  background: var(--bg-primary);
  color: var(--primary);
}

.crop__count {
  flex: none;
  padding-bottom: 8px;
  text-align: center;
  font-size: 14px;
  line-height: 20px;
}

.crop__stage {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  touch-action: none; /* a drag moves the photo, two fingers zoom it: not the page */
  cursor: grab;
}

.crop__img {
  position: absolute;
  top: 0;
  left: 0;
  max-width: none; /* its natural size, the scale is set from the code */
  transform-origin: 0 0;
  user-select: none;
  pointer-events: none;
}

/* the frame: its own box-shadow dims what is outside it */
.crop__frame {
  position: absolute;
  border: 2px solid var(--primary);
  border-radius: 4px;
  box-shadow: 0 0 0 100vmax color-mix(in srgb, var(--bg-primary) 65%, transparent);
  pointer-events: none;
}

.crop__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding: 16px 12px 0;
}

.crop__ratios {
  display: flex;
  gap: 4px;
}

.crop__btn {
  height: 36px;
  padding: 0 12px;
  flex: none;
  border-radius: 18px;
  background: var(--bg-secondary);
  color: var(--primary);
  font-size: 14px;
  line-height: 36px;
}

.crop__btn:active,
.crop__btn.is-active {
  background: var(--color-neutral);
  font-weight: 700;
}

/* after Done: the cut photo fills the frame, the buttons are off */
.crop__shot {
  position: absolute;
  z-index: 1;
  border-radius: 4px;
  object-fit: cover;
  box-shadow: 0 0 0 100vmax var(--bg-primary);
  animation: crop-shot 0.3s var(--ease);
}

.crop.is-done .crop__bar {
  pointer-events: none;
}

.crop.is-done .crop__btn:not(.is-active) {
  opacity: 0.4;
}

@keyframes crop-shot {
  from { opacity: 0; transform: scale(1.06); }
}

/* the bar under the frame fills while the photo is being added */
.crop__progress {
  position: absolute;
  z-index: 1;
  font-size: 12px;
  line-height: 16px;
  text-align: center;
}

.crop__progress i {
  display: block;
  height: 4px;
  margin-bottom: 4px;
  border-radius: 2px;
  background: var(--primary);
  transform-origin: 0 0;
  animation: crop-progress 0.7s linear forwards;
}

.crop__progress span {
  display: block;
}

@keyframes crop-progress {
  from { transform: scaleX(0); }
}
