/**
 * WP Modals - Frontend Styles
 *
 * Modal container, overlay, animations, and responsive design
 */

/* ===========================
   Modal Base Styles
   =========================== */

.wp-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    padding: 20px;
}

.wp-modal--active {
    opacity: 1;
    visibility: visible;
}

/* ===========================
   Modal Overlay
   =========================== */

.wp-modal__overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    cursor: pointer;
}

/* ===========================
   Modal Container
   =========================== */

.wp-modal__container {
    position: relative;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    max-width: 90%;
    max-height: 90vh;
    width: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: scale(0.9);
    transition: transform 0.3s ease;
    z-index: 1;
}

.wp-modal--active .wp-modal__container {
    transform: scale(1);
}

/* Modal Width Sizes */
.wp-modal__container--small {
    max-width: 400px;
}

.wp-modal__container--medium {
    max-width: 600px;
}

.wp-modal__container--large {
    max-width: 800px;
}

.wp-modal__container--full {
    max-width: 95%;
    max-height: 95vh;
}

/* ===========================
   Modal Header
   =========================== */

.wp-modal__header {
    position: relative;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

.wp-modal__close {
    background: none;
    border: none;
    font-size: 32px;
    line-height: 1;
    color: #666;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
    border-radius: 4px;
}

.wp-modal__close:hover,
.wp-modal__close:focus {
    color: #000;
    background-color: #f0f0f0;
    outline: none;
}

/* ===========================
   Modal Content
   =========================== */

.wp-modal__content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.wp-modal__title {
    margin: 0;
    padding: 0;
}

.wp-modal__body {
    padding: 30px;
}

/* WordPress Block Editor Content Spacing */
.wp-modal__body > *:first-child {
    margin-top: 0;
}

.wp-modal__body > *:last-child {
    margin-bottom: 0;
}

/* ===========================
   Accessibility
   =========================== */

/* Screen reader only text */
.screen-reader-text {
    border: 0;
    clip: rect(1px, 1px, 1px, 1px);
    clip-path: inset(50%);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    width: 1px;
    word-wrap: normal !important;
}

/* Focus styles */
.wp-modal__close:focus {
    outline: 2px solid #2271b1;
    outline-offset: 2px;
}

/* ===========================
   Responsive Design
   =========================== */

@media (max-width: 768px) {
    .wp-modal {
        padding: 10px;
    }

    .wp-modal__container {
        max-width: 100%;
        max-height: 95vh;
    }

    .wp-modal__container--small,
    .wp-modal__container--medium,
    .wp-modal__container--large {
        max-width: 100%;
    }

    .wp-modal__header {
        padding: 12px 15px;
    }

    .wp-modal__body {
        padding: 20px 15px;
    }

    .wp-modal__close {
        font-size: 28px;
        width: 28px;
        height: 28px;
    }
}

@media (max-width: 480px) {
    .wp-modal__body {
        padding: 15px;
    }
}

/* ===========================
   WordPress Block Compatibility
   =========================== */

/* Ensure WordPress blocks display correctly in modals */
.wp-modal__body .wp-block-image {
    margin-bottom: 1em;
}

.wp-modal__body .wp-block-button {
    margin-bottom: 1em;
}

.wp-modal__body .wp-block-buttons {
    margin-bottom: 1em;
}

/* Responsive embeds */
.wp-modal__body .wp-block-embed {
    margin-bottom: 1em;
}

.wp-modal__body .wp-block-embed__wrapper {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    height: 0;
    overflow: hidden;
}

.wp-modal__body .wp-block-embed__wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* ===========================
   Print Styles
   =========================== */

@media print {
    .wp-modal {
        display: none !important;
    }
}
