/* Soul Scrolls Modal - Clean MLNF Design System */

/* ===== MODAL FOUNDATION ===== */
#blogModal.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal);
    padding: 1rem;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

#blogModal.modal.show {
    display: flex;
    opacity: 1;
}

/* ===== MODAL CONTENT CONTAINER ===== */
.blog-modal-content {
    background: linear-gradient(135deg, 
        rgba(26, 26, 51, 0.98), 
        rgba(42, 64, 102, 0.95)
    );
    border: 2px solid rgba(255, 94, 120, 0.4);
    border-radius: 20px;
    padding: 0;
    max-width: min(900px, 95vw);
    max-height: min(85vh, 900px);
    width: 100%;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
    box-shadow: 
        0 25px 50px rgba(0, 0, 0, 0.8),
        0 15px 35px rgba(255, 94, 120, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    transform: scale(0.9) translateY(20px);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Mystical border glow */
    &::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        border-radius: inherit;
        padding: 2px;
        background: linear-gradient(45deg, 
            rgba(255, 94, 120, 0.8), 
            rgba(255, 202, 40, 0.6),
            rgba(255, 94, 120, 0.8)
        );
        mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
        mask-composite: exclude;
        opacity: 0.7;
        animation: modalGlow 3s ease-in-out infinite alternate;
    }
}

#blogModal.modal.show .blog-modal-content {
    transform: scale(1) translateY(0);
}

@keyframes modalGlow {
    0% { opacity: 0.4; }
    100% { opacity: 0.8; }
}

/* ===== MODAL HEADER ===== */
.modal-header-controls {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: var(--z-modal-controls);
}

.close-modal {
    background: rgba(255, 94, 120, 0.2);
    border: 2px solid rgba(255, 94, 120, 0.4);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
}

.close-modal:hover {
    background: rgba(255, 94, 120, 0.4);
    border-color: rgba(255, 94, 120, 0.8);
    transform: scale(1.1);
    box-shadow: 0 0 20px rgba(255, 94, 120, 0.5);
}

/* ===== MODAL BODY ===== */
.modal-body {
    padding: 2rem;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: smooth;
    position: relative;
    min-height: 0; /* Important for flexbox scrolling */
}

/* Custom scrollbar for modal body */
.modal-body::-webkit-scrollbar {
    width: 8px;
}

.modal-body::-webkit-scrollbar-track {
    background: rgba(26, 26, 51, 0.5);
    border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, 
        rgba(255, 94, 120, 0.6), 
        rgba(255, 202, 40, 0.6)
    );
    border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, 
        rgba(255, 94, 120, 0.8), 
        rgba(255, 202, 40, 0.8)
    );
}

/* ===== BODY SCROLL LOCK ===== */
body.modal-open {
    overflow: hidden !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
}

/* ===== MODAL LOADING STATE ===== */
.modal-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    color: rgba(255, 255, 255, 0.8);
    font-size: 1.1rem;
}

.modal-spinner .relic-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(255, 94, 120, 0.3);
    border-top: 3px solid rgba(255, 94, 120, 0.9);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===== BLOG MODAL HEADER ===== */
.blog-modal-header {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 2px solid rgba(255, 94, 120, 0.3);
    position: relative;
}

.modal-author-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

/* ===== MODAL TITLE ===== */
#modal-title {
    color: rgba(255, 255, 255, 0.95);
    font-family: 'Cinzel', serif;
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    font-weight: 700;
    margin: 0 0 1.5rem 0;
    line-height: 1.3;
    text-align: center;
    background: linear-gradient(135deg, 
        rgba(255, 94, 120, 0.9), 
        rgba(255, 202, 40, 0.8)
    );
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* ===== MODAL CONTENT ===== */
#modal-content {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.1rem;
    line-height: 1.7;
    margin-bottom: 2rem;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

#modal-content p {
    margin-bottom: 1.2rem;
}

#modal-content h1, #modal-content h2, #modal-content h3 {
    color: rgba(255, 94, 120, 0.9);
    font-family: 'Cinzel', serif;
    margin: 1.5rem 0 1rem 0;
}

#modal-content img {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* ===== MODAL ACTIONS ===== */
.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(255, 94, 120, 0.2);
    flex-wrap: wrap;
}

.modal-actions button {
    background: linear-gradient(135deg, 
        rgba(255, 94, 120, 0.8), 
        rgba(255, 202, 40, 0.7)
    );
    color: rgba(26, 26, 51, 0.95);
    border: 1px solid rgba(255, 94, 120, 0.4);
    border-radius: 12px;
    padding: 0.75rem 1.5rem;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: 'Cinzel', serif;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 44px;
    text-decoration: none;
}

.modal-actions button:hover {
    background: linear-gradient(135deg, 
        rgba(255, 94, 120, 0.9), 
        rgba(255, 202, 40, 0.8)
    );
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 6px 20px rgba(255, 94, 120, 0.4);
}

.modal-actions button:focus {
    outline: 3px solid rgba(255, 94, 120, 0.6);
    outline-offset: 2px;
}

/* ===== COMMENTS SECTION ===== */
.blog-comments {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 2px solid rgba(255, 94, 120, 0.3);
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
    #blogModal.modal {
        padding: 0.5rem;
    }
    
    .blog-modal-content {
        max-height: 95vh;
        border-radius: 16px;
    }
    
    .modal-body {
        padding: 1.5rem;
    }
    
    #modal-title {
        font-size: clamp(1.3rem, 5vw, 2rem);
    }
    
    .modal-actions {
        flex-direction: column;
        align-items: stretch;
    }
    
    .modal-actions button {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .modal-body {
        padding: 1rem;
    }
    
    .close-modal {
        width: 36px;
        height: 36px;
        font-size: 1.2rem;
    }
}

/* ===== ACCESSIBILITY ===== */
@media (prefers-reduced-motion: reduce) {
    #blogModal.modal,
    .blog-modal-content,
    .close-modal,
    .modal-actions button {
        transition: none;
        animation: none;
    }
    
    .blog-modal-content::before {
        animation: none;
    }
}

@media (prefers-contrast: high) {
    .blog-modal-content {
        border-width: 3px;
        border-color: rgba(255, 94, 120, 0.8);
    }
    
    #modal-title,
    #modal-content {
        color: rgba(255, 255, 255, 1);
    }
}

/* ===== FOCUS MANAGEMENT ===== */
#blogModal.modal:focus-within {
    outline: none;
}

.modal-body:focus {
    outline: 2px solid rgba(255, 94, 120, 0.6);
    outline-offset: 2px;
}

/* ===== DARK MODE SUPPORT ===== */
@media (prefers-color-scheme: dark) {
    .blog-modal-content {
        background: linear-gradient(135deg, 
            rgba(13, 13, 26, 0.98), 
            rgba(21, 32, 51, 0.95)
        );
    }
}