/* ==========================================================
   POPUP ENGINE — HUB V8 (Clean & Conflict-Free)
========================================================== */


/* ==========================================================
   OVERLAY
========================================================== */
#popup-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(4px);

    opacity: 0;
    visibility: hidden;

    transition: opacity .25s ease, visibility .25s ease;

    z-index: var(--z-overlay);
    pointer-events: none;
}

#popup-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* ⚠️ FIX: NON blocchiamo più *tutto* il sito 
   → impediva i click anche ai popup stessi.
*/


/* ==========================================================
   BODY LOCK WHILE POPUP OPEN
========================================================== */
body.popup-open {
    overflow: hidden;
}


/* ==========================================================
   POPUP ROOT WRAPPER (anti-transform conflicts)
========================================================== */
#popup-root {
    position: fixed;
    inset: 0;
    z-index: var(--z-popup);
    pointer-events: none;
}


/* ==========================================================
   POPUP WINDOW
========================================================== */
.mirc-popup {
    position: absolute;
    top: 50%;
    left: 50%;
    width: min(92%, 480px);

    transform: translate(-50%, -50%) scale(.9);
    opacity: 0;
    visibility: hidden;

    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;

    box-shadow: 0 0 18px var(--glow);
    backdrop-filter: blur(10px);

    padding: 24px 30px;
    color: var(--text);

    display: flex;
    flex-direction: column;
    gap: 14px;

    max-height: 80vh;
    overflow-y: auto;

    transition:
        opacity .22s ease,
        transform .25s cubic-bezier(.25,.1,.25,1),
        visibility .22s ease;

    pointer-events: none;
}

.mirc-popup.active {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
    pointer-events: auto;
}


/* ==========================================================
   SCROLLBAR
========================================================== */
.mirc-popup::-webkit-scrollbar {
    width: 8px;
}
.mirc-popup::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 6px;
}


/* ==========================================================
   CLOSE BUTTON
========================================================== */
.popup-close {
    position: absolute;
    top: 10px;
    right: 12px;

    width: 28px;
    height: 28px;

    border-radius: 50%;
    border: 1px solid var(--border);
    background: rgba(0,0,0,0.22);

    display: flex;
    justify-content: center;
    align-items: center;

    color: var(--text);
    cursor: pointer;

    transition: .22s ease;
}

.popup-close:hover {
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: 0 0 12px var(--accent);
    transform: scale(1.05);
}


/* ==========================================================
   OPTIONAL FX CORNERS (tema decide)
========================================================== */
.popup-corner {
    position: absolute;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    opacity: .75;
    pointer-events: none;
}


/* ==========================================================
   MOBILE OPTIMIZATION
========================================================== */
@media (max-width:520px) {
    .mirc-popup {
        width: 94%;
        padding: 20px;
        max-height: 82vh;
        border-radius: 10px;
    }

    .popup-close {
        top: 8px;
        right: 10px;
    }
}


/* ==========================================================
   DIM UI ELEMENTS WHILE POPUP IS OPEN
========================================================== */
body.popup-open #mobile-menu,
body.popup-open .theme-switcher,
body.popup-open .theme-mobile-btn,
body.popup-open .theme-mobile-panel {
    pointer-events: none !important;
    opacity: .4;
}
