/* map.css — /map page styles */

:root {
    --bg: #f6f2e8;
    --text: #1c1c1c;
    --muted: #5a5050;
    --mc-green: #4A7C59;
    --os-blue: #1a5c8a;
    --os-yellow: #f0c060;
    --rule: rgba(28,28,28,.15);
    --max-width: 1080px;
    --nav-height: 56px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; -webkit-font-smoothing: antialiased; }
body.map-page { background: var(--bg); font-family: 'Barlow Condensed', sans-serif; }

/* Nav */
.nav { position: fixed; top: 0; left: 0; right: 0; z-index: 1000; background: var(--text); border-bottom: 3px solid var(--mc-green); }
.nav-inner { max-width: var(--max-width); margin: 0 auto; padding: 0 32px; height: var(--nav-height); display: flex; align-items: center; justify-content: space-between; }
.nav-brand { font-family: 'Barlow Condensed', sans-serif; font-weight: 700; font-size: 18px; letter-spacing: 2px; text-transform: uppercase; color: #fff; text-decoration: none; }
.nav-brand em { font-style: normal; color: var(--os-yellow); }
.nav-links { display: flex; gap: 32px; align-items: center; }
.nav-links a { font-family: 'Barlow Condensed', sans-serif; font-size: 14px; font-weight: 600; letter-spacing: 1.5px; text-transform: uppercase; color: rgba(255,255,255,.6); text-decoration: none; }
.nav-links a:hover { color: #fff; }
.nav-link-active { color: var(--os-yellow) !important; }
.nav-cta { color: var(--os-yellow) !important; border: 1px solid rgba(240,192,96,.35); padding: 5px 16px; }
.nav-cta:hover { background: rgba(240,192,96,.1); }

/* Map viewport */
#mc-map {
    position: fixed;
    top: var(--nav-height);
    left: 0; right: 0; bottom: 0;
    background: var(--bg);
    background-image:
        linear-gradient(rgba(74,124,89,.07) 1px, transparent 1px),
        linear-gradient(90deg, rgba(74,124,89,.07) 1px, transparent 1px);
    background-size: 40px 40px;
    z-index: 0;
}

/* ── Corner panel ── */
#mc-panel {
    position: fixed;
    top: calc(var(--nav-height) + 12px);
    right: 12px;
    z-index: 500;
    background: var(--bg);
    border: 1px solid var(--rule);
    box-shadow: 0 2px 16px rgba(0,0,0,.12);
    width: 220px;
}
#mc-panel-toggle { display: none; }
#mc-panel-inner { padding: 12px; }

.mc-panel-logo {
    font-weight: 800; font-size: 12px; letter-spacing: 1px; text-transform: uppercase;
    color: var(--text); border-bottom: 1px solid var(--rule); padding-bottom: 8px;
    margin-bottom: 10px; line-height: 1.3;
}
.mc-panel-logo em { font-style: normal; color: var(--mc-green); }

.mc-panel-divider { height: 1px; background: var(--rule); margin-bottom: 8px; }
.mc-panel-regions-label {
    font-size: 9px; font-weight: 700; letter-spacing: 2px; text-transform: uppercase;
    color: var(--muted); margin-bottom: 6px;
}

.mc-region-row {
    display: flex; align-items: center; gap: 6px; width: 100%; padding: 5px 4px;
    background: transparent; border: none; cursor: pointer;
    font-family: 'Barlow Condensed', sans-serif; text-align: left;
    transition: background .1s;
}
.mc-region-row:hover { background: rgba(28,28,28,.04); }
.mc-region-row.active { background: rgba(28,28,28,.07); }
.mc-region-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.mc-region-name {
    font-size: 9px; font-weight: 700; letter-spacing: .3px; text-transform: uppercase;
    color: var(--text); flex: 1; line-height: 1.3;
}
.mc-region-sub { color: var(--muted); font-weight: 600; }
.mc-region-count {
    font-family: 'Space Mono', monospace; font-size: 9px; color: var(--muted); flex-shrink: 0;
}

/* ── App Store CTA ── */
#mc-map-cta {
    position: fixed; bottom: 20px; right: 20px; z-index: 500;
    display: inline-flex; align-items: center; gap: 8px; padding: 12px 24px;
    background: var(--mc-green); color: #fff; font-family: 'Barlow Condensed', sans-serif;
    font-weight: 700; font-size: 14px; letter-spacing: 1.5px; text-transform: uppercase;
    text-decoration: none; box-shadow: 0 2px 12px rgba(74,124,89,.35);
    transition: background .2s;
}
#mc-map-cta:hover { background: #3a6347; }

/* ── MapLibre popup ── */
.maplibregl-popup-content {
    padding: 0;
    border-radius: 0;
}
.maplibregl-popup.mc-tooltip-card .maplibregl-popup-content {
    background: var(--bg);
    border: 1px solid rgba(28,28,28,.18);
    box-shadow: 0 4px 20px rgba(0,0,0,.18);
    width: 240px;
}
.maplibregl-popup.mc-tooltip-card .maplibregl-popup-tip { display: none; }

/* The hover card must never intercept the pointer. The wrapper-level rule that
   used to sit here was a no-op — MapLibre's own CSS already has
   .maplibregl-popup { pointer-events: none } and then re-enables it with
   .maplibregl-popup-content { pointer-events: auto }, so the CONTENT div is the
   element that steals hover. When the popup's anchor auto-flips near the
   top/left viewport edges it lands under the cursor, the canvas fires
   mouseleave, and the remove→re-add loop makes the card flicker. The card is
   hover-only with no links, so it is safe to make it fully transparent. */
.maplibregl-popup.mc-tooltip-card .maplibregl-popup-content { pointer-events: none; }

.mcp-accent { height: 4px; }
.mcp-body { padding: 12px 14px 14px; font-family: 'Barlow Condensed', sans-serif; }
.mcp-name { font-size: 22px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px; color: var(--text); line-height: 1; margin-bottom: 6px; }
.mcp-region { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; }
.mcp-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.mcp-region-name { font-size: 10px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted); }
.mcp-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; margin-bottom: 10px; }
.mcp-stat { background: rgba(28,28,28,.04); border: 1px solid rgba(28,28,28,.1); padding: 6px 8px; }
.mcp-val { font-size: 16px; font-weight: 700; color: var(--text); line-height: 1; }
.mcp-lbl { font-size: 8px; font-weight: 600; letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted); margin-top: 2px; }
.mcp-rank { font-size: 10px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; border-top: 1px solid var(--rule); padding-top: 8px; }
.mcp-grid { font-family: 'Space Mono', monospace; font-size: 10px; color: var(--os-blue); background: rgba(26,92,138,.07); border: 1px solid rgba(26,92,138,.15); padding: 4px 9px; display: inline-block; letter-spacing: .5px; }

/* ── MapLibre attribution ── */
.maplibregl-ctrl-attrib { display: none; }
.maplibregl-ctrl-logo { display: none; }

/* ── Region cluster DivIcon ── */
.mc-region-cluster {
    width: 52px; height: 52px; border-radius: 50%;
    border: 2.5px solid rgba(255,255,255,.9);
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 18px; font-weight: 800; letter-spacing: .5px;
    box-shadow: 0 2px 12px rgba(0,0,0,.28);
    cursor: pointer;
    animation: mcClusterPopIn 0.45s cubic-bezier(0.34,1.56,0.64,1) both;
}

@keyframes mcClusterPopIn {
    from { transform: scale(0); opacity: 0; }
    80%  { transform: scale(1.1); opacity: 1; }
    to   { transform: scale(1);   opacity: 1; }
}

.mc-map-attr { margin-top: 8px; padding-top: 6px; border-top: 1px solid var(--rule); font-size: 8px; color: var(--muted); line-height: 1.4; }
.mc-map-attr a { color: var(--os-blue); text-decoration: none; }

/* ── Visually-hidden (h1 for crawlers/screen readers) ── */
.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ── Summit index — static, crawlable summit facts in a bottom-left drawer.
      The content is real DOM present in the initial HTML (generated by
      tools/generate-summit-index.mjs) so crawlers and AI scrapers that never
      run map.js still see every Munro's name, height and grid ref. ── */
#mc-summit-index {
    position: fixed; bottom: 20px; left: 20px; z-index: 500;
    width: 300px; max-width: calc(100vw - 24px);
    background: var(--bg); border: 1px solid var(--rule);
    box-shadow: 0 2px 16px rgba(0,0,0,.12);
    font-family: 'Barlow Condensed', sans-serif;
}
#mc-summit-index summary {
    padding: 10px 14px; cursor: pointer; list-style: none;
    color: var(--text);
}
#mc-summit-index summary::-webkit-details-marker { display: none; }
.mc-index-title {
    display: block; font-size: 13px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase;
}
.mc-index-title::after { content: ' ▴'; color: var(--muted); font-weight: 400; }
#mc-summit-index[open] .mc-index-title::after { content: ' ▾'; }
#mc-summit-index[open] summary { border-bottom: 1px solid var(--rule); }
.mc-index-sub {
    display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    font-size: 10px; font-weight: 400; letter-spacing: .3px; text-transform: uppercase;
    color: var(--muted); margin-top: 2px;
}
.mc-index-body { max-height: 50vh; overflow-y: auto; padding: 12px 14px; }
.mc-index-toolbar { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--rule); }
.mc-index-search {
    width: 100%; padding: 6px 8px; font-family: 'Barlow Condensed', sans-serif; font-size: 12px;
    border: 1px solid var(--rule); background: var(--bg); color: var(--text);
}
.mc-index-search:focus { outline: 1px solid var(--os-blue); }
.mc-index-height-filter label {
    display: flex; justify-content: space-between; font-size: 9px; font-weight: 700;
    letter-spacing: 1px; text-transform: uppercase; color: var(--muted); margin-bottom: 4px;
}
.mc-index-height-val { font-family: 'Space Mono', monospace; color: var(--text); }
.mc-index-height-filter input[type="range"] { width: 100%; accent-color: var(--mc-green); }
.mc-index-empty { font-size: 12px; color: var(--muted); padding: 4px 0 12px; }
.mc-index-hidden { display: none !important; }
.mc-index-intro { font-size: 12px; color: var(--muted); line-height: 1.5; margin-bottom: 12px; }
.mc-index-group { margin-bottom: 14px; }
.mc-index-group h2 {
    display: flex; align-items: center; gap: 6px;
    font-size: 12px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase;
    color: var(--text); margin-bottom: 6px;
}
.mc-index-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.mc-index-count { font-family: 'Space Mono', monospace; font-size: 10px; font-weight: 400; color: var(--muted); }
.mc-index-group ul { list-style: none; }
.mc-index-group li { font-size: 12px; color: var(--text); line-height: 1.7; }
.mc-index-group li[data-lat] { cursor: pointer; }
.mc-index-group li[data-lat]:hover,
.mc-index-group li[data-lat]:focus-visible { color: var(--os-blue); }
.mc-index-group li[data-lat]:focus-visible { outline: 2px solid var(--os-blue); outline-offset: 2px; }
.mc-index-h { color: var(--muted); }
.mc-index-g { font-family: 'Space Mono', monospace; font-size: 9px; color: var(--os-blue); }

/* ── Mobile ── */
@media (max-width: 768px) {
    .nav-links a:not(.nav-cta) { display: none; }

    #mc-panel {
        width: 100%; left: 0; top: auto; bottom: 0;
        max-height: 56px; overflow: hidden; transition: max-height .3s ease;
        border-top: 2px solid var(--mc-green); border-left: none; border-right: none; border-bottom: none;
    }
    #mc-panel.expanded { max-height: 70vh; overflow-y: auto; }

    #mc-panel-toggle {
        display: flex; align-items: center; justify-content: space-between;
        width: 100%; padding: 0 16px; height: 56px; background: var(--bg);
        border: none; font-family: 'Barlow Condensed', sans-serif; font-size: 13px;
        font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase;
        color: var(--text); cursor: pointer;
    }
    #mc-panel-toggle::after { content: '▾'; font-size: 16px; color: var(--muted); }
    #mc-panel.expanded #mc-panel-toggle::after { content: '▴'; }
    #mc-panel-inner { padding: 12px 16px 24px; }

    #mc-map-cta { bottom: 68px; right: 12px; font-size: 12px; padding: 10px 16px; }

    /* Sit above the bottom panel bar; keep the collapsed pill compact so it
       doesn't collide with the App Store CTA on the right. */
    #mc-summit-index { bottom: 68px; left: 12px; width: auto; max-width: 46vw; }
    #mc-summit-index[open] { max-width: calc(100vw - 24px); }
    #mc-summit-index summary { font-size: 10px; padding: 8px 10px; }
    .mc-index-body { max-height: 45vh; }
}
