/*
 * CHS Border Village Map — component stylesheet.
 *
 * Follows the wireframe Sandip approved on 24 June: a single card with a title
 * row, a horizontal filter bar of select menus, a full-width map, and the
 * legend overlaid bottom-left. Not the checkbox sidebar the first build used.
 *
 * EVERY rule is scoped under .vmap (popups under .vm-pop, which Google renders
 * outside the component). This file loads inside the SNU ProcessWire theme,
 * where a bare `body`, `h1` or `.title` rule is not a style choice but a
 * site-wide regression: the previous version set body{display:flex},
 * html,body{height:100%} and a global font stack, which re-laid-out the whole
 * page and broke the header.
 *
 * Two further house rules, both learned the hard way:
 *   - no `*{box-sizing}` outside the component, no element selectors, and no
 *     :root custom properties (the theme has its own and ours would leak);
 *   - no prefers-color-scheme block. The SNU site is light-only, and flipping
 *     this component to dark on a visitor's OS preference reads as a fault.
 *
 * Colour comes from the theme's own --primary-color (#CD1739 live). The
 * fallback is the wireframe's #C8102E, for the standalone dev harness.
 */

.vmap{
  --vm-brand:var(--primary-color,#C8102E);
  --vm-ink:#232321;
  --vm-muted:#6b6862;
  --vm-faint:#8e8a83;
  --vm-line:#e4e1db;
  --vm-panel:#fff;
  --vm-shade:#f7f5f2;
  /* Village categories. Mirrored in map.js's CATEGORY table - see the note
     on .vm-dot.is-old below. --vm-cat-old tracks the theme's own primary so
     the commonest category stays the brand colour on any SNU skin. */
  --vm-cat-old:var(--primary-color,#C8102E);
  --vm-cat-relocated:#0F7B8A;
  --vm-cat-old-relocated:#D98C00;
  --vm-mono:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;

  color:var(--vm-ink);
  margin:0 0 8px;
}

/* The theme uppercases headings and labels site-wide. Our filter values are
   proper nouns in transliteration ("Tho-ling Town"); GAR COUNTY is not how CHS
   write them. Opt out explicitly rather than fight specificity later. */
.vmap,
.vmap h2,.vmap h3,.vmap h4,
.vmap label,.vmap button,.vmap input,.vmap select,.vmap option{
  text-transform:none;
  letter-spacing:normal;
}
.vmap *{ box-sizing:border-box; }

/* Tibetan.
 *
 * The browser must find a Tibetan face or བོད་ renders as tofu. These are the
 * faces that ship with Windows, macOS and common Linux installs. It is a
 * stopgap: a visitor without any of them still sees boxes, so the real fix is
 * to self-host a subset of Noto Serif Tibetan. Tracked for Phase 2.
 */
.vmap [lang="bo"],
.vm-pop [lang="bo"]{
  font-family:"Noto Serif Tibetan","Noto Sans Tibetan","Microsoft Himalaya",
              "Kailasa","Tibetan Machine Uni",inherit;
}

/* ------------------------------------------------------------- dev banner */

.vmap .vm-devbar{
  background:#fbe9e2; color:#b3421a; border:1px solid #b3421a; border-bottom:none;
  border-radius:6px 6px 0 0; padding:10px 16px; font-size:13px; line-height:1.5;
}

/* -------------------------------------------------------------------- card */

.vmap .vm-card{
  background:var(--vm-panel);
  border:1px solid var(--vm-line);
  border-radius:6px;
  overflow:hidden;
}

.vmap .vm-head{
  display:flex; align-items:center; justify-content:space-between;
  gap:20px; flex-wrap:wrap;
  padding:16px 20px;
  border-bottom:1px solid var(--vm-line);
}
.vmap .vm-head-title{
  margin:0; font-size:17px; font-weight:700; line-height:1.3;
}
.vmap .vm-head-sub{
  margin-left:8px; font-size:11px; font-weight:700; color:var(--vm-brand);
  letter-spacing:.08em; text-transform:uppercase;
}
.vmap .vm-head-tools{ display:flex; align-items:center; gap:14px; flex-wrap:wrap; }

.vmap .vm-count{ font-size:13px; color:var(--vm-muted); display:flex; align-items:center; gap:7px; }
.vmap .vm-count::before{
  content:""; width:8px; height:8px; border-radius:50%;
  background:var(--vm-brand); flex:0 0 auto;
}
.vmap .vm-count b{ color:var(--vm-ink); font-weight:700; }

/* ----------------------------------------------------------- filter strip */

.vmap .vm-filters{
  display:flex; align-items:flex-end; gap:16px; flex-wrap:wrap;
  padding:14px 20px; border-bottom:1px solid var(--vm-line);
}
.vmap .vm-filters-label{
  font-size:9.5px; font-weight:700; letter-spacing:.09em; text-transform:uppercase;
  color:var(--vm-faint); padding-bottom:10px;
}
.vmap .vm-fields{ display:flex; align-items:flex-end; gap:16px; flex-wrap:wrap; }
/* margin:0 is load-bearing. These are <label> elements and the theme sets a
   bottom margin on every label, which made each field 6px taller than the
   control inside it. The strip bottom-aligns its children, so that invisible
   6px sat under the selects and pushed the Reset button below their line. */
.vmap .vm-field{ display:flex; flex-direction:column; gap:5px; margin:0; }
.vmap .vm-field > span{
  font-size:9.5px; font-weight:700; letter-spacing:.09em; text-transform:uppercase;
  color:var(--vm-faint);
}
.vmap .vm-field > span i{ font-style:normal; color:var(--vm-muted); }
.vmap .vm-field select,
.vmap .vm-field input{
  min-width:200px; padding:8px 10px;
  border:1px solid var(--vm-line); border-radius:3px;
  background:var(--vm-panel); color:var(--vm-ink);
  font:inherit; font-size:14px; line-height:1.4;
}
.vmap .vm-field select:focus,
.vmap .vm-field input:focus{
  outline:2px solid var(--vm-brand); outline-offset:-1px; border-color:var(--vm-brand);
}
.vmap .vm-reset{
  appearance:none; border:1px solid var(--vm-brand); border-radius:3px;
  background:var(--vm-panel); color:var(--vm-brand);
  padding:8px 14px; font:inherit; font-size:14px; font-weight:700; cursor:pointer;
  /* Matches the selects exactly: without it the button inherits the theme's
     21px line-height and stands 1px taller than every control beside it. */
  line-height:1.4;
}
.vmap .vm-reset:hover{ background:var(--vm-brand); color:#fff; }


/* ------------------------------------------------- predictive search panel
 *
 * The dropdown under the search box: what the box has found, grouped under
 * the field each match came from, in columns across the strip.
 *
 * The z-index goes on the STRIP, not on the panel: the panel is positioned
 * against the strip, so lifting the strip lifts the panel with it and keeps
 * one number to reason about instead of two.
 *
 * 2 is enough, and staying small is the point. The map overlays below are
 * sealed into their own stacking context by isolation on .vm-mapwrap, so the
 * strip only has to beat the map as a whole - and it stays far below the SNU
 * header's 1020, which must keep covering this card when the page scrolls
 * under it.
 */

.vmap .vm-filters{ position:relative; z-index:2; }

.vmap .vm-suggest{
  position:absolute; top:100%; left:0; right:0;
  /* Over the strip's own bottom border, so the panel reads as hanging from
     the strip rather than floating a pixel below it. */
  margin-top:-1px;
  background:var(--vm-panel);
  border:1px solid var(--vm-line);
  border-top:2px solid var(--vm-brand);
  border-radius:0 0 4px 4px;
  box-shadow:0 18px 40px rgba(35,35,33,.18);
  padding:12px 16px 10px;
  /* Long result sets scroll inside the panel rather than running off the
     bottom of the map. */
  max-height:60vh; overflow-y:auto; -webkit-overflow-scrolling:touch;
  display:grid;
  grid-template-columns:repeat(auto-fill,minmax(228px,1fr));
  gap:0 22px; align-items:start;
}
/* display:grid beats the hidden attribute's UA display:none, so it has to be
   said again here or the panel is permanently on screen. */
.vmap .vm-suggest[hidden]{ display:none; }

.vmap .vm-sgroup{ min-width:0; }
.vmap .vm-sgroup h4{
  margin:6px 0 3px; padding:0 8px;
  font-size:9.5px; font-weight:700; letter-spacing:.09em; text-transform:uppercase;
  color:var(--vm-brand);
}

.vmap .vm-sitem{
  display:flex; align-items:center; gap:8px;
  padding:7px 8px; border-radius:3px; cursor:pointer;
  font-size:14px; line-height:1.35; color:var(--vm-ink);
  min-width:0;
}
.vmap .vm-sitem:hover,
.vmap .vm-sitem.is-active{ background:var(--vm-shade); }
/* The matched letters. A background highlight on top of the row's own hover
   shade reads as two overlapping rectangles; colour and weight carry it.

   padding:0 is not tidiness. The SNU theme sets .2em of padding on <mark>,
   which is 2.8px here - so the highlighted run was pushed apart from the rest
   of its own word and Dromo County listed itself as "Dro mo County". */
.vmap .vm-sitem mark{
  background:none; color:var(--vm-brand); font-weight:700;
  padding:0; margin:0;
}

.vmap .vm-stext{ min-width:0; }
.vmap .vm-slabel{ display:block; overflow-wrap:anywhere; }
.vmap .vm-salt{ margin-left:7px; font-size:12.5px; color:var(--vm-muted); }
.vmap .vm-salt[lang="bo"]{ line-height:1.5; }
.vmap .vm-smeta{
  display:block; font-size:11.5px; line-height:1.4; color:var(--vm-muted);
  overflow-wrap:anywhere;
}
.vmap .vm-scount{ margin-left:auto; padding-left:8px; font-size:12px; color:var(--vm-faint); }
/* The category colour, same shape as the legend swatch so the two read as
   the same thing. */
.vmap .vm-sdot{
  width:8px; height:8px; flex:0 0 auto;
  border-radius:50% 50% 50% 0; transform:rotate(-45deg);
  /* Beside the NAME, not in the middle of the row. The row centres its
     items, which is right while everything is one line; on a phone a long
     name wraps to three and the dot drifted down to the county line under
     it, pointing at nothing. */
  align-self:flex-start; margin-top:5px;
}

.vmap .vm-smore{ margin:1px 0 4px; padding:0 8px; font-size:11.5px; color:var(--vm-faint); }
.vmap .vm-sempty{ grid-column:1 / -1; margin:4px 8px; font-size:13.5px; color:var(--vm-muted); }

/* The free-text row, under a rule across the full width: it is not one of
   the groups, it is what to do when none of them is what you meant. */
.vmap .vm-sfoot{
  grid-column:1 / -1;
  margin-top:6px; padding-top:4px; border-top:1px solid var(--vm-line);
}
/* display:block, not flex. This row is a sentence, not a label and a count,
   and as a flex row any stray text node beside an element would be laid out
   as a separate item - which is exactly how "Show all / 3 / villages
   matching..." came to wrap into three blocks on a phone. The markup also
   keeps it in one span; either alone fixes it, and the pair means a later
   edit to the sentence cannot bring it back. */
.vmap .vm-sitem.is-text{ display:block; color:var(--vm-brand); font-weight:600; }
.vmap .vm-sitem.is-text b{ font-weight:700; }

/* -------------------------------------------------------------------- map */

/* isolation:isolate is load-bearing, not housekeeping.

   The overlays inside this wrapper carry big z-indexes - the empty prompt at
   1002, the legend at 1001, Leaflet's own panes at 1000 - because they have
   to clear Leaflet. Without an isolate, .vm-mapwrap has no stacking context
   of its own (position:relative, z-index:auto), so those numbers are judged
   against everything else on the page, the SNU sticky header among them.

   That is how the search panel ended up fighting the site header: to put the
   dropdown over the prompt, the filter strip had to out-rank 1002, and
   anything over 1002 is also over the header's 1020 - so the strip punched
   through the header on scroll.

   Isolating here contains all of it. Inside the wrapper the overlays keep
   their order; outside it the whole map counts as one layer, and the strip
   needs a z-index of 2 to sit above it rather than 1400. */
.vmap .vm-mapwrap{ position:relative; isolation:isolate; }
.vmap .vm-canvas{ height:560px; background:var(--vm-shade); }

/* Deliberately small: it is an overlay on the map, so every pixel it takes is
   a pixel of Tibet it hides. The explanatory paragraph went for the same
   reason — it restated what the coloured pins already say, and the popup
   carries the per-village detail anyway. */
.vmap .vm-legend{
  /* Above Leaflet's panes and controls, which run to z-index 1000. */
  position:absolute; left:16px; bottom:16px; z-index:1001;
  background:var(--vm-panel); border:1px solid var(--vm-line); border-radius:3px;
  padding:7px 10px; box-shadow:0 1px 4px rgba(0,0,0,.12); max-width:218px;
}
.vmap .vm-legend h3{
  margin:0 0 4px; font-size:8.5px; font-weight:700; letter-spacing:.09em;
  text-transform:uppercase; color:var(--vm-faint);
}
.vmap .vm-legend p{
  margin:2px 0; font-size:11px; line-height:1.35;
  display:flex; align-items:center; gap:6px;
}
.vmap .vm-dot{
  width:8px; height:8px; border-radius:50% 50% 50% 0; transform:rotate(-45deg);
  background:var(--vm-brand); flex:0 0 auto;
  /* A transparent border on every swatch, overridden to a real one by
     .is-multi below. Declared here rather than only there so that the ringed
     swatch is the same 8px across as the plain ones and the legend's four
     lines of text stay left-aligned with each other. */
  border:1.5px solid transparent; box-sizing:content-box;
}

/* The three village categories. These MUST match the `colour` values in the
   CATEGORY table in map.js: that table paints the pins on the map, this
   paints the swatches that explain them, and the two are read side by side.
   Changing one without the other is a legend that lies. */
.vmap .vm-dot.is-old{ background:var(--vm-cat-old); }
.vmap .vm-dot.is-relocated{ background:var(--vm-cat-relocated); }
.vmap .vm-dot.is-old-relocated{ background:var(--vm-cat-old-relocated); }

/* Not a fourth category - a property a village of ANY category can have. So
   it is shown as the outline that marks it on the map, over a neutral fill
   that deliberately matches none of the three above. */
.vmap .vm-dot.is-multi{
  background:var(--vm-faint); border-color:var(--vm-ink);
}

/* ----------------------------------------------------------- empty prompt */
/*
 * What sits over the map before a county has been chosen.
 *
 * An overlay rather than a replacement for the canvas: the basemap stays
 * visible and interactive underneath, so the visitor can see WHICH frontier
 * they are about to filter, and Google is not torn down and rebuilt every
 * time the filters are cleared. pointer-events:none on the wrapper with
 * auto on the panel means panning and zooming the map still works with the
 * prompt on screen; only the panel itself swallows clicks.
 */
.vmap .vm-prompt{
  position:absolute; inset:0; z-index:1002;
  display:flex; align-items:center; justify-content:center;
  padding:24px; pointer-events:none;
  /* Enough to lift the panel off the terrain, not enough to hide it. */
  background:rgba(247,245,242,.55);
}
.vmap .vm-prompt[hidden]{ display:none; }
.vmap .vm-prompt > div{
  pointer-events:auto; max-width:360px; text-align:center;
  background:var(--vm-panel); border:1px solid var(--vm-line); border-radius:3px;
  padding:18px 22px; box-shadow:0 2px 10px rgba(0,0,0,.14);
}
.vmap .vm-prompt strong{
  display:block; margin-bottom:6px; font-size:15px; color:var(--vm-ink);
}
.vmap .vm-prompt p{
  margin:0; font-size:13px; line-height:1.55; color:var(--vm-muted);
}

/* ---------------------------------------------------------- map  failure */

.vmap .vm-fail{
  display:flex; align-items:center; justify-content:center;
  height:100%; padding:32px; text-align:center;
}
.vmap .vm-fail > div{ max-width:470px; }
.vmap .vm-fail strong{ display:block; margin-bottom:9px; font-size:15px; }
.vmap .vm-fail p{ margin:0 0 9px; font-size:13.5px; color:var(--vm-muted); line-height:1.55; }
.vmap .vm-fail code{
  font:12px var(--vm-mono); background:rgba(0,0,0,.06);
  padding:2px 6px; border-radius:3px; word-break:break-all;
}

/* ------------------------------------------------------------------ popup */
/* Google renders the InfoWindow outside .vmap, so scope on .vm-pop. */

.vm-pop{
  font-family:inherit; font-size:14px; line-height:1.5;
  color:#232321; width:286px; max-width:100%;
}

/* The theme uppercases headings site-wide and Google renders this InfoWindow
   OUTSIDE .vmap, so the opt-out on .vmap never reaches it. Without this,
   "Tho-ling Town" ships as "THO-LING TOWN". */
.vm-pop,
.vm-pop h3,.vm-pop dt,.vm-pop dd,.vm-pop span{
  text-transform:none; letter-spacing:normal;
}

/* Title line: Pu-ling | 波林村 | སྤུ་གླིང
   baseline alignment, so the three scripts sit on one line despite their very
   different sizes and metrics. */
.vm-pop .vm-pop-title{
  margin:0; font-weight:400; line-height:1.3;
  /* The close button sits beyond the text column, not over it: the reserved
     scrollbar gutter already holds it clear, so this only needs a hair. */
  padding:0 6px 7px 0;

  /* The rule under the name. It belongs to the pinned header rather than to
     the first row, so it stays put while the table scrolls under it — a
     border on the County row would slide away with the row. */
  border-bottom:2px solid var(--primary-color,#C8102E);

  /* The name stays put while the table scrolls under it. The whole popup is
     inside Google's one scrolling box, so the only way to hold the heading
     still is to pin it there — hence the opaque background, which is what
     stops row borders showing through as they pass beneath. */
  position:sticky; top:0; z-index:2; background:#fff;
}
.vm-pop .vm-name{ font-size:13.5px; font-weight:400; }
.vm-pop .vm-name.is-lead{ display:block; font-size:19px; font-weight:700; }
/* Chinese and Tibetan share the second line. Baseline alignment, because the
   two scripts have very different metrics at the same font-size. */
.vm-pop .vm-alt{
  display:flex; flex-wrap:wrap; align-items:baseline; gap:0 7px; margin-top:1px;
}
/* All three names stay ink. They were briefly crimson, which broke down as
   soon as the title wrapped: a long name pushes the Tibetan onto its own line,
   and a second coloured line directly above the table read as one more field
   rather than part of the heading. */
/* Tibetan stacks vowel marks above and below the base letter and clips at a
   tight line-height. It stays at body size — only the room around it grows.
   Kept modest: every extra tenth here pushes the county away from the name,
   because this is the tallest span on the title's line. */
.vm-pop .vm-name[lang="bo"]{ line-height:1.5; }
.vm-pop .vm-sep{ color:#bdb9b2; font-size:13.5px; font-weight:400; }

/* Rows.
 *
 * align-items:start plus an identical font-size and line-height on both sides
 * is what makes the two requirements one rule: a single-line label and a
 * single-line value are exactly the same height, so starting them together
 * reads as centred, while a value that wraps to two lines keeps its first
 * line level with the label instead of dropping the label to the middle.
 * That was the "Housing" line sitting below "Key projects".
 */
.vm-pop .vm-rows{ margin:0; }
.vm-pop .vm-rows > div{
  display:grid; grid-template-columns:104px 1fr; gap:4px 12px;
  align-items:start;
  padding:7px 0; border-bottom:1px solid #e4e1db;
}
/* The last row's rule would be a line under nothing. */
.vm-pop .vm-rows > div:last-child{ border-bottom:none; }
.vm-pop .vm-rows dt,
.vm-pop .vm-rows dd{ font-size:13.5px; line-height:1.45; }
.vm-pop .vm-rows dt{ font-weight:600; color:#8e8a83; }
.vm-pop .vm-rows dd{ margin:0; }
/* A note, not a warning.
 *
 * This was amber on cream, which is a warning palette: it read as "something
 * is wrong with this village" when it only says the village has two settlement
 * groups, and it matched nothing else on the site. Brand tint instead.
 *
 * #fbecef is --primary-color at 8% on white, hard-coded rather than mixed: the
 * theme hands the colour over as a hex, and a tint of it has to be a literal.
 * Keep the two in step if the theme's crimson ever changes.
 */
.vm-pop .vm-flag{
  margin-top:10px; padding:6px 9px; border-radius:3px;
  background:#fbecef; border:1px solid #f2d3da;
  color:var(--primary-color,#C8102E);
  font-size:12px; line-height:1.4;
}

/* Google's InfoWindow chrome.
 *
 * The API reserves `.gm-style-iw-chr` — a 48px flex row — above the content,
 * purely to hold the close button. Our popup has its own title, so that row
 * is 48px of nothing at the top of every village. Taking it out of the flow
 * closes the gap and lets the button sit on the title's own line.
 *
 * The class is added by map.js on domready, NOT by InfoWindowOptions.className
 * — that option is ignored by the API version served here.
 */
/* Even on all four sides. Google's own padding is `0 0 0 12px`, so the popup
   sat flush against the top, right and bottom edges — most visible on the note
   box, which ran into the corner.
   
   The right-hand 12px is on the SCROLLER, not here: inside the scroller it is
   a gap between the text and the scrollbar, which is what reads as even. Put
   on the container it stacks with the scrollbar instead, and the right margin
   measures 38px against the left's 12px. */
.vmap-iw{ position:relative; padding:12px 0 12px 12px !important; }
/* top aligns the 30px button on the title's FIRST line (12px container pad +
   half a 25px line), not on the title box's centre — the title wraps to two
   lines on a phone and the button must not drift down with it. */
.vmap-iw .gm-style-iw-chr{
  /* right:0 with a 28px button, against a 28px scrollbar gutter, puts the
     button's centre and the scrollbar's centre on the same vertical axis —
     they were 10px apart, which is what read as crooked. The two widths are a
     pair: change one and the other has to follow. Currently 28px each. */
  position:absolute; top:10px; right:0; z-index:4;
  height:auto; min-height:0;
}
.vmap-iw .gm-style-iw-ch{ padding:0 !important; height:auto; }
.vmap-iw .gm-style-iw-d{
  overflow:auto !important;
  padding-right:10px;
  /* Reserve the gutter even when the content fits, so a short popup and a
     long one have their text in the same place and the close button never
     lands on a different axis depending on how much a village has filled in. */
  scrollbar-gutter:stable;
}

/* The scroll track starts BELOW the close button.
 *
 * `margin` on -webkit-scrollbar-track insets the track, which moves the bar
 * down without moving the title — the title is inside this same scrolling box,
 * so padding here would push the name down with it.
 *
 * NOTE the deliberate absence of `scrollbar-width` / `scrollbar-color`. Those
 * are the standard properties, and once either is set Chrome renders the
 * standard scrollbar and IGNORES every -webkit-scrollbar rule — including this
 * margin. Setting them is what left the bar running the full height and
 * colliding with the close button last time: the colour applied, the offset
 * silently did not. Leaving them unset keeps the default scrollbar appearance,
 * which is what is wanted anyway.
 */
.vmap-iw .gm-style-iw-d::-webkit-scrollbar{ width:28px; }
.vmap-iw .gm-style-iw-d::-webkit-scrollbar-track{
  background:transparent; margin-top:40px; margin-bottom:6px;
}
/* A wide gutter holding a hairline bar: the transparent border is clipped
   away by background-clip, so 28px of spacing carries a 4px thumb. The border
   is what sets the thumb width — 12px each side off 28 leaves 4 — and because
   it is symmetrical the thumb stays centred in the gutter, which is what keeps
   it on the close button's axis. Change the gutter and this has to follow. */
.vmap-iw .gm-style-iw-d::-webkit-scrollbar-thumb{
  background:#d6d2cb; background-clip:content-box;
  border:12px solid transparent; border-radius:14px;
}
.vmap-iw .gm-style-iw-d::-webkit-scrollbar-thumb:hover{
  background:#bab5ad; background-clip:content-box;
}
/* The close button.
 *
 * Google ships a 40px hit area wrapping a grey sprite at 0.6 opacity, which
 * reads as a stray artefact rather than part of the card. Its glyph is hidden
 * and the cross is drawn here instead, so its weight and colour follow the
 * site: quiet by default, brand tint on hover.
 *
 * 22px to match the scrollbar gutter above.
 */
.vmap-iw .gm-ui-hover-effect{
  position:relative !important;
  width:28px !important; height:28px !important;
  min-width:0 !important; min-height:0 !important;
  margin:0 !important; padding:0 !important;
  opacity:1 !important;
  border:none !important; border-radius:50% !important;
  background:transparent !important; background-image:none !important;
  cursor:pointer;
  transition:background-color .16s ease;
}
/* Google's own glyph, whatever element it uses in this API version. */
.vmap-iw .gm-ui-hover-effect > *{ display:none !important; }

.vmap-iw .gm-ui-hover-effect::before,
.vmap-iw .gm-ui-hover-effect::after{
  content:''; position:absolute; left:50%; top:50%;
  width:13px; height:1.8px; border-radius:2px;
  background:#8e8a83;
  transition:background-color .16s ease;
}
.vmap-iw .gm-ui-hover-effect::before{ transform:translate(-50%,-50%) rotate(45deg); }
.vmap-iw .gm-ui-hover-effect::after{ transform:translate(-50%,-50%) rotate(-45deg); }

.vmap-iw .gm-ui-hover-effect:hover{ background:#fbecef !important; }
.vmap-iw .gm-ui-hover-effect:hover::before,
.vmap-iw .gm-ui-hover-effect:hover::after{ background:var(--primary-color,#C8102E); }
.vmap-iw .gm-ui-hover-effect:active{ background:#f6dde2 !important; }
/* The focus ring is drawn INSIDE the button, hence the negative offset.
 *
 * `.gm-style-iw-c` is `overflow:hidden` with an 8px radius, and this button
 * sits flush against its right edge (`right:0` on .gm-style-iw-chr, which is
 * what keeps it on the scrollbar's axis). An outline at a POSITIVE offset
 * therefore extends 4px past the card and is clipped by the rounded corner —
 * the ring came out as a broken arc straddling the card's edge, most obvious
 * on a phone where the card is narrow. Measured on the live page: button 28px
 * at the card's right edge, ring overflowing by 4px into the clip.
 *
 * Chrome honours border-radius on outlines, so at -2px this is a clean circle
 * hugging the inside of the button and nothing can crop it.
 */
.vmap-iw .gm-ui-hover-effect:focus-visible{
  outline:2px solid var(--primary-color,#C8102E); outline-offset:-2px;
}

/* ...and it should not appear at all for a mouse or touch user.
 *
 * Google focuses this close button as soon as the InfoWindow opens, which is
 * right for a keyboard user — it is where they need to land. But Chrome counts
 * a programmatic focus that follows no prior interaction as :focus-visible, so
 * EVERY popup opened with a crimson ring round its cross, for everyone. map.js
 * adds this class when the keyboard was not what opened the popup, and removes
 * it the moment the user presses Tab, Enter or Space — so keyboard focus stays
 * visible and pointer users see nothing. */
.vmap-iw .gm-ui-hover-effect.vm-autofocus:focus-visible{ outline:none; }

/* Leaflet's popup in the dev harness, for the same reason. Scoped under .vmap
   because Leaflet renders its popup inside the map container (Google does
   not), so this never escapes the component. */
.vmap .leaflet-popup-content{ margin:12px 14px 12px 12px; }
.vmap .leaflet-popup-content .vm-pop-title{ padding-right:20px; }

/* ------------------------------------------------------------ responsive */

@media (max-width:820px){
  .vmap .vm-head,
  .vmap .vm-filters{ padding:14px 16px; }
  .vmap .vm-head{ gap:10px; }
  .vmap .vm-filters{ gap:12px; }
  /* The strip is a row of equal columns on desktop; on a phone each control
     needs the full width or the select truncates its own option text. */
  .vmap .vm-fields{ width:100%; gap:12px; }
  .vmap .vm-field{ width:100%; }
  .vmap .vm-field select,
  .vmap .vm-field input{ width:100%; min-width:0; }
  .vmap .vm-reset{ width:100%; }
  /* The panel is one column on a phone - 228px columns would be one column
     anyway, but the gap and the group spacing are wrong at that width - and
     every row gets a 44px target. */
  .vmap .vm-suggest{
    grid-template-columns:1fr; padding:8px 10px 10px; max-height:58vh;
  }
  .vmap .vm-sitem{ padding:11px 8px; min-height:44px; font-size:15px; }
  /* 16px exactly. Safari zooms the whole page in when a focused input's text
     is smaller than that, and a zoomed page with an open dropdown over a map
     is unusable. */
  .vmap .vm-field input[type="search"]{ font-size:16px; }
  .vmap .vm-canvas{ height:62vh; min-height:380px; }
  .vmap .vm-legend{ left:10px; bottom:10px; padding:6px 9px; max-width:190px; }
}

/* Phones. Google caps the InfoWindow to the viewport, so the popup has to be
   able to shrink; a fixed 286px would otherwise force horizontal scrolling
   inside it. Below this width the label column stops earning its keep, so
   label and value stack. */
@media (max-width:420px){
  .vm-pop{ width:auto; min-width:0; max-width:100%; }
  .vm-pop .vm-rows > div{ grid-template-columns:1fr; gap:1px; }
  .vm-pop .vm-rows dt{ font-size:12.5px; }
  .vm-pop .vm-name.is-lead{ font-size:17px; }
  .vm-pop .vm-flag{ font-size:11.5px; padding:5px 8px; margin-top:9px; }
}

@media (max-width:560px){
  .vmap .vm-head-title{ font-size:16px; }
  /* Legend goes under the map rather than over it: on a phone an overlay
     covers a quarter of the visible frontier. */
  .vmap .vm-legend{
    position:static; max-width:none; box-shadow:none;
    border:none; border-top:1px solid var(--vm-line); border-radius:0;
    padding:9px 16px;
  }
  /* Two columns rather than four stacked lines.
     The legend grew from two entries to four when colour started carrying the
     village Category, and four rows under the map pushed the footer down by
     most of a thumb on a phone. Paired up it is two rows, the same height the
     old two-line legend was, and the category swatches still read in the
     order the dropdown lists them (reading across, not down). */
  .vmap .vm-legend{ display:grid; grid-template-columns:1fr 1fr; gap:2px 14px; }
  .vmap .vm-legend h3{ grid-column:1 / -1; }
  .vmap .vm-legend p{ font-size:11.5px; margin:0; }
}
