/* Home map — menu box and search */
.map-wrap { position: relative; z-index: 0; }
#town-main-map { height: clamp(390px, calc(75vh - 90px), 660px); width: 100%; border-radius: 8px; }
@media (max-width: 640px) {   /* phone: keep the map clear of the sticky header and short enough to see the footer */
  .map-wrap:not(.map-expanded) { scroll-margin-top: 155px; }   /* clear of the sticky header when scrolled or jumped to */
  .map-wrap:not(.map-expanded) #town-main-map { height: clamp(220px, calc(75vh - 270px), 480px); }
}
.map-menu { border: 1px solid #d6d6d6; border-radius: 8px; background: #fff; margin: 0.75rem 0; }
.map-menu > summary { cursor: pointer; padding: 0.6rem 0.9rem; font-weight: 600; }
.map-menu .menu-body { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; padding: 0.25rem 0.9rem 0.9rem; }
.map-menu fieldset { border: 1px solid #eee; border-radius: 6px; padding: 0.6rem 0.8rem; margin: 0; }
.map-menu legend { font-weight: 600; padding: 0 0.3rem; }
.map-menu label { display: block; margin: 0.35rem 0 0.15rem; font-size: 0.9rem; }
.map-menu select, .map-menu input[type=text], .map-menu input[type=date], .map-menu input[type=search] { width: 100%; padding: 0.4rem; border: 1px solid #bbb; border-radius: 4px; box-sizing: border-box; }
.map-menu .row { display: flex; gap: 0.5rem; align-items: center; }
.map-menu .row > * { flex: 1; }
.map-menu .check { display: flex; align-items: center; gap: 0.4rem; }
.map-menu .check input { width: auto; }
.map-menu button, .tp-go { padding: 0.45rem 0.8rem; border-radius: 4px; border: 1px solid var(--primary, #2e7d32); background: var(--primary, #2e7d32); color: #fff; cursor: pointer; }
.map-menu button.plain { background: #fff; color: var(--primary, #2e7d32); }
.map-menu .buttons { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.6rem; }
#mapStatus { margin: 0.25rem 0; font-size: 0.9rem; color: #4a4a4a; min-height: 1.2rem; }
.result-list { list-style: none; margin: 0.5rem 0 0; padding: 0; max-height: 240px; overflow-y: auto; border: 1px solid #eee; border-radius: 6px; }
.result-list:empty { display: none; }
.result-list li button { display: block; width: 100%; text-align: left; background: #fff; color: inherit; border: 0; border-bottom: 1px solid #eee; border-radius: 0; padding: 0.45rem 0.6rem; cursor: pointer; }
.result-list li button:hover, .result-list li button:focus { background: #f3f8f3; }
.result-list small { color: #4a4a4a; }
#townActions { margin-top: 0.6rem; font-size: 0.9rem; }
#townActions p { margin: 0.2rem 0; }
.map-pin { --pin: var(--primary, #2e7d32); position: relative; background: var(--primary, #2e7d32); color: #fff; border-radius: 50%; width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; font-size: 15px; box-shadow: 0 1px 4px rgba(0,0,0,.35); }
.map-pin.event { background: #e67e22; --pin: #e67e22; }
.map-pin.site-pin { background: #2e7d32; --pin: #2e7d32; }   /* heritage sites: green, as on the walk maps (30 Nov) */
.map-error { padding: 1rem; color: #b00020; }
/* Town picker (account page; later event and walk forms) */
.town-picker .tp-row { display: flex; gap: 0.4rem; }
.town-picker .tp-row input { flex: 1; padding: 0.5rem; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; }
.town-picker .tp-current { margin: 0.4rem 0; font-weight: 600; }
.town-picker .tp-note { font-size: 0.85rem; color: #4a4a4a; margin: 0.25rem 0; }

/* Buttons over the map, expanded map, Options popup */
.map-ctl { display: block; width: 34px; height: 34px; font-size: 18px; line-height: 30px; text-align: center; cursor: pointer; background: #fff; color: #333; border: 2px solid rgba(0,0,0,.25); border-radius: 4px; padding: 0; }
.map-ctl:hover, .map-ctl:focus { background: #f3f8f3; }
.map-wrap.map-expanded { position: fixed; inset: 0; z-index: 2000; background: #fff; padding: 0; }
.map-wrap.map-expanded #town-main-map { height: 100vh; border-radius: 0; }
body.map-lock { overflow: hidden; }
.map-dialog { border: 1px solid #ccc; border-radius: 10px; padding: 1rem 1.2rem; max-width: 460px; width: calc(100% - 2rem); }
.map-dialog::backdrop { background: rgba(0,0,0,.4); }
.map-dialog .dlg-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.5rem; margin-bottom: 0.4rem; }
.map-dialog .dlg-head h2 { margin: 0; }
.map-dialog button.dlg-close { background: #fff; color: #333; border: 1px solid #bbb; padding: 0.25rem 0.6rem; font-size: 0.9rem; white-space: nowrap; }
.map-dialog .dlg-style { display: block; margin: 0.3rem 0 0; font-weight: 600; }
.map-dialog select#mapStyle { margin-bottom: 0.8rem; }
.map-dialog h2 { margin: 0 0 0.6rem; font-size: 1.2rem; }
.map-dialog fieldset { border: 1px solid #eee; border-radius: 6px; margin: 0 0 0.8rem; padding: 0.5rem 0.8rem; }
.map-dialog legend { font-weight: 600; padding: 0 0.3rem; }
.map-dialog .check { display: flex; align-items: center; gap: 0.4rem; margin: 0.25rem 0; }
.map-dialog select { width: 100%; padding: 0.4rem; margin-top: 0.3rem; }
.map-dialog #typeFilter { max-height: 260px; overflow-y: auto; }
.map-dialog .count { color: #4a4a4a; font-size: 0.85rem; }
.map-dialog button { padding: 0.45rem 0.9rem; border-radius: 4px; border: 1px solid var(--primary, #2e7d32); background: var(--primary, #2e7d32); color: #fff; cursor: pointer; }
.map-dialog button.plain { background: #fff; color: var(--primary, #2e7d32); }
.map-dialog .buttons { display: flex; gap: 0.5rem; margin-top: 0.5rem; }
.map-menu .note { font-size: 0.85rem; color: #4a4a4a; margin: 0.5rem 0 0; }

/* Walks: route editor and walks map */
.wp { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 3px solid #2e7d32; box-sizing: border-box; }
.wp.start { background: #2e7d32; border-color: #1b5e20; width: 18px; height: 18px; margin: -2px; }
.wp.end { background: #c62828; border-color: #8e0000; width: 18px; height: 18px; margin: -2px; }
.town-chips { margin-top: 0.5rem; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.town-chip { background: #eef6ee; border: 1px solid #cfe3cf; border-radius: 999px; padding: 0.2rem 0.6rem; font-size: 0.9rem; }
.town-chip button { border: 0; background: none; cursor: pointer; color: #a00; padding: 0 0.2rem; }
#walksMap { height: clamp(450px, 68vh, 690px); width: 100%; border-radius: 8px; margin: 0.75rem 0; }
.walks-tools { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0.75rem; margin: 0.5rem 0; }
.walks-tools label { display: block; font-size: 0.9rem; margin-bottom: 0.2rem; font-weight: 600; }
.walks-tools input[type=search], .walks-tools input[type=text] { width: 100%; padding: 0.45rem; border: 1px solid #bbb; border-radius: 4px; box-sizing: border-box; }
.walk-card.is-hit { outline: 3px solid var(--primary, #2e7d32); }
.walk-card[hidden] { display: none; }

/* Side panel (replaces popups) */
.side-panel { position: absolute; z-index: 1000; top: 0.6rem; bottom: 0.6rem; left: 0.6rem; width: min(360px, 38%); min-width: 280px; background: #fff; border-radius: 8px; box-shadow: 0 2px 14px rgba(0,0,0,.3); display: flex; flex-direction: column; overflow: hidden; }
.side-panel[hidden] { display: none; }
.sp-head { display: flex; align-items: flex-start; gap: 0.5rem; padding: 0.7rem 0.8rem 0.4rem; border-bottom: 1px solid #eee; }
.sp-titles { flex: 1; min-width: 0; }
.sp-title { margin: 0; font-size: 1.1rem; line-height: 1.25; overflow-wrap: anywhere; }
.sp-sub { color: #4a4a4a; font-size: 0.85rem; }
.sp-close { border: 0; background: #f0f0f0; border-radius: 50%; width: 2rem; height: 2rem; cursor: pointer; font-size: 1rem; flex: none; }
.sp-tabs { display: flex; border-bottom: 1px solid #ddd; }
.sp-tabs:empty { display: none; }
.sp-tab { flex: 1; padding: 0.5rem; border: 0; background: none; cursor: pointer; border-bottom: 3px solid transparent; font: inherit; }
.sp-tab[aria-selected="true"] { border-bottom-color: var(--primary, #2e7d32); font-weight: 600; }
.sp-body { overflow-y: auto; padding: 0.7rem 0.8rem; flex: 1; }
.sp-facts { display: grid; grid-template-columns: auto 1fr; gap: 0.2rem 0.8rem; margin: 0 0 0.7rem; }
.sp-facts dt { color: #4a4a4a; }
.sp-facts dd { margin: 0; }
.sp-text { margin: 0 0 0.7rem; }
.sp-links { display: flex; flex-direction: column; gap: 0.4rem; margin: 0.5rem 0; }
.sp-coords { font-family: monospace; font-size: 0.9rem; }
.sp-btn { display: inline-block; margin: 0.15rem 0.3rem 0.15rem 0; padding: 0.4rem 0.8rem; border-radius: 4px; border: 1px solid var(--primary, #2e7d32); background: var(--primary, #2e7d32); color: #fff !important; cursor: pointer; text-decoration: none; font: inherit; }
.sp-btn.plain { background: #fff; color: var(--primary, #2e7d32) !important; }
@media (max-width: 640px) {
  .side-panel { top: auto; left: 0; right: 0; bottom: 0; width: auto; min-width: 0; max-height: 60%; border-radius: 12px 12px 0 0; }
}

/* Comments and Photos tabs in the side panel */
.sp-switch { display: block; margin: 0 0 0.6rem; font-size: 0.9rem; color: #4a4a4a; cursor: pointer; }
.sp-muted { color: #4a4a4a; font-size: 0.9rem; margin: 0.3rem 0; }
.sp-cm { padding: 0.5rem 0; border-bottom: 1px solid #e6e6e6; }
.sp-cm p { margin: 0.2rem 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.sp-cm-reply { margin-left: 1rem; border-left: 3px solid #e0e0e0; padding-left: 0.6rem; }
.sp-cm-date { color: #4a4a4a; font-size: 0.85rem; }
.sp-cm-mod { display: block; color: #6b4400; font-size: 0.85rem; }
.sp-cm-form { margin-top: 0.8rem; }
.sp-cm-form textarea { width: 100%; box-sizing: border-box; font: inherit; padding: 0.4rem; border: 1px solid #bbb; border-radius: 4px; }
.sp-ph-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 0.4rem; }
.sp-ph img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 4px; display: block; }

/* Hospitality pins, key above the map */
.map-pin.hosp-pin { background: #7b3fa0; --pin: #7b3fa0; border-radius: 8px; }
.map-key { list-style: none; display: flex; flex-wrap: wrap; gap: 0.3rem 1.1rem; align-items: center; margin: 0.4rem 0; padding: 0; font-size: 0.9rem; }
.map-key li { display: flex; align-items: center; gap: 0.35rem; }
.map-key .map-pin.key { width: 22px; height: 22px; font-size: 12px; box-shadow: none; }
.map-key .key-note { color: #4a4a4a; }
.map-pin.mine { outline: 3px solid #fff; box-shadow: 0 0 0 3px #c0392b; }
.map-pin.info-pin { background: #1f78b4; --pin: #1f78b4; }
/* country list with search (country-picker.js) inside the map menu */
.map-menu .country-picker-button { width: 100%; box-sizing: border-box; background: #fff !important; color: #222 !important; border: 1px solid #bbb !important; text-align: left; padding: 0.4rem !important; font-size: 1rem; }

/* A point under each pin so the exact spot is clear (the tip is where the place is) */
.map-pin::after { content: ''; position: absolute; left: 50%; top: 100%; margin-left: -6px; border: 6px solid transparent; border-top: 12px solid var(--pin); border-bottom: 0; }
.map-key .map-pin.key::after { display: none; }
.map-hint { margin: 0 0 .4rem; color: #333; font-size: .95rem; }

/* Accessibility (10 Nov 2026): the note under the key, at 7:1 like the rest of the grey text above (was #666 = 5.7:1) */
.key-note { color: #4a4a4a; }
