.mt-hike-map {
    margin: 12px 0 2rem;
    color: #333;
}

:is(p, h1, h2, h3, h4, h5, h6):has(+ section.mt-hike-map) {
    margin-block-end: 0;
}

.mt-hike-map__canvas {
    height: clamp(360px, 60svh, 540px);
    min-height: 350px;
    background: #edf1ed;
    border: 0;
    border-radius: 12px;
    overflow: hidden;
    isolation: isolate;
}

.mt-hike-map .leaflet-tile {
    max-width: none !important;
    max-height: none !important;
    margin: 0 !important;
    box-shadow: none !important;
}

.mt-hike-map__camera {
    box-sizing: border-box;
    position: relative;
    display: grid;
    place-items: center;
    width: 100%;
    height: 100%;
    border: 1px solid white;
    border-radius: 50%;
    background: #1481be;
    box-shadow: 0 1px 4px #0006;
}

.mt-hike-map__camera::before {
    content: "";
    width: 12px;
    height: 9px;
    background: white;
    border-radius: 2px;
}

.mt-hike-map__camera::after {
    content: "";
    position: absolute;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #1481be;
}

.mt-hike-map__camera-count {
    position: absolute;
    z-index: 1;
    right: -5px;
    top: -6px;
    background: #fff;
    border: 1px solid #1481be;
    border-radius: 9px;
    color: #174764;
    padding: 0 4px;
    font-weight: 700;
    line-height: 15px;
}

.mt-hike-map .mt-hike-map__photo-date {
    flex: none;
    height: 1.4em;
    margin: 0 0 4px;
    color: #666;
    font-size: 11px;
    line-height: 1.4;
    text-align: center;
}

a:has(img[data-mt-hike-photo]) {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    border-radius: 12px;
    vertical-align: top;
}

:is(.wp-caption, figure) > a:has(img[data-mt-hike-photo]) {
    display: block;
}

:is(.wp-caption, figure):has(> img[data-mt-hike-photo]) {
    overflow: hidden;
}

.mt-hike-photo-zoom-frame {
    max-width: 100%;
    overflow: hidden;
    border-radius: 12px;
}

img[data-mt-hike-photo].mt-hike-photo-arrival {
    animation: mt-hike-photo-arrival 1.1s ease-in-out !important;
}

@keyframes mt-hike-photo-arrival {
    0%, 100% { transform: scale(1); }
    35% { transform: scale(1.08); }
}

@media (prefers-reduced-motion: reduce) {
    img[data-mt-hike-photo].mt-hike-photo-arrival {
        animation: none !important;
    }
}

.mt-hike-map .mt-hike-map__popup .leaflet-popup-content {
    margin-inline: 8px;
}

.mt-hike-map .mt-hike-map__photo-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: var(--mt-hike-map-preview-height);
    overflow: hidden;
}

.mt-hike-map .mt-hike-map__photo-preview > img {
    display: block;
    float: none;
    flex: 0 1 auto;
    min-height: 0;
    width: auto;
    max-width: 100%;
    max-height: 220px;
    height: auto;
    margin: 0 auto;
    object-fit: contain;
}

.mt-hike-map .mt-hike-map__photo-caption {
    flex: none;
    max-width: 100%;
    max-height: 3em;
    overflow: auto;
    margin: 8px 0 0;
    color: #333;
    line-height: 1.5;
    text-align: center;
    white-space: normal;
    overflow-wrap: anywhere;
}

.mt-hike-map__photo-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 40px;
    gap: 8px;
    margin-top: 6px;
}

.mt-hike-map__photo-actions button {
    display: grid;
    place-items: center;
    flex: 0 0 40px;
    height: 40px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: #fff;
    cursor: pointer;
    touch-action: manipulation;
}

.mt-hike-map__photo-previous {
    --mt-photo-arrow-offset: -4px;
    --mt-photo-arrow-rotation: 180deg;
}

.mt-hike-map__photo-next {
    --mt-photo-arrow-offset: 4px;
    --mt-photo-arrow-rotation: 0deg;
}

.mt-hike-map__photo-actions button::before,
.mt-hike-map__photo-actions button::after {
    content: "";
    grid-area: 1 / 1;
    pointer-events: none;
}

.mt-hike-map__photo-actions button::before {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #1581BE;
    transform: translateX(var(--mt-photo-arrow-offset));
}

.mt-hike-map__photo-actions button::after {
    width: 8px;
    height: 10px;
    background: #fff;
    clip-path: polygon(0 0, 100% 50%, 0 100%);
    transform: translateX(var(--mt-photo-arrow-offset)) rotate(var(--mt-photo-arrow-rotation)) translateX(1px);
}

.mt-hike-map__photo-actions button:focus-visible {
    outline: 2px solid #1581BE;
    outline-offset: -2px;
}

.mt-hike-map__photo-actions button:disabled {
    opacity: 0.35;
    cursor: default;
}

.mt-hike-map__photo-actions a {
    color: #126a9a;
    text-decoration: underline;
    text-align: center;
    white-space: normal;
}

@media (max-width: 600px) {
    .mt-hike-map__canvas {
        height: auto;
        min-height: 0;
        aspect-ratio: 4 / 3;
    }
}

.mt-hike-map .leaflet-control-zoom.leaflet-bar {
    display: grid;
    gap: 6px;
    border: 0;
    box-shadow: none;
}

.mt-hike-map .leaflet-control-zoom.leaflet-bar a {
    display: grid;
    place-items: center;
    box-sizing: border-box;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 50%;
    background: #fff;
    color: #1581BE;
    box-shadow: none;
    text-decoration: none;
}

.mt-hike-map .leaflet-control-zoom.leaflet-bar a::before,
.mt-hike-map .leaflet-control-zoom.leaflet-bar .leaflet-control-zoom-in::after {
    content: "";
    grid-area: 1 / 1;
    width: 12px;
    height: 2px;
    background: currentColor;
    border-radius: 1px;
}

.mt-hike-map .leaflet-control-zoom.leaflet-bar .leaflet-control-zoom-in::after {
    transform: rotate(90deg);
}

.mt-hike-map .leaflet-control-zoom.leaflet-bar a:not(.leaflet-disabled):is(:hover, :active, :focus) {
    background: #1581BE;
    color: #fff;
}

.mt-hike-map .leaflet-control-zoom.leaflet-bar .leaflet-disabled {
    color: #777;
    background: #edf0f2;
}

.mt-hike-map .mt-hike-map__photo-control button {
    display: grid;
    place-items: center;
    box-sizing: border-box;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #1581BE;
    box-shadow: none;
    cursor: pointer;
}

.mt-hike-map .mt-hike-map__photo-control button[aria-pressed="false"] {
    background: #e1e5e8;
}

.mt-hike-map .mt-hike-map__photo-control .mt-hike-map__camera {
    width: 20px;
    height: 20px;
    border: 0;
    background: transparent;
    box-shadow: none;
}

.mt-hike-map .mt-hike-map__photo-control button[aria-pressed="false"] .mt-hike-map__camera::before {
    background: #1581BE;
}

.mt-hike-map .mt-hike-map__photo-control button[aria-pressed="false"] .mt-hike-map__camera::after {
    background: #e1e5e8;
}

.mt-hike-map .mt-hike-map__photo-control button:focus-visible,
.mt-hike-map .leaflet-control-zoom a:focus-visible {
    outline: 2px solid #164c65;
    outline-offset: 2px;
}

.mt-hike-map .mt-hike-map__gpx {
    margin-top: 12px;
}

.mt-hike-map .mt-hike-map__gpx-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(115px, 100%), 1fr));
    gap: 10px 16px;
    margin: 0;
    padding: 10px 0;
    border-bottom: 1px solid #dbe4e8;
}

.mt-hike-map .mt-hike-map__gpx-stats dt {
    margin: 0;
    color: #555;
    font-size: 13px;
    line-height: 1.4;
}

.mt-hike-map .mt-hike-map__gpx-stats dd {
    margin: 2px 0 0;
    font-size: 17px;
    line-height: 1.4;
}

.mt-hike-map .mt-hike-map__gpx-stats dd strong {
    font-weight: 700;
}
.mt-hike-map .mt-hike-map__elevation-source {
    margin: 4px 0 10px;
    color: #666;
    font-size: 12px;
    line-height: 1.5;
}

.mt-hike-map .mt-hike-map__profile {
    margin-top: 8px;
}

.mt-hike-map .mt-hike-map__profile-readout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.55fr) minmax(0, 1.25fr);
    align-items: baseline;
    column-gap: 0.65em;
    max-width: 22em;
    min-height: 1.5em;
    margin: 6px auto 0;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    text-align: start;
}

.mt-hike-map .mt-hike-map__profile-readout > output {
    display: block;
    min-width: 0;
    margin: 0;
    text-align: start;
}

.mt-hike-map .mt-hike-map__plot {
    position: relative;
}

.mt-hike-map .mt-hike-map__plot canvas {
    display: block;
    width: 100%;
    height: 150px;
    margin: 0;
    cursor: crosshair;
    touch-action: none;
}

@media (max-width: 600px) {
    .mt-hike-map .mt-hike-map__gpx-stats {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 10px 8px;
    }

    .mt-hike-map .mt-hike-map__gpx-stats dd {
        font-size: clamp(13px, 3.6vw, 16px);
        white-space: nowrap;
    }
}

.mt-hike-map .mt-hike-map__plot-cursor:not([hidden]) {
    position: absolute;
    display: block;
    width: 10px;
    height: 10px;
    border: 2px solid #fff;
    border-radius: 50%;
    background: #1581BE;
    box-shadow: 0 0 0 1px #1581BE;
    pointer-events: none;
    transform: translate(-50%, -50%);
}

.mt-hike-map .mt-hike-map__plot canvas:focus-visible {
    outline: 2px solid #1581BE;
    outline-offset: 2px;
}

.mt-hike-map .mt-hike-map__bell {
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: #1581BE;
    box-shadow: 0 0 0 2px #fff, 0 1px 5px #0007;
    pointer-events: none;
}

.mt-hike-map .mt-hike-map__bell svg {
    display: block;
    width: 17px;
    height: 17px;
    fill: #fff;
    stroke: none;
}
