/* ==========================================================================
   SECTION: MAP
   ========================================================================== */

.map {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    width: 100%;
    padding: 56px 72px 0;
}

.map__background {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
    z-index: -2;
}

.map__spacer {
    height: 120px;
    width: 100%;
}

.map::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        180deg,
        transparent 0%,
        rgba(88, 132, 92, 0.42) 37.5%,
        rgba(95, 125, 98, 0.42) 83.654%,
        transparent 100%
    );
    mix-blend-mode: plus-lighter;
    pointer-events: none;
    z-index: -1;
}

.map__title {
    font-family: 'Jura', sans-serif;
    font-weight: 400;
    font-size: 96px;
    line-height: 1.1;
    color: #f1fee0;
    text-align: center;
    width: 994px;
    max-width: 100%;
    margin: 0;
}

.map__subtitle {
    font-family: var(--font-primary);
    font-weight: var(--font-weight-light);
    font-size: 24px;
    line-height: normal;
    color: #f1fee0;
    text-align: center;
    width: 994px;
    max-width: 100%;
    margin: 0;
}

.map__container {
    width: 1296px;
    max-width: 100%;
    height: 831px;
    border-radius: 32px;
    overflow: hidden;
    position: relative;
}

.map__image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 32px;
}

.map__leaflet {
    width: 100%;
    height: 100%;
    min-height: 500px;
    border-radius: 32px;
    background: rgba(14, 18, 10, 0.5);
    position: relative;
    z-index: 1;
}

/* Custom Leaflet marker styling */
.leaflet-marker-icon {
    background: transparent;
    border: none;
}

/* Leaflet control styling */
.map__container .leaflet-control-zoom {
    border: none;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.map__container .leaflet-control-zoom a {
    background-color: rgba(14, 18, 10, 0.85);
    color: var(--color-text-light);
    border: none;
    width: 32px;
    height: 32px;
    line-height: 32px;
    font-size: 18px;
    transition: background-color 0.2s ease;
}

.map__container .leaflet-control-zoom a:hover {
    background-color: rgba(14, 18, 10, 0.95);
    color: var(--color-text-light);
}

.map__container .leaflet-control-zoom-in {
    border-bottom: 1px solid rgba(241, 254, 224, 0.2) !important;
}

.map__container .leaflet-control-attribution {
    background: rgba(14, 18, 10, 0.7) !important;
    color: var(--color-text-light) !important;
    font-size: 10px;
    padding: 2px 6px;
}

.map__container .leaflet-control-attribution a {
    color: var(--color-forest-green) !important;
}

/* Ensure Leaflet container respects border radius */
.map__container .leaflet-container {
    border-radius: inherit;
}

/* Fix for marker click area */
.leaflet-marker-icon {
    cursor: pointer;
    transition: transform 0.2s ease;
}

.leaflet-marker-icon:hover {
    transform: scale(1.1);
    z-index: 1000 !important;
}

/* ==========================================================================
   MAP POPUP OVERLAY
   ========================================================================== */

.map-popup {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.map-popup--open {
    opacity: 1;
    visibility: visible;
}

/* Backdrop with blur - same as navbar burger menu */
.map-popup__backdrop {
    position: absolute;
    inset: 0;
    background-color: rgba(14, 18, 10, 0.66);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.map-popup__content {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 1440px;
    display: flex;
    flex-direction: column;
    padding: 80px 89px;
}

.map-popup__inner {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 35px;
    justify-content: center;
    overflow: hidden;
}

.map-popup__main {
    display: flex;
    gap: 40px;
    position: relative;
}

/* Fade transition applied to inner container (covers both content and nav) */
.map-popup__inner {
    opacity: 1;
    transition: opacity 0.15s ease-out;
}

.map-popup__inner--fading {
    opacity: 0;
}

/* Disable all child transitions during content swap */
.map-popup__inner--swapping,
.map-popup__inner--swapping * {
    transition: none !important;
}

/* Image container - absolute positioned to match text height */
/* Image takes 38.18% (golden ratio complement), text takes 61.82% */
.map-popup__image-container {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: calc(38.18% - 20px);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    overflow: hidden;
    background: rgba(14, 18, 10, 0.5);
}

.map-popup__image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 10px;
}

/* Placeholder image - contain instead of cover, don't stretch */
.map-popup__image--placeholder {
    object-fit: contain;
}

/* Hide container background when showing placeholder */
.map-popup__image-container:has(.map-popup__image--placeholder) {
    background: transparent;
}

.map-popup__image--hidden {
    display: none;
}

.map-popup__image-placeholder {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    color: var(--color-forest-green);
    padding: 40px;
}

.map-popup__image-placeholder--visible {
    display: flex;
}

.map-popup__image-placeholder svg {
    width: 64px;
    height: 64px;
    opacity: 0.5;
}

.map-popup__image-placeholder span {
    font-family: var(--font-primary);
    font-size: 14px;
    font-weight: var(--font-weight-light);
    opacity: 0.7;
}

/* Text content - determines the height of the popup */
/* Text takes 61.82% (golden ratio) */
.map-popup__text {
    width: calc(61.82% - 20px);
    margin-left: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.map-popup__header {
    display: flex;
    align-items: center;
    gap: 22px;
}

.map-popup__title {
    font-family: var(--font-primary);
    font-weight: var(--font-weight-bold);
    font-size: 40px;
    line-height: normal;
    color: var(--color-text-light);
    margin: 0;
}

.map-popup__meta {
    display: flex;
    align-items: center;
    gap: 17px;
    flex-wrap: wrap;
}

.map-popup__id {
    font-family: var(--font-primary);
    font-weight: var(--font-weight-light);
    font-size: 14px;
    color: var(--color-text-light);
}

.map-popup__tag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 3px 10px;
    background-color: var(--color-forest-green);
    border-radius: 10px;
    font-family: var(--font-primary);
    font-weight: var(--font-weight-light);
    font-size: 14px;
    color: var(--color-dark-green);
}

.map-popup__tag--hidden {
    display: none;
}

.map-popup__description,
.map-popup__reason {
    font-family: var(--font-primary);
    font-weight: var(--font-weight-light);
    font-size: 20px;
    line-height: 1.5;
    color: var(--color-text-light);
    margin: 0;
}

/* Navigation */
.map-popup__nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 35px;
    padding: 10px;
}

.map-popup__nav-btn {
    font-family: var(--font-primary);
    font-weight: var(--font-weight-thin);
    font-size: 20px;
    color: var(--color-text-light);
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px 16px;
    transition: opacity 0.2s ease;
    white-space: nowrap;
}

.map-popup__nav-btn:hover {
    opacity: 0.7;
}

.map-popup__nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Play button - matches floating audio button style */
.map-popup__play-btn {
    height: 72px;
    padding: 0 24px;
    border-radius: 36px;
    border: 1px solid var(--color-moss-green);
    background: var(--color-dark-green);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease, box-shadow 0.3s ease, transform 0.15s ease;
}

.map-popup__play-btn:hover {
    transform: scale(1.03);
}

.map-popup__play-btn:active {
    transform: scale(0.97);
}

/* Icon wrapper */
.map-popup__play-icon-wrapper {
    position: relative;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}

/* Icon styles */
.map-popup__play-icon {
    position: absolute;
    top: 0;
    left: 0;
    width: 40px;
    height: 40px;
    transition: opacity 0.2s ease;
}

.map-popup__play-icon--play {
    opacity: 1;
}

.map-popup__play-icon--pause {
    opacity: 0;
}

/* Playing state - orange glow */
.map-popup__play-btn--playing {
    opacity: 0.5;
    box-shadow:
        0 0 20px rgba(255, 136, 0, 0.5),
        0 0 40px rgba(255, 136, 0, 0.25),
        0 0 60px rgba(255, 136, 0, 0.15);
}

.map-popup__play-btn--playing .map-popup__play-icon--play {
    opacity: 0;
}

.map-popup__play-btn--playing .map-popup__play-icon--pause {
    opacity: 1;
}

/* Paused state */
.map-popup__play-btn--paused {
    opacity: 1;
    box-shadow: none;
}

.map-popup__play-btn--paused .map-popup__play-icon--play {
    opacity: 1;
}

.map-popup__play-btn--paused .map-popup__play-icon--pause {
    opacity: 0;
}

/* Back button */
.map-popup__back {
    position: absolute;
    bottom: 40px;
    left: 89px;
    display: flex;
    align-items: center;
    gap: 10px;
    height: 48px;
    padding: 0 20px 0 16px;
    font-family: var(--font-primary);
    font-weight: var(--font-weight-regular);
    font-size: 15px;
    color: var(--color-text-light);
    background: rgba(14, 18, 10, 0.6);
    border: 1px solid var(--color-moss-green);
    border-radius: 24px;
    cursor: pointer;
    z-index: 10;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: all 0.2s ease;
}

.map-popup__back:hover {
    background: rgba(70, 80, 60, 0.5);
    border-color: var(--color-forest-green);
    transform: translateX(-4px);
}

.map-popup__back:active {
    transform: translateX(-2px) scale(0.98);
}

.map-popup__back-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.map-popup__back:hover .map-popup__back-icon {
    transform: translateX(-3px);
}

.map-popup__back-text {
    white-space: nowrap;
}

/* ==========================================================================
   MAP POPUP - RESPONSIVE
   ========================================================================== */

@media (max-width: 1024px) {
    .map-popup__content {
        padding: 60px 40px;
    }

    .map-popup__main {
        flex-direction: column;
        gap: 24px;
    }

    .map-popup__image-container {
        position: static;
        width: 100%;
        height: 250px;
    }

    .map-popup__text {
        width: 100%;
        margin-left: 0;
    }

    .map-popup__title {
        font-size: 28px;
    }

    .map-popup__description,
    .map-popup__reason {
        font-size: 16px;
    }

    .map-popup__nav {
        gap: 20px;
    }

    .map-popup__play-btn {
        height: 64px;
        padding: 0 20px;
    }

    .map-popup__back {
        left: 40px;
        bottom: 24px;
        height: 44px;
        padding: 0 18px 0 14px;
        font-size: 14px;
    }
}

@media (max-width: 768px) {
    .map-popup__content {
        padding: 40px 20px;
    }

    .map-popup__inner {
        gap: 20px;
    }

    .map-popup__image-container {
        height: 200px;
    }

    .map-popup__title {
        font-size: 24px;
    }

    .map-popup__meta {
        gap: 10px;
    }

    .map-popup__description,
    .map-popup__reason {
        font-size: 14px;
    }

    .map-popup__nav-btn {
        font-size: 16px;
        padding: 8px 12px;
    }

    .map-popup__play-btn {
        height: 56px;
        padding: 0 16px;
    }

    .map-popup__play-icon-wrapper {
        width: 28px;
        height: 28px;
    }

    .map-popup__play-icon {
        width: 28px;
        height: 28px;
    }

    .map-popup__back {
        left: 20px;
        bottom: 16px;
        height: 40px;
        padding: 0 16px 0 12px;
        font-size: 13px;
        gap: 8px;
    }

    .map-popup__back-icon {
        width: 18px;
        height: 18px;
    }

    .map__leaflet {
        border-radius: 20px;
    }
}

@media (max-width: 480px) {
    .map-popup__content {
        padding: 24px 16px;
    }

    .map-popup__image-container {
        height: 150px;
    }

    .map-popup__title {
        font-size: 20px;
    }

    .map-popup__tag {
        font-size: 12px;
        padding: 2px 8px;
    }

    .map-popup__nav {
        gap: 8px;
        flex-wrap: wrap;
    }

    .map-popup__nav-btn {
        font-size: 14px;
        padding: 6px 8px;
    }

    .map-popup__play-btn {
        height: 48px;
        padding: 0 14px;
        border-radius: 24px;
    }

    .map-popup__play-icon-wrapper {
        width: 24px;
        height: 24px;
    }

    .map-popup__play-icon {
        width: 24px;
        height: 24px;
    }

    .map-popup__back {
        left: 16px;
        bottom: 12px;
        height: 36px;
        padding: 0 14px 0 10px;
        font-size: 12px;
        gap: 6px;
        border-radius: 18px;
    }

    .map-popup__back-icon {
        width: 16px;
        height: 16px;
    }

    .map__leaflet {
        border-radius: 16px;
    }
}

/* Fade overlay */
.map__fade {
    width: 100%;
    pointer-events: none;
}

.map__fade--bottom {
    height: 215px;
    background: linear-gradient(to bottom, transparent 0%, #0e120a 100%);
    margin: 56px -72px 0;
    width: calc(100% + 144px);
}

/* Responsive adjustments */
@media (max-width: 1400px) {
    .map__container {
        width: 100%;
        height: auto;
        aspect-ratio: 1296 / 831;
    }
}

@media (max-width: 768px) {
    .map {
        padding: 40px 20px 0;
        gap: 24px;
    }

    .map__fade--bottom {
        margin: 40px -20px 0;
        width: calc(100% + 40px);
    }

    .map__title {
        font-size: 48px;
    }

    .map__subtitle {
        font-size: 18px;
    }

    .map__container {
        border-radius: 20px;
    }

    .map__image {
        border-radius: 20px;
    }
}

@media (max-width: 480px) {
    .map__title {
        font-size: 36px;
    }

    .map__subtitle {
        font-size: 16px;
    }

    .map__container {
        border-radius: 16px;
    }

    .map__image {
        border-radius: 16px;
    }
}
