/**
 * Public styles for the Info Modal plugin
 */

/* Modal overlay */
.info-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 999999;
    display: none; /* Keep as none - controlled by JavaScript */
    justify-content: center;
    align-items: center;
    overflow: auto;
    padding: 20px;
    box-sizing: border-box;
}

/* When modal is shown */
.info-modal-overlay.visible {
    display: flex;
}

/* Modal container */
.info-modal {
    width: 80%;
    max-width: 800px; /* Better width for landscape */
    margin: 0 auto;
    position: relative;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    border-radius: 5px;
    overflow: hidden;
    left: 0;
    right: 0;
    margin-left: auto;
    margin-right: auto;
}

/* Aspect ratio containers */
.info-modal-inner {
    position: relative;
    background-size: cover;
    background-position: center;
    background-color: #f0f0f0;
    z-index: 1; /* Lower z-index for background */
}

/* Aspect ratios for DESKTOP only */
@media (min-width: 1025px) {
    /* Limit modal width on desktop for better aspect ratios */
    .info-modal {
        max-width: 60% !important;
    }
    
    /* Auto aspect ratio - uses image natural dimensions */
    .aspect-ratio-auto {
        height: auto !important;
        padding-bottom: 0 !important;
    }
    
    .aspect-ratio-auto .info-modal-content {
        position: relative !important;
        height: auto !important;
    }
    
    .aspect-ratio-16-9 {
        padding-bottom: 56.25% !important; /* 9/16 = 0.5625 = 56.25% */
        height: 0 !important;
        overflow: hidden !important;
    }

    .aspect-ratio-4-3 {
        padding-bottom: 75% !important; /* 3/4 = 0.75 = 75% */
        height: 0 !important;
        overflow: hidden !important;
    }
    
    .aspect-ratio-3-4 {
        padding-bottom: 133.33% !important; /* 4/3 = 1.3333 = 133.33% */
        height: 0 !important;
        overflow: hidden !important;
    }

    .aspect-ratio-1-1 {
        padding-bottom: 100% !important; /* 1/1 = 1 = 100% */
        height: 0 !important;
        overflow: hidden !important;
    }

    .aspect-ratio-4-5 {
        padding-bottom: 125% !important; /* 5/4 = 1.25 = 125% */
        height: 0 !important;
        overflow: hidden !important;
    }

    .aspect-ratio-9-16 {
        padding-bottom: 177.78% !important; /* 16/9 = 1.7778 = 177.78% */
        height: 0 !important;
        overflow: hidden !important;
    }
    
    /* Content positioned absolutely on desktop for fixed ratios */
    .info-modal-content {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100% !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
    }
}

/* For vertical formats, adjust the modal width and add max-height */
.info-modal:has(.aspect-ratio-9-16),
.info-modal:has(.aspect-ratio-4-5),
.info-modal:has(.aspect-ratio-3-4) {
    width: 40% !important;
    max-width: 500px !important;
}

/* Auto aspect ratio modal adjusts based on image */
.info-modal:has(.aspect-ratio-auto) {
    width: auto !important;
    max-width: 90% !important;
    max-height: 90vh !important;
}

/* Modal content - default styles */
.info-modal-content {
    box-sizing: border-box !important;
    padding: 20px !important;
    z-index: 2 !important;
}

/* Text container to center content */
.info-modal-text-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

/* Close button */
.info-modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    background-color: transparent;
    border: none;
    color: #333;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    z-index: 10;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    margin: 0;
}

.info-modal-close:hover {
    color: #000;
}

/* Modal heading */
.info-modal-heading {
    margin-top: 0;
    margin-bottom: 20px;
    width: 100%;
    text-align: center;
    line-height: 1.4;
    font-family: inherit;
    position: relative;
    z-index: 15; /* Higher z-index than the content container */
}

h1.info-modal-heading {
    font-size: 48px;
    font-family: Lobster;
}

h2.info-modal-heading {
    font-size: 36px;
    font-family: Permanent Marker;
}

h3.info-modal-heading {
    font-size: 32px;
    font-family: inherit;
}

h4.info-modal-heading {
    font-size: 28px;
    font-family: inherit;
}

h5.info-modal-heading {
    font-size: 24px;
    font-family: inherit;
}

/* Modal body */
.info-modal-body {
    max-width: 80%;
    overflow: auto;
    max-height: 70vh;
    font-size: 16px;
    line-height: 1.5;
    width: 100%;
    font-family: Permanent Marker;
    position: relative;
    z-index: 15; /* Higher z-index than the content container */
}

.info-modal-body p {
    margin-bottom: 15px;
    font-size: 16px;
    line-height: 1.5;
    font-family: inherit;
}

.info-modal-body ul,
.info-modal-body ol {
    display: inline-block;
    text-align: left;
    margin-left: 0;
    margin-bottom: 15px;
    padding-left: 20px;
    font-size: 16px;
    line-height: 1.5;
    font-family: inherit;
}

.info-modal-body img {
    max-width: 100%;
    height: auto;
}

/* WordPress image alignment classes */
.info-modal-body .alignleft,
.info-modal-body img.alignleft,
.info-modal-body figure.alignleft {
    float: left;
    margin: 5px 20px 15px 0;
    max-width: 50%;
}

.info-modal-body .alignright,
.info-modal-body img.alignright,
.info-modal-body figure.alignright {
    float: right;
    margin: 5px 0 15px 20px;
    max-width: 50%;
}

.info-modal-body .aligncenter,
.info-modal-body img.aligncenter,
.info-modal-body figure.aligncenter {
    display: block;
    margin: 10px auto 15px auto;
    clear: both;
    float: none;
}

.info-modal-body .alignnone {
    margin: 5px 0;
}

/* WordPress figure elements */
.info-modal-body figure {
    margin: 0;
    padding: 0;
}

.info-modal-body figure img {
    display: block;
    width: 100%;
    height: auto;
}

.info-modal-body figcaption {
    font-size: 0.9em;
    font-style: italic;
    margin-top: 5px;
    text-align: center;
}

/* Clear floats after images */
.info-modal-body::after {
    content: "";
    display: table;
    clear: both;
}

/* Allow paragraphs to flow around floated images */
.info-modal-body p {
    overflow: visible;
    clear: none;
}

/* Ensure all elements inside the modal body inherit colors and fonts */
.info-modal-body * {
    color: inherit;
    font-family: inherit;
}

/* Preserve color inheritance but allow font inheritance from theme */
.info-modal-body a {
    text-shadow: none !important;
    text-decoration: underline;
}

/* Ensure paragraphs and other elements inside the modal body inherit the color */
.info-modal-body p,
.info-modal-body div,
.info-modal-body span,
.info-modal-body li,
.info-modal-body h1,
.info-modal-body h2,
.info-modal-body h3,
.info-modal-body h4,
.info-modal-body h5,
.info-modal-body h6 {
    color: inherit;
}

/* Make sure lists display correctly */
.info-modal-body ul, 
.info-modal-body ol {
    text-align: left;
    margin-left: 20px;
    margin-right: 20px;
    padding-left: 20px;
}

.info-modal-body li {
    margin-bottom: 5px;
    list-style-position: outside;
    display: list-item;
}

.info-modal-body ul li {
    list-style-type: disc;
}

.info-modal-body ol li {
    list-style-type: decimal;
}

/* Ensure all elements inside the modal body inherit fonts */
.info-modal-content *,
.info-modal-heading,
.info-modal-body,
.info-modal-body p,
.info-modal-body ul,
.info-modal-body ol,
.info-modal-body li,
.info-modal-body div,
.info-modal-body span {
    font-family: inherit !important;
}

/* Explicit font-sizes for headings */
.info-modal-body h1 {
    font-size: 36px !important;
    font-weight: 700 !important;
    line-height: 1.2 !important;
}

.info-modal-body h2 {
    font-size: 30px !important;
    font-weight: 700 !important;
    line-height: 1.2 !important;
}

.info-modal-body h3 {
    font-size: 24px !important;
    font-weight: 700 !important;
    line-height: 1.2 !important;
}

.info-modal-body h4 {
    font-size: 20px !important;
    font-weight: 700 !important;
    line-height: 1.2 !important;
}

.info-modal-body h5 {
    font-size: 14px !important;
    font-weight: 700 !important;
    line-height: 1.2 !important;
}

.info-modal-body h6 {
    font-size: 16px !important;
    font-weight: 700 !important;
    line-height: 1.2 !important;
}

/* Make sure text shadow doesn't affect links */
.info-modal-body a {
    text-shadow: none !important;
    text-decoration: underline;
}

/* Links inside headings should inherit the heading font size - high specificity to override theme */
#info-modal-overlay .info-modal-content .info-modal-body h1 a,
#info-modal-overlay .info-modal-content .info-modal-body h2 a,
#info-modal-overlay .info-modal-content .info-modal-body h3 a,
#info-modal-overlay .info-modal-content .info-modal-body h4 a,
#info-modal-overlay .info-modal-content .info-modal-body h5 a,
#info-modal-overlay .info-modal-content .info-modal-body h6 a {
    font-size: inherit !important;
    line-height: inherit !important;
    font-weight: inherit !important;
    font-family: inherit !important;
    color: inherit !important;
}

/* Mobile-specific classes applied by JavaScript - highest priority */
.info-modal-inner.mobile-view,
.mobile-view {
    padding-bottom: 0 !important;
    height: auto !important;
    max-height: 95vh !important;
    position: relative !important;
    overflow-y: scroll !important;
    -webkit-overflow-scrolling: touch !important;
}

.info-modal-content.mobile-content,
.mobile-content {
    position: relative !important;
    height: auto !important;
    min-height: 100% !important;
    max-height: none !important;
    padding: 15px !important;
    overflow: visible !important;
    box-sizing: border-box !important;
}

.mobile-heading {
    font-size: 18px !important;
    line-height: 1.2 !important;
    margin-bottom: 10px !important;
}

.mobile-text {
    font-size: 14px !important;
    line-height: 1.3 !important;
}

.mobile-text p {
    margin-bottom: 10px !important;
}

/* Responsive adjustments - Combined for all mobile and tablet devices */
@media (max-width: 1024px) {
    /* Mobile and Tablet view */
    .info-modal {
        width: 95% !important;
        max-width: 100% !important;
        margin: 0 auto !important;
    }
    
    /* Reset aspect ratios to allow content to flow */
    .info-modal-inner {
        padding-bottom: 0 !important;
        height: auto !important;
        max-height: 95vh !important;
        overflow-y: scroll !important;
        -webkit-overflow-scrolling: touch !important;
        position: relative !important;
    }
    
    /* Make content scrollable */
    .info-modal-content {
        position: relative !important;
        height: auto !important;
        min-height: 100% !important;
        max-height: none !important;
        overflow: visible !important;
        padding: 15px !important;
        box-sizing: border-box !important;
    }
    
    /* Smaller heading on mobile */
    .info-modal-heading {
        font-size: 16px !important;
        line-height: 1.2 !important;
        margin-bottom: 8px !important;
    }
    
    /* Much smaller body text on mobile */
    .info-modal-body {
        font-size: 13px !important;
        line-height: 1.3 !important;
    }
    
    /* Minimal margins */
    .info-modal-body p {
        margin-bottom: 8px !important;
    }
    
    /* Ensure images fit */
    .info-modal-body img {
        max-width: 100% !important;
        height: auto !important;
    }
    
    /* Stack aligned images on mobile for better readability */
    .info-modal-body .alignleft,
    .info-modal-body .alignright,
    .info-modal-body img.alignleft,
    .info-modal-body img.alignright,
    .info-modal-body figure.alignleft,
    .info-modal-body figure.alignright {
        float: none !important;
        display: block !important;
        margin: 10px auto !important;
        max-width: 100% !important;
    }
    
    /* Smaller form elements */
    .info-modal-body button,
    .info-modal-body input[type="button"],
    .info-modal-body input[type="submit"] {
        padding: 6px 10px !important;
        font-size: 12px !important;
    }
    
    /* Position close button */
    .info-modal-close {
        top: 10px !important;
        right: 10px !important;
        font-size: 20px !important;
    }
}
