/* ==================================================================
   Image Cropper tool — loaded only on /tools/image-cropper/
   Uses the brand variables defined in main.css.
   ================================================================== */

.mr-crop__grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr); }
.mr-crop__work { padding: clamp(1.25rem, 3vw, 2rem); min-width: 0; }
.mr-crop__side { padding: clamp(1.25rem, 3vw, 2rem); border-left: 1px solid var(--mr-border); background: var(--mr-navy-03); }
@media (max-width: 991.98px) {
  .mr-crop__grid { grid-template-columns: 1fr; }
  .mr-crop__side { border-left: 0; border-top: 1px solid var(--mr-border); }
}

/* Step headings */
.mr-crop__bar { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1rem; margin-bottom: 1.25rem; min-height: 40px; }
.mr-crop__step { display: inline-flex; align-items: center; gap: .65rem; margin: 0; font-size: 1.05rem; color: var(--mr-navy); }
.mr-crop__step > span { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0;
  background: var(--mr-navy); color: var(--mr-gold); font-size: .85rem; }
.mr-crop__side > .mr-crop__step { margin-bottom: 1.5rem; }
.mr-crop__step--dark { color: var(--mr-white); }
.mr-crop__step--dark > span { background: var(--mr-teal); color: var(--mr-white); }

.mr-crop__file { display: flex; align-items: center; gap: .5rem; min-width: 0; margin-left: auto; font-size: .86rem; color: var(--mr-text-muted); }
.mr-crop__file .bi { color: var(--mr-teal); }
.mr-crop__file strong { color: var(--mr-navy); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 575.98px) { .mr-crop__file { margin-left: 0; width: 100%; } .mr-crop__file strong { max-width: 45vw; } }

/* Drop zone */
.mr-crop__drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .55rem;
  min-height: 380px; padding: 2rem 1.5rem; margin: 0; text-align: center; cursor: pointer;
  border: 2px dashed var(--mr-navy-12); border-radius: var(--mr-radius); background: var(--mr-surface-alt);
  transition: border-color .2s var(--mr-ease), background-color .2s var(--mr-ease);
}
.mr-crop__drop:hover, .mr-crop.is-drag .mr-crop__drop { border-color: var(--mr-teal); background: var(--mr-teal-12); }
.mr-crop__drop:focus-within { outline: 3px solid var(--mr-gold); outline-offset: 3px; }
.mr-crop__drop .mr-icon { width: 68px; height: 68px; font-size: 1.9rem; margin-bottom: .5rem; }
.mr-crop__drop strong { font-family: var(--mr-font-heading); font-size: 1.2rem; font-weight: 600; color: var(--mr-navy); }
.mr-crop__drop strong u { color: var(--mr-teal-700); text-underline-offset: 4px; }
.mr-crop__drop > span:not(.mr-icon) { font-size: .9rem; color: var(--mr-text-muted); }
.mr-crop__privacy { display: inline-flex; align-items: center; gap: .45rem; margin-top: .9rem; padding: .4rem .8rem;
  border: 1px solid var(--mr-border); background: var(--mr-white); font-weight: 700; font-size: .82rem !important; color: var(--mr-teal-700) !important; }
.mr-crop.is-drag .mr-crop__stage { outline: 3px dashed var(--mr-teal); outline-offset: -3px; }

/* Crop stage */
.mr-crop__stage {
  display: grid; place-items: center; min-height: 300px; padding: 16px; border-radius: var(--mr-radius);
  background-color: var(--mr-navy-06);
  background-image: conic-gradient(var(--mr-navy-12) 25%, transparent 0 50%, var(--mr-navy-12) 0 75%, transparent 0);
  background-size: 20px 20px;
  user-select: none; -webkit-user-select: none;
}
@media (max-width: 575.98px) { .mr-crop__stage { min-height: 0; padding: 12px; } .mr-crop__drop { min-height: 300px; } }
.mr-crop__canvas { position: relative; overflow: hidden; box-shadow: var(--mr-shadow); touch-action: none; }
.mr-crop__canvas img { display: block; width: 100%; height: 100%; pointer-events: none; -webkit-user-drag: none; }

.mr-crop__box {
  position: absolute; cursor: move; touch-action: none; outline: none;
  border: 1.5px solid var(--mr-white);
  box-shadow: 0 0 0 9999px color-mix(in srgb, var(--mr-navy) 62%, transparent);
}
.mr-crop__box:focus-visible { border-color: var(--mr-gold);
  box-shadow: 0 0 0 9999px color-mix(in srgb, var(--mr-navy) 62%, transparent), inset 0 0 0 2px var(--mr-gold); }

/* Rule-of-thirds guides */
.mr-crop__line { position: absolute; pointer-events: none; background: color-mix(in srgb, var(--mr-white) 45%, transparent); opacity: .55; transition: opacity .15s; }
.mr-crop__box.is-dragging .mr-crop__line { opacity: 1; }
.mr-crop__line--v1, .mr-crop__line--v2 { top: 0; bottom: 0; width: 1px; }
.mr-crop__line--v1 { left: 33.333%; } .mr-crop__line--v2 { left: 66.666%; }
.mr-crop__line--h1, .mr-crop__line--h2 { left: 0; right: 0; height: 1px; }
.mr-crop__line--h1 { top: 33.333%; } .mr-crop__line--h2 { top: 66.666%; }

/* Corner handles — large hit areas, gold brackets drawn inside the box */
.mr-crop__h { position: absolute; width: 36px; height: 36px; z-index: 2; }
.mr-crop__h::before { content: ""; position: absolute; width: 18px; height: 18px; border: 0 solid var(--mr-gold); }
.mr-crop__h--nw { left: -8px; top: -8px; cursor: nwse-resize; }
.mr-crop__h--ne { right: -8px; top: -8px; cursor: nesw-resize; }
.mr-crop__h--sw { left: -8px; bottom: -8px; cursor: nesw-resize; }
.mr-crop__h--se { right: -8px; bottom: -8px; cursor: nwse-resize; }
.mr-crop__h--nw::before { left: 8px; top: 8px; border-left-width: 4px; border-top-width: 4px; }
.mr-crop__h--ne::before { right: 8px; top: 8px; border-right-width: 4px; border-top-width: 4px; }
.mr-crop__h--sw::before { left: 8px; bottom: 8px; border-left-width: 4px; border-bottom-width: 4px; }
.mr-crop__h--se::before { right: 8px; bottom: 8px; border-right-width: 4px; border-bottom-width: 4px; }

/* Edge handles (free ratio only) */
.mr-crop__e { position: absolute; z-index: 1; }
.mr-crop__e::before { content: ""; position: absolute; background: var(--mr-gold); }
.mr-crop__e--n, .mr-crop__e--s { left: 28px; right: 28px; height: 20px; cursor: ns-resize; }
.mr-crop__e--w, .mr-crop__e--e { top: 28px; bottom: 28px; width: 20px; cursor: ew-resize; }
.mr-crop__e--n { top: -8px; } .mr-crop__e--s { bottom: -8px; }
.mr-crop__e--w { left: -8px; } .mr-crop__e--e { right: -8px; }
.mr-crop__e--n::before, .mr-crop__e--s::before { left: 50%; width: 26px; height: 4px; transform: translateX(-50%); }
.mr-crop__e--n::before { top: 8px; } .mr-crop__e--s::before { bottom: 8px; }
.mr-crop__e--w::before, .mr-crop__e--e::before { top: 50%; width: 4px; height: 26px; transform: translateY(-50%); }
.mr-crop__e--w::before { left: 8px; } .mr-crop__e--e::before { right: 8px; }
.mr-crop__box.is-locked .mr-crop__e { display: none; }

/* Under the stage */
.mr-crop__below { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-top: 1.25rem; }
.mr-crop__ratios { min-width: 0; }
.mr-crop__ratios legend { float: none; width: auto; margin-bottom: .45rem; font-family: var(--mr-font-body); font-size: .88rem; font-weight: 700; color: var(--mr-navy); }
.mr-rates--sm { gap: .4rem; }
.mr-rates--sm label { min-width: 0; padding: .45rem .75rem; font-size: .84rem; }
.mr-crop__readout {
  display: inline-flex; align-items: center; gap: .55rem; padding: .6rem .9rem; white-space: nowrap;
  background: var(--mr-navy); color: var(--mr-white); border-radius: var(--mr-radius-sm);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-weight: 700; font-size: .92rem; font-variant-numeric: tabular-nums;
}
.mr-crop__readout .bi { color: var(--mr-gold); }

/* Options panel */
.mr-crop__wh { display: flex; align-items: center; gap: .5rem; }
.mr-crop__wh > span { color: var(--mr-text-muted); font-weight: 700; }
.mr-crop__side .mr-range { margin: .85rem 0 .1rem; }
.mr-crop__side .form-control:disabled, .mr-crop__side .mr-range:disabled { opacity: .5; cursor: not-allowed; }
.mr-crop__side .form-select { border: 1.5px solid var(--mr-border); border-radius: var(--mr-radius-sm); padding: .75rem 2.25rem .75rem .95rem; }
.mr-seg input:disabled + label { opacity: .45; cursor: not-allowed; }
.mr-crop__side .mr-btn:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }
.mr-crop__spin[hidden] { display: none; }
.mr-crop__spin { width: 15px; height: 15px; border-radius: 50%; display: inline-block;
  border: 2px solid color-mix(in srgb, var(--mr-white) 40%, transparent); border-top-color: var(--mr-white);
  animation: mrCropSpin .7s linear infinite; }
@keyframes mrCropSpin { to { transform: rotate(360deg); } }

/* Result */
.mr-crop__result { padding: clamp(1.25rem, 3vw, 2rem); background: var(--mr-navy); color: var(--mr-on-dark-muted); border-top: 3px solid var(--mr-gold); outline: none; }
.mr-crop__result-grid { display: grid; grid-template-columns: minmax(0, 320px) minmax(0, 1fr); gap: clamp(1.25rem, 3vw, 2.5rem); align-items: start; margin-top: 1.5rem; }
@media (max-width: 767.98px) { .mr-crop__result-grid { grid-template-columns: 1fr; } }
.mr-crop__preview {
  display: grid; place-items: center; min-height: 200px; padding: 12px; border-radius: var(--mr-radius);
  background-color: color-mix(in srgb, var(--mr-white) 94%, var(--mr-navy));
  background-image: conic-gradient(color-mix(in srgb, var(--mr-white) 84%, var(--mr-navy)) 25%, transparent 0 50%, color-mix(in srgb, var(--mr-white) 84%, var(--mr-navy)) 0 75%, transparent 0);
  background-size: 18px 18px;
}
.mr-crop__preview img { display: block; max-width: 100%; max-height: 340px; box-shadow: var(--mr-shadow); transition: opacity .2s; }
.mr-crop__result .mr-result-rows { margin-bottom: 1.25rem; }
.mr-crop__result .mr-result-rows strong { word-break: break-word; }
.mr-crop__note { display: flex; gap: .6rem; margin: 0 0 1.25rem; padding: .8rem 1rem; border-radius: var(--mr-radius-sm); font-size: .9rem;
  background: color-mix(in srgb, var(--mr-gold) 16%, transparent); border-left: 3px solid var(--mr-gold); color: var(--mr-white); }
.mr-crop__stale { display: none; align-items: center; gap: .5rem; padding: .45rem .8rem; border-radius: var(--mr-radius-sm); font-size: .86rem;
  background: color-mix(in srgb, var(--mr-teal) 22%, transparent); color: var(--mr-white); }
.mr-crop__stale strong { color: var(--mr-white); }
.mr-crop__result.is-stale .mr-crop__stale { display: inline-flex; }
.mr-crop__result.is-stale .mr-crop__preview img { opacity: .45; }
