/* ============================================================
   CCG-MODAL.CSS — OMEGA CINEMATIC MODAL (ENHANCED)
============================================================ */

.ccg-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.88);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(3px);
    padding: 12px;
    overflow-y: auto;
    overflow-x: hidden;
}

.ccg-modal.active,
.ccg-modal.open {
    display: flex;
}

.ccg-modal-content {
    position: relative;
    max-width: 92vw;
    max-height: calc(100vh - 40px);
    background: #111;
    padding: 1rem;
    border-radius: 12px;
    box-shadow: 0 0 40px rgba(0,0,0,0.85);
}

.ccg-modal-close {
    position: absolute;
    top: 14px;
    right: 18px;
    font-size: 2rem;
    cursor: pointer;
    opacity: 0.6;
}

.ccg-modal-close:hover {
    opacity: 1;
}

.ccg-modal--doc .ccg-modal-nav {
    display: none;
}

.ccg-modal--doc .ccg-modal-content {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    gap: 10px;
    padding: 14px 16px 16px;
    overflow: auto;
    box-shadow:
        0 0 22px rgba(var(--accent-rgb), 0.42),
        0 0 56px rgba(var(--accent-rgb), 0.34),
        0 0 84px rgba(0,0,0,0.84);
}

/* Manual modal body must have real height */
.ccg-modal--doc .ccg-modal-content,
.ccg-modal--manual .ccg-modal__content {
    width: min(92vw, 980px);
    height: min(85vh, 820px);
    height: min(85dvh, 820px);
    min-height: min(70vh, 620px);
    max-height: 85vh;
    max-height: 85dvh;
    display: flex;
    flex-direction: column;
}

.ccg-pdf-frame {
    width: 80vw;
    height: 78vh;
    border: none;
    background: #000;
}

.ccg-modal--doc.open .ccg-modal-content {
    box-shadow:
        0 0 26px rgba(var(--accent-rgb), 0.48),
        0 0 64px rgba(var(--accent-rgb), 0.36),
        0 0 88px rgba(0,0,0,0.86);
}

.ccg-modal--doc .ccg-pdf-frame {
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.06);
}

.ccg-modal--doc .ccg-pdf-frame,
.ccg-modal--manual iframe {
    flex: 1 1 auto;
    width: 100%;
    height: 100%;
    border: 0;
    background: #000;
}

.ccg-modal--doc {
    position: fixed;
    inset: 0;
    overflow: hidden;
    display: none;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(3px);
    z-index: 10001;
}

.ccg-modal--doc.open,
.ccg-modal--doc.active {
    display: block;
}

#manualModal .ccg-modal-header {
    position: sticky;
    top: 0;
    z-index: 2;
    background: rgba(0, 0, 0, 0.85);
}

#manualModal .ccg-modal-content {
    width: min(100vw, 1200px);
    height: 100%;
    max-height: 100%;
    padding-top: 1.5rem;
    border-radius: 10px;
}

#manualModal .ccg-pdf-frame {
    width: 100%;
    height: 100%;
    min-height: 50vh;
    min-height: 50dvh;
}



/* Manual viewer UX + mobile safety */
.manual-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    z-index: 9999;
}

body.modal-open {
    overflow: hidden;
    height: 100%;
}

.manual-content {
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    height: 100%;
    max-height: 100%;
}

.manual-loading {
    margin: 0 48px 0.75rem 0;
    color: #cfcfcf;
    font-size: 0.9rem;
}

.manual-loading[hidden] {
    display: none;
}

.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ============================================================
   MODAL NAV ARROWS — PREMIUM
============================================================ */

.ccg-modal-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 3rem;
    background: none;
    border: none;
    color: rgba(255,255,255,0.6);
    cursor: pointer;
    padding: 12px 18px;
    z-index: 10000;

    text-shadow:
        0 0 12px rgba(var(--accent-rgb),0.45),
        0 0 32px rgba(var(--accent-rgb),0.25);
}

.ccg-modal-nav:hover {
    color: #fff;
}

.ccg-modal-nav--prev { left: 18px; }
.ccg-modal-nav--next { right: 18px; }

@media (max-width: 768px) {
    .ccg-modal-nav {
        font-size: 2.2rem;
    }

    /* Mobile doc modal centring fix */
    .ccg-modal--doc.open,
    .ccg-modal--doc.active {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .ccg-modal--doc .ccg-modal-content {
        position: relative;
        top: auto;
        left: auto;
        transform: none;
        margin: auto;
        width: calc(100vw - 18px);
        min-height: min(68vh, 560px);
        height: min(85vh, 820px);
    height: min(85dvh, 820px);
        max-height: calc(100vh - 18px);
        max-height: calc(100dvh - 18px);
        padding: 12px;
    }

    @supports (height: 1dvh) {
        .ccg-modal--doc .ccg-modal-content {
            top: 50dvh;
            min-height: min(68dvh, 560px);
            height: min(85dvh, 820px);
            max-height: 85dvh;
            padding-top: calc(12px + env(safe-area-inset-top));
            padding-bottom: calc(12px + env(safe-area-inset-bottom));
        }
    }

    .ccg-modal {
        padding: 8px;
    }

    .ccg-modal--doc .ccg-pdf-frame {
        width: 100%;
        height: 100%;
    }

    .ccg-modal-close {
        top: 10px;
        right: 12px;
    }
}


@supports (-webkit-touch-callout: none) {
    body.modal-open {
        position: fixed;
        width: 100%;
    }
}
