/* Carte publique des producteurs (page d'accueil) */
.ma-map-page {
    --ma-green: #2f7d32;
    --ma-green-dark: #1f5d23;
    --ma-ink: #161e2d;
    --ma-muted: #5c6368;
    --ma-line: #e4e7ea;
    display: grid;
    grid-template-columns: minmax(340px, 420px) 1fr;
    height: calc(100vh - 78px);
    height: calc(100dvh - 78px);
    min-height: 560px;
    border-top: 1px solid var(--ma-line);
}

.ma-map-panel { display: flex; flex-direction: column; min-height: 0; background: #fff; border-right: 1px solid var(--ma-line); }
.ma-map-panel-head { padding: 20px 20px 14px; border-bottom: 1px solid var(--ma-line); }
.ma-map-title { font-size: 1.35rem; line-height: 1.25; margin: 0 0 4px; color: var(--ma-ink); }
.ma-map-intro { margin: 0 0 14px; color: var(--ma-muted); font-size: .95rem; }

/* Formulaire : le thème public arrondit et agrandit les champs, on reprend la main ici */
.ma-map-search { display: grid; gap: 10px; }
.ma-map-page .ma-field--place { grid-template-columns: 1fr auto; }
.ma-map-page .ma-input {
    height: 46px; min-height: 46px; padding: 8px 12px; border-radius: 12px;
    border: 1px solid #c9ced3; font-size: 1rem; line-height: 1.3; box-shadow: none;
}
.ma-map-page select.ma-input { padding-right: 32px; }
.ma-place-wrap { position: relative; }
.ma-place-wrap .ma-input { padding-left: 40px; }
.ma-place-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; color: var(--ma-muted); pointer-events: none; display: flex; }
.ma-place-icon svg { width: 20px; height: 20px; }
.ma-map-page .ma-btn { height: 46px; border-radius: 12px; }
.ma-map-page .ma-btn svg { width: 20px; height: 20px; flex: none; }
.ma-btn--filters { display: none; position: relative; }
.ma-badge[hidden] { display: none; }

.ma-suggestions {
    position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px);
    margin: 0; padding: 4px; list-style: none; background: #fff;
    border: 1px solid var(--ma-line); border-radius: 12px; box-shadow: 0 12px 28px rgba(0, 0, 0, .14);
}
.ma-suggestions [role="option"] { display: grid; padding: 10px 12px; border-radius: 8px; cursor: pointer; }
.ma-suggestions [role="option"] small { color: var(--ma-muted); }
.ma-suggestions [role="option"][aria-selected="true"],
.ma-suggestions [role="option"]:hover { background: #eef6ee; }

/* Liste des fermes de la zone */
.ma-map-results { flex: 1; min-height: 0; display: flex; flex-direction: column; background: #fff; }
.ma-results-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 20px 0; }
.ma-results-head [hidden] { display: none; }
.ma-results-count { font-size: 1rem; margin: 0; color: var(--ma-ink); }
.ma-results-status { margin: 4px 20px 8px; color: var(--ma-muted); font-size: .85rem; min-height: 1.2em; }
.ma-results { list-style: none; margin: 0; padding: 0 12px 16px; overflow-y: auto; flex: 1; overscroll-behavior: contain; }

.ma-result {
    display: grid; grid-template-columns: 56px 1fr; column-gap: 12px; align-items: start;
    padding: 12px 8px; border-bottom: 1px solid var(--ma-line); border-radius: 10px;
    transition: background-color .15s;
}
.ma-result:hover { background: #f6f8f6; }
.ma-result.is-selected { background: #eef6ee; }
.ma-result-photo { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; background: #f2f4f5; }
.ma-result-photo--empty { display: block; position: relative; background: linear-gradient(135deg, #f1f7f0, #e7efe6); }
.ma-result-photo--empty::after {
    content: ""; position: absolute; inset: 0; margin: auto; width: 16px; height: 16px; border-radius: 50%;
    background: var(--dot); border: 3px solid #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .15);
}
.ma-result-body { min-width: 0; }
.ma-result-title { font-size: 1rem; margin: 0; line-height: 1.3; }
.ma-result-title a { color: var(--ma-ink); text-decoration: none; }
.ma-result-title a:hover { color: var(--ma-green-dark); text-decoration: underline; }
.ma-result-meta { margin: 2px 0 6px; color: var(--ma-muted); font-size: .85rem; }
.ma-result-locate {
    margin-top: 4px; min-height: 32px;
    background: none; border: 0; padding: 2px 0; color: var(--ma-green-dark); font-weight: 600; font-size: .85rem; text-decoration: underline; cursor: pointer;
}
.ma-result-empty { padding: 24px 8px; color: var(--ma-muted); }
.ma-verified { color: #8a5300; font-weight: 600; }

/* Carte */
.ma-map-canvas-wrap { position: relative; min-height: 0; background: #eef0ec; }
/* MapLibre impose position: relative sur le conteneur : on force le remplissage du bloc */
.ma-map-canvas { position: absolute !important; inset: 0; width: 100%; height: 100%; }
.ma-map-canvas:focus-visible { outline: 3px solid var(--ma-green); outline-offset: -3px; }
.ma-map-fallback { margin: 24px; padding: 16px; color: var(--ma-ink); background: #fff; border-radius: 12px; max-width: 420px; }

.ma-map-overlay {
    position: absolute; inset: 0; z-index: 4; display: grid; place-items: center;
    background: rgba(238, 240, 236, .55); pointer-events: none;
}
.ma-map-overlay[hidden] { display: none; }
.ma-map-overlay.is-error { pointer-events: auto; }
.ma-map-overlay-box {
    display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center;
    padding: 18px 22px; background: #fff; border-radius: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .12); max-width: 300px;
}
.ma-map-overlay-box p { margin: 0; color: var(--ma-ink); font-weight: 600; }
.ma-map-overlay.is-error .ma-spinner { display: none; }
.ma-spinner {
    width: 28px; height: 28px; border-radius: 50%;
    border: 3px solid #d7e5d6; border-top-color: var(--ma-green); animation: ma-spin .8s linear infinite;
}
@keyframes ma-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .ma-spinner { animation-duration: 2.4s; } }

.ma-map-legend {
    position: absolute; left: 12px; bottom: 12px; z-index: 2;
    background: rgba(255, 255, 255, .96); border-radius: 12px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .12); font-size: .8rem;
}
.ma-map-legend summary {
    display: flex; align-items: center; gap: 6px; min-height: 36px; padding: 6px 12px;
    font-weight: 700; cursor: pointer; list-style: none;
}
.ma-map-legend summary::-webkit-details-marker { display: none; }
.ma-map-legend summary::after { content: "▴"; font-size: .7rem; color: var(--ma-muted); }
.ma-map-legend[open] summary::after { content: "▾"; }
.ma-map-legend ul { list-style: none; margin: 0; padding: 0 12px 10px; display: grid; gap: 3px; }
.ma-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .15); }
.ma-dot--owned { background: #fff; border-color: #f59f00; box-shadow: none; border-width: 3px; }

.maplibregl-ctrl-group button { width: 36px; height: 36px; }

/* Popup */
.ma-popup .maplibregl-popup-content { padding: 0; border-radius: 14px; overflow: hidden; box-shadow: 0 16px 40px rgba(0, 0, 0, .22); }
.ma-popup .maplibregl-popup-close-button { width: 36px; height: 36px; font-size: 22px; background: rgba(255, 255, 255, .92); border-radius: 0 14px 0 10px; }
.ma-popup-photo { display: block; width: 100%; height: 140px; object-fit: cover; }
.ma-popup-body { padding: 14px 16px 16px; }
.ma-popup-title { font-size: 1.05rem; margin: 0 28px 2px 0; line-height: 1.3; }
.ma-popup-meta { margin: 0 0 8px; color: var(--ma-muted); }
.ma-popup-cats { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 8px; }
.ma-popup-actions { display: flex; gap: 8px; margin-top: 10px; }
.ma-popup-actions .ma-btn { flex: 1; min-height: 42px; }

/* Bascule carte / liste : mobile seulement */
.ma-view-switch { display: none; }

/* Appel aux producteurs */
.ma-producer-cta { padding: 48px 0; background: #f4f8f4; }
.ma-producer-cta-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 20px; }
.ma-producer-cta h2 { font-size: 1.5rem; margin: 0 0 6px; }
.ma-producer-cta p { margin: 0; max-width: 640px; color: var(--ma-muted); }

/* ---------- Tablette et mobile : recherche compacte, puis carte OU liste ---------- */
@media (max-width: 991.98px) {
    .ma-map-page { display: flex; flex-direction: column; height: auto; min-height: 0; }
    .ma-map-panel { display: contents; }
    .ma-map-panel-head { order: 1; padding: 12px 16px; position: relative; z-index: 6; background: #fff; }
    .ma-map-title { font-size: 1.1rem; margin-bottom: 10px; }
    .ma-map-intro { display: none; }
    .ma-map-search { gap: 0; }
    .ma-map-page .ma-field--place { grid-template-columns: 1fr auto auto; gap: 8px; }
    .ma-field--place > label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
    .ma-btn--filters { display: inline-flex; }

    .ma-map-filters { display: none; margin-top: 10px; }
    .ma-map-filters.is-open { display: grid; }

    .ma-map-canvas-wrap { order: 2; height: calc(100svh - 78px - 106px); min-height: 360px; }
    .ma-map-results { order: 2; min-height: calc(100svh - 78px - 106px); }
    .ma-results { overflow: visible; padding-bottom: 84px; }

    .ma-map-page[data-view="map"] .ma-map-results { display: none; }
    .ma-map-page[data-view="list"] .ma-map-canvas-wrap { display: none; }

    /* Bouton flottant en bas de l'écran, au-dessus de la carte ou de la liste */
    .ma-view-switch {
        order: 3; display: flex; justify-content: center;
        position: sticky; bottom: 16px; z-index: 7; height: 0; pointer-events: none;
    }
    .ma-view-btn {
        pointer-events: auto; transform: translateY(-64px);
        display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 10px 20px;
        border: 0; border-radius: 999px; background: var(--ma-ink); color: #fff; font-weight: 600; font-size: .95rem;
        box-shadow: 0 8px 24px rgba(0, 0, 0, .28); cursor: pointer;
    }
    .ma-view-btn:focus-visible { outline: 3px solid #fff; box-shadow: 0 0 0 6px var(--ma-ink); }
    .ma-view-btn-icon { display: flex; }
    .ma-view-btn-icon svg { width: 20px; height: 20px; }
    .ma-map-page[data-view="map"] .ma-view-btn-icon--map,
    .ma-map-page[data-view="list"] .ma-view-btn-icon--list { display: none; }

    .ma-map-legend { bottom: 12px; font-size: .75rem; }
    .ma-map-page .maplibregl-ctrl-scale { display: none; }
}
@media (max-width: 575.98px) {
    /* Boutons réduits à leur icône : le libellé reste lu par les lecteurs d'écran */
    .ma-field--place .ma-btn { width: 46px; padding: 0; }
    .ma-field--place .ma-btn-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
    .ma-btn--filters .ma-badge { position: absolute; top: -6px; right: -6px; }
    .ma-map-page .ma-field-row { grid-template-columns: 1fr; gap: 8px; }
    .ma-map-legend { top: 12px; bottom: auto; }
}

/* Sans WebGL : liste seule, pas de bascule vers une carte absente */
.ma-map-page[data-no-map] .ma-view-switch { display: none; }
.ma-map-page select.ma-input { font-size: .95rem; }
.ma-map-legend summary::after { content: "▴" / ""; }
.ma-map-legend[open] summary::after { content: "▾" / ""; }

/* Cibles tactiles d'au moins 44 px sur écran tactile */
@media (pointer: coarse) {
    .ma-result-locate, .ma-map-legend summary { min-height: 44px; }
    .maplibregl-ctrl-group button { width: 44px; height: 44px; }
    .ma-popup .maplibregl-popup-close-button { width: 44px; height: 44px; }
}
/* Le bouton flottant carte/liste ne doit pas masquer l'élément qui a le focus */
@media (max-width: 991.98px) { html { scroll-padding-bottom: 96px; } }

/* ---------- Marchés de producteurs ---------- */
.ma-market-dot {
    display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%;
    background: #9a3412; color: #fff; font-size: 11px; font-weight: 700; line-height: 1; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .2);
    vertical-align: middle; margin-right: 4px;
}
.ma-map-legend .ma-market-dot { width: 16px; height: 16px; font-size: 9px; margin-right: 6px; }
.ma-check { display: flex; align-items: center; gap: 8px; min-height: 44px; margin: 0; cursor: pointer; font-size: .9rem; color: var(--ma-ink); grid-column: 1 / -1; }
.ma-check input { width: 18px; height: 18px; accent-color: var(--ma-green); }
.ma-market-kind { margin: 0 0 2px; font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: #9a3412; }
.ma-market-sessions { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; font-size: .9rem; }
.ma-market-sessions li { display: grid; gap: 2px; }
.ma-market-farms { color: var(--ma-muted); }
.ma-market-farms a { color: var(--ma-green-dark); }
.ma-market-list { margin: 0 20px 8px; border: 1px solid #f1d3c3; border-radius: 12px; background: #fff8f4; }
.ma-market-list[hidden] { display: none; }
.ma-market-list > summary { padding: 10px 14px; font-weight: 600; cursor: pointer; color: #7c2d12; min-height: 44px; display: flex; align-items: center; }
.ma-market-list > ul { list-style: none; margin: 0; padding: 0 8px 8px; display: grid; gap: 8px; }
.ma-market-item { background: #fff; border-radius: 10px; border: 1px solid var(--ma-line); padding: 4px 6px 8px; }
.ma-market-item .ma-popup-body { padding: 8px 8px 0; }
.ma-market-item .ma-popup-title { font-size: 1rem; margin: 0; }
.ma-market-item .ma-popup-actions { display: none; }
.ma-market-item .ma-result-locate { margin-left: 8px; }
@media (max-width: 991.98px) { .ma-market-list { margin: 0 16px 8px; } }/* Colonne de résultats : en-tête, message et marchés ne se tassent pas ; seule la liste des fermes défile */
.ma-results-head, .ma-results-status, .ma-market-list { flex-shrink: 0; }
.ma-market-list[open] > ul { max-height: 40vh; overflow-y: auto; overscroll-behavior: contain; }
@media (max-width: 991.98px) { .ma-market-list[open] > ul { max-height: none; overflow: visible; } }

.ma-market-page { margin: 8px 0 0; font-size: .9rem; }
.ma-market-page a { color: var(--ma-green-dark); font-weight: 600; }

/* Filtre « Ouvert maintenant » et statut d'ouverture dans la liste */
.ma-check-group { grid-column: 1 / -1; }
.ma-check-group .ma-check svg { width: 18px; height: 18px; color: var(--ma-green-dark); }
.ma-check-help { margin: -6px 0 0 26px; font-size: .8rem; color: var(--ma-muted); }
.ma-result-open { display: inline-flex; align-items: center; gap: 4px; margin: 0 0 6px; padding: 1px 8px; border-radius: 999px; background: #e3f3e4; color: #146c2e; font-size: .8rem; font-weight: 600; }

/* Cœur « Favori » dans la liste et les fenêtres de la carte */
.ma-result { position: relative; }

.ma-map-fav {
    display: inline-grid; place-items: center; width: 44px; height: 44px; padding: 0;
    border: 0; border-radius: 50%; background: transparent; color: #5c6368; cursor: pointer;
}
.ma-map-fav svg { width: 22px; height: 22px; }
.ma-map-fav:hover { background: #fdecef; color: #8a1c33; }
.ma-map-fav[aria-pressed="true"] { color: #8a1c33; }
.ma-map-fav[aria-pressed="true"] svg, .ma-map-fav[aria-pressed="true"] svg path { fill: currentColor; }
.ma-map-fav:focus-visible { outline: 3px solid var(--ma-green); outline-offset: 1px; }

.ma-popup-actions .ma-map-fav { border: 1px solid var(--ma-line); }
#wrapper .ma-results-count { line-height: 1.3; }
.ma-popup-actions .ma-map-fav { flex: none; }
@media (pointer: coarse) { .ma-popup-actions .ma-btn { min-height: 44px; } }
.ma-map-producer { display: block; margin-top: 6px; font-weight: 600; color: var(--ma-green-dark); }

/* ---------- Ordinateur : panneau plus large, recherche compacte, liste lisible ---------- */
.ma-map-page { grid-template-columns: clamp(380px, 33vw, 560px) 1fr; }
.ma-map-page.is-wide { grid-template-columns: minmax(380px, 50%) 1fr; }
.ma-map-panel-head { padding: 16px 20px 12px; }
.ma-map-title { font-size: 1.25rem; }
.ma-map-intro { margin: 0 0 12px; font-size: .9rem; }
.ma-map-intro .ma-map-producer { display: inline; margin: 0; }
.ma-map-search { gap: 8px; }
.ma-field--place > label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ma-map-page .ma-field--place, .ma-map-page .ma-field--product { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.ma-btn--filters { display: inline-flex; }
.ma-btn--filters .ma-badge { margin-left: 4px; }
.ma-map-filters { display: none; margin-top: 4px; padding: 12px; border: 1px solid var(--ma-line); border-radius: 12px; background: #fafbfa; }
.ma-map-filters.is-open { display: grid; }

.ma-results-head { flex-wrap: wrap; row-gap: 4px; }
.ma-widen {
    display: inline-flex; align-items: center; gap: 6px; min-height: 36px; margin-left: auto; padding: 4px 10px;
    border: 1px solid var(--ma-line); border-radius: 999px; background: #fff; color: var(--ma-ink); font-size: .85rem; font-weight: 600; cursor: pointer;
}
.ma-widen:hover { border-color: var(--ma-green); color: var(--ma-green-dark); }
.ma-widen svg { width: 16px; height: 16px; }
.ma-widen-off, .ma-map-page.is-wide .ma-widen-on { display: none; }
.ma-map-page.is-wide .ma-widen-off { display: inline-flex; align-items: center; gap: 6px; }
.ma-widen-on { display: inline-flex; align-items: center; gap: 6px; }
@media (max-width: 1199.98px) { .ma-widen { display: none; } .ma-map-page.is-wide { grid-template-columns: clamp(380px, 33vw, 560px) 1fr; } }

/* Liste : barre de défilement visible et confortable, cartes aérées mais compactes */
.ma-results { padding: 4px 12px 16px; scrollbar-gutter: stable; scrollbar-width: auto; scrollbar-color: #9aa5a0 transparent; }
.ma-results::-webkit-scrollbar { width: 12px; }
.ma-results::-webkit-scrollbar-thumb { background: #b4bdb8; border-radius: 8px; border: 3px solid #fff; }
.ma-results::-webkit-scrollbar-thumb:hover { background: #8a958f; }
.ma-result { grid-template-columns: 64px 1fr auto; padding: 12px 8px; }
.ma-result-photo { width: 64px; height: 64px; }
.ma-result-title { font-size: 1.05rem; font-weight: 700; }
.ma-result-meta { margin: 2px 0 4px; font-size: .9rem; }
.ma-result-distance { font-weight: 600; color: var(--ma-ink); }
.ma-result-owned { margin: 0 0 4px; color: #8a5300; font-size: .8rem; font-weight: 600; }
.ma-result-actions { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.ma-result-pin {
    display: inline-grid; place-items: center; width: 44px; height: 44px; padding: 0;
    border: 0; border-radius: 50%; background: transparent; color: var(--ma-green-dark); cursor: pointer;
}
.ma-result-pin:hover { background: #eef6ee; }
.ma-result-pin:focus-visible { outline: 3px solid var(--ma-green); outline-offset: 1px; }
@media (min-width: 1200px) {
    .ma-map-page.is-wide .ma-results { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 8px; align-content: start; }
}
@media (max-width: 991.98px) {
    .ma-map-page, .ma-map-page.is-wide { grid-template-columns: none; }
    .ma-map-intro { display: none; }
    .ma-map-canvas-wrap { height: calc(100svh - 78px - 160px); }
    .ma-map-results { min-height: calc(100svh - 78px - 160px); }
}
@media (max-width: 575.98px) {
    .ma-field--product .ma-btn { width: auto; padding: 0 12px; }
}
.ma-results-head { flex-wrap: nowrap; }
.ma-results-status { font-size: .8rem; margin-bottom: 6px; }
.ma-results-status:empty { display: none; }
.ma-market-list > summary { min-height: 40px; padding: 8px 12px; font-size: .9rem; }
.ma-result-actions { gap: 0; }
@media (max-width: 1439.98px) { .ma-map-title { font-size: 1.1rem; } }
