/* =========================================
   BYMTEL POPUP STYLES
   Aligned with bymtel-modern theme design system.
   ========================================= */

/* =========================================
   BODY BLUR EFFECT FOR ACTIVE POPUP
   ========================================= */
body.popup-active .wp-site-blocks {
    filter: blur(6px);
    transition: filter 0.3s ease;
}

body.popup-active::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: color-mix(in srgb, var(--wp--preset--color--on-surface, #121211), transparent 40%); /* Onyx overlay using theme var if available, else fallback */
    z-index: 9990; /* Below popup overlay */
    pointer-events: none;
}

/* =========================================
   POPUP OVERLAY
   ========================================= */
.bymtel-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* Background handled by body::before for blur effect */
    background: transparent; 
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.bymtel-popup-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* =========================================
   POPUP CONTENT (Card)
   ========================================= */
.bymtel-popup-content {
    background-color: var(--wp--preset--color--surface, #FFFFFF);
    border: 1px solid color-mix(in srgb, var(--wp--preset--color--text), transparent 92%);
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px color-mix(in srgb, var(--wp--preset--color--text), transparent 75%); /* Elevated shadow */
    padding: 2rem 2.5rem;
    width: 90%;
    max-width: 480px;
    position: relative;
    transform: translateY(20px) scale(0.96);
    opacity: 0;
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
}

.bymtel-popup-overlay.active .bymtel-popup-content {
    transform: translateY(0) scale(1);
    opacity: 1;
}

/* Shake Animation for Errors */
.bymtel-popup-content.shake {
    animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both;
}

/* =========================================
   CLOSE BUTTON
   ========================================= */
.bymtel-popup-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    width: 44px;  /* WCAG 2.5.5: Minimum touch target */
    height: 44px; /* WCAG 2.5.5: Minimum touch target */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    color: var(--wp--preset--color--heading, #121211);
    background: color-mix(in srgb, var(--wp--preset--color--text), transparent 97%);
    border: none;
    border-radius: 50%;
    transition: background 0.2s ease, transform 0.2s ease;
}

.bymtel-popup-close:hover,
.bymtel-popup-close:focus {
    background: color-mix(in srgb, var(--wp--preset--color--text), transparent 92%);
    transform: rotate(90deg);
}

/* =========================================
   TITLE (ORBITRON - Theme Heading Style)
   ========================================= */
.bymtel-popup-title {
    font-family: var(--wp--preset--font-family--orbitron, 'Orbitron', sans-serif);
    font-weight: 700;
    font-size: 1.35rem;
    line-height: 1.2;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--wp--preset--color--heading, #121211);
    margin-bottom: 0.5rem;
    text-align: center;
}

.bymtel-popup-subtitle {
    font-family: var(--wp--preset--font-family--primary, 'Inter', sans-serif);
    font-size: 0.95rem;
    color: var(--wp--preset--color--text, #121211);
    opacity: 0.75;
    margin-bottom: 1.5rem;
    text-align: center;
    line-height: 1.5;
}

/* =========================================
   FORM CONTROLS
   ========================================= */
.bymtel-form-group {
    margin-bottom: 1rem;
    text-align: left;
}

.bymtel-form-group label {
    display: block;
    margin-bottom: 0.4rem;
    font-family: var(--wp--preset--font-family--primary, 'Inter', sans-serif);
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--wp--preset--color--heading, #121211);
}

.bymtel-form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 8px;
    background: var(--wp--preset--color--base, #F6F1F1);
    font-family: var(--wp--preset--font-family--primary, 'Inter', sans-serif);
    font-size: 1rem;
    color: var(--wp--preset--color--text, #121211);
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.bymtel-form-control::placeholder {
    color: rgba(0, 0, 0, 0.4);
}

.bymtel-form-control:focus {
    outline: none;
    border-color: var(--wp--preset--color--primary, #41BAC8);
    box-shadow: 0 0 0 3px rgba(65, 186, 200, 0.15);
}

/* =========================================
   SUBMIT BUTTON (Theme Button Style)
   ========================================= */
.bymtel-btn {
    width: 100%;
    padding: 0.85rem 1.5rem;
    border: none;
    border-radius: 50px; /* Pill shape like nav CTA */
    background: linear-gradient(135deg, var(--wp--preset--color--primary, #41BAC8) 0%, var(--wp--preset--color--primary-dark, #213667) 100%);
    color: #FFFFFF;
    font-family: var(--wp--preset--font-family--primary, 'Inter', sans-serif);
    font-size: 1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s ease, filter 0.2s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    margin-top: 0.5rem;
}

.bymtel-btn:hover,
.bymtel-btn:focus {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.18);
    filter: brightness(1.08);
    outline: none;
}

.bymtel-btn:focus-visible {
    box-shadow: 0 0 0 3px rgba(65, 186, 200, 0.5), 0 6px 12px rgba(0, 0, 0, 0.18);
}

.bymtel-btn:active {
    transform: translateY(0) scale(0.98);
}

.bymtel-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* =========================================
   MESSAGES
   ========================================= */
.bymtel-popup-message {
    margin-top: 1rem;
    font-size: 0.9rem;
    text-align: center;
    display: none;
    padding: 0.5rem;
    border-radius: 6px;
}

.bymtel-popup-message.success {
    display: block;
    color: #166534;
    background-color: rgba(22, 163, 74, 0.1);
}

.bymtel-popup-message.error {
    display: block;
    color: #991b1b;
    background-color: rgba(220, 38, 38, 0.1);
}

/* =========================================
   REQUIRED INDICATOR
   ========================================= */
.required-star {
    color: var(--wp--preset--color--primary, #41BAC8);
    font-weight: bold;
}

/* =========================================
   SUCCESS ANIMATION
   ========================================= */
.bymtel-popup-success-view {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem 0;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.bymtel-popup-success-view.active {
    display: flex;
    opacity: 1;
}

/* Checkmark Animation */
.success-checkmark {
    width: 80px;
    height: 80px;
    margin-bottom: 1.5rem;
}

.check-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: block;
    stroke-width: 2;
    stroke: #fff;
    stroke-miterlimit: 10;
    box-shadow: inset 0px 0px 0px #4bb71b;
    animation: fill .4s ease-in-out .4s forwards, scale .3s ease-in-out .9s both;
}

.check-circle {
    stroke-dasharray: 166;
    stroke-dashoffset: 166;
    stroke-width: 2;
    stroke-miterlimit: 10;
    stroke: #4bb71b;
    fill: none;
    animation: stroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}

.check-check {
    transform-origin: 50% 50%;
    stroke-dasharray: 48;
    stroke-dashoffset: 48;
    animation: stroke 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.8s forwards;
}

@keyframes stroke {
    100% { stroke-dashoffset: 0; }
}

@keyframes scale {
    0%, 100% { transform: none; }
    50% { transform: scale3d(1.1, 1.1, 1); }
}

@keyframes fill {
    100% { box-shadow: inset 0px 0px 0px 50px #4bb71b; }
}

/* Hide form smoothly */
.bymtel-popup-content form {
    transition: opacity 0.3s ease;
}

/* =========================================
   MOBILE RESPONSIVE
   ========================================= */
@media (max-width: 600px) {
    .bymtel-popup-content {
        padding: 1.75rem 1.5rem;
        width: 94%;
        max-width: none;
    }
    
    .bymtel-popup-title {
        font-size: 1.15rem;
    }

    .bymtel-popup-subtitle {
        font-size: 0.9rem;
    }
}

/* =========================================
   DARK MODE SUPPORT
   ========================================= */
@media (prefers-color-scheme: dark) {
    body.popup-active::before {
        background: rgba(0, 0, 0, 0.75);
    }

    .bymtel-popup-content {
        background-color: #1E1E1E;
        border-color: rgba(255, 255, 255, 0.1);
    }

    .bymtel-popup-title,
    .bymtel-form-group label {
        color: #FFFFFF;
    }

    .bymtel-popup-subtitle {
        color: #E0E0E0;
    }

    .bymtel-form-control {
        background-color: #2A2A2A;
        border-color: rgba(255, 255, 255, 0.15);
        color: #FFFFFF;
    }

    .bymtel-form-control::placeholder {
        color: rgba(255, 255, 255, 0.4);
    }

    .bymtel-popup-close {
        color: #FFFFFF;
        background: rgba(255, 255, 255, 0.08);
    }

    .bymtel-popup-close:hover,
    .bymtel-popup-close:focus {
        background: rgba(255, 255, 255, 0.15);
    }
}

/* =========================================
   ACCESSIBILITY: REDUCED MOTION SUPPORT
   ========================================= */
@media (prefers-reduced-motion: reduce) {
    body.popup-active .wp-site-blocks {
        filter: none; /* Remove blur effect */
        transition: none;
    }
    
    .bymtel-popup-overlay,
    .bymtel-popup-content,
    .bymtel-popup-close,
    .bymtel-btn,
    .bymtel-form-control,
    .check-icon,
    .check-circle,
    .check-check {
        animation: none !important;
        transition: none !important;
    }
    
    /* Show popups instantly without transform animations */
    .bymtel-popup-overlay.active .bymtel-popup-content {
        transform: none;
    }
    
    .bymtel-popup-close:hover {
        transform: none;
    }
}
