/* =========================
   Phantom Module Lightbox
   ========================= */


/* Lightbox Container */
.phantom-lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    animation: fadeIn 0.3s ease-out;
}

.phantom-lightbox.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Overlay Background */
.lightbox-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    /* Removed cursor pointer - no clicking to close */
    animation: fadeIn 0.3s ease-out;
    /* Prevent touch events from closing */
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* Lightbox Content Container */
.lightbox-content {
    position: relative;
    width: 90%;
    max-width: 900px;
    max-height: 90vh;
    background: var(--bg-primary);
    border: 1px solid var(--green-primary);
    border-radius: 16px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5),
                0 0 100px rgba(74, 222, 128, 0.1);
    animation: slideUp 0.4s ease-out;
    overflow: hidden;
}

/* Close Button */
.lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background: rgba(74, 222, 128, 0.1);
    border: 1px solid var(--green-primary);
    border-radius: 50%;
    cursor: pointer;
    transition: all var(--transition-fast);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-close span {
    font-size: 28px;
    color: var(--green-primary);
    font-weight: 200;
    line-height: 1;
}

.lightbox-close:hover {
    background: var(--green-primary);
    transform: rotate(90deg);
}

.lightbox-close:hover span {
    color: var(--bg-primary);
}

/* Lightbox Inner Content */
.lightbox-inner {
    width: 100%;
    height: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 40px;
    box-sizing: border-box;
}

/* Custom Scrollbar */
.lightbox-inner::-webkit-scrollbar {
    width: 8px;
}

.lightbox-inner::-webkit-scrollbar-track {
    background: rgba(74, 222, 128, 0.05);
    border-radius: 4px;
}

.lightbox-inner::-webkit-scrollbar-thumb {
    background: var(--green-dark);
    border-radius: 4px;
}

.lightbox-inner::-webkit-scrollbar-thumb:hover {
    background: var(--green-primary);
}

/* Module Detail Styles */
.module-detail {
    animation: contentFadeIn 0.5s ease-out;
}

.module-header {
    text-align: center;
    margin-bottom: 40px;
    padding-bottom: 30px;
    border-bottom: 1px solid rgba(74, 222, 128, 0.2);
}

.module-title {
    font-family: var(--font-mono), monospace;
    font-size: 28px;
    color: var(--green-primary);
    margin: 0 0 12px 0;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.module-subtitle {
    font-size: 15px;
    color: var(--text-secondary);
    margin: 0;
    font-weight: 400;
    letter-spacing: 1px;
}

/* Module Body */
.module-body {
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* Diagram Container */
.module-diagram-container {
    background: rgba(15, 23, 42, 0.6);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid rgba(74, 222, 128, 0.1);
    position: relative;
    min-height: 200px;
}

/* Diagram Loading State */
.module-diagram-container.diagram-loading::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.95);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.module-diagram-container.diagram-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 3px solid rgba(74, 222, 128, 0.2);
    border-top-color: var(--green-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 11;
}

.module-diagram {
    width: 100%;
    height: auto;
    max-height: 200px;
    object-fit: contain;
    filter: brightness(0.95);
    transition: opacity 0.3s ease;
}

.module-diagram-container.diagram-loading .module-diagram {
    opacity: 0.3;
}

/* Module Description Container */
.module-description-container {
    background: rgba(74, 222, 128, 0.03);
    border: 1px solid rgba(74, 222, 128, 0.2);
    border-radius: 12px;
    padding: 25px;
    margin-top: 20px;
}

.module-description-container p {
    font-family: var(--font-mono), monospace;
    font-size: 13px;
    color: var(--text-primary);
    line-height: 1.8;
    margin: 0 0 15px 0;
    text-align: justify;
}

.module-description-container p:last-child {
    margin-bottom: 0;
}

/* Info Grid */
.module-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 30px;
}

.info-section {
    background: rgba(74, 222, 128, 0.03);
    border-left: 3px solid var(--green-primary);
    padding: 20px;
    border-radius: 4px;
}

.info-section h3 {
    font-family: var(--font-mono), monospace;
    font-size: 14px;
    color: var(--green-primary);
    margin: 0 0 15px 0;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.info-section p {
    font-size: 14px;
    color: var(--text-primary);
    line-height: 1.6;
    margin: 0;
}

/* Feature List */
.feature-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.feature-list li {
    font-size: 14px;
    color: var(--text-primary);
    padding: 8px 0;
    border-bottom: 1px solid rgba(74, 222, 128, 0.1);
}

.feature-list li:last-child {
    border-bottom: none;
}

/* Code Block */
.code-block {
    position: relative;
    background: var(--bg-primary);
    border: 1px solid var(--green-dark);
    border-radius: 6px;
    padding: 12px 50px 12px 15px;
    margin-top: 10px;
}

.code-block code {
    font-family: var(--font-mono), monospace;
    font-size: 13px;
    color: var(--green-secondary);
    white-space: nowrap;
    overflow-x: auto;
    display: block;
}

.copy-code {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--green-dark);
    border: none;
    color: var(--green-primary);
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-family: var(--font-mono), monospace;
    font-size: 11px;
    text-transform: uppercase;
    transition: all var(--transition-fast);
}

.copy-code:hover {
    background: var(--green-primary);
    color: var(--bg-primary);
}

.copy-code.copied {
    background: var(--green-primary);
    color: var(--bg-primary);
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes contentFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

/* Responsive - Tablet */
@media (max-width: 768px) {
    .lightbox-content {
        width: 95%;
        max-height: 95vh;
        border-radius: 12px;
    }

    .lightbox-inner {
        padding: 30px 20px;
    }

    .lightbox-close {
        top: 15px;
        right: 15px;
        width: 36px;
        height: 36px;
    }

    .module-icon-large {
        font-size: 48px;
    }

    .module-title {
        font-size: 24px;
    }

    .module-subtitle {
        font-size: 14px;
    }

    .module-info-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .info-section {
        padding: 15px;
    }
}

/* Responsive - Mobile */
@media (max-width: 480px) {
    /* Full viewport coverage on mobile */
    .phantom-lightbox {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100vw;
        height: 100vh; /* Fallback for older browsers */
    }

    /* Modern browsers with dynamic viewport height support */
    @supports (height: 100dvh) {
        .phantom-lightbox {
            height: 100dvh; /* Dynamic viewport height for mobile browsers */
        }
    }

    .lightbox-content {
        width: 100%;
        height: 100%;
        max-height: 100vh; /* Fallback for older browsers */
        border-radius: 0;
        border: none;
    }

    /* Modern browsers with dynamic viewport height support */
    @supports (max-height: 100dvh) {
        .lightbox-content {
            max-height: 100dvh;
        }
    }

    .lightbox-inner {
        padding: 60px 20px 20px 20px;
        max-height: 100vh;
    }

    .lightbox-close {
        top: 10px;
        right: 10px;
        width: 32px;
        height: 32px;
        background: var(--bg-primary);
    }

    .lightbox-close span {
        font-size: 24px;
    }

    .module-header {
        margin-bottom: 30px;
        padding-bottom: 20px;
    }

    .module-icon-large {
        font-size: 40px;
        margin-bottom: 15px;
    }

    .module-title {
        font-size: 20px;
    }

    .module-subtitle {
        font-size: 13px;
    }

    .module-body {
        gap: 0;
    }

    .module-diagram-container {
        padding: 15px;
    }

    .module-diagram {
        max-height: 585px;
        height: auto;
        width: 100%;
    }

    .info-section {
        padding: 12px;
    }

    .info-section h3 {
        font-size: 13px;
        margin-bottom: 10px;
    }

    .info-section p,
    .feature-list li {
        font-size: 13px;
    }

    .code-block {
        padding: 10px 45px 10px 12px;
    }

    .code-block code {
        font-size: 11px;
    }

    .copy-code {
        padding: 5px 8px;
        font-size: 10px;
    }
}

/* Prevent body scroll when lightbox is open */
body.lightbox-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
}

/* Loading state */
.lightbox-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 400px;
}

.lightbox-loading::after {
    content: '';
    width: 40px;
    height: 40px;
    border: 3px solid rgba(74, 222, 128, 0.2);
    border-top-color: var(--green-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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