/* ============================================================
   Custom Crop Image Tool — style.css
   Classes  : xc-crop-*
   Approach : Mobile-first (base = mobile, @media min-width = desktop)
   Brand    : #42B5A4 (teal) — matches the sibling circle-crop tool
   Font     : Inter (var(--font-primary) from imgtry-fonts.css)
   ============================================================ */


/* ══════════════════════════════════════════
   0. BASE / RESET / BRAND TOKENS
   ══════════════════════════════════════════ */
.xc-crop-wrap,
.xc-crop-wrap * {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

/* Form controls don't inherit the page font by default — make them Inter too. */
.xc-crop-wrap button,
.xc-crop-wrap input,
.xc-crop-wrap select,
.xc-crop-wrap textarea {
  font-family: inherit;
}

.xc-crop-wrap {
  --xc-brand: #42B5A4;
  --xc-brand-dark: #2E8577;
  --xc-brand-soft: #E8F8F6;

  --xc-ink: #1a1a22;
  --xc-ink-soft: #55555f;
  --xc-line: #e4e4ee;
  --xc-line-strong: #c4c4d4;
  --xc-bg: #f5f5fa;
  --xc-error: #c0392b;

  font-family: var(--font-primary, 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif);
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 16px 56px;
  touch-action: manipulation;
  overscroll-behavior-y: contain;
}


/* ══════════════════════════════════════════
   1. HEADER
   ══════════════════════════════════════════ */
.xc-crop-header {
  text-align: center;
  margin-bottom: 24px;
}

.xc-crop-header__title {
  font-weight: 800;
  font-size: clamp(1.5rem, 6vw, 2.2rem);
  letter-spacing: -0.8px;
  color: var(--xc-ink);
  margin: 0 0 8px;
}

.xc-crop-header__title strong {
  font-weight: 900;
  color: var(--xc-brand);
}

.xc-crop-header__subtitle {
  font-size: 14.5px;
  font-weight: 500;
  color: var(--xc-ink-soft);
  line-height: 1.6;
  margin: 0;
}


/* ══════════════════════════════════════════
   2. STEPPER
   ══════════════════════════════════════════ */
.xc-crop-stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: 28px;
}

.xc-crop-stepper__step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.xc-crop-stepper__dot {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: #9999a2;
  background: #fff;
  border: 1.5px solid var(--xc-line);
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.xc-crop-stepper__step.is-active .xc-crop-stepper__dot {
  background: var(--xc-brand);
  border-color: var(--xc-brand);
  color: #fff;
}

.xc-crop-stepper__step.is-done .xc-crop-stepper__dot {
  background: var(--xc-brand-soft);
  border-color: var(--xc-brand);
  color: var(--xc-brand);
}

.xc-crop-stepper__dot--export {
  width: auto;
  border-radius: 9999px;
  padding: 0 16px;
  font-size: 12px;
  letter-spacing: 0.3px;
}

.xc-crop-stepper__label {
  font-size: 11.5px;
  font-weight: 600;
  color: #9999a2;
}

.xc-crop-stepper__step.is-active .xc-crop-stepper__label {
  color: var(--xc-ink);
}

.xc-crop-stepper__line {
  width: 32px;
  height: 1.5px;
  background: var(--xc-line);
}


/* ══════════════════════════════════════════
   3. PANELS
   ══════════════════════════════════════════ */
.xc-crop-panel {
  display: none;
}

.xc-crop-panel.is-active {
  display: block;
  animation: xcFadeIn 0.28s ease backwards;
}

@keyframes xcFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}


/* ══════════════════════════════════════════
   4. STEP 1 — UPLOAD SECTION
   ══════════════════════════════════════════ */
.xc-crop-dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 480px;
  margin: 8px auto 0;
  padding: 40px 24px;
  border-radius: 24px;
  cursor: pointer;
}

.xc-crop-dropzone__ring {
  position: absolute;
  inset: 0;
  border-radius: 24px;
  border: 1.5px dashed transparent;
  box-shadow: 0 0 0 0 rgba(66, 181, 164, 0);
  transition: box-shadow 0.25s ease, border-color 0.25s ease;
  pointer-events: none;
}

.xc-crop-dropzone.is-dragover .xc-crop-dropzone__ring {
  border-color: rgba(66, 181, 164, 0.45);
  box-shadow: 0 0 0 8px rgba(66, 181, 164, 0.08);
}

.xc-crop-dropzone__button {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 56px;
  padding: 0 32px;
  border-radius: 9999px;
  background: var(--xc-brand);
  border: 1.5px solid var(--xc-brand);
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.1px;
  box-shadow: 0 2px 10px rgba(66,181,164,0.28);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.xc-crop-dropzone__icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: #fff;
}

.xc-crop-dropzone:hover .xc-crop-dropzone__button {
  transform: translateY(-2px);
  background: var(--xc-brand-dark);
  border-color: var(--xc-brand-dark);
  box-shadow: 0 14px 32px rgba(66,181,164,0.28);
}

.xc-crop-dropzone:active .xc-crop-dropzone__button {
  transform: translateY(0) scale(0.98);
  box-shadow: 0 6px 16px rgba(66,181,164,0.24);
}

.xc-crop-dropzone:focus-visible { outline: none; }

.xc-crop-dropzone:focus-visible .xc-crop-dropzone__button {
  box-shadow: 0 0 0 4px var(--xc-brand-soft), 0 8px 24px rgba(66,181,164,0.28);
}

.xc-crop-dropzone.is-dragover .xc-crop-dropzone__button {
  transform: translateY(-2px);
  background: var(--xc-brand-dark);
  border-color: var(--xc-brand-dark);
  box-shadow: 0 14px 32px rgba(66,181,164,0.32);
}

.xc-crop-dropzone__divider {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  max-width: 300px;
  margin-top: 28px;
  color: #a3a3ae;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.xc-crop-dropzone__divider::before,
.xc-crop-dropzone__divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--xc-line-strong));
}

.xc-crop-dropzone__divider::after {
  background: linear-gradient(to left, transparent, var(--xc-line-strong));
}

.xc-crop-dropzone__trust {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 22px 0 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--xc-ink-soft);
}

.xc-crop-dropzone__trust svg {
  width: 15px;
  height: 15px;
  color: var(--xc-brand);
  flex-shrink: 0;
}


/* ══════════════════════════════════════════
   5. THUMBNAIL STRIP (bulk — each image keeps its own crop)
   ══════════════════════════════════════════ */
.xc-crop-thumbs {
  margin: 0;
  min-width: 0;
}

.xc-crop-thumbs__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 34px;
  margin-bottom: 4px;
}

.xc-crop-thumbs__count {
  font-size: 13px;
  font-weight: 800;
  color: var(--xc-ink);
}

.xc-crop-thumbs__hint {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--xc-ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.xc-crop-thumbs__track {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 2px 2px 6px;
  scrollbar-width: none;
}

.xc-crop-thumbs__track::-webkit-scrollbar { display: none; }

.xc-crop-thumbs__item {
  position: relative;
  flex: 0 0 auto;
  width: 64px;
  height: 64px;
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid transparent;
  cursor: pointer;
  background: #eaeaf1;
}

.xc-crop-thumbs__item.is-selected {
  border-color: var(--xc-brand);
  box-shadow: 0 0 0 2px var(--xc-brand-soft);
}

.xc-crop-thumbs__img {
  width: 100%;
  height: 100%;
  object-fit: contain;   /* the thumbnail shows the CROPPED result, so never trim it further */
  display: block;
  pointer-events: none;
}

.xc-crop-thumbs__badge {
  position: absolute;
  left: 4px;
  bottom: 4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--xc-brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(0,0,0,0.35);
}

.xc-crop-thumbs__badge svg {
  width: 11px;
  height: 11px;
}

.xc-crop-thumbs__remove {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: none;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(26,26,34,0.65);
  color: #fff;
  cursor: pointer;
  touch-action: manipulation;
}

.xc-crop-thumbs__remove svg {
  width: 11px;
  height: 11px;
}

.xc-crop-thumbs__add {
  flex: 0 0 auto;
  width: 64px;
  height: 64px;
  border-radius: 12px;
  border: 1.5px dashed var(--xc-line-strong);
  background: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--xc-ink-soft);
  cursor: pointer;
  touch-action: manipulation;
  font-family: inherit;
}

.xc-crop-thumbs__add svg {
  width: 16px;
  height: 16px;
}

.xc-crop-thumbs__add span {
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1;
}

.xc-crop-thumbs__add:active {
  background: var(--xc-bg);
}


/* ══════════════════════════════════════════
   6. STEP 2 — STAGE (image + crop frame + masks)

   Two layers on purpose: .xc-crop-stage is an UNCLIPPED padded
   wrapper. That padding is what keeps a corner handle from being
   cut in half when the crop frame reaches the true edge of the
   image. .xc-crop-frame is the image-shaped, clipped box holding
   only the canvas and the darkening masks; the crop frame and its
   handles live in the outer padded layer, never clipped.
   ══════════════════════════════════════════ */
.xc-crop-stage {
  position: relative;
  flex: 0 0 auto;
  touch-action: none;
}

.xc-crop-frame {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  background:
    linear-gradient(45deg, #e9e9ef 25%, transparent 25%) -10px 0/ 20px 20px,
    linear-gradient(-45deg, #e9e9ef 25%, transparent 25%) -10px 0/ 20px 20px,
    linear-gradient(45deg, transparent 75%, #e9e9ef 75%) -10px 0/ 20px 20px,
    linear-gradient(-45deg, transparent 75%, #e9e9ef 75%) -10px 0/ 20px 20px,
    #fafafd;
  box-shadow: 0 1px 3px rgba(26,26,34,0.08);
}

.xc-crop-canvas {
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}

/* ── Darkened surround (4 divs framing the crop frame), inside the image frame ── */
.xc-crop-mask {
  position: absolute;
  background: rgba(26, 26, 34, 0.55);
  pointer-events: none;
  z-index: 1;
}

.xc-crop-mask--top    { top: 0; left: 0; right: 0; height: 0; }
.xc-crop-mask--bottom { bottom: 0; left: 0; right: 0; height: 0; }
.xc-crop-mask--left   { left: 0; width: 0; }
.xc-crop-mask--right  { right: 0; width: 0; }

/* ── The crop frame: white border, rule-of-thirds grid, clear handles ── */
.xc-crop-box {
  position: absolute;
  z-index: 2;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(26,26,34,0.28);
  cursor: move;
  touch-action: none;
  outline: none;
  background-image:
    linear-gradient(to right, transparent calc(33.333% - .5px), rgba(255,255,255,.6) calc(33.333% - .5px), rgba(255,255,255,.6) calc(33.333% + .5px), transparent calc(33.333% + .5px), transparent calc(66.666% - .5px), rgba(255,255,255,.6) calc(66.666% - .5px), rgba(255,255,255,.6) calc(66.666% + .5px), transparent calc(66.666% + .5px)),
    linear-gradient(to bottom, transparent calc(33.333% - .5px), rgba(255,255,255,.6) calc(33.333% - .5px), rgba(255,255,255,.6) calc(33.333% + .5px), transparent calc(33.333% + .5px), transparent calc(66.666% - .5px), rgba(255,255,255,.6) calc(66.666% - .5px), rgba(255,255,255,.6) calc(66.666% + .5px), transparent calc(66.666% + .5px));
}

.xc-crop-box:focus-visible {
  box-shadow: 0 0 0 1px rgba(26,26,34,0.28), 0 0 0 4px var(--xc-brand-soft);
}

/* Handles: a clear white square with a brand outline (pill-shaped on the edges),
   centred on an oversized invisible touch target so they stay easy to grab. */
.xc-crop-box__handle {
  position: absolute;
  width: 18px;
  height: 18px;
  transform: translate(-50%, -50%);
  border-radius: 5px;
  border: 2px solid var(--xc-brand);
  background: #fff;
  touch-action: none;
}

.xc-crop-box__handle::after {
  content: '';
  position: absolute;
  inset: -14px;
}

.xc-crop-box__handle[data-handle="nw"] { top: 0;    left: 0;    cursor: nwse-resize; }
.xc-crop-box__handle[data-handle="ne"] { top: 0;    left: 100%; cursor: nesw-resize; }
.xc-crop-box__handle[data-handle="se"] { top: 100%; left: 100%; cursor: nwse-resize; }
.xc-crop-box__handle[data-handle="sw"] { top: 100%; left: 0;    cursor: nesw-resize; }
.xc-crop-box__handle[data-handle="n"]  { top: 0;    left: 50%;  cursor: ns-resize; width: 34px; height: 10px; border-radius: 9999px; }
.xc-crop-box__handle[data-handle="s"]  { top: 100%; left: 50%;  cursor: ns-resize; width: 34px; height: 10px; border-radius: 9999px; }
.xc-crop-box__handle[data-handle="e"]  { top: 50%;  left: 100%; cursor: ew-resize; width: 10px; height: 34px; border-radius: 9999px; }
.xc-crop-box__handle[data-handle="w"]  { top: 50%;  left: 0;    cursor: ew-resize; width: 10px; height: 34px; border-radius: 9999px; }

/* Very small frames: drop the edge handles that would crowd the corners, so the four corners stay easy to hit. */
.xc-crop-box.is-narrow .xc-crop-box__handle[data-handle="n"],
.xc-crop-box.is-narrow .xc-crop-box__handle[data-handle="s"],
.xc-crop-box.is-short .xc-crop-box__handle[data-handle="e"],
.xc-crop-box.is-short .xc-crop-box__handle[data-handle="w"] {
  display: none;
}

.xc-crop-stage__loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(250, 250, 253, 0.85);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 4;
}

.xc-crop-stage__loading.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.xc-crop-spinner {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 3px solid var(--xc-line);
  border-top-color: var(--xc-brand);
  animation: xcSpin 0.7s linear infinite;
}

@keyframes xcSpin {
  to { transform: rotate(360deg); }
}

.xc-crop-dims {
  margin: 0;
  text-align: center;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.2px;
  color: var(--xc-ink-soft);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}


/* ══════════════════════════════════════════
   7. ACTIVE CONTROLS
   (tool dock, panels, ratio chips, zoom — see editor.css)
   ══════════════════════════════════════════ */

/* Step 3 still uses these two: */
.xc-crop-controls__row {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-bottom: 18px;
}

.xc-crop-controls__label {
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: #7a7a86;
}

.xc-crop-controls__hint {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: var(--xc-ink-soft);
  margin-left: 4px;
}


/* ══════════════════════════════════════════
   8. STEP 3 — EXPORT PREVIEW
   ══════════════════════════════════════════ */
.xc-crop-select {
  height: 44px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1.5px solid var(--xc-line);
  background: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--xc-ink);
  width: 100%;
}

.xc-crop-progress {
  margin: 4px 0 8px;
}

.xc-crop-progress__track {
  height: 8px;
  border-radius: 9999px;
  background: var(--xc-line);
  overflow: hidden;
}

.xc-crop-progress__fill {
  height: 100%;
  width: 0%;
  background: var(--xc-brand);
  transition: width 0.2s ease;
}

.xc-crop-progress__label {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--xc-ink-soft);
  text-align: center;
}


/* ══════════════════════════════════════════
   9. ACTION BUTTONS
   ══════════════════════════════════════════ */
.xc-crop-btn {
  flex: 1;
  height: 48px;
  border-radius: 9999px;
  font-family: inherit;
  font-weight: 700;
  font-size: 15px;
  border: 1.5px solid transparent;
  cursor: pointer;
  touch-action: manipulation;
}

.xc-crop-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.xc-crop-btn--primary {
  background: var(--xc-brand);
  color: #fff;
  box-shadow: 0 2px 10px rgba(66,181,164,0.28);
}

.xc-crop-btn--primary:active {
  transform: scale(0.98);
}

.xc-crop-btn--ghost {
  background: #fff;
  border-color: var(--xc-line);
  color: var(--xc-ink);
}

.xc-crop-btn--ghost:active {
  background: var(--xc-bg);
}

.xc-crop-btn--outline {
  background: #fff;
  border-color: var(--xc-brand);
  color: var(--xc-brand);
}

.xc-crop-btn--outline:active {
  background: var(--xc-brand-soft);
}

/* ══════════════════════════════════════════
   10. TOAST
   ══════════════════════════════════════════ */
.xc-crop-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  background: #1a1a22;
  color: #fff;
  padding: 12px 22px;
  border-radius: 9999px;
  font-family: var(--font-primary, 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif);
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 999;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  max-width: 90vw;
  text-align: center;
}

.xc-crop-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.xc-crop-toast.is-error {
  background: #c0392b;
}

.xc-crop-toast.is-success {
  background: #2E8577;
}


/* ══════════════════════════════════════════
   11. DESKTOP ENHANCEMENTS (≥768px)
   ══════════════════════════════════════════ */
@media (min-width: 768px) {
  .xc-crop-wrap {
    padding: 40px 24px 72px;
  }

  .xc-crop-header__subtitle {
    font-size: 16px;
  }

  .xc-crop-stepper {
    gap: 10px;
    margin-bottom: 36px;
  }

  .xc-crop-stepper__line {
    width: 56px;
  }

  .xc-crop-dropzone {
    max-width: 520px;
    padding: 56px 24px;
  }

  .xc-crop-dropzone__button {
    height: 60px;
    padding: 0 36px;
    font-size: 16.5px;
  }

  .xc-crop-btn--ghost:hover {
    border-color: var(--xc-ink);
  }

  .xc-crop-btn--primary:hover {
    box-shadow: 0 4px 16px rgba(66,181,164,0.36);
  }

}


/* ══════════════════════════════════════════
   11b. MORE TOOLS (internal links inside an H2)
   ══════════════════════════════════════════ */
.xc-crop-more {
  margin: 44px auto 0;
  padding-top: 24px;
  border-top: 1px solid var(--xc-line);
  text-align: center;
}

.xc-crop-more__title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.7;
  color: var(--xc-ink-soft);
}

.xc-crop-more__title a {
  color: var(--xc-brand-dark);
  font-weight: 800;
  text-decoration: underline;
  text-decoration-color: rgba(46,133,119,0.35);
  text-underline-offset: 3px;
  white-space: nowrap;
}

.xc-crop-more__title a:hover {
  text-decoration-color: var(--xc-brand-dark);
}

.xc-crop-more__title a:focus-visible {
  outline: 2px solid var(--xc-brand);
  outline-offset: 3px;
  border-radius: 4px;
}


/* ══════════════════════════════════════════
   12. ACCESSIBILITY
   ══════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  .xc-crop-panel.is-active,
  .xc-crop-spinner {
    animation: none;
  }

  .xc-crop-dropzone__button {
    transition: box-shadow 0.18s ease, border-color 0.18s ease;
  }

  .xc-crop-dropzone:hover .xc-crop-dropzone__button,
  .xc-crop-dropzone:active .xc-crop-dropzone__button,
  .xc-crop-dropzone.is-dragover .xc-crop-dropzone__button {
    transform: none;
  }
}
