/* Image Resizer & Cropper — page-specific styles (uses site tokens only). */
main [hidden] { display: none !important; }

.ir-gap { margin-top: 14px; }
.ir-gap-b { margin: -4px 0 16px; }
.ir-upload { max-width: 760px; margin: 0 auto; }
.ir-upload .form-section { padding-bottom: 22px; }
.ir-upload .dropzone { cursor: pointer; }
.ir-upload .dropzone label.btn { margin-top: 6px; }

/* Layout: big crop stage + settings column */
.ir-shell { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.ir-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.ir-side { min-width: 0; }
.ir-stage-box { min-width: 0; }

/* Crop stage — the only area that disables touch scrolling */
.ir-stage {
  position: relative; display: flex; align-items: center; justify-content: center;
  padding: 18px; min-height: 200px; touch-action: none;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
.ir-stage.is-dragging, .ir-stage.is-dragging * { cursor: grabbing; }
.ir-wrap { position: relative; flex: none; line-height: 0; box-shadow: var(--shadow-sm); }
.ir-wrap canvas { display: block; width: 100%; height: 100%; }
.ir-clip { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.ir-shade { position: absolute; box-shadow: 0 0 0 9999px rgba(15, 23, 42, .58); }

.ir-crop { position: absolute; cursor: move; outline: none; box-shadow: 0 0 0 1px rgba(15, 23, 42, .5); border: 2px solid #fff; box-sizing: border-box; }
.ir-crop:focus-visible { border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 55%, transparent); }
.ir-grid { position: absolute; inset: 0; pointer-events: none; opacity: .55;
  background:
    linear-gradient(to right, transparent calc(33.333% - .5px), rgba(255, 255, 255, .8) calc(33.333% - .5px), rgba(255, 255, 255, .8) calc(33.333% + .5px), transparent calc(33.333% + .5px), transparent calc(66.666% - .5px), rgba(255, 255, 255, .8) calc(66.666% - .5px), rgba(255, 255, 255, .8) calc(66.666% + .5px), transparent calc(66.666% + .5px)),
    linear-gradient(to bottom, transparent calc(33.333% - .5px), rgba(255, 255, 255, .8) calc(33.333% - .5px), rgba(255, 255, 255, .8) calc(33.333% + .5px), transparent calc(33.333% + .5px), transparent calc(66.666% - .5px), rgba(255, 255, 255, .8) calc(66.666% - .5px), rgba(255, 255, 255, .8) calc(66.666% + .5px), transparent calc(66.666% + .5px));
}

/* Handles: 40 px touch target, 14 px visible square */
.ir-handle { position: absolute; width: 40px; height: 40px; margin: -20px 0 0 -20px; z-index: 2; }
.ir-handle::after { content: ""; position: absolute; left: 13px; top: 13px; width: 14px; height: 14px; background: #fff; border: 2px solid var(--primary); border-radius: 3px; box-sizing: border-box; box-shadow: 0 1px 3px rgba(0, 0, 0, .35); }
.ir-handle[data-handle="nw"] { left: 0; top: 0; cursor: nwse-resize; }
.ir-handle[data-handle="n"] { left: 50%; top: 0; cursor: ns-resize; }
.ir-handle[data-handle="ne"] { left: 100%; top: 0; cursor: nesw-resize; }
.ir-handle[data-handle="e"] { left: 100%; top: 50%; cursor: ew-resize; }
.ir-handle[data-handle="se"] { left: 100%; top: 100%; cursor: nwse-resize; }
.ir-handle[data-handle="s"] { left: 50%; top: 100%; cursor: ns-resize; }
.ir-handle[data-handle="sw"] { left: 0; top: 100%; cursor: nesw-resize; }
.ir-handle[data-handle="w"] { left: 0; top: 50%; cursor: ew-resize; }
.ir-handle[data-handle="n"]::after, .ir-handle[data-handle="s"]::after { width: 20px; height: 8px; left: 10px; top: 16px; border-radius: 4px; }
.ir-handle[data-handle="e"]::after, .ir-handle[data-handle="w"]::after { width: 8px; height: 20px; left: 16px; top: 10px; border-radius: 4px; }
.ir-crop.is-small .ir-handle[data-handle="n"], .ir-crop.is-small .ir-handle[data-handle="s"],
.ir-crop.is-small .ir-handle[data-handle="e"], .ir-crop.is-small .ir-handle[data-handle="w"] { display: none; }

.ir-tools { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.ir-glyph { font-size: 1.1rem; line-height: 1; }
.ir-row { margin: 0 0 12px -10px; }

.ir-result { padding: 16px 18px 18px; }
.ir-result-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.ir-h { font-size: 1.05rem; margin: 0; }
.ir-result .img-frame { min-height: 120px; }
.ir-result .img-frame img { max-height: 50vh; }
.ir-faq { margin-top: 32px; }

input[type="range"]:disabled { opacity: .5; cursor: not-allowed; }
.segmented input:disabled + span { opacity: .5; cursor: not-allowed; }

@media (max-width: 1023px) {
  .ir-shell { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .ir-stage { padding: 16px 12px; }
  .ir-tools .btn { flex: 1 1 auto; }
  .ir-dims { grid-template-columns: 1fr 1fr; }
}
