/*
 * Styles for the Custom World Map plugin
 */

/* Container for the map */
/* Map container
   Use CSS aspect‑ratio property when supported to maintain the original image
   dimensions in a responsive way. Fall back to padding‑top for older browsers. */
.custom-world-map-container {
    position: relative;
    width: 100%;
    /* Use aspect-ratio for modern browsers */
    aspect-ratio: 1326 / 722;
    background-repeat: no-repeat;
    background-position: center center;
    background-size: contain;
    overflow: visible;
}
@supports not (aspect-ratio: 1 / 1) {
    .custom-world-map-container {
        /* Fallback: maintain aspect ratio using padding-top
           Height/width ≈ 0.545 => padding-top: 55% */
        padding-top: 55%;
    }
}

/* Marker pins */
/* Map markers utilise a CSS variable for colour. The variable defaults to the
   standard red used in the original implementation. When the `highlight`
   class is present, the variable is overridden to blue. Individual markers
   may set the `--marker-color` inline to choose a custom colour. */
/* Marker container */
.custom-world-map-container .map-marker {
    position: absolute;
    width: 18px;
    height: 18px;
    /* Use a CSS custom property to define colour; fallback to red */
    --marker-color: #e74c3c;
    background-color: var(--marker-color);
    color: var(--marker-color);
    border-radius: 50%;
    transform: translate(-50%, -100%);
    cursor: pointer;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
}
/* Arrow pointer element appended inside marker */
.custom-world-map-container .map-marker .pin-pointer {
    position: absolute;
    left: 50%;
    top: 100%;
    margin-left: -5px;
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 8px solid currentColor;
}
/* Blue highlighted marker overrides the CSS variable */
.custom-world-map-container .map-marker.highlight {
    --marker-color: #3498db;
}

/* Popup box for marker details */
.custom-world-map-container .map-popup {
    position: absolute;
    max-width: 240px;
    background: #ffffff;
    border: 1px solid #cccccc;
    padding: 10px;
    border-radius: 4px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    z-index: 3;
    font-size: 14px;
    line-height: 1.4;
}

/* When popup is opened to the left of a marker, shift its origin so that it doesn't overflow the right edge */
.custom-world-map-container .map-popup.left-popup {
    transform: translateX(-100%);
}
.custom-world-map-container .map-popup h4 {
    margin: 0 0 6px;
    font-size: 16px;
    font-weight: 600;
}
.custom-world-map-container .map-popup p {
    margin: 0 0 6px;
}
.custom-world-map-container .map-popup .contact-button {
    display: inline-block;
    padding: 6px 12px;
    background: #21759b;
    color: #ffffff;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 14px;
    text-decoration: none;
}
.custom-world-map-container .map-popup .contact-form {
    margin-top: 6px;
    display: none;
}
.custom-world-map-container .map-popup input[type="email"] {
    width: 100%;
    padding: 6px;
    margin-bottom: 6px;
    border: 1px solid #ccc;
    border-radius: 3px;
    box-sizing: border-box;
    font-size: 14px;
}

/* Additional input styles for name and phone fields */
.custom-world-map-container .map-popup input[type="text"],
.custom-world-map-container .map-popup input[type="tel"] {
    width: 100%;
    padding: 6px;
    margin-bottom: 6px;
    border: 1px solid #ccc;
    border-radius: 3px;
    box-sizing: border-box;
    font-size: 14px;
}
.custom-world-map-container .map-popup .submit-email {
    display: inline-block;
    padding: 6px 12px;
    background: #28a745;
    color: #ffffff;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 14px;
}
.custom-world-map-container .map-popup .message {
    margin-top: 4px;
    font-size: 13px;
    color: #555;
}

/* Responsive adjustments */
@media (max-width: 600px) {
    /* On very small screens increase the height to give more space for the map */
    .custom-world-map-container {
        /* Maintain original aspect ratio on very small screens */
        aspect-ratio: 1326 / 722;
    }
    @supports not (aspect-ratio: 1 / 1) {
        .custom-world-map-container {
            /* Set padding-top equal to height/width ratio (~54.5%) */
            padding-top: 54.5%;
        }
    }
    .custom-world-map-container .map-popup {
        max-width: 180px;
        font-size: 13px;
        /* Ensure popup text wraps and stays within view */
        word-wrap: break-word;
    }
}

/* Additional responsive rules for tablets and small desktops */
@media (max-width: 768px) {
    .custom-world-map-container {
        /* Maintain original aspect ratio even on smaller screens */
        aspect-ratio: 1326 / 722;
    }
    @supports not (aspect-ratio: 1 / 1) {
        .custom-world-map-container {
            /* Set padding-top to maintain original ratio: height/width = 722/1326 ≈ 54.5% */
            padding-top: 54.5%;
        }
    }
    .custom-world-map-container .map-popup {
        max-width: 80vw;
        font-size: 14px;
        word-wrap: break-word;
    }
}