/* Mobile avatar crop — full-screen Cropper.js modal styles.
 *
 * Companion to ow_plugins/elevate_admin_tools/static/js/mobile_avatar_crop.js.
 * Only loads on join + edit-profile pages via injectProfileWidgets.
 *
 * Design intent:
 *   - Full-viewport modal on phones, fixed-positioned so address bar
 *     show/hide doesn't cause jumping.
 *   - Header bar: Cancel (left) / Title (center) / Apply (right). The
 *     buttons are large, tappable, and visually distinct (ghost vs
 *     primary).
 *   - Single-column body: Cropper.js canvas fills the available space.
 *     No floated preview block, no separate column.
 *   - Body lock so the page underneath doesn't scroll while the modal
 *     is open.
 */

/* Lock background scroll while modal is open. */
body.elv-mavc-locked {
    overflow: hidden;
    position: fixed;
    width: 100%;
}

#elv-mavc-modal {
    position: fixed;
    inset: 0;
    z-index: 100000; /* above the legacy floatbox z-index of 9000+ */
    background: #000;
    color: #fff;
    display: flex;
    flex-direction: column;
    -webkit-tap-highlight-color: transparent;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI",
                 Roboto, Helvetica, Arial, sans-serif;
}

#elv-mavc-modal[hidden] {
    display: none !important;
}

/* On wider viewports (>= 720px desktop), present the modal as a
   centered card with a dimmed backdrop instead of full-screen black.
   Keeps the same single-column layout — just gives some breathing
   room around it on a roomy display. */
@media (min-width: 720px) {
    #elv-mavc-modal {
        background: rgba(0, 0, 0, 0.78);
        backdrop-filter: blur(2px);
        align-items: center;
        justify-content: center;
        padding: 32px;
    }
    #elv-mavc-modal .elv-mavc-header,
    #elv-mavc-modal .elv-mavc-body {
        width: 560px;
        max-width: 100%;
    }
    #elv-mavc-modal .elv-mavc-header {
        background: #1a1a1a;
        border-radius: 14px 14px 0 0;
        padding-top: 16px;
        border-bottom: 1px solid rgba(255,255,255,0.08);
    }
    #elv-mavc-modal .elv-mavc-body {
        background: #000;
        border-radius: 0 0 14px 14px;
        max-height: 70vh;
        overflow: hidden;
        box-shadow: 0 18px 60px rgba(0, 0, 0, 0.6);
    }
    #elv-mavc-modal .elv-mavc-canvas {
        height: 480px;
    }
    #elv-mavc-modal .elv-mavc-hint {
        padding-bottom: 14px;
    }
}

.elv-mavc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 12px 12px;
    /* Use safe-area-inset-top so the header sits below the iOS notch. */
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
    background: #111;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    flex: 0 0 auto;
}

.elv-mavc-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    color: #fff;
    flex: 1;
    text-align: center;
}

.elv-mavc-btn {
    -webkit-appearance: none;
    appearance: none;
    border: none;
    border-radius: 999px;
    padding: 10px 18px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    min-width: 88px;
    flex: 0 0 auto;
    transition: opacity 0.15s, transform 0.1s, background 0.15s;
}

.elv-mavc-btn:active {
    transform: scale(0.97);
}

.elv-mavc-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.elv-mavc-cancel {
    background: rgba(255,255,255,0.10);
    color: #fff;
}
.elv-mavc-cancel:hover {
    background: rgba(255,255,255,0.18);
}

.elv-mavc-apply {
    background: #e83e6c;
    color: #fff;
    box-shadow: 0 1px 0 rgba(255,255,255,0.06) inset;
}
.elv-mavc-apply:hover {
    background: #d23560;
}

/* Body: take all remaining space. Cropper.js will fit its container. */
.elv-mavc-body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: #000;
}

/* Cropper container — fills body minus the hint at bottom. */
.elv-mavc-canvas {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
}

/* The <img> Cropper binds to. Cropper.js takes over its display, so
   we just need to make sure it doesn't overflow before init. */
.elv-mavc-image {
    max-width: 100%;
    max-height: 100%;
    display: block;
    /* Prevent iOS from showing the broken-image icon mid-load. */
    visibility: visible;
}

/* Hint text under the canvas — explains the gesture model in plain
   language. Hidden when the canvas dominates very small viewports. */
.elv-mavc-hint {
    margin: 0;
    padding: 10px 16px;
    /* Push the hint above the iOS home-indicator. */
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    background: #111;
    color: rgba(255,255,255,0.65);
    font-size: 0.78rem;
    text-align: center;
    line-height: 1.4;
    flex: 0 0 auto;
    border-top: 1px solid rgba(255,255,255,0.06);
}

@media (max-height: 520px) {
    /* Tight viewport (landscape iPhone, etc.) — drop the hint to
       give the canvas more vertical space. */
    .elv-mavc-hint {
        display: none;
    }
}

/* Loading overlay — covers everything except header during upload+crop. */
.elv-mavc-loading {
    position: absolute;
    /* Sit below the header but above the body. */
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.78);
    backdrop-filter: blur(2px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    color: #fff;
    font-size: 0.95rem;
    z-index: 1;
}
.elv-mavc-loading[hidden] { display: none !important; }

.elv-mavc-spinner {
    width: 44px;
    height: 44px;
    border: 3px solid rgba(255,255,255,0.18);
    border-top-color: #ff75a3;
    border-radius: 50%;
    animation: elv-mavc-spin 0.7s linear infinite;
}

@keyframes elv-mavc-spin {
    to { transform: rotate(360deg); }
}

/* Cropper.js dark background so the cropping mask is more visible
   on the all-black modal background. */
#elv-mavc-modal .cropper-modal {
    background-color: #000;
    opacity: 0.6;
}

/* Cropper.js drag handles — already touch-friendly by default but we
   bump contrast for visibility against the dark modal. */
#elv-mavc-modal .cropper-line,
#elv-mavc-modal .cropper-point {
    background-color: #fff;
}
#elv-mavc-modal .cropper-view-box {
    outline-color: rgba(255,255,255,0.95);
}
