.villages-layout {
    display: grid;
    grid-template-columns: clamp(10rem, 18vw, 14rem) minmax(0, 1fr);
    grid-template-areas: "list intro" "list map";
    grid-template-rows: auto 1fr;
    align-items: start;
    gap: 2rem clamp(1.5rem, 4vw, 3.75rem);
    padding: clamp(2rem, 4.5vw, 4.1rem) var(--gutter) clamp(2.5rem, 5vw, 4.7rem);
}

.villages-intro { grid-area: intro; }
.villages-sidebar { grid-area: list; }
.villages-map-section { grid-area: map; }

.villages-intro h1, .villages-layout h2 {
    margin: 0 0 .65rem;
    font: 400 clamp(2.3rem, 4.6vw, 4.1rem)/1.1 var(--serif);
    letter-spacing: -.045em;
}

.villages-layout h2 {
    font-size: clamp(1.5rem, 2.6vw, 2.25rem);
    letter-spacing: -.025em;
}

.villages-intro p, .villages-map-section p {
    margin: 0 0 1rem;
    color: var(--muted);
    overflow-wrap: anywhere;
}

.villages-map-section p { max-width: 85ch; }
.villages-intro p:last-of-type { margin-bottom: 0; }
.villages-intro a, .villages-map-section a { text-underline-offset: .2em; }

.villages-sidebar {
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: .5rem;
    background: var(--surface);
}

.villages-sidebar h2 {
    padding: .15rem .55rem .9rem;
    margin: 0 0 .3rem;
    border-bottom: 1px solid var(--line);
    font-size: 1.45rem;
}

.villages-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.villages-list a {
    display: flex;
    align-items: center;
    min-height: 2.12rem;
    padding: .25rem .55rem;
    border-radius: .25rem;
    text-decoration: none;
}

.villages-list a:hover, .villages-list a:focus-visible {
    background: #e8eddf;
    text-decoration: underline;
    text-underline-offset: .2em;
}

.villages-list-jump { display: none; }

.villages-map-figure {
    margin: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: .5rem;
    background: var(--surface);
}

#muhu-map {
    height: clamp(25rem, 50vw, 37rem);
    background: #dce8e9;
    font: 1rem/1.4 var(--sans);
    isolation: isolate;
}

#muhu-map:focus-visible { outline-offset: -3px; }

.villages-map-figure figcaption {
    padding: .55rem .85rem;
    color: var(--muted);
    font-size: .8rem;
}

.leaflet-marker-icon.village-pin { pointer-events: none; }

.village-map-marker {
    position: absolute;
    inset: 50% auto auto 50%;
    width: var(--pin-hit, 24px);
    height: var(--pin-hit, 24px);
    transform: translate(-50%, -50%);
    border-radius: 50%;
    color: var(--ink) !important;
    text-decoration: none;
    pointer-events: auto;
}

.village-map-marker::before {
    content: "";
    position: absolute;
    inset: 50% auto auto 50%;
    width: .65rem;
    height: .65rem;
    transform: translate(-50%, -50%);
    pointer-events: none;
    border: 1.5px solid #fffdf7;
    border-radius: 50%;
    background: #305543;
    box-shadow: 0 0 0 1px #305543;
}

.village-map-marker:hover::before, .village-map-marker:focus-visible::before {
    background: #a64b25;
    box-shadow: 0 0 0 1px #a64b25;
}

.village-map-label {
    position: absolute;
    left: calc(50% + 8px);
    top: 50%;
    width: max-content;
    padding: 0 .18rem;
    transform: translateY(-50%);
    visibility: hidden;
    font-size: .78rem;
    font-weight: 650;
    text-shadow: 0 0 3px #fffdf7, 0 0 4px #fffdf7, 0 0 5px #fffdf7;
}

.village-map-label[data-side="left"] {
    left: auto;
    right: calc(50% + 8px);
}

.village-map-label[data-side="top"] {
    left: 50%;
    top: calc(50% - 8px);
    transform: translate(-50%, -100%);
}

.village-map-label[data-side="bottom"] {
    left: 50%;
    top: calc(50% + 8px);
    transform: translateX(-50%);
}

.label-visible .village-map-label { visibility: visible; }

.village-map-marker:hover .village-map-label,
.village-map-marker:focus-visible .village-map-label {
    visibility: visible;
    color: #fffdf7;
    background: #305543;
    border-radius: .2rem;
    text-shadow: none;
}

.map-reset {
    padding: .45rem .7rem;
    border: 1px solid #a3aca2;
    border-radius: .25rem;
    background: #fffdf7;
    color: var(--ink);
    font: 650 .85rem/1.2 var(--sans);
    cursor: pointer;
}

.map-reset:hover { background: #e8eddf; }

@media (max-width: 52rem) {
    .villages-layout {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas: "intro" "map" "list";
        grid-template-rows: auto;
    }

    .villages-list-jump {
        display: inline-block;
        margin-top: 1rem;
        font-weight: 650;
    }

    .villages-list { columns: 3 7rem; column-gap: .5rem; }
    .villages-list li { break-inside: avoid; }
    .villages-list a { min-height: 2.75rem; }
    #muhu-map { height: clamp(21rem, 65vw, 31rem); }
}
