/* --- Parallax Background Image --- */
.contacts-cemac-map__bg {
    width: 100%;
    height: 100%;
    background-image: url('../assets/images/bg/d5b09544-11fc-41ec-97f7-03a92060a7c9.jpg');
    background-size: cover;
    background-position: center;
    pointer-events: none;
}

#africa-map-bg {
    opacity: 0;
    transition: opacity 0.8s ease;
}

/* --- CEMAC Country hover colours --- */

.cemac-bg-positioned {
    position: absolute;
    transform-origin: top left;
}

/* --- CEMAC Index Map Animation --- */
.contacts-cemac-map-svg path:not(.africa-map):not(.office-pin) {
    --accent-gold: #b88e53;
    --accent-green: #e8c56a;
    animation: index-region-morph 14s ease-in-out infinite;
    transform-origin: center;
    transform-box: fill-box;
    transition: fill 0.4s ease, fill-opacity 0.4s ease, filter 0.4s ease, transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.contacts-cemac-map-svg {
    transform: scale(1);

    &.zoomed {
        transform: scale(2.2);
    }
}

.contacts-cemac-map-svg.zoomed path:not(.africa-map):not(.office-pin) {
    /* From https://css.glass */
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(5.1px);
    -webkit-backdrop-filter: blur(5.1px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    stroke: black !important;
    stroke-opacity: 0.5;
    fill-opacity: 0.5;
}

.contacts-cemac-map-svg path.cemac-cg {
    animation-delay: -2s;
}

.contacts-cemac-map-svg path.cemac-ga {
    animation-delay: -5s;
}

.contacts-cemac-map-svg path.equatorial-guinea-continental,
.contacts-cemac-map-svg path.equatorial-guinea-island,
.contacts-cemac-map-svg path.cemac-gq {
    animation-delay: -8s;
}

.contacts-cemac-map-svg path.cemac-cm {
    animation-delay: -11s;
}

.contacts-cemac-map-svg path.cemac-cf {
    animation-delay: 0s;
}

.contacts-cemac-map-svg path.cemac-td {
    animation-delay: -3s;
}

.contacts-cemac-map-svg path:not(.africa-map):not(.office-pin):hover,
.contacts-cemac-map-svg:has(.equatorial-guinea-continental:hover) .equatorial-guinea-island,
.contacts-cemac-map-svg:has(.equatorial-guinea-island:hover) .equatorial-guinea-continental {
    animation: none;
    fill: var(--accent-green);
    fill-opacity: 1;
    transform: translateY(-3px) scale(1.005);
}

.contacts-cemac-map-svg:has(.office-pin:hover) path:not(.africa-map):not(.office-pin) {
    animation: none;
    fill: white;
}

@keyframes index-region-morph {
    0% {
        fill: var(--accent-gold);
        stroke: #ffffff;
    }

    7.14% {
        fill: var(--accent-green);
        stroke: #ffffff;
    }

    14.28% {
        fill: var(--accent-gold);
        stroke: #ffffff;
    }

    100% {
        fill: var(--accent-gold);
        stroke: #ffffff;
    }
}

/* Cursors for .cemac-* classes (matching the contacts page) */
.contacts-cemac-map-svg path.cemac-cg {
    cursor: url('../assets/images/flags/cg.png'), pointer;
    cursor: -webkit-image-set(url('../assets/images/flags/cg.png') 2x), pointer;
    cursor: image-set(url('../assets/images/flags/cg.png') 2x), pointer;
}

.contacts-cemac-map-svg path.cemac-ga {
    cursor: url('../assets/images/flags/ga.png'), pointer;
    cursor: -webkit-image-set(url('../assets/images/flags/ga.png') 2x), pointer;
    cursor: image-set(url('../assets/images/flags/ga.png') 2x), pointer;
}

.contacts-cemac-map-svg path.equatorial-guinea-continental,
.contacts-cemac-map-svg path.equatorial-guinea-island,
.contacts-cemac-map-svg path.cemac-gq {
    cursor: url('../assets/images/flags/gq.png'), pointer;
    cursor: -webkit-image-set(url('../assets/images/flags/gq.png') 2x), pointer;
    cursor: image-set(url('../assets/images/flags/gq.png') 2x), pointer;
}

.contacts-cemac-map-svg path.cemac-cm {
    cursor: url('../assets/images/flags/cm.png'), pointer;
    cursor: -webkit-image-set(url('../assets/images/flags/cm.png') 2x), pointer;
    cursor: image-set(url('../assets/images/flags/cm.png') 2x), pointer;
}

.contacts-cemac-map-svg path.cemac-cf {
    cursor: url('../assets/images/flags/cf.png'), pointer;
    cursor: -webkit-image-set(url('../assets/images/flags/cf.png') 2x), pointer;
    cursor: image-set(url('../assets/images/flags/cf.png') 2x), pointer;
}

.contacts-cemac-map-svg path.cemac-td {
    cursor: url('../assets/images/flags/td.png'), pointer;
    cursor: -webkit-image-set(url('../assets/images/flags/td.png') 2x), pointer;
    cursor: image-set(url('../assets/images/flags/td.png') 2x), pointer;
}

/* --- CEMAC Index Map Office Pins & Radar --- */
.contacts-cemac-map-svg .office-pin {
    fill: black;
    cursor: url('../assets/images/bg/fedhen-shield.svg') 8 20, pointer;
    transform-box: fill-box;
    transform-origin: center bottom;
    transform: scale(0.75);
}

.contacts-cemac-map-svg .radar-ring {
    fill: none;
    stroke: var(--primary-color);
    transform-origin: center;
    transform-box: fill-box;
    animation: index-radar-sweep 2s cubic-bezier(0.1, 0.5, 0.3, 1) infinite;
    pointer-events: none;
}

.contacts-cemac-map-svg .radar-ring:nth-of-type(2) {
    animation-delay: -1s;
}

@keyframes index-radar-sweep {
    0% {
        transform: scale(0.5);
        stroke-opacity: 0.9;
        stroke-width: 8;
    }

    100% {
        transform: scale(4.5);
        stroke-opacity: 0;
        stroke-width: 1;
    }
}

/* --- Pin Hover Tooltip --- */
.pin-hover-tooltip {
    position: absolute;
    top: 0;
    left: 0;
    width: 250px;
    aspect-ratio: 1 / 1;
    background: #fff;
    /* border: 1px solid rgba(13, 27, 42, 0.08); */
    border-radius: 12px;
    overflow: hidden;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    /* Default initial transform (hidden state) */
    transform: translate(-50%, 0) translateY(15px);
    transition: opacity 0.3s ease, visibility 0.3s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 1000;
}

.pin-hover-tooltip.active {
    opacity: 1;
    visibility: visible;
}

.pin-hover-tooltip.active.pos-bottom {
    transform: translate(-50%, 0) translateY(25px);
}

.pin-hover-tooltip.active.pos-top {
    transform: translate(-50%, -100%) translateY(-25px);
}

.pin-hover-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.pin-hover-title {
    position: absolute;
    bottom: 0;
    right: 0;
    background: #ffffff;
    font-family: var(--font-body);
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #000;
    padding-inline: 8px;
    z-index: 2;
    line-height: 2;
}

/* Container and Scrolling */
.cemac-africa-map {
    overflow: hidden;
    padding: 0 !important;
}

.cemac-scroll-container {
    --cemac-scroll-container-height: calc(100vh - var(--header-height, 0) + 2px);
    position: sticky;
    bottom: 0;
    height: var(--cemac-scroll-container-height);
    overflow-y: scroll;
    scroll-snap-type: y mandatory;
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE and Edge */
}

.cemac-scroll-container::-webkit-scrollbar {
    display: none;
    /* Chrome, Safari and Opera */
}

.cemac-scroll-container > .container {
    display: flex;
    flex-wrap: wrap;
    gap: 48px;
    align-items: flex-start;
    position: relative;
    padding-block: 0;
}

/* Map Graphic Side */
.cemac-map-graphic-wrapper {
    position: sticky;
    top: 0;
    height: var(--cemac-scroll-container-height);
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 300px;
    z-index: 10;
}

.cemac-map-container {
    position: relative;
    width: 100%;
    max-width: calc((80vh - 48px) * 2066 / 2464 + 48px);
    margin: 0 auto;
    overflow: hidden;
    background-image: url('../assets/images/bg/d5b09544-11fc-41ec-97f7-03a92060a7c9.jpg');
    background-size: cover;
    background-position: center;
    border-radius: 8px;
    padding: 24px;
    height: fit-content;
    max-height: 80vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cemac-map-overlay {
    position: absolute;
    inset: 0;
    background-color: rgba(5, 12, 22, 0.7);
    border-radius: inherit;
    z-index: 1;
}

.contacts-cemac-map-svg {
    width: 100%;
    position: relative;
    z-index: 2;
    transition: transform 0.8s cubic-bezier(0.25, 0.8, 0.25, 1);
    transform-origin: 49% 38%;
}

/* Text Column Side */
.cemac-map-text-column {
    flex: 1;
    min-width: 300px;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.cemac-map-content {
    height: var(--cemac-scroll-container-height);
    display: flex;
    flex-direction: column;
    justify-content: center;
    scroll-snap-align: center;
}

.cemac-africa-map .btn {
    width: fit-content;
}

.cemac-africa-map .section-subtitle {
    color: var(--text-secondary);
    padding-block: 24px;
}

.map-inactive {
    pointer-events: none;
    overflow-y: hidden;

    & path[class^="cemac"],
    & .btn,
    & .office-pin {
        pointer-events: auto;
    }
}

.mission-bg .hero-breadcrumb {
    color: var(--primary-color);
}

@media (max-width: 992px) {
    .cemac-scroll-container {
        height: auto;
        overflow-y: visible;
        position: static;
        scroll-snap-type: none;
    }
    
    .cemac-scroll-container > .container {
        flex-direction: column;
        gap: 32px;
        padding-block: 48px;
    }

    .cemac-map-graphic-wrapper {
        position: static;
        height: auto;
        min-width: 100%;
    }

    .cemac-map-text-column {
        min-width: 100%;
        gap: 32px;
    }

    .cemac-map-content {
        height: auto;
        scroll-snap-align: none;
        padding-block: 16px;
    }

    .contacts-cemac-map-svg,
    .contacts-cemac-map-svg.zoomed {
        transform: scale(1) !important;
    }
    
    #africa-map-bg {
        opacity: 1 !important;
    }
    
    .map-inactive {
        pointer-events: auto !important;
        overflow-y: visible !important;
    }
}