/* CropModal — reusable "crop before upload" step. See crop_modal.js. */

body.crop-modal-open { overflow: hidden; }

.crop-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(15, 23, 42, 0.62);
    backdrop-filter: blur(2px);
}
.crop-modal[hidden] { display: none; }

.crop-modal__panel {
    background: #fff;
    border-radius: 0.9rem;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.35);
    width: 100%;
    max-width: 640px;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    padding: 1rem 1.1rem 1.15rem;
    gap: 0.75rem;
}

.crop-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}
.crop-modal__title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: #0f172a;
}
.crop-modal__close {
    border: none;
    background: transparent;
    font-size: 1.6rem;
    line-height: 1;
    color: #64748b;
    cursor: pointer;
    padding: 0.15rem 0.5rem;
    border-radius: 0.5rem;
}
.crop-modal__close:hover { background: #f1f5f9; color: #0f172a; }

.crop-modal__stage {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;   /* let the flex child shrink inside the panel */
    overflow: hidden;
}

/* Shrink-wraps the image so the crop box coordinates are image-relative.
   overflow:hidden clips the box's shade box-shadow to the image area. */
.crop-modal__frame {
    position: relative;
    display: inline-block;
    line-height: 0;
    overflow: hidden;
    max-width: 100%;
    user-select: none;
    -webkit-user-select: none;
}
.crop-modal__img {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: min(62vh, 560px);
    -webkit-user-drag: none;
    user-select: none;
    pointer-events: none;   /* gestures are handled on the frame */
}

.crop-modal__box {
    position: absolute;
    box-sizing: border-box;
    border: 2px solid #fff;
    box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.5);
    cursor: move;
    /* faint rule-of-thirds hint */
    background-image:
        linear-gradient(to right, rgba(255,255,255,0.35) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(255,255,255,0.35) 1px, transparent 1px);
    background-size: 33.33% 33.33%;
    background-position: center;
}
.crop-modal__box[hidden] { display: none; }

.crop-modal__handle {
    position: absolute;
    width: 20px;
    height: 20px;
    background: #fff;
    border: 2px solid var(--color-brand-orange, #E4632B);
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.35);
    touch-action: none;
}
.crop-modal__handle--nw { left: -11px;  top: -11px;    cursor: nwse-resize; }
.crop-modal__handle--ne { right: -11px; top: -11px;    cursor: nesw-resize; }
.crop-modal__handle--sw { left: -11px;  bottom: -11px; cursor: nesw-resize; }
.crop-modal__handle--se { right: -11px; bottom: -11px; cursor: nwse-resize; }

.crop-modal__hint {
    margin: 0;
    font-size: 0.85rem;
    line-height: 1.4;
    color: #64748b;
    text-align: center;
}

.crop-modal__actions {
    display: flex;
    gap: 0.6rem;
    justify-content: flex-end;
    flex-wrap: wrap;
}
.crop-modal__btn {
    border: none;
    border-radius: 0.6rem;
    padding: 0.7rem 1.25rem;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
}
.crop-modal__btn--ghost {
    background: #f1f5f9;
    color: #334155;
}
.crop-modal__btn--ghost:hover { background: #e2e8f0; }
.crop-modal__btn--primary {
    background: var(--color-brand-orange, #E4632B);
    color: #fff;
}
.crop-modal__btn--primary:hover { filter: brightness(0.96); }

@media (max-width: 480px) {
    .crop-modal__panel { padding: 0.85rem 0.9rem 1rem; }
    .crop-modal__img { max-height: 54vh; }
    .crop-modal__actions { justify-content: stretch; }
    .crop-modal__btn { flex: 1 1 auto; }
}
