/* Force Leaflet's background color so it's never a black void */
.leaflet-container {
    background-color: #d2b790 !important; 
}

/* =========================================
   8. MAP POPUPS
   ========================================= */
/* Dark like every other panel, rather than Leaflet's white bubble. */
.leaflet-popup-content-wrapper, .leaflet-popup-tip {
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: 0 3px 14px rgba(0,0,0,.5);
}
.leaflet-popup-content-wrapper { border-radius: 6px; }
.leaflet-popup-content { font-family: Georgia, serif; font-size: 13px; line-height: 1.4; }
.leaflet-popup-content b { color: #fff; font-size: 14px; }
.leaflet-container a.leaflet-popup-close-button { color: var(--ink-muted); }
.leaflet-container a.leaflet-popup-close-button:hover { color: #fff; }
.popup-warning {
    margin-top: 6px;
    padding: 6px;
    background: #b71c1c;
    color: #fff;
    font-size: 11px;
}
.popup-note {
    margin-top: 6px;
    font-size: 12px;
    color: var(--ink-muted);
    max-width: 220px;
}
.popup-track-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 8px;
}
.popup-track-status { font-size: 11px; color: var(--ink-muted); }
/* The button is a .tx-action (cards.css) and takes its spacing from there. */
.popup-chest-contents {
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px solid var(--line);
    font-size: 11px;
    color: var(--ink-muted);
}
.popup-chest-contents .popup-track-row { margin-top: 4px; }

/* Clustering is gone: the dense categories draw to a canvas
   (densePinLayer) and the sparse ones are viewport-culled teardrops
   (mapRenderer), so nothing produces a count bubble any more - and
   leaflet.markercluster, which drew them, is no longer loaded at all.
   2026-08-13: "figure out how to optimize this website for lower end
   devices." */
.pin-icon { background: none; border: none; }

/* The dense-category canvas. Pointer events stay off: it sits over the tiles
   and would otherwise swallow every click meant for an icon pin below it. Its
   own clicks come from a map-level handler instead - see densePinLayer. */
.dense-pin-layer {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
}

/* THE TEARDROP
   2026-08-13: "instead of circular pins we should have teardrop pins so that
   players will have extremely precise map locations." The tip is the
   coordinate - see PIN_W/iconAnchor in mapRenderer - and everything here is
   laid out around keeping that tip exactly at the bottom centre of the box.

   The head and the glyph are siblings, not nested: the head is rotated 45deg
   to make its one square corner point downward, and a glyph inside it would
   inherit that rotation and sit on its ear. */
.pin-drop {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
}

.pin-drop-head {
    box-sizing: border-box;
    position: absolute;
    top: 0;
    left: 0;
    /* A square as wide as the icon box. Its own height is its width, NOT the
       box's height - the extra height below it is where the rotated corner
       hangs down to reach the tip. */
    width: 100%;
    aspect-ratio: 1;
    /* Three round corners and one square one, turned so the square one is at
       the bottom. */
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    /* Same dark ring as the cluster bubble, for the same reason: a pale
       outline disappears over desert tiles. */
    border: 3px solid rgba(0, 0, 0, 0.7);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

/* Centred on the round part of the head, which is the middle of the top square
   - not the middle of the taller icon box, or every glyph would sit low and
   drift into the tail.

   An <i> with a background-image, not an inline <svg>. Each icon is emitted
   once as a class (installIconStyles in categoryIcons.js) and shared by every
   pin that uses it - inlining the path into each marker cost 19.9 MB of
   duplicated path data with the plants chip on. The browser decodes one image
   per icon and reuses it, which image caching is already very good at. */
.pin-drop-glyph {
    position: absolute;
    top: 50%;
    left: 50%;
    /* Square, and square against the WIDTH - the icon box is taller than it is
       wide because of the tail, so a 52% height would not match a 52% width and
       the glyph would sit in a letterboxed slot rather than centred on the head. */
    width: 52%;
    aspect-ratio: 1;
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    /* top:50% is half the BOX height (0.6036W), but the head's centre is at
       half its own width (0.5W). A margin-top percentage resolves against the
       container's width, so the correction is exactly that gap: -0.1036W. */
    margin-top: -10.36%;
    transform: translate(-50%, -50%);
    display: block;
    /* Clicks must land on the outer span. This mattered more when the glyph was
       an inline <svg>: an SVGElement's `className` is an SVGAnimatedString
       rather than a string, and Leaflet's class helpers read `.baseVal` off it,
       so a click resolving to the <svg> or its <path> could eat the event. The
       glyph is a plain <i> now, but the rule still earns its place - a click
       belongs to the pin, not to the picture on it. */
    pointer-events: none;
}

/* The glyph's near-black fill is baked into the image - see GLYPH_FILL in
   categoryIcons.js. Near-black rather than pure, and never white: the category
   colours run from pale bone to mid red, and only a dark glyph is legible on
   all of them. */

/* 2026-08-12: "when tracked it puts a dot on the store" - a tracked outfit has
   no coords of its own (see build_shops.py), so the pin that changes is its
   shop's. A small white dot on the shop's own pin, not a second colour for the
   whole marker, because the shop is still a shop first - this says "and
   something here is wanted" without hiding what it already told you. */
/* Tracked, but outside the chosen chapter or mission - see isLockedNow in
   main.js. Faded and desaturated rather than removed, so a pin you asked for
   never silently disappears. */
.pin-drop.is-locked { opacity: .55; filter: grayscale(1); }

.pin-drop.is-wanted::after {
    content: '';
    position: absolute;
    top: -3px;
    right: -3px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #fff;
    border: 3px solid rgba(0, 0, 0, 0.7);
}

/* Coordinate picker, ?pick only - see js/coordPicker.js. A data-authoring
   tool, so it deliberately sits over the map rather than earning sidebar
   space no player would ever use. */
.coord-picker {
    position: absolute; top: 12px; right: 12px; z-index: 1200;
    width: 230px; max-height: 60vh; overflow-y: auto;
    background: #14110d; border: 1px solid #4a3f2d;
    padding: 8px; font-size: 11px; color: #d8cfba;
    font-family: ui-monospace, Menlo, Consolas, monospace;
}
.coord-picker .cp-head {
    font-family: Georgia, serif; color: #c8a951; margin-bottom: 6px;
}
.coord-picker .cp-list div { padding: 1px 0; white-space: nowrap; }
.coord-picker .cp-list b { color: #c8a951; margin-right: 4px; }
.coord-picker .cp-row { margin-top: 8px; display: flex; gap: 4px; }
.coord-picker button { flex: 1; font-size: 10px; }


/* The map key: closed it is one line in the corner; open, a short list. */
.map-legend {
    max-width: min(280px, 70vw);
    font-family: Georgia, serif;
    color: var(--ink);
    background: rgba(26, 26, 26, .92);
    border: 1px solid var(--line);
    border-radius: 4px;
    font-size: 12px;
}
.map-legend[hidden] { display: none; }
.map-legend summary { display: flex; align-items: center; gap: 6px; padding: 6px 10px; cursor: pointer; color: var(--gold); letter-spacing: .5px; list-style: none; }
.map-legend summary::-webkit-details-marker { display: none; }
.map-legend summary::before { content: '▸'; }
.map-legend[open] summary::before { content: '▾'; }
.map-legend ul { list-style: none; margin: 0; padding: 0 10px 8px; max-height: 40vh; overflow-y: auto; }
.map-legend li { display: flex; align-items: center; gap: 8px; padding: 2px 0; }
.map-legend i { width: 11px; height: 11px; border-radius: 50%; flex: none; border: 1px solid rgba(0,0,0,.5); }

/* Zoom buttons and attribution in the panel colours, not Leaflet's white. */
.leaflet-bar { border: 1px solid var(--line) !important; box-shadow: 0 2px 8px rgba(0,0,0,.4) !important; }
.leaflet-bar a, .leaflet-bar a:hover { color: var(--ink); background: var(--surface); border-bottom-color: var(--line); }
.leaflet-bar a:hover { color: #fff; background: var(--surface-3); }
.leaflet-control-attribution { color: var(--ink-muted); background: rgba(26, 26, 26, .75) !important; }
.leaflet-control-attribution a { color: var(--ink); }
