/* Basic popup overlay and content */
.popup-overlay {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.75);
    z-index: 9999;
    
    /* 1. ENABLE FLEXBOX CENTERING */
    display: flex; 
    justify-content: center;
    align-items: center;
    
    /* Allow scrolling on the overlay if the content overflows the screen */
    overflow-y: auto; 
    padding: 100px 20px; /* Forces at least 100px gap at the top/bottom when content is tall */
    box-sizing: border-box;
}

.popup-content-wrap {
    display: flex; 
    margin-left: auto;
    margin-right: auto;
    max-width: 640px;
    width: 100%; /* Ensures it stretches to max-width beautifully */
    height: auto;
    justify-content: center; 
    align-items: center; 
    
    /* 2. ADD THE ENTRANCE ANIMATION */
    animation: modalFadeUp 0.4s ease-out forwards;
}

.popup-content {
    background: white;
    padding: 3rem 2rem 3rem 2rem;
    border-radius: 0;
    /* Changed to max-height logic so the modal behaves nicely within the viewport */
    max-height: calc(100vh - 200px); 
    overflow-y: auto;
    position: relative;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
    width: 100%;
}

/* 3. KEYFRAMES FOR THE SLIDE UP & FADE IN */
@keyframes modalFadeUp {
    from {
        opacity: 0;
        transform: translateY(30px); /* Starts 30px lower */
    }
    to {
        opacity: 1;
        transform: translateY(0); /* Slides up to its natural position */
    }
}

.popup-close {
    position: absolute;
    top: .5rem;
    right: .5rem;
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: #666;
    line-height: 1;
    width: 48px;
    height: 48px;
}

.popup-close:hover {
    color: #000;
}

.popup-content h2 {
    font-size: 2.5rem;
    color: #53aae5;
	margin: 1rem 0 2rem 0;
}

.popup-content p {
    font-size: 1rem;
    margin: 1rem 0 1rem 0;
    line-height: 1.5;
    color: #181746; /* Fixed double declaration and quotes typo */
}

.popup-link {
    display: inline-block;
    background: #53aae5;
    color: white !important;
    padding: 0.75rem 1.5rem;
    text-decoration: none;
    border-radius: 4px;
    float: right;
    margin-top: 1rem;
    transition: background 0.3s ease, transform 0.2s ease-in-out; 
}

/* FIX 2: Added :focus-visible for excellent keyboard accessibility */
.popup-link:hover,
.popup-link:focus-visible {
    transform: scale(1.05);
    background: #4298d2; /* Optional: slightly darker blue on hover/focus for better UX */
}

/* Ensure clicking doesn't break the scale transform scale unexpectedly */
.popup-link:active {
    transform: scale(0.98); /* Optional: slight shrink on click for a tactile button feel */
}


/* Responsive tweaks */
@media (max-width: 600px) {
    .popup-overlay {
        padding: 40px 10px; /* Tighter margins on small mobile screens */
    }
    .popup-content {
        margin: 0;
        padding: 2rem 1.5rem 2rem 1.5rem;
        max-height: calc(100vh - 80px);
    }
}

/* Focus styles for accessibility */
.popup-overlay:focus-within .popup-content,
.popup-close:focus,
.popup-link:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

.popup-content h2:focus {
    outline: none;
}