/* Descobrir: alternância entre lista e mapa, sem alterar o restante portal. */
.portal-view-switch {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-left: auto;
}

.portal-view-switch .button {
    min-height: 44px;
    font-size: 14px;
}

.portal-map-browser {
    --map-pin-color: #9f7305;
    min-width: 0;
    color: var(--ml-ink);
    font-size: 15px;
}

.portal-map-summary {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px 20px;
    margin-bottom: 16px;
    line-height: 1.6;
}

.portal-map-summary a {
    font-size: 14px;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.portal-map-layout {
    display: grid;
    grid-template-columns: minmax(230px, 280px) minmax(0, 1fr);
    align-items: start;
    gap: 18px;
}

.portal-map-list,
.portal-map-column {
    min-width: 0;
    border: 1px solid var(--ml-border);
    border-radius: 10px;
    background: var(--ml-surface);
}

.portal-map-list-heading {
    padding: 18px;
    border-bottom: 1px solid var(--ml-border);
}

.portal-map-list-heading h2 {
    font-size: 26px;
    line-height: 1.15;
    margin-top: 5px;
}

.portal-map-list-heading .eyebrow {
    font-size: 14px;
}

.portal-map-points {
    list-style: none;
    max-height: 568px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-color: #9f7305 var(--ml-bg);
}

.portal-map-point {
    display: grid;
    grid-template-columns: 58px minmax(0, 1fr);
    gap: 12px;
    padding: 18px 14px;
    border-bottom: 1px solid var(--ml-border);
    border-left: 3px solid transparent;
    transition: background .15s ease, border-color .15s ease;
}

.portal-map-point:last-child {
    border-bottom: 0;
}

.portal-map-point.is-selected {
    background: var(--ml-pale);
    border-left-color: var(--map-pin-color);
}

.portal-map-point-image img {
    display: block;
    width: 58px;
    height: 66px;
    border-radius: 6px;
    object-fit: cover;
}

.portal-map-point-body {
    min-width: 0;
}

.portal-map-point-type {
    display: flex;
    align-items: center;
    gap: 5px;
    color: var(--ml-soft);
    font-size: 14px;
    line-height: 1.4;
}

.portal-map-point-type svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: var(--map-pin-color);
}

.portal-map-point h3 {
    margin: 7px 0;
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 23px;
    line-height: 1.15;
    overflow-wrap: anywhere;
}

.portal-map-point h3 a:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.portal-map-point p,
.portal-map-point .sample-label {
    font-size: 14px;
    line-height: 1.5;
}

.portal-map-point p {
    color: var(--ml-soft);
}

.portal-map-point .sample-label {
    margin-top: 8px;
    padding: 3px 6px;
    letter-spacing: 0;
    text-transform: none;
}

.portal-map-focus {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    margin-top: 6px;
    padding: 6px 0;
    border: 0;
    background: transparent;
    color: #694b00;
    font: inherit;
    font-size: 14px;
    font-weight: 700;
    text-align: left;
    cursor: pointer;
}

.portal-map-focus:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.portal-map-focus:disabled {
    opacity: .6;
    cursor: default;
}

.portal-map-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    padding: 14px;
}

.portal-map-toolbar p {
    flex: 1;
    min-width: 140px;
    font-size: 14px;
    line-height: 1.5;
}

.portal-map-toolbar .button {
    min-height: 44px;
    font-size: 14px;
}

.portal-map-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.portal-map-toolbar .portal-map-zoom {
    width: 44px;
    padding: 0;
    justify-content: center;
    font-size: 22px;
}

/* Um contexto próprio mantém os controlos Leaflet abaixo do menu do site. */
.portal-map-canvas {
    position: relative;
    z-index: 0;
    height: 520px;
    background: #e5e4d7;
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
}

.portal-map-canvas .leaflet-control-attribution {
    max-width: 100%;
    padding: 3px 7px;
    background: #fffdf9ed;
    font-size: 14px;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.portal-map-status {
    padding: 12px 14px;
    border-top: 1px solid var(--ml-border);
    font-size: 14px;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.portal-map-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 18px;
    padding: 14px;
    border-top: 1px solid var(--ml-border);
}

.portal-map-legend > span {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 14px;
    line-height: 1.4;
}

.portal-map-legend-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--map-pin-color);
    color: white;
}

.portal-map-legend-icon svg {
    width: 16px;
    height: 16px;
}

.portal-map-type-parques,
.portal-map-type-trilhos {
    --map-pin-color: #3a5c3a;
}

.portal-map-type-saude,
.portal-map-type-festas,
.portal-map-type-atividades {
    --map-pin-color: #8b3a2a;
}

.portal-map-type-escolas,
.portal-map-type-minibus,
.portal-map-type-mobilidade {
    --map-pin-color: #376276;
}

/* A ponta do marcador corresponde à coordenada, como na referência enviada. */
.portal-map-marker {
    border: 0;
    background: transparent;
}

.portal-map-pin {
    display: block;
    position: relative;
    width: 36px;
    height: 44px;
    transform-origin: 50% 100%;
    transition: transform .15s ease;
    filter: drop-shadow(0 3px 4px #1c17124d);
}

.portal-map-pin-shape {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 2px solid white;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    background: var(--map-pin-color);
    color: white;
}

.portal-map-pin-shape svg {
    width: 18px;
    height: 18px;
    transform: rotate(45deg);
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.portal-map-marker.is-selected .portal-map-pin {
    transform: scale(1.2);
}

.portal-map-pin-count {
    position: absolute;
    top: -10px;
    right: -10px;
    min-width: 24px;
    height: 24px;
    padding: 1px 5px;
    border: 1px solid white;
    border-radius: 99px;
    background: var(--ml-ink);
    color: white;
    font-size: 14px;
    line-height: 20px;
    text-align: center;
}

.portal-map-popup-shell .leaflet-popup-content-wrapper {
    border: 1px solid var(--ml-border);
    border-radius: 10px;
    background: var(--ml-surface);
    color: var(--ml-ink);
    box-shadow: 0 10px 35px #1c17122e;
}

.portal-map-popup-shell .leaflet-popup-tip {
    background: var(--ml-surface);
}

.portal-map-popup-shell .leaflet-popup-content {
    margin: 14px;
    max-width: calc(100vw - 100px);
    font-size: 14px;
    line-height: 1.6;
}

.portal-map-popup {
    max-height: 340px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.portal-map-popup-image {
    display: block;
    width: 100%;
    height: 115px;
    border-radius: 6px;
    object-fit: cover;
}

.portal-map-popup-shell .portal-map-popup h3 {
    margin: 6px 0 10px;
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 26px;
    line-height: 1.1;
}

.portal-map-popup-shell h3 a {
    color: var(--ml-ink);
}

.portal-map-popup-shell h3 a:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.portal-map-popup-shell .portal-map-popup p {
    margin: 10px 0;
    font-size: 14px;
    line-height: 1.6;
}

.portal-map-popup-type,
.portal-map-popup-address {
    color: var(--ml-soft);
}

.portal-map-popup-item + .portal-map-popup-item {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--ml-border);
}

.portal-map-popup-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 16px;
    margin-top: 15px;
}

.portal-map-popup-actions .button {
    min-height: 44px;
    font-size: 14px;
    color: white;
}

.portal-map-popup-shell .portal-map-directions {
    color: #694b00;
    font-size: 14px;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.portal-map-popup-shell a.leaflet-popup-close-button {
    top: 4px;
    right: 4px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--ml-surface);
    color: var(--ml-ink);
    font-size: 26px;
    line-height: 44px;
}

@media (max-width: 1150px) {
    .portal-map-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .portal-map-column {
        grid-row: 1;
    }

    .portal-map-points {
        max-height: 500px;
    }
}

@media (max-width: 760px) {
    .portal-map-canvas {
        height: 430px;
    }

    .portal-view-switch {
        margin-left: 0;
    }

    .portal-map-point {
        grid-template-columns: 66px minmax(0, 1fr);
    }

    .portal-map-point-image img {
        width: 66px;
        height: 72px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .portal-map-pin,
    .portal-map-point {
        transition: none;
    }
}
