/* Map layout */

#map {
    position: relative;
    width: 100%;
    height: 100vh;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.map-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.map-image-wrapper {
    margin: 0;
}

.map-image {
    max-height: 100vh;
    max-width: 100vw;
    object-fit: contain;
}

.map-background {
    aspect-ratio: var(--aspect-ratio, 16 / 9);
    background-position: center;
    background-repeat: no-repeat;
    background-size: contain;
    position: relative;
    width: 100%;
    height: 100%;
    max-width: calc(100vh * var(--aspect-ratio, 1.778));
    max-height: calc(100vw / var(--aspect-ratio, 1.778));
}

/* Map legend */

.map-legend-toggle {
    align-items: center;
    appearance: none;
    background-color: transparent;
    border-width: 0;
    cursor: pointer;
    display: flex;
    justify-content: center;
    padding: 0.5rem 0.25em;
    transition: background-color 0.25s ease-out;
}

.map-legend-toggle-icon {
    min-width: 2.25em;
    opacity: 0.8;
    transition: opacity 0.25s ease-out;
    width: auto;
}

.map-legend-toggle:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.map-legend-toggle:hover > .map-legend-toggle-icon {
    opacity: 1;
}

.map-legend {
    position: absolute;
    right: 2rem;
    top: 2rem;
    z-index: 10;
}

.map-legend-dialog {
    animation: legend-reveal 0.25s ease-out forwards;
    border-width: 0;
    box-shadow: -0.75rem 0.75rem 0 0 rgba(0, 0, 0, 0.25);
    cursor: auto;
    display: none;
    flex-direction: column;
    left: unset;
    padding: 0 0.75em 0.75em;
    right: -0.75rem;
    top: -0.75rem;
    min-width: 16rem;
}

.map-legend-dialog[open] {
    display: flex;
}

.map-legend-header {
    align-items: center;
    display: flex;
    justify-content: space-between;
}

.map-legend-title {
    font-size: 1.25rem;
    font-weight: bold;
    letter-spacing: 0.05em;
}

.map-legend-close {
    align-items: center;
    appearance: none;
    background-color: transparent;
    border-width: 0;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    font-size: 2.25rem;
    justify-content: center;
    line-height: 1;
    outline: 2px solid transparent;
    padding: 0 0.5rem;
    transition: all 0.25s ease-out;
    transition-property: background-color, outline-color;
}

.map-legend-close:hover {
    background-color: var(--color-neutral-light-2);
}

.map-legend-close:focus {
    outline-color: currentColor;
}

.map-legend-content {
    display: flex;
    flex-direction: column;
}

.map-legend-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: flex-start;
    list-style: none;
    margin: 0;
    padding: 0;
}

.map-legend-item {
    width: 100%;
}

.map-legend-item-label {
    border: 2px solid currentColor;
    border-radius: 0.375rem;
    background-color: currentColor;
    display: block;
    opacity: 0.5;
    padding: 0.5rem 0.75rem;
    text-align: center;
    transition: all 0.25s ease-out;
    transition-property: background-color, outline-color;
}

.map-legend-item-label-text {
    color: white;
}

.map-legend-item-checkbox {
    height: 0;
    opacity: 0;
    overflow: hidden;
    position: absolute;
    width: 0;
}

.map-legend-item-checkbox:checked + .map-legend-item-label {
    opacity: 1;
}

.map-legend-item:hover .map-legend-item-label {
    background-color: transparent;
}

.map-legend-item:hover .map-legend-item-label > .map-legend-item-label-text {
    color: inherit;
}

.map-legend-item:focus-within .map-legend-item-label {
}

/* Map clouds */

.map-clouds {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.map-cloud {
    animation: move-cloud 100s ease-in-out infinite;
    background-position: center;
    background-repeat: no-repeat;
    background-size: contain;
    height: auto;
    opacity: var(--cloud-opacity);
    opacity: 1;
    pointer-events: none;
    position: absolute;
    width: var(--cloud-width, 150px);
    z-index: 101;
}

.map-cloud--left {
    animation-name: move-cloud--left;
    transform: translateX(100%);
}

.map-cloud.map-cloud--stationary {
    animation: none;
}

/* Map textures */

.map-overlay--texture {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background-size: cover;
    background-repeat: no-repeat;
    background-position: center;
    pointer-events: none;
    opacity: 0.125;
    width: 100%;
}

/* Map markers */

.map-markers {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    list-style: none;
    margin: 0;
    padding: 0;
    pointer-events: none;
}

.map-marker {
    position: absolute;
    cursor: pointer;
    z-index: 100;
    transform: translate(-50%, -50%);
    appearance: none;
    background-color: transparent;
    border-width: 0;
    display: block;
    height: 1.5rem;
    width: 1.5rem;
    transform-origin: center center;
    pointer-events: auto;
}

.map-marker[aria-hidden=true] {
    display: none;
}

.map-marker-button {
    appearance: none;
    background-color: currentColor;
    border: 0.25em solid #EAD9BD;
    border-radius: 50%;
    cursor: pointer;
    display: block;
    height: 1.5rem;
    width: 1.5rem;
    position: absolute;
    bottom: 0;
    left: 0;
    padding: 0;
    transition: transform 0.125s ease-out;
}

.map-marker:has(.map-marker-button:hover) {
    z-index: 110;
}

.map-marker-button:hover {
    transform: scale(1.25);
}

/* Map marker content */

.map-marker-content {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    border: 1px solid #ccc;
    border-radius: 8px;
    padding: 12px;
    min-width: 200px;
    max-width: 300px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    display: none;
    z-index: 1000;
    cursor: auto;
    margin-top: 0.5rem;
    animation: reveal-marker-content 0.25s ease-out forwards;
    transform-origin: center top;
}

.map-marker--active .map-marker-content {
    display: block;
}

.map-marker-title {
    font-size: 1.5rem;
    font-weight: bold;
}

.map-marker-location,
.map-marker-date {
    margin-block: 0.25em;
}

.map-marker-location {
    font-size: 1.25rem;
    font-weight: bold;
}

.map-marker-description {
    font-size: 0.875rem;
    line-height: 1.4;
}

.map-marker-image,
.map-marker-video {
    border-radius: 4px;
    height: auto;
    width: 100%;
}

.map-marker-location:empty,
.map-marker-date:empty,
.map-marker-description:empty,
.map-marker-content--video:empty {
    display: none;
}

.map-marker-contents .alignleft,
.map-marker-contents .alignright {
    margin-block-end: 1em;
}

.map-marker-contents .alignleft {
    float: inline-start;
    margin-inline-end: 1em;
}

.map-marker-contents .aligncenter {
    display: block;
    margin: auto;
}

.map-marker-contents .alignright {
    float: inline-end;
    margin-inline-start: 1em;
}

/* Map marker content variations */

.map-marker-content--gallery,
.map-marker-content--image,
.map-marker-content--video {
    margin-top: 20px;
}

.map-marker-content--video {
    height: auto;
    width: 100%;
}

.map-marker-video {
    aspect-ratio: 16 / 9;
    width: 100%;
}

/* Map marker slider */

.map-marker-content--gallery:has(.map-marker-gallery:empty) {
    display: none;
}

/* Map marker gallery */

.map-marker-gallery {
    list-style: none;
    margin: 0;
    padding: 0;
}

.map-marker-gallery-item {
    align-items: center;
    display: flex;
}

.map-marker-gallery-image {
    height: auto;
    object-fit: cover;
    width: 100%;
}

.map-marker-gallery-video {
    max-width: 100%;
}

/* Marker dialog */

.map-marker-dialog {
    border-width: 0;
    box-shadow: -0.75rem 0.75rem 0 0 rgba(0, 0, 0, 0.25);
    flex-direction: column;
    max-height: calc(100% - 4rem);
    max-width: calc(100% - 4rem);
    min-width: 40%;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 1rem;
    position: fixed;
    transform-origin: center;
    width: 48rem;
}

.map-marker-dialog[open] {
    display: flex;
}

.map-marker-dialog::backdrop {
    background: rgba(0, 0, 0, 0.25);
}

.map-marker-dialog + .backdrop {
    background: rgba(0, 0, 0, 0.25);
}

.map-marker-dialog--animated {
    animation: show-dialog 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.map-marker-dialog-header {
    align-items: flex-start;
    border-bottom: 1px solid currentColor;
    color: var(--color, currentColor);
    display: flex;
    flex-wrap: nowrap;
    justify-content: space-between;
}

.map-marker-title {
    color: inherit;
    font-size: 1.5rem;
    margin-block-end: 0.5em;
    margin-block-start: 0;
}

.map-marker-dialog-close {
    align-items: center;
    appearance: none;
    background-color: transparent;
    border: none;
    border-radius: 50%;
    color: inherit;
    cursor: pointer;
    display: flex;
    font-size: 2.25rem;
    justify-content: center;
    line-height: 1;
    outline: 2px solid transparent;
    padding: 0 8px;
    transition: all 0.25s ease-out;
    transition-property: background-color, color, outline-color, transform;
    z-index: 10;
}

.map-marker-dialog-close:hover {
    background-color: revert;
}

.map-marker-dialog-close:focus {
    outline-color: var(--color-black);
}

.map-marker-contents {
    cursor: auto;
    flex-grow: 1;
    padding: 1rem 0 0;
}

/* Map controls */

.map-controls {
    background-color: var(--color-neutral-light);
    border-radius: 0.25rem;
    bottom: 2rem;
    display: flex;
    gap: 1px;
    right: 2rem;
    overflow: hidden;
    position: absolute;
    z-index: 10;
}

.map-control {
    appearance: none;
    background-color: var(--color-white);
    border-width: 0;
    padding: 0.5rem 0.75rem;
    transition: background-color 0.25s ease-out;
}

.map-control:hover {
    background-color: var(--color-neutral-light-2);
}

.map-control:active {
    background-color: var(--color-neutral-light-3);
    transition-duration: 1ms;
}

.map-control--reset {
    color: transparent;
    position: relative;
}

.map-control--reset::before {
    content: '';
    background-color: var(--color-neutral-dark);
    border-radius: 50%;
    display: block;
    height: 0.5em;
    left: 50%;
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 0.5em;
}

.map-reset-button {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 200;
    background: white;
    border: 1px solid var(--color-neutral-light-4);
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    font-weight: 500;
    color: var(--color-neutral-dark);
    transition: all 0.2s ease;
}

.map-reset-button:hover {
    background: var(--color-neutral-light-5);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    transform: translateY(-1px);
}

.map-reset-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.map-reset-button svg {
    width: 16px;
    height: 16px;
}

/* Responsive tweaks */

@media (pointer: coarse) {
    .map-marker,
    .map-marker-button {
        min-width: 3rem;
        min-height: 3rem;
    }

    .map-marker,
    .map-marker-button {
        width: 2rem;
        height: 2rem;
    }

    .map-controls {
        bottom: 4rem;
        flex-direction: column-reverse;
    }

    .map-control {
        font-size: 2rem;
        padding-inline: 1rem;
    }
}

/* Keyframes */

@keyframes reveal-marker-content {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-0.25rem);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

@keyframes move-cloud {
    0% {
        transform: translateX(-100%);
    }
    50% {
        transform: translateX(100%);
    }
    100% {
        transform: translateX(-100%);
    }
}

@keyframes move-cloud--left {
    0% {
        transform: translateX(100%);
    }
    50% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

@keyframes show-dialog {
    0% {
        opacity: 0;
        transform: scale(0.95) translateY(-0.5rem);
    }
    60% {
        opacity: 1;
        transform: scale(1.02) translateY(0.25rem);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes spin-loader {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(180deg);
    }
}

@keyframes legend-reveal {
    from {
        opacity: 0;
        transform: translateY(-0.5em);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
