:root {
  /* VHCC brand tokens — taken from vhcc.edu's compiled theme (July 2026).
     Ratios below are vs white; verify with: node tools/contrast.js */
  --brand-navy: #0b2439; /* header bar */
  --brand-blue: #4578ba; /* mountain in the logo / accent — 4.5:1 */
  /* Attention accent — FILL ONLY, 1.7:1 as text. Unused since the header rule
     went green (2026-08-10); kept as a brand token, still contrast-tested. */
  --brand-gold: #febc00;
  --brand-green: #284e36; /* logo wordmark / primary — 9.4:1 */

  --ink: #212529; /* body text — 15.4:1 on white */
  --paper: #ffffff; /* panel / surface */
  --muted: #595f66; /* secondary text — 6.5:1 on white */

  /* --line is DECORATIVE only (row dividers, internal rules); at ~1.4:1 it must
     never bound a control. --edge (3.7:1 on white) is for anything whose border
     identifies a UI component — inputs, buttons, the panel edge. */
  --line: #d9dde1;
  --edge: #7d858d;

  --accent: var(--brand-green);
  --focus: var(--brand-navy); /* 15.8:1, and distinct from every marker hue */
  --header-h: 3.75rem;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  font-family: "Fira Sans", -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: var(--paper);
  color: var(--ink);
}

.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;
}

/* Skip link: visually hidden until focused (WCAG 2.4.1) */
.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--focus);
  color: #fff;
  padding: 0.6rem 1rem;
  font-weight: 600;
  font-size: 0.9rem;
  z-index: 2000;
  text-decoration: none;
}
.skip-link:focus {
  left: 1rem;
  top: 1rem;
}

/* ─── Header ─────────────────────────────────────────────────────────────── */

.app-header {
  flex: 0 0 auto;
  min-height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.5rem 1rem;
  /* Navy top bar with the reversed logo, as on VHCC's own site. White title on
     navy is 15.8:1.

     The accent rule under it was --brand-gold (9.4:1 against the navy, a hard
     bright line); it is --brand-green from 2026-08-10. Green on navy is
     1.68:1, so the rule deliberately does not read as a line against the bar
     above it — what you see is its 9.4:1 edge against the white below, i.e. a
     navy bar that ends in a green lip rather than a bar with a stripe under
     it. That is a look, not a bug; it is only decorative either way (1.4.11
     covers UI components and meaningful graphics, not brand trim), so no
     contrast minimum applies. Going back to a rule that reads against the
     navy means a lighter green, not this one. */
  background: var(--brand-navy);
  border-bottom: 3px solid var(--brand-green);
}

/* Official reversed (white) VHCC logo. Intrinsic width/height in the markup
   keep the aspect ratio and reserve space before the image loads. */
.brand-mark {
  flex: 0 0 auto;
  height: 2.4rem;
  width: auto;
  display: block;
}

.brand-text h1 {
  margin: 0;
  font-family: "Fira Sans Condensed", "Fira Sans", sans-serif;
  font-weight: 700;
  font-size: 1.2rem;
  line-height: 1.2;
  color: #fff;
}

.brand-text p {
  margin: 0.1rem 0 0;
  font-size: 0.78rem;
  color: #c7d0d8; /* light slate on navy — ~9:1 */
}

@media (max-width: 520px) {
  /* The wordmark is wide (2925×888, ~3.29:1), so it scales down here rather
     than disappearing — it used to be display:none, which left a phone with
     no VHCC mark at all. At 1.9rem tall it is ~100px wide, so on a 320px
     viewport the mark, the tightened padding and the gap take ~134px and
     leave ~186px for the <h1> — more than "Campus Map" needs at 1.2rem
     condensed. Shrink it further before adding anything else to this bar. */
  .brand-mark {
    height: 1.9rem;
  }

  .app-header {
    gap: 0.6rem;
    padding-inline: 0.75rem;
  }
}

/* ─── Layout ─────────────────────────────────────────────────────────────── */

.app-main {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
}

.map-wrap {
  position: absolute;
  inset: 0;
}

#map {
  height: 100%;
  width: 100%;
  background: #dfe3e7;
}

/* ─── Directory panel ────────────────────────────────────────────────────── */
/*
  Solid background, never translucent: text over shifting map tiles cannot
  hold a 4.5:1 ratio (WCAG 1.4.3).
*/

.directory {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 900;
  width: 21rem;
  max-width: calc(100% - 1.5rem);
  max-height: calc(100% - 1.5rem);
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border: 1px solid var(--edge);
  border-radius: 6px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.18);
}

.directory-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.6rem 0.5rem 0.6rem 0.85rem;
  border-bottom: 1px solid var(--line);
}

.directory.is-collapsed .directory-head {
  border-bottom: none;
}

.directory-head h2 {
  margin: 0;
  font-family: "Fira Sans Condensed", "Fira Sans", sans-serif;
  font-size: 1rem;
}

.directory-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 2.25rem;
  padding: 0.35rem 0.6rem;
  background: none;
  border: 1px solid var(--edge);
  border-radius: 4px;
  font: inherit;
  font-size: 0.82rem;
  color: var(--ink);
  cursor: pointer;
}

.directory-toggle:hover {
  background: rgba(40, 78, 54, 0.08);
}

.directory-chevron {
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
  transition: transform 0.15s ease;
}

.directory.is-collapsed .directory-chevron {
  transform: rotate(180deg);
}

.directory-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 0.75rem 0.85rem 0.85rem;
}

.directory.is-collapsed .directory-body {
  display: none;
}

/* ─── Search ─────────────────────────────────────────────────────────────── */

.directory-search label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.directory-search input {
  width: 100%;
  min-height: 2.5rem;
  padding: 0.4rem 0.55rem;
  font: inherit;
  font-size: 0.88rem;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--edge);
  border-radius: 4px;
}

.directory-search input::placeholder {
  color: #626973;
}

/* ─── Filters ────────────────────────────────────────────────────────────── */

.directory-filters {
  margin: 0.85rem 0 0;
  padding: 0.5rem 0.65rem 0.6rem;
  border: 1px solid var(--edge);
  border-radius: 4px;
}

.directory-filters legend {
  padding: 0 0.3rem;
  font-size: 0.78rem;
  font-weight: 600;
}

.filter-option {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 1.9rem;
}

.filter-option input {
  flex: 0 0 auto;
  width: 1.05rem;
  height: 1.05rem;
  accent-color: var(--accent);
  cursor: pointer;
}

.filter-option label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.84rem;
  cursor: pointer;
}

.filter-count {
  color: var(--muted);
  font-size: 0.78rem;
}

.filter-actions {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--line);
}

.filter-actions button {
  flex: 1 1 auto;
  min-height: 2rem;
  padding: 0.25rem 0.5rem;
  background: none;
  border: 1px solid var(--edge);
  border-radius: 4px;
  font: inherit;
  font-size: 0.78rem;
  color: var(--ink);
  cursor: pointer;
}

.filter-actions button:hover {
  background: rgba(40, 78, 54, 0.08);
}

/* Category colour key. Decorative — the adjacent label carries the meaning. */
.swatch {
  display: inline-block;
  flex: 0 0 auto;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.25);
}

/* Routes draw as lines on the map, so their key is a line, not a dot. */
.swatch--line {
  width: 0.95rem;
  height: 0.28rem;
  border-radius: 1px;
}

/* ─── Results ────────────────────────────────────────────────────────────── */

.directory-count {
  margin: 0.7rem 0 0.2rem;
  font-size: 0.76rem;
  color: var(--muted);
}

.result-group + .result-group {
  margin-top: 0.6rem;
}

.result-heading {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0.5rem 0 0.15rem;
  font-family: "Fira Sans Condensed", "Fira Sans", sans-serif;
  font-size: 0.88rem;
}

.result-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.result-list li + li {
  border-top: 1px solid var(--line);
}

.result-btn {
  width: 100%;
  min-height: 2.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  text-align: left;
  padding: 0.55rem 0.35rem;
  background: none;
  border: none;
  border-radius: 3px;
  font: inherit;
  font-size: 0.86rem;
  color: var(--ink);
  cursor: pointer;
}

.result-btn:hover {
  background: rgba(40, 78, 54, 0.08);
}

.result-name {
  font-weight: 600;
}

.result-meta {
  font-size: 0.76rem;
  color: var(--muted);
}

.result-tag {
  margin-top: 0.15rem;
  font-size: 0.73rem;
  font-weight: 600;
  color: var(--muted);
}

.result-pending {
  margin: 0.1rem 0 0.35rem 1.1rem;
  font-size: 0.78rem;
  font-style: italic;
  color: var(--muted);
}

.result-empty {
  margin: 0.6rem 0.35rem;
  font-size: 0.84rem;
  color: var(--muted);
}

/* ─── Focus (WCAG 2.4.7) ─────────────────────────────────────────────────── */

a:focus-visible,
button:focus-visible,
input:focus-visible,
.campus-marker:focus-visible,
.leaflet-control-zoom a:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* ─── Markers ────────────────────────────────────────────────────────────── */

.campus-marker {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
}

.campus-marker--building {
  background: var(--accent);
}
/* Distinct from the building green: lighter and yellower, and the glyph
   differs too (canopy vs. a building code), so the two never rely on hue
   alone to be told apart. */
.campus-marker--space {
  background: #4a7c2f;
}
/* Burnt orange — freed up from blue so the two accessibility categories
   below could take the ISA (International Symbol of Access) blue instead. */
.campus-marker--parking {
  background: #a35a19;
}
/* The ISA (International Symbol of Access) blue — Accessibility features'
   own hue since 2026-07-30, when Accessible routes moved to a distinct teal
   (below) so the two "accessibility" categories are told apart by hue too,
   not just by structure (lines vs. points) and glyph. */
.campus-marker--accessibility {
  background: #2a6099;
}
.campus-marker--emergency {
  background: #b5281c;
}
.campus-marker--services {
  background: #8a6200;
}
/* Teal, not the Accessibility-features blue — same white-on-colour 4.5:1
   floor applies (verify with tools/contrast.js after touching this). Picked
   to read clearly as a distinct hue from both that blue and the two greens
   (Buildings/Open-spaces) at marker size, not just a lighter/darker shade of
   one of them. */
.campus-marker--route {
  background: #00798f;
}
/* Building green again (see the comment on --space above for the precedent
   of sharing a hue), but shrunk to an unobtrusive dot with no glyph or
   badge — deliberately can't be mistaken for the full-size accessible-door
   marker even when a plain entrance sits close to one. iconSize/iconAnchor
   in js/map.js are set to match via `cat.size`. */
.campus-marker--entrance-dot {
  width: 12px;
  height: 12px;
  background: var(--accent);
  border: 1.5px solid #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

.marker-icon {
  display: block;
  width: 17px;
  height: 17px;
  pointer-events: none;
}

/* Building code (ADM, ISC, …). Sized to fit four characters in the 26px
   inner circle. Decorative — the marker's aria-label carries the full name. */
.marker-code {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
  pointer-events: none;
}

/* ─── Leaflet chrome ─────────────────────────────────────────────────────── */

.leaflet-popup-content {
  font-size: 0.88rem;
  line-height: 1.45;
}

.leaflet-popup-content h3 {
  margin: 0 0 0.3rem;
  font-family: "Fira Sans Condensed", "Fira Sans", sans-serif;
  font-size: 1rem;
}

.leaflet-popup-content p {
  margin: 0 0 0.4rem;
}

/* Recenter control. Leaflet's .leaflet-bar styles anchors, not buttons, so the
   button needs explicit sizing to match the zoom control stacked above it. */
.recenter-control {
  margin-top: 0.5rem !important;
}

.recenter-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  background: #fff;
  border: none;
  border-radius: 3px;
  color: var(--ink);
  cursor: pointer;
}

.recenter-btn:hover {
  background: #f4f4f4;
}

.recenter-btn svg {
  width: 16px;
  height: 16px;
  display: block;
}

/* Attribution is a licence obligation, so it sits above the panel and must
   stay legible — Leaflet's default grey does not clear 4.5:1. */
.leaflet-bottom.leaflet-right {
  z-index: 1000;
}

.leaflet-control-attribution {
  background: rgba(255, 255, 255, 0.92) !important;
  color: #3a3a34 !important;
  font-size: 0.68rem !important;
}

/* Leaflet ships these links with text-decoration: none, and their colour is
   nearly identical in luminance to the surrounding text — so they were
   distinguished by hue alone (WCAG 1.4.1). Underline them. */
.leaflet-control-attribution a {
  color: #2b4f42 !important;
  text-decoration: underline !important;
}

/* ─── Narrow viewports ───────────────────────────────────────────────────── */
/*
  Below 900px the panel stops floating and docks to the bottom as a sheet, so
  it never permanently covers the map at 400% zoom (WCAG 1.4.10 Reflow).
  It starts collapsed at this width — see setExpanded() in js/map.js.
*/

@media (max-width: 900px) {
  .directory {
    top: auto;
    left: 0;
    right: 0;
    /* --attr-h is measured in js/map.js — the attribution wraps to two lines
       on narrow screens, and a fixed offset let the panel cover it. */
    bottom: calc(var(--attr-h, 1.25rem) + 0.35rem);
    width: auto;
    max-width: none;
    max-height: 65%;
    border-width: 1px 0 0;
    border-radius: 10px 10px 0 0;
  }

  /* Bumped 2026-08-10. The panel is a floating card on a desktop, where it
     competes with the map for room and small type is a fair trade; docked as
     a sheet it is the primary reading surface and 0.76rem descriptions were
     too small on a phone. Descriptions move most (0.76 → 0.88rem) because
     they carry the room numbers, phone numbers and door detail — the part
     someone is actually reading when they open this on a phone. Sizes stay in
     rem so a browser text-size setting still scales them (1.4.4). */
  .result-btn {
    font-size: 0.95rem;
  }

  .result-meta {
    font-size: 0.88rem;
  }

  .result-heading {
    font-size: 0.95rem;
  }

  .result-tag,
  .result-pending {
    font-size: 0.85rem;
  }

  .directory-count {
    font-size: 0.82rem;
  }

  .result-empty {
    font-size: 0.92rem;
  }
}

@media (max-width: 420px) {
  .brand-text p {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }
}
