body {
    margin: 0;
}

#map {
    height: 100vh;
    width: 100%;
}

.maplibregl-popup {
    z-index: 1;
}

.map-tooltip .maplibregl-popup-content {
    padding: 6px;
    border-radius: 3px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
    color: #222;
    white-space: nowrap;
    font-size: 22px;
    line-height: 1.5;
    font-family: 'Raleway', sans-serif;
}

.photo-preview {
    position: fixed;
    z-index: 1100;
    display: none;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.55);
    pointer-events: none;
}

/* when tapped/clicked, images shown in own layer to occupy entire browser viewport */
.image-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    cursor: pointer;
}

.image-overlay img {
    max-width: 80%;
    max-height: 70%;
    object-fit: contain;
}

.image-caption {
    font-family: 'Raleway', sans-serif;
    color: white;
    font-size: 20px;
    margin-top: 20px;
    text-align: center;
    max-width: 80%;
}

.image-day {
    display: block;
    margin-bottom: 6px;
    font-size: 15px;
    font-weight: 400;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.65);
}

.nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 48px;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    user-select: none;
    z-index: 10001;
}

.nav-arrow:hover {
    color: white;
}

.nav-arrow.left {
    left: 22px;
}

.nav-arrow.right {
    right: 22px;
}

.close-button {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 36px;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    user-select: none;
    z-index: 10001;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-button:hover {
    color: white;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
}

/* map legend */
.map-legend {
    position: absolute;
    bottom: 20px;
    left: 20px;
    background: rgba(255, 255, 255, 0.9);
    padding: 15px;
    border-radius: 5px;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.4);
    font-family: 'Raleway', sans-serif;
    font-size: 22px;
    z-index: 1000;
}

.legend-item {
    display: flex;
    align-items: center;
    margin: 5px 0;
    cursor: pointer;
    user-select: none;
}

.legend-item input {
    margin-right: 8px;
}

.legend-icon {
    margin-right: 8px;
    width: 26px;
    height: 26px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.legend-icon .material-symbols-outlined {
    font-size: 16px;
}

.legend-icon + .legend-icon {
    margin-left: -2px;
}

/* map back button and language switcher */
.map-top-left {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    gap: 10px;
    z-index: 1000;
}

.map-back-button,
.language-switcher {
    background: rgba(255, 255, 255, 0.9);
    padding: 12px 16px;
    border-radius: 5px;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.4);
    font-family: 'Raleway', sans-serif;
    font-size: 22px;
    cursor: pointer;
    text-decoration: none;
    color: #333;
    display: block;
}

.language-switcher {
    border: none;
    font-weight: 400;
    line-height: inherit;
}

.map-back-button:hover,
.language-switcher:hover {
    background: rgba(255, 255, 255, 1);
    text-decoration: none;
    color: #333;
}

/* Buy button styles */
.buy-button {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 1000;
    padding: 10px 20px;
    background-color: rgb(66, 133, 244, 0.7);
    color: white;
    border: 1px solid rgb(66, 133, 244);
    border-radius: 3px;
    font-family: 'Raleway', sans-serif;
    font-size: 24px;
    font-weight: 300;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.buy-button:hover {
    background-color: rgba(66, 133, 244, 1);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.buy-button:active {
    transform: translateY(0);
}

.material-icon-marker {
    cursor: pointer;
}

.endpoint-marker {
    cursor: default;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.45));
}

.endpoint-marker::after {
    content: '';
    margin-top: -1px;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 8px solid #fff;
}

.photo-marker {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.map-pin {
    box-sizing: border-box;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease;
}

.map-pin .material-symbols-outlined {
    font-size: 18px;
    font-variation-settings: 'FILL' 1, 'wght' 600;
}

.endpoint-marker .map-pin {
    width: 34px;
    height: 34px;
    box-shadow: none;
}

.endpoint-marker .map-pin .material-symbols-outlined {
    font-size: 22px;
}

.map-pin-camp {
    background-color: #c8a96e;
}

.map-pin-photo {
    background-color: #6b1f9a;
}

.map-pin-start {
    background-color: #2e8b57;
}

.map-pin-end {
    background-color: #d02020;
}

@media (hover: hover) {
    .photo-marker:hover .map-pin {
        transform: scale(1.15);
    }
}

/* photo clusters */
.marker-cluster {
    box-sizing: border-box;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
    background-color: #6b1f9a;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font: bold 13px "Helvetica Neue", Arial, Helvetica, sans-serif;
    cursor: pointer;
}

.marker-cluster-small {
    width: 32px;
    height: 32px;
}

.marker-cluster-medium {
    width: 38px;
    height: 38px;
    font-size: 14px;
}

.marker-cluster-large {
    width: 44px;
    height: 44px;
    font-size: 15px;
}

.legend-text-short {
    display: none;
}

.day-card {
    display: none;
}

/* phone layout */
@media (max-width: 640px), (max-height: 500px) {
    #map {
        height: 100vh;
        height: 100dvh;
    }

    .map-top-left {
        top: 12px;
        left: 12px;
        gap: 8px;
    }

    .map-back-button,
    .language-switcher {
        width: 44px;
        height: 44px;
        padding: 0;
        border-radius: 22px;
        display: flex;
        align-items: center;
        justify-content: center;
        box-sizing: border-box;
    }

    .back-text {
        display: none;
    }

    .buy-button {
        top: 12px;
        right: 12px;
        height: 44px;
        padding: 0 16px;
        box-sizing: border-box;
        display: flex;
        align-items: center;
        border-radius: 22px;
        font-size: 16px;
        font-weight: 400;
        background-color: rgba(66, 133, 244, 0.9);
    }

    .buy-button:hover {
        transform: none;
    }

    .map-legend {
        left: 12px;
        right: 12px;
        bottom: 28px;
        padding: 0;
        background: none;
        box-shadow: none;
        border-radius: 0;
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
        font-size: 15px;
        pointer-events: none;
    }

    .legend-item {
        position: relative;
        margin: 0;
        height: 40px;
        padding: 0 14px;
        border-radius: 20px;
        background: rgba(255, 255, 255, 0.95);
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
        pointer-events: auto;
        -webkit-tap-highlight-color: transparent;
    }

    .legend-item input {
        position: absolute;
        opacity: 0;
        width: 1px;
        height: 1px;
        margin: 0;
    }

    .legend-item:has(input:not(:checked)) > * {
        opacity: 0.4;
    }

    .legend-item:has(input:not(:checked)) .legend-text-short {
        text-decoration: line-through;
    }

    .legend-item:has(input:focus-visible) {
        outline: 2px solid #4285f4;
    }

    .legend-icon {
        width: 22px;
        height: 22px;
        margin-right: 6px;
    }

    .legend-icon .material-symbols-outlined {
        font-size: 14px;
    }

    .legend-text {
        display: none;
    }

    .legend-text-short {
        display: inline;
    }

    .maplibregl-ctrl-bottom-right .maplibregl-ctrl-group {
        display: none;
    }

    .map-tooltip .maplibregl-popup-content {
        font-size: 15px;
        padding: 4px 8px;
    }

    .day-card {
        display: block;
        position: fixed;
        left: 8px;
        right: 8px;
        bottom: 8px;
        max-width: 520px;
        margin: 0 auto;
        padding: 10px 12px 14px;
        background: #fff;
        border-radius: 16px;
        box-shadow: 0 2px 14px rgba(0, 0, 0, 0.3);
        font-family: 'Raleway', sans-serif;
        color: #222;
        z-index: 1001;
        transform: translateY(calc(100% + 16px));
        transition: transform 0.25s ease;
    }

    .day-card.open {
        transform: none;
    }

    .day-card-header {
        display: flex;
        align-items: center;
        gap: 8px;
        padding-right: 52px;
    }

    .day-card-title {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        line-height: 1.3;
    }

    .day-card-title strong {
        font-size: 20px;
    }

    .day-card-title span {
        font-size: 14px;
        color: #666;
    }

    .day-card-button {
        width: 44px;
        height: 44px;
        flex: none;
        border: none;
        border-radius: 22px;
        background: #f1f1f1;
        color: #333;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    .day-card-button:disabled {
        opacity: 0.3;
        cursor: default;
    }

    .day-card-close {
        position: absolute;
        top: 10px;
        right: 12px;
        background: none;
    }

    .day-card-route {
        margin: 10px 0 12px;
        text-align: center;
        font-size: 17px;
    }

    .day-card-stats {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px 16px;
        margin: 0;
    }

    .day-card-stats div {
        text-align: center;
    }

    .day-card-stats dt {
        font-size: 13px;
        color: #666;
    }

    .day-card-stats dd {
        margin: 2px 0 0;
        font-size: 18px;
    }

    .image-overlay img {
        max-width: 100%;
        max-height: 75%;
    }

    .language-switcher {
        font-size: 16px;
    }

    .image-day {
        font-size: 13px;
    }

    .image-caption {
        font-size: 16px;
        padding: 0 16px;
        max-width: none;
    }

    .nav-arrow.left {
        left: 8px;
    }

    .nav-arrow.right {
        right: 8px;
    }

    .close-button {
        top: 12px;
        right: 12px;
    }
}

@media (max-width: 640px) {
    .map-legend {
        display: grid;
        grid-template-columns: 1fr 1fr;
        max-width: 360px;
        margin: 0 auto;
    }

    .legend-item {
        justify-content: center;
    }
}

@media (max-height: 500px) {
    .day-card-stats {
        grid-template-columns: repeat(4, 1fr);
    }
}
