/* =================================================================
   The Land of Sigma Pi — Atlas Stylesheet
   Architecture: every themeable value is a CSS variable so the
   /designer admin page can override them at runtime.
   ================================================================= */

/* =================================================================
   Brand fonts — self-hosted .otf for offline / print parity
   ================================================================= */

@font-face {
  font-family: 'Gobold';
  src: url('/assets/fonts/Gobold_Regular.otf') format('opentype');
  font-weight: 400;
  font-style: normal;
  font-display: block;
}
@font-face {
  font-family: 'Gobold';
  src: url('/assets/fonts/Gobold_Regular_Italic.otf') format('opentype');
  font-weight: 400;
  font-style: italic;
  font-display: block;
}

@font-face {
  font-family: 'Gotham';
  src: url('/assets/fonts/Gotham-XLight.otf') format('opentype');
  font-weight: 200;
  font-style: normal;
  font-display: block;
}
@font-face {
  font-family: 'Gotham';
  src: url('/assets/fonts/Gotham-XLightItalic.otf') format('opentype');
  font-weight: 200;
  font-style: italic;
  font-display: block;
}
@font-face {
  font-family: 'Gotham';
  src: url('/assets/fonts/Gotham-Medium.otf') format('opentype');
  font-weight: 500;
  font-style: normal;
  font-display: block;
}
@font-face {
  font-family: 'Gotham';
  src: url('/assets/fonts/Gotham-MediumItalic.otf') format('opentype');
  font-weight: 500;
  font-style: italic;
  font-display: block;
}
@font-face {
  font-family: 'Gotham';
  src: url('/assets/fonts/Gotham_Bold.otf') format('opentype');
  font-weight: 700;
  font-style: normal;
  font-display: block;
}
@font-face {
  font-family: 'Gotham';
  src: url('/assets/fonts/Gotham-BoldItalic.otf') format('opentype');
  font-weight: 700;
  font-style: italic;
  font-display: block;
}
@font-face {
  font-family: 'Gotham';
  src: url('/assets/fonts/Gotham-Black.otf') format('opentype');
  font-weight: 900;
  font-style: normal;
  font-display: block;
}
@font-face {
  font-family: 'Gotham';
  src: url('/assets/fonts/Gotham-BlackItalic.otf') format('opentype');
  font-weight: 900;
  font-style: italic;
  font-display: block;
}

@font-face {
  font-family: 'Amasis';
  src: url('/assets/fonts/Amasis_MT_W1G.otf') format('opentype');
  font-weight: 400;
  font-style: normal;
  font-display: block;
}
@font-face {
  font-family: 'Amasis';
  src: url('/assets/fonts/AmasisMTW1G-Italic.otf') format('opentype');
  font-weight: 400;
  font-style: italic;
  font-display: block;
}
@font-face {
  font-family: 'Amasis';
  src: url('/assets/fonts/AmasisMTW1G-Bold.otf') format('opentype');
  font-weight: 700;
  font-style: normal;
  font-display: block;
}
@font-face {
  font-family: 'Amasis';
  src: url('/assets/fonts/AmasisMTW1G-BoldItalic.otf') format('opentype');
  font-weight: 700;
  font-style: italic;
  font-display: block;
}

/* =================================================================
   Theme variables — every themeable value lives here so the
   /designer page can override them at the :root level
   ================================================================= */

:root {
  /* --- Brand palette --- */
  --purple-900: #211c35;
  --purple-700: #2d2848;
  --purple-500: #403a60;
  --purple-300: #8c88a3;
  --gold-500:   #d0b787;
  --gold-700:   #a8946b;
  --gold-300:   #e6d5b5;

  /* --- Atlas paper --- */
  --paper-50:   #faf7f0;
  --paper-100:  #f5f1e6;
  --paper-200:  #ebe5d3;
  --ink-faint:  #c9c3b0;

  /* --- Province colors (Brand Guidelines) --- */
  --p-pnw:   #54b948;
  --p-sw:    #d5c1de;
  --p-ozark: #ffeb84;
  --p-gl:    #a2def9;
  --p-mid:   #fcdadf;
  --p-fv:    #cc7676;
  --p-gnj:   #8d88a3;
  --p-app:   #71c1a5;
  --p-se:    #f2ad70;
  --p-ne:    #7488be;

  /* --- Type families (designer overrides these) --- */
  --font-display: 'Gobold', 'Fraunces', 'Iowan Old Style', Georgia, serif;
  --font-serif:   'Amasis', 'Iowan Old Style', 'Charter', 'Spectral', Georgia, serif;
  --font-ui:      'Gotham', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;

  /* --- Type roles --- */
  --type-display-family: var(--font-display);
  --type-display-weight: 400;
  --type-display-size:   clamp(2.75rem, 6vw, 5rem);
  --type-display-case:   none;
  --type-display-tracking: 0.01em;

  --type-eyebrow-family: var(--font-ui);
  --type-eyebrow-weight: 500;
  --type-eyebrow-size:   0.7rem;
  --type-eyebrow-case:   uppercase;
  --type-eyebrow-tracking: 0.22em;

  --type-lede-family:    var(--font-serif);
  --type-lede-style:     italic;
  --type-lede-size:      1.05rem;

  --type-body-family:    var(--font-serif);
  --type-body-size:      16px;

  --type-ui-family:      var(--font-ui);
  --type-ui-size:        0.85rem;
  --type-ui-weight:      500;

  --type-label-family:   var(--font-ui);
  --type-label-weight:   500;
  --type-label-size:     0.7rem;
  --type-label-case:     uppercase;
  --type-label-tracking: 0.18em;

  /* --- Page chrome --- */
  --color-fg:           var(--purple-900);
  --color-fg-muted:     var(--purple-300);
  --color-fg-accent:    var(--purple-500);
  --bg-page:            var(--paper-50);
  --bg-card:            white;
  --rule-color:         var(--ink-faint);
  --rule-accent-color:  var(--gold-500);

  /* --- Map --- */
  --map-bg:             transparent;
  --map-border:         transparent;
  --map-border-width:   0;
  --map-padding:        0;
  --state-fill:         var(--paper-100);
  --state-stroke:       white;
  --state-stroke-width: 1.2;
  --nation-stroke:      rgba(33, 28, 53, 0.18);

  /* --- Pins --- */
  --pin-active-fill:    var(--gold-500);
  --pin-active-border:  var(--purple-500);
  --pin-active-r:       6;

  --pin-colony-fill:    var(--purple-500);
  --pin-colony-border:  var(--gold-500);
  --pin-colony-r:       5;

  --pin-inactive-fill:  transparent;
  --pin-inactive-border: var(--purple-300);
  --pin-inactive-r:     4.5;

  --pin-alumni-fill:    #71c1a5;
  --pin-alumni-border:  #4a8d75;
  --pin-alumni-r:       5;

  --pin-stroke-width:   1.4;

  /* --- Tooltip --- */
  --tooltip-bg:           var(--purple-900);
  --tooltip-fg:           var(--paper-100);
  --tooltip-border:       transparent;
  --tooltip-border-width: 0;
  --tooltip-radius:       6px;
  --tooltip-pad-y:        0.7rem;
  --tooltip-pad-x:        0.9rem;
  --tooltip-accent:       var(--gold-500);
  --tooltip-shadow:       0 12px 28px rgba(33, 28, 53, 0.35);

  --province-opacity:        0.55;
  --province-stripe-opacity: 0.55;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html {
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--type-body-family);
  font-weight: 400;
  font-size: var(--type-body-size);
  line-height: 1.55;
  color: var(--color-fg);
  background: var(--bg-page);
  background-image:
    radial-gradient(ellipse at 20% 10%, rgba(64, 58, 96, 0.025) 0, transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(208, 183, 135, 0.04) 0, transparent 50%);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* =================================================================
   Masthead
   ================================================================= */

.masthead {
  padding: 3rem 2rem 1rem;
  border-bottom: 1px solid var(--rule-color);
  position: relative;
}

.masthead::before {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 50%;
  transform: translateX(-50%);
  width: 80px;
  height: 1px;
  background: var(--rule-accent-color);
}

.masthead-inner {
  max-width: 1280px;
  margin: 0 auto;
  text-align: center;
}

.eyebrow {
  font-family: var(--type-eyebrow-family);
  font-weight: var(--type-eyebrow-weight);
  font-size: var(--type-eyebrow-size);
  letter-spacing: var(--type-eyebrow-tracking);
  text-transform: var(--type-eyebrow-case);
  color: var(--color-fg-muted);
  margin-bottom: 1rem;
}

h1.display {
  font-family: var(--type-display-family);
  font-weight: var(--type-display-weight);
  font-size: var(--type-display-size);
  line-height: 1;
  letter-spacing: var(--type-display-tracking);
  color: var(--color-fg);
  margin-bottom: 0.75rem;
  text-transform: var(--type-display-case);
}

h1.display em {
  font-style: italic;
  font-weight: var(--type-display-weight);
  color: var(--color-fg-accent);
}

.lede {
  font-family: var(--type-lede-family);
  font-style: var(--type-lede-style);
  font-size: var(--type-lede-size);
  color: var(--color-fg-muted);
  max-width: 540px;
  margin: 0 auto;
}

/* =================================================================
   Atlas — vertical stack: toolbar → map → legend
   ================================================================= */

.atlas {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  max-width: 1480px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 2rem 2rem;
}

/* =================================================================
   Toolbar (search + filter summary)
   ================================================================= */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
}

.search-wrap {
  flex: 1;
  min-width: 240px;
  max-width: 420px;
  position: relative;
}

.search-wrap::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0.85rem;
  width: 14px;
  height: 14px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14'><circle cx='6' cy='6' r='4.5' fill='none' stroke='%238c88a3' stroke-width='1.4'/><line x1='9.4' y1='9.4' x2='12.5' y2='12.5' stroke='%238c88a3' stroke-width='1.4' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat;
  transform: translateY(-50%);
  pointer-events: none;
}

#search {
  width: 100%;
  font-family: var(--type-ui-family);
  font-size: var(--type-ui-size);
  font-weight: 400;
  color: var(--color-fg);
  background: var(--bg-card);
  border: 1px solid var(--rule-color);
  border-radius: 6px;
  padding: 0.55rem 2.25rem 0.55rem 2.25rem;
  outline: none;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

#search:focus {
  border-color: var(--purple-500);
  box-shadow: 0 0 0 3px rgba(64, 58, 96, 0.12);
}

#search::placeholder {
  color: var(--color-fg-muted);
}

.search-help {
  position: absolute;
  right: 0.45rem;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  border: 0;
  background: transparent;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: help;
  color: var(--color-fg-muted, #8c88a3);
  transition: color 120ms ease, background 120ms ease;
}
.search-help:hover, .search-help:focus-visible {
  color: var(--color-fg, #211c35);
  background: rgba(33, 28, 53, 0.06);
  outline: none;
}

.search-help-popover {
  position: absolute;
  top: calc(100% + 0.4rem);
  right: 0;
  min-width: 280px;
  max-width: 360px;
  background: var(--paper-50, #faf7f0);
  border: 1px solid var(--rule-30, #c9c3b0);
  border-radius: 8px;
  box-shadow: 0 14px 36px -8px rgba(33, 28, 53, 0.22), 0 4px 10px -3px rgba(33, 28, 53, 0.10);
  padding: 0.85rem 1rem 0.95rem;
  z-index: 90;
  font-family: var(--type-ui-family);
}
.search-help-popover[hidden] { display: none; }
.search-help-title {
  font-size: 0.74rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-fg-muted, #8c88a3);
  margin: 0 0 0.55rem;
  font-weight: 600;
}
.search-help-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  font-size: 0.85rem;
  color: var(--color-fg, #211c35);
  line-height: 1.45;
}
.search-help-list li strong {
  font-weight: 600;
}
.search-help-list li em {
  font-family: var(--font-body, var(--type-body-family));
  font-style: italic;
  color: var(--color-fg-muted, #8c88a3);
  margin-right: 0.3rem;
}

.toolbar-meta {
  flex: 0 0 auto;
  font-family: var(--type-ui-family);
  font-size: 0.8rem;
  color: var(--color-fg-muted);
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.filter-summary {
  font-style: italic;
}

.clear-filters {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--type-ui-family);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  color: var(--color-fg-accent);
  background: transparent;
  border: 1px solid var(--rule-color);
  border-radius: 4px;
  padding: 0.3rem 0.6rem;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, background 120ms ease;
}

.clear-filters.show {
  opacity: 1;
  pointer-events: auto;
}

.clear-filters:hover {
  background: var(--paper-100);
}

/* =================================================================
   Status pills — Active / Colony / Inactive / Alumni Clubs
   ================================================================= */

.status-pills {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-left: auto;  /* push to the right end of the toolbar */
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem 0.4rem 0.55rem;
  font-family: var(--type-ui-family);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  color: var(--color-fg-muted);
  background: var(--bg-card);
  border: 1px solid var(--rule-color);
  border-radius: 999px;
  cursor: pointer;
  transition: all 180ms ease;
  white-space: nowrap;
}

.status-pill:hover:not(:disabled) {
  background: var(--paper-100);
  border-color: var(--purple-300, #b5b1c7);
  color: var(--color-fg);
}

.status-pill.is-active {
  background: var(--purple-500, #403a60);
  color: var(--paper-50, #fdfaf3);
  border-color: var(--purple-500, #403a60);
}

.status-pill.is-active:hover {
  background: var(--purple-600, #322c4a);
  color: var(--paper-50, #fdfaf3);
}

.status-pill:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.pill-swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1.5px solid;
  flex-shrink: 0;
}

.pill-swatch-active   { background: var(--pin-active-fill);    border-color: var(--pin-active-border); }
.pill-swatch-colony   { background: var(--pin-colony-fill);    border-color: var(--pin-colony-border); }
.pill-swatch-inactive { background: transparent;               border-color: var(--pin-inactive-border, #8c88a3); }
.pill-swatch-alumni   { background: var(--pin-alumni-fill, #71c1a5); border-color: var(--pin-alumni-border, #4a8d75); }

.status-pill.is-active .pill-swatch {
  /* Lighten swatch borders against the dark active-pill background */
  box-shadow: inset 0 0 0 1px rgba(253, 250, 243, 0.25);
}

.pill-count {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  opacity: 0.8;
  font-size: 0.72rem;
}

.pill-label {
  font-weight: 500;
}

/* Province filter pill — sits in the same row as Active/Colony/Inactive */
.province-pill-wrap {
  position: relative;
}
.province-pill {
  /* Inherits .status-pill base layout */
}
.province-pill-swatch {
  background: linear-gradient(135deg,
    var(--p-fv) 0%, var(--p-fv) 25%,
    var(--p-app) 25%, var(--p-app) 50%,
    var(--p-pnw) 50%, var(--p-pnw) 75%,
    var(--p-sw) 75%, var(--p-sw) 100%);
  border-color: var(--rule-30);
}
.province-pill[aria-pressed="true"] .province-pill-swatch {
  background: var(--swatch-bg, var(--p-fv));
}
/* When a province is selected, the swatch fills with that province's color (set via data-province) */
.province-pill-swatch[data-province] {
  background: transparent;
}
.province-pill-swatch[data-province]::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
}
.pill-caret {
  margin-left: 0.1rem;
  opacity: 0.7;
  transition: transform 180ms ease;
}
.province-pill[aria-expanded="true"] .pill-caret {
  transform: rotate(180deg);
}

.province-dropdown {
  position: absolute;
  top: calc(100% + 0.4rem);
  right: 0;
  min-width: 240px;
  max-height: 380px;
  overflow-y: auto;
  background: var(--paper-50, #faf7f0);
  border: 1px solid var(--rule-30, #c9c3b0);
  border-radius: 10px;
  box-shadow: 0 12px 32px -10px rgba(33, 28, 53, 0.18), 0 4px 10px -3px rgba(33, 28, 53, 0.10);
  padding: 0.4rem;
  z-index: 100;
}
.province-option {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: 0;
  background: transparent;
  border-radius: 6px;
  font: inherit;
  font-size: 0.82rem;
  color: var(--ink, #211c35);
  cursor: pointer;
  text-align: left;
  transition: background 120ms ease;
}
.province-option:hover,
.province-option:focus-visible {
  background: rgba(33, 28, 53, 0.06);
}
.province-option .province-name {
  flex: 1;
  font-weight: 500;
}
.province-option .province-count {
  font-variant-numeric: tabular-nums;
  opacity: 0.55;
  font-size: 0.74rem;
}
.province-option-clear {
  font-weight: 600;
  color: var(--muted, #8c88a3);
  border-bottom: 1px solid var(--rule-30, #c9c3b0);
  border-radius: 6px 6px 0 0;
  margin-bottom: 0.25rem;
  padding-bottom: 0.55rem;
}
.province-option .province-swatch {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  flex-shrink: 0;
}

/* =================================================================
   Map Stage — full-width, no box
   ================================================================= */

.map-stage {
  position: relative;
  background: var(--map-bg);
  border: var(--map-border-width) solid var(--map-border);
  padding: var(--map-padding);
}

#map-container {
  position: relative;
  width: 100%;
  aspect-ratio: 960 / 600;
}

#map {
  width: 100%;
  height: 100%;
  display: block;
}

.loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--type-ui-family);
  font-size: 0.85rem;
  color: var(--color-fg-muted);
  background: var(--bg-page);
  z-index: 5;
  transition: opacity 380ms ease;
}

.loading.fade { opacity: 0; }

.loading .dots { display: inline-flex; margin-left: 2px; }
.loading .dots span { animation: bounce 1.4s infinite ease-in-out; opacity: 0; }
.loading .dots span:nth-child(1) { animation-delay: 0.0s; }
.loading .dots span:nth-child(2) { animation-delay: 0.15s; }
.loading .dots span:nth-child(3) { animation-delay: 0.30s; }

@keyframes bounce {
  0%, 80%, 100% { opacity: 0; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}

/* =================================================================
   SVG: states, provinces, pins
   ================================================================= */

.state {
  stroke: var(--state-stroke);
  stroke-width: var(--state-stroke-width);
  stroke-linejoin: round;
  cursor: pointer;
  transition: filter 120ms ease;
}
.state:hover { filter: brightness(0.94); }
.state.is-focused { filter: brightness(0.92); }

/* Canada — drawn behind US states, neutral tone for context */
.canada {
  fill: var(--state-fill, #f5f1e6);
  fill-opacity: 0.75;
  stroke: var(--state-stroke, #ffffff);
  stroke-width: 0.6;
  stroke-linejoin: round;
  pointer-events: none;
}

.nation-outline {
  fill: none;
  stroke: var(--nation-stroke);
  stroke-width: 0.6;
  stroke-linejoin: round;
  pointer-events: none;
}

.partial-stripe {
  pointer-events: none;
  opacity: var(--province-stripe-opacity);
}

.pin {
  cursor: pointer;
  transition: r 180ms cubic-bezier(0.34, 1.56, 0.64, 1), stroke-width 180ms ease;
  filter: drop-shadow(0 1px 1px rgba(33, 28, 53, 0.18));
  /* Stroke renders at constant pixel width regardless of zoom */
  vector-effect: non-scaling-stroke;
}

.pin[data-status="Active"],
path.pin-shape[data-status="Active"] {
  fill:   var(--pin-active-fill);
  stroke: var(--pin-active-border);
  stroke-width: var(--pin-stroke-width);
  vector-effect: non-scaling-stroke;
}
.pin[data-status="Colony"],
path.pin-shape[data-status="Colony"] {
  fill:   var(--pin-colony-fill);
  stroke: var(--pin-colony-border);
  stroke-width: var(--pin-stroke-width);
  vector-effect: non-scaling-stroke;
}
.pin-inactive,
path.pin-shape[data-status="Inactive"] {
  fill:   var(--pin-inactive-fill);
  stroke: var(--pin-inactive-border);
  stroke-width: var(--pin-stroke-width);
  vector-effect: non-scaling-stroke;
}

.pin[data-status="Alumni"], .pin-alumni,
path.pin-shape[data-status="Alumni"] {
  fill:   var(--pin-alumni-fill);
  stroke: var(--pin-alumni-border);
  stroke-width: var(--pin-stroke-width);
  vector-effect: non-scaling-stroke;
}

.pin-glow[data-status="Active"] { fill: var(--pin-active-fill); }
.pin-glow[data-status="Colony"] { fill: var(--pin-colony-fill); }

.pin.hovered { stroke-width: 2.2; }

.pin-glow {
  pointer-events: none;
  opacity: 0;
  transition: opacity 220ms ease;
}

.pin-glow.hovered { opacity: 0.30; }

/* Transparent hit-pad — sits on top of the visible pin, captures pointer
   events from a generously larger area so taps don't need pixel-perfect
   aim. Visible pin and glow underneath continue to render normally. */
.pin-hit-target {
  fill: rgba(0, 0, 0, 0);
  stroke: none;
  pointer-events: visible;
  cursor: pointer;
}

/* Leg line — connects each displaced (non-anchor) pin back to the true
   location. Faint dashed gray so it reads as a relationship marker, not
   a route. Pointer events off so the line itself isn't clickable. */
.leg-line {
  stroke: rgba(64, 58, 96, 0.55);
  stroke-width: 0.9;
  stroke-dasharray: 2.4 1.8;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}
.leg-line.hidden { display: none; }
.leg-line.dimmed { opacity: 0.18; }

/* Alumni coverage-radius overlay — independent of pin shape. When the
   "Show coverage radius" toggle is on, alumni pins render normally AND
   a coverage circle appears behind each one. Body class drives visibility
   of the radii layer. */
.pins-alumni-radii-layer { display: none; }
body.alumni-radius-enabled .pins-alumni-radii-layer { display: block; }
/* If the user filters alumni off via the status pill, hide both layers */
body.hide-alumni .pins-alumni-layer,
body.hide-alumni .pins-alumni-radii-layer { display: none; }

.pin-alumni-radius {
  fill: var(--pin-alumni-fill, #71c1a5);
  fill-opacity: var(--pin-alumni-radius-opacity, 0.22);
  stroke: var(--pin-alumni-border, #4a8d75);
  stroke-width: var(--pin-alumni-radius-stroke-width, 1.2);
  stroke-opacity: 0.55;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
  transition: r 200ms ease;
}
.pin.dimmed { opacity: 0.18; pointer-events: none; }
.pin-glow.dimmed { opacity: 0; }
.pin.hidden, .pin-glow.hidden { display: none; }

.pin-inactive {
  fill: var(--pin-inactive-fill);
  stroke: var(--pin-inactive-border);
  stroke-width: var(--pin-stroke-width);
  cursor: pointer;
  transition: r 160ms ease, stroke-width 160ms ease;
  vector-effect: non-scaling-stroke;
}
.pin-inactive.hovered { stroke-width: 2.0; }
.pin-inactive.dimmed { opacity: 0.18; pointer-events: none; }

body:not(.show-inactive) .pin-inactive { display: none; }

/* Whole-layer toggle for alumni clubs (matches inactive layer pattern).
   When the user deselects the Alumni Clubs status pill, body.hide-alumni
   is set and the whole layer is hidden. */
body.hide-alumni .pins-alumni-layer { display: none; }

/* =================================================================
   Tooltip
   ================================================================= */

.tooltip {
  position: absolute;
  pointer-events: auto;
  background: var(--tooltip-bg);
  color: var(--tooltip-fg);
  font-family: var(--type-ui-family);
  font-size: 0.85rem;
  line-height: 1.4;
  padding: var(--tooltip-pad-y) var(--tooltip-pad-x);
  border: var(--tooltip-border-width) solid var(--tooltip-border);
  border-radius: var(--tooltip-radius);
  box-shadow: var(--tooltip-shadow);
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, calc(-100% - 14px));
  transition: opacity 140ms ease, visibility 0s linear 140ms;
  z-index: 100;
  max-width: 320px;
}

.tooltip.show {
  opacity: 1;
  visibility: visible;
  transition: opacity 140ms ease, visibility 0s linear 0s;
}

/* Status pill at the top of the tooltip */
.tip-status-row {
  margin: 0 0 0.5rem;
}
.tip-status-pill {
  display: inline-block;
  font-family: var(--type-ui-family);
  font-size: 0.66rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 600;
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
}
.tip-status-active {
  background: rgba(208, 183, 135, 0.32);
  color: #f5e8c0;
  border: 1px solid rgba(208, 183, 135, 0.55);
}
.tip-status-colony {
  background: rgba(245, 241, 230, 0.92);
  color: #211c35;
  border: 1px solid rgba(245, 241, 230, 0.92);
}
.tip-status-inactive {
  background: rgba(245, 241, 230, 0.10);
  color: rgba(245, 241, 230, 0.65);
  border: 1px solid rgba(245, 241, 230, 0.25);
}
.tip-status-alumni {
  background: rgba(113, 193, 165, 0.28);
  color: #d8f5e8;
  border: 1px solid rgba(113, 193, 165, 0.55);
}

.tip-headline {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.005em;
  margin-bottom: 0.15rem;
  color: var(--tooltip-fg);
}

.tip-location {
  font-family: var(--type-ui-family);
  font-size: 0.85rem;
  color: var(--tooltip-fg);
  opacity: 0.9;
  margin-bottom: 0.1rem;
}

.tip-detail {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding-top: 0.4rem;
  margin-top: 0.4rem;
  border-top: 1px solid rgba(208, 183, 135, 0.25);
  font-family: var(--type-ui-family);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--tooltip-accent);
}

.tip-province-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* "Chartered ..." line — keep as plain meta, not all caps */
.tip-detail.tip-meta {
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.78rem;
  color: var(--tooltip-fg);
  opacity: 0.78;
}

/* Small uppercase label preceding alumni meta values: "President: …" */
.tip-meta-label {
  display: inline-block;
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 600;
  margin-right: 0.4rem;
  opacity: 0.65;
}

/* Website link inherits tooltip color (no blue), still clickable */
.tip-website {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: rgba(208, 183, 135, 0.55);
  text-underline-offset: 2px;
  word-break: break-all;
  cursor: pointer;
  transition: text-decoration-color 120ms ease;
}
.tip-website:hover, .tip-website:focus {
  text-decoration-color: currentColor;
  outline: none;
}

/* Old single-line .tip-status kept hidden; the pill above replaces it */
.tip-status { display: none; }

/* =================================================================
   Legend (now BELOW the map; provinces in 3 columns)
   ================================================================= */

.legend {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  border-top: 1px solid var(--rule-color);
  padding-top: 1.5rem;
}

.legend-block + .legend-block {
  border-top: 1px solid var(--rule-color);
  padding-top: 1.5rem;
}

.legend-title {
  font-family: var(--font-ui);
  font-weight: var(--type-label-weight);
  font-size: var(--type-label-size);
  letter-spacing: var(--type-label-tracking);
  text-transform: var(--type-label-case);
  color: var(--color-fg-muted);
  margin-bottom: 0.85rem;
}

/* Pins block: row layout for swatches + toggle */
.legend-block.pins-block {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1.25rem 2rem;
  align-items: center;
}

.legend-block.pins-block .legend-title {
  grid-column: 1 / -1;
  margin-bottom: 0;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  font-family: var(--font-serif);
  font-size: 0.95rem;
  cursor: pointer;
  user-select: none;
  padding: 0.25rem 0;
  border-radius: 4px;
}

.legend-row:hover {
  background: rgba(64, 58, 96, 0.04);
}

.legend-row.dimmed { opacity: 0.4; }

.legend-row.dimmed .legend-label {
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}

.legend-label { flex: 1; }

.legend-count {
  font-family: var(--font-ui);
  font-size: 0.8rem;
  color: var(--color-fg-muted);
  font-variant-numeric: tabular-nums;
}

.pin-swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1.4px solid;
}

.pin-swatch.pin-active {
  background: var(--pin-active-fill);
  border-color: var(--pin-active-border);
}

.pin-swatch.pin-colony {
  background: var(--pin-colony-fill);
  border-color: var(--pin-colony-border);
}

.pin-swatch.pin-inactive {
  background: transparent;
  border-color: var(--pin-inactive-border);
}

/* Inactive toggle */
.toggle-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  font-family: var(--font-serif);
  font-size: 0.95rem;
  user-select: none;
  cursor: pointer;
  padding: 0.25rem 0;
}

.toggle-row input {
  appearance: none;
  -webkit-appearance: none;
  width: 30px;
  height: 18px;
  border-radius: 9px;
  background: var(--paper-200);
  border: 1px solid var(--rule-color);
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 180ms ease;
}

.toggle-row input::after {
  content: "";
  position: absolute;
  top: 1px;
  left: 1px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: white;
  transition: transform 180ms ease;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}

.toggle-row input:checked {
  background: var(--purple-500);
  border-color: var(--purple-500);
}

.toggle-row input:checked::after {
  transform: translateX(12px);
}

.toggle-row .legend-label { flex: 1; }

/* Provinces in 3 columns */
#province-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  column-gap: 2rem;
  row-gap: 0.4rem;
}

.province-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  font-family: var(--font-serif);
  font-size: 0.95rem;
  cursor: pointer;
  user-select: none;
  padding: 0.25rem 0;
  border-radius: 4px;
}

.province-row:hover {
  background: rgba(64, 58, 96, 0.04);
}

.province-row.dimmed { opacity: 0.35; }

.province-row.dimmed .province-name {
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}

.province-row.solo {
  background: rgba(208, 183, 135, 0.18);
}

.province-swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  flex-shrink: 0;
}

.province-name { flex: 1; }

.province-count {
  font-family: var(--font-ui);
  font-size: 0.8rem;
  color: var(--color-fg-muted);
  font-variant-numeric: tabular-nums;
}

.legend-footnote {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 0.8rem;
  color: var(--color-fg-muted);
  margin-top: 1rem;
  padding-left: 0.7rem;
  border-left: 2px solid var(--gold-500);
  max-width: 56ch;
}

/* Stats — horizontal grid */
.legend-block.stats {
  display: grid;
  /* 2 columns on narrow viewports, 4 columns on wider — never 3+1 or other
     uneven arrangements that leave a single tile on its own row. */
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem 2rem;
}

@media (min-width: 720px) {
  .legend-block.stats {
    grid-template-columns: repeat(4, 1fr);
  }
}

.stat-num {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 2.5rem;
  line-height: 1;
  color: var(--color-fg);
}

.stat-label {
  font-family: var(--type-label-family);
  font-size: var(--type-label-size);
  font-weight: var(--type-label-weight);
  letter-spacing: var(--type-label-tracking);
  text-transform: var(--type-label-case);
  color: var(--color-fg-muted);
  margin-top: 0.4rem;
}

/* =================================================================
   Footer
   ================================================================= */

.colophon {
  border-top: 1px solid var(--rule-color);
  padding: 1.25rem 2rem;
  background: rgba(208, 183, 135, 0.04);
}

.colophon-inner {
  max-width: 1480px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  font-family: var(--type-ui-family);
  font-size: 0.75rem;
  color: var(--color-fg-muted);
  letter-spacing: 0.02em;
}

.colophon-meta {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
}

.source-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--type-ui-family);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: rgba(113, 193, 165, 0.12);
  color: #51a087;
  border: 1px solid rgba(113, 193, 165, 0.3);
}

.source-badge.cached {
  background: rgba(204, 118, 118, 0.12);
  color: #b86767;
  border-color: rgba(204, 118, 118, 0.3);
}

.source-badge::before {
  content: "●";
  font-size: 0.5rem;
  animation: pulse 2.4s infinite ease-in-out;
}

@keyframes pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* Error log badge — sits next to "Live" indicator */
.error-log-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--type-ui-family);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  border: 1px solid;
  cursor: pointer;
  background: transparent;
  transition: background 120ms ease, border-color 120ms ease, transform 120ms ease;
  user-select: none;
}
/* The `hidden` attribute must always win over our display rule */
.error-log-badge[hidden] { display: none; }
.error-log-badge:hover { transform: translateY(-1px); }
.error-log-badge:active { transform: translateY(0); }
.error-log-badge:focus-visible {
  outline: 2px solid var(--purple-500, #403a60);
  outline-offset: 2px;
}
.error-log-badge.is-clean {
  background: rgba(113, 193, 165, 0.10);
  color: #51a087;
  border-color: rgba(113, 193, 165, 0.3);
}
.error-log-badge.is-clean:hover {
  background: rgba(113, 193, 165, 0.18);
}
.error-log-badge.has-issues {
  background: rgba(184, 70, 38, 0.10);
  color: #b84626;
  border-color: rgba(184, 70, 38, 0.35);
}
.error-log-badge.has-issues:hover {
  background: rgba(184, 70, 38, 0.18);
}
.error-log-icon { font-size: 0.85rem; line-height: 1; }

/* Expandable panel */
.error-log-panel {
  position: fixed;
  bottom: 4rem;
  right: 1.25rem;
  width: min(440px, calc(100vw - 2.5rem));
  max-height: min(60vh, 500px);
  background: var(--paper-50, #faf7f0);
  border: 1px solid var(--rule-30, #c9c3b0);
  border-radius: 8px;
  box-shadow: 0 14px 36px -8px rgba(33, 28, 53, 0.30), 0 4px 10px -3px rgba(33, 28, 53, 0.15);
  z-index: 200;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
/* The `hidden` attribute must always win over our display rule */
.error-log-panel[hidden] { display: none; }
.error-log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--rule-30, #c9c3b0);
  font-family: var(--type-ui-family);
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-fg, #211c35);
}
.error-log-close {
  width: 24px; height: 24px;
  border: 0;
  background: transparent;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  color: var(--color-fg-muted, #8c88a3);
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.error-log-close:hover {
  background: rgba(33, 28, 53, 0.06);
  color: var(--color-fg);
}
.error-log-body {
  overflow-y: auto;
  padding: 0.6rem 1rem 1rem;
  font-family: var(--type-ui-family);
  font-size: 0.82rem;
  color: var(--color-fg);
}
.error-log-empty {
  margin: 0.5rem 0;
  color: var(--color-fg-muted, #8c88a3);
  font-style: italic;
}
.error-log-group {
  margin-top: 0.85rem;
}
.error-log-group:first-child { margin-top: 0.3rem; }
.error-log-group h4 {
  margin: 0 0 0.4rem;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--color-fg-muted, #8c88a3);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.error-log-count {
  display: inline-block;
  font-size: 0.7rem;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  background: rgba(33, 28, 53, 0.08);
  color: var(--color-fg, #211c35);
  letter-spacing: 0;
  text-transform: none;
}
.error-log-group-severe h4 { color: #b84626; }
.error-log-group-severe .error-log-count {
  background: rgba(184, 70, 38, 0.12);
  color: #b84626;
}
.error-log-group ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.error-log-group li {
  padding: 0.45rem 0.6rem;
  background: rgba(33, 28, 53, 0.04);
  border-left: 2px solid rgba(33, 28, 53, 0.15);
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.error-log-group-severe li {
  background: rgba(184, 70, 38, 0.06);
  border-left-color: rgba(184, 70, 38, 0.5);
}
.error-log-msg { color: var(--color-fg, #211c35); line-height: 1.4; }
.error-log-detail {
  font-size: 0.74rem;
  color: var(--color-fg-muted, #8c88a3);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  word-break: break-word;
}

/* =================================================================
   Responsive
   ================================================================= */

@media (max-width: 960px) {
  .atlas {
    padding: 1.25rem 1rem;
    gap: 1.25rem;
  }
  #province-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .legend-block.pins-block {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 600px) {
  /* Hard stop on any horizontal overflow at the viewport level. Without this
     a flex child sometimes blows out the container width (the search input's
     width:100% inside a column-direction flex parent with stretch alignment
     can resolve to its intrinsic content size, which then propagates up). */
  html, body { overflow-x: hidden; max-width: 100vw; }

  /* Compact masthead — one row, tight padding, smaller font.
     Eyebrow + lede are not rendered on the main map page, so we only need
     to size the title down. */
  .masthead {
    padding: 0.5rem 1rem;
  }
  h1.display {
    font-size: 1.25rem;
    line-height: 1.15;
    margin-bottom: 0;
    white-space: nowrap;
  }
  h1.display em { display: inline; }
  .lede { font-size: 0.95rem; }

  .atlas {
    padding: 1rem;
    gap: 1rem;
    max-width: 100vw;
    min-width: 0;
    overflow-x: hidden;
  }
  .toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  /* Each toolbar child must be allowed to shrink below its content size
     (min-width: 0) and constrained to the toolbar's width. */
  .search-wrap {
    min-width: 0;
    max-width: 100%;
    width: 100%;
    flex: 0 0 auto;
  }

  /* Status pills: one horizontal row that scrolls if it overflows.
     Each pill stays its natural width; the container clips and scrolls. */
  .status-pills {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    margin-left: 0;
    margin-right: 0;
    padding: 2px 0 6px;
    scrollbar-width: thin;
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }
  .status-pill { flex-shrink: 0; }
  .province-pill-wrap { flex-shrink: 0; }
  .toolbar-meta {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    flex-wrap: wrap;
  }

  .toolbar-meta {
    justify-content: space-between;
    text-align: left;
  }
  #province-list { grid-template-columns: 1fr; }
  .legend-block.pins-block { grid-template-columns: 1fr; }
  .legend-block.pins-block .legend-title { margin-bottom: 0.5rem; }
  .stat-num { font-size: 2rem; }
  .colophon { padding: 1rem; }
  .tooltip {
    font-size: 0.8rem;
    padding: 0.55rem 0.75rem;
    max-width: calc(100vw - 2rem);
    white-space: normal;
  }
  .tip-chapter { font-size: 1rem; }
}

/* =================================================================
   Print mode (?print=1)
   ================================================================= */

body.print-mode { background: white; }

body.print-mode .toolbar,
body.print-mode .source-badge,
body.print-mode .tooltip,
body.print-mode .clear-filters,
body.print-mode #loading {
  display: none !important;
}

body.print-mode .colophon-inner { justify-content: center; }

@media print {
  body { background: white; }
  .toolbar, .tooltip, .source-badge, .clear-filters { display: none !important; }
}

/* =================================================================
   Designer-driven visibility toggles
   The designer page sets these classes on <body> via postMessage.
   ================================================================= */

body.hide-masthead         .masthead         { display: none; }
body.hide-search           .search-wrap      { display: none; }
body.hide-status-pills     .status-pills     { display: none; }
body.hide-province-legend  .legend-block:has(#province-list) { display: none; }
body.hide-stats            .legend-block.stats { display: none; }
body.hide-footer           .colophon         { display: none; }
body.hide-designer-link    .designer-link    { display: none; }

/* Province colors off — render every state as the neutral fill */
body.hide-province-colors path.state {
  fill: var(--state-fill) !important;
  fill-opacity: 1 !important;
}
body.hide-province-colors .province-swatch { background: var(--state-fill) !important; }
body.hide-province-colors .province-stripe { display: none; }

/* State borders off */
body.hide-state-borders path.state {
  stroke: transparent !important;
  stroke-width: 0 !important;
}

/* Country outline off */
body.hide-country-outline path.nation,
body.hide-country-outline .nation {
  stroke: transparent !important;
}

/* Designer mode: the iframe inside designer hides chrome that doesn't make
   sense in the editor preview */
body.designer-mode .designer-link { display: none; }
body.designer-mode .colophon { font-size: 0.7rem; }

/* Embed mode: tighter chrome, no source-badge, no designer button */
body.embed-mode { background: var(--paper-50); padding: 0.5rem; }
body.embed-mode .masthead-inner { padding-top: 1rem; padding-bottom: 0.5rem; }
body.embed-mode .designer-link,
body.embed-mode .source-badge,
body.embed-mode .colophon { display: none; }
body.embed-mode .display { font-size: clamp(1.6rem, 4vw, 2.5rem); }
body.embed-mode .lede { font-size: 0.95rem; }

/* =================================================================
   Designer link — paint brush button, top-right of page
   ================================================================= */

.designer-link {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 50;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card, #ffffff);
  border: 1px solid var(--rule-color);
  border-radius: 50%;
  color: var(--color-fg-accent);
  text-decoration: none;
  box-shadow: 0 2px 6px rgba(33, 28, 53, 0.08);
  transition: transform 180ms cubic-bezier(0.34, 1.56, 0.64, 1),
              background 180ms ease,
              border-color 180ms ease,
              color 180ms ease,
              box-shadow 180ms ease;
}

.designer-link:hover {
  background: var(--purple-500);
  border-color: var(--purple-500);
  color: var(--paper-50);
  transform: scale(1.08) rotate(-6deg);
  box-shadow: 0 4px 14px rgba(33, 28, 53, 0.18);
}

.designer-link svg {
  display: block;
  pointer-events: none;
}

@media (max-width: 720px) {
  .designer-link {
    top: 0.6rem;
    right: 0.6rem;
    width: 38px;
    height: 38px;
  }
  .designer-link svg { width: 18px; height: 18px; }
}

/* =================================================================
   Counties layer (Phase B) — split-state color division
   ================================================================= */

path.county {
  pointer-events: none;
  transition: fill-opacity 220ms ease;
}

body.hide-province-colors path.county {
  fill-opacity: 0 !important;
}

/* =================================================================
   Province fills — driven by data-province attribute → CSS var.
   This makes designer color changes apply instantly across the map.
   ================================================================= */

path.state[data-province=""], path.state:not([data-province]) {
  fill: var(--state-fill);
}
path.state[data-province="Pacific Northwest"]    { fill: var(--p-pnw); }
path.state[data-province="Southwest"]            { fill: var(--p-sw); }
path.state[data-province="Ozark"]                { fill: var(--p-ozark); }
path.state[data-province="Great Lakes"]          { fill: var(--p-gl); }
path.state[data-province="Midatlantic"]          { fill: var(--p-mid); }
path.state[data-province="Founders' Valley"]     { fill: var(--p-fv); }
path.state[data-province="Founders\2019  Valley"] { fill: var(--p-fv); }
path.state[data-province="Greater New Jersey"]   { fill: var(--p-gnj); }
path.state[data-province="Appalachian"]          { fill: var(--p-app); }
path.state[data-province="Southeast"]            { fill: var(--p-se); }
path.state[data-province="New England"]          { fill: var(--p-ne); }

path.county[data-province="Pacific Northwest"]    { fill: var(--p-pnw); }
path.county[data-province="Southwest"]            { fill: var(--p-sw); }
path.county[data-province="Ozark"]                { fill: var(--p-ozark); }
path.county[data-province="Great Lakes"]          { fill: var(--p-gl); }
path.county[data-province="Midatlantic"]          { fill: var(--p-mid); }
path.county[data-province="Founders' Valley"]     { fill: var(--p-fv); }
path.county[data-province="Founders\2019  Valley"] { fill: var(--p-fv); }
path.county[data-province="Greater New Jersey"]   { fill: var(--p-gnj); }
path.county[data-province="Appalachian"]          { fill: var(--p-app); }
path.county[data-province="Southeast"]            { fill: var(--p-se); }
path.county[data-province="New England"]          { fill: var(--p-ne); }

/* Province legend swatches also driven by CSS var — so designer changes
   propagate to the legend chips at the same time as the map. */
.province-swatch[data-province="Pacific Northwest"]    { background: var(--p-pnw); }
.province-swatch[data-province="Southwest"]            { background: var(--p-sw); }
.province-swatch[data-province="Ozark"]                { background: var(--p-ozark); }
.province-swatch[data-province="Great Lakes"]          { background: var(--p-gl); }
.province-swatch[data-province="Midatlantic"]          { background: var(--p-mid); }
.province-swatch[data-province="Founders' Valley"]     { background: var(--p-fv); }
.province-swatch[data-province="Founders\2019  Valley"] { background: var(--p-fv); }
.province-swatch[data-province="Greater New Jersey"]   { background: var(--p-gnj); }
.province-swatch[data-province="Appalachian"]          { background: var(--p-app); }
.province-swatch[data-province="Southeast"]            { background: var(--p-se); }
.province-swatch[data-province="New England"]          { background: var(--p-ne); }

/* =================================================================
   Zoom controls (Phase B)
   ================================================================= */

#map-container {
  position: relative;
}

.zoom-controls {
  position: absolute;
  top: 0.6rem;
  left: 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 30;
  background: var(--bg-card, #fff);
  border: 1px solid var(--rule-color);
  border-radius: 6px;
  padding: 3px;
  box-shadow: 0 2px 6px rgba(33, 28, 53, 0.08);
}

.zoom-btn {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  border-radius: 4px;
  color: var(--color-fg-accent);
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease;
}

.zoom-btn:hover {
  background: var(--paper-100);
  color: var(--purple-900);
}

.zoom-btn:active {
  background: var(--paper-200);
}

.zoom-btn svg { display: block; }

#map {
  cursor: grab;
}
#map:active { cursor: grabbing; }

/* Keep state/county/nation borders the same visual weight regardless of zoom */
path.state, path.county, path.nation-outline {
  vector-effect: non-scaling-stroke;
}

@media (max-width: 720px) {
  .zoom-controls { top: 0.4rem; left: 0.4rem; }
  .zoom-btn { width: 32px; height: 32px; }
}

body.embed-mode .zoom-controls { top: 0.3rem; left: 0.3rem; }

/* =================================================================
   Phase E: Chapter detail drawer
   ================================================================= */

.chapter-drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: 380px;
  max-width: 95vw;
  background: var(--paper-50, #faf7f0);
  border-left: 1px solid var(--rule-30, #c9c3b0);
  box-shadow: -16px 0 40px -12px rgba(33, 28, 53, 0.22);
  z-index: 200;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 280ms cubic-bezier(0.4, 0.0, 0.2, 1);
  padding: 1.4rem 1.6rem 2rem;
}
.chapter-drawer[hidden] { display: none; }
.chapter-drawer.is-open { transform: translateX(0); }

/* State drawer — clicking a US state opens this with all chapters,
   colonies, alumni clubs, and province tag(s) in that state. Desktop
   slides in from the right; mobile slides up from the bottom as a sheet. */
.state-drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: 360px;
  max-width: 95vw;
  background: var(--paper-50, #faf7f0);
  border-left: 1px solid var(--rule-30, #c9c3b0);
  box-shadow: -16px 0 40px -12px rgba(33, 28, 53, 0.22);
  z-index: 195; /* below chapter-drawer (200) so chapter drawer covers it when opened */
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 280ms cubic-bezier(0.4, 0.0, 0.2, 1);
  padding: 1.4rem 1.6rem 2rem;
}
.state-drawer[hidden] { display: none; }
.state-drawer.is-open { transform: translateX(0); }
/* When the chapter drawer is open on top, fade the state drawer slightly */
body.chapter-drawer-open .state-drawer.is-open {
  opacity: 0.55;
  pointer-events: none;
}

.state-drawer-close {
  position: absolute;
  top: 0.9rem;
  right: 0.9rem;
  width: 32px;
  height: 32px;
  border: 0;
  background: transparent;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--ink, #211c35);
  opacity: 0.65;
  transition: opacity 120ms ease, background 120ms ease;
  z-index: 2;
}
.state-drawer-close:hover {
  opacity: 1;
  background: rgba(33, 28, 53, 0.06);
}

/* Drag handle — only visible on mobile (bottom-sheet variant) */
.state-drawer-handle {
  display: none;
}

.sd-state-name {
  font-family: var(--font-display, 'Gobold', serif);
  font-size: 1.6rem;
  margin: 0.4rem 0 0.2rem;
  letter-spacing: 0.01em;
  color: var(--ink, #211c35);
}

.sd-province-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 1.2rem;
}

.sd-province-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-family: var(--font-ui);
  font-weight: 500;
  background: var(--paper-100, #f1ebd8);
  color: var(--ink, #211c35);
}
.sd-province-dot {
  width: 8px; height: 8px; border-radius: 50%;
  display: inline-block;
}

.sd-section {
  margin: 0.8rem 0 1.2rem;
}
.sd-section h3 {
  font-family: var(--font-ui);
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted, #8c88a3);
  margin: 0 0 0.5rem;
  font-weight: 500;
}
.sd-section.empty { display: none; }

.sd-entity-list {
  list-style: none;
  padding: 0; margin: 0;
  display: flex; flex-direction: column;
  gap: 2px;
}
.sd-entity-row {
  width: 100%;
  display: grid;
  grid-template-columns: 14px 1fr auto;
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem 0.6rem;
  background: transparent;
  border: 0;
  border-radius: 5px;
  text-align: left;
  cursor: pointer;
  color: var(--ink, #211c35);
  font-family: var(--font-body, var(--font-serif));
  font-size: 0.95rem;
  transition: background 120ms ease;
}
.sd-entity-row:hover {
  background: var(--paper-100, #f1ebd8);
}
.sd-entity-swatch {
  width: 11px; height: 11px;
  border-radius: 50%;
  border: 1.4px solid #fff;
}
.sd-entity-name {
  line-height: 1.25;
}
.sd-entity-sub {
  display: block;
  font-size: 0.78rem;
  color: var(--muted, #8c88a3);
  margin-top: 1px;
  font-family: var(--font-ui);
}
.sd-entity-chevron {
  color: var(--muted, #8c88a3);
  font-size: 0.85rem;
  opacity: 0.7;
}

.sd-empty-note {
  font-style: italic;
  color: var(--muted, #8c88a3);
  font-size: 0.9rem;
  padding: 0.6rem 0;
}

/* Mobile — slide up from the bottom as a sheet */
@media (max-width: 600px) {
  .state-drawer {
    top: auto;
    bottom: 0;
    right: 0;
    left: 0;
    height: 70vh;
    width: 100%;
    max-width: 100%;
    border-left: 0;
    border-top: 1px solid var(--rule-30, #c9c3b0);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -16px 40px -12px rgba(33, 28, 53, 0.22);
    transform: translateY(100%);
    padding-top: 1.6rem;
  }
  .state-drawer.is-open {
    transform: translateY(0);
  }
  .state-drawer-handle {
    display: block;
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 38px;
    height: 4px;
    border-radius: 2px;
    background: rgba(33, 28, 53, 0.18);
  }
}

.chapter-drawer-close {
  position: absolute;
  top: 0.9rem;
  right: 0.9rem;
  width: 32px;
  height: 32px;
  border: 0;
  background: transparent;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--ink, #211c35);
  opacity: 0.65;
  transition: opacity 120ms ease, background 120ms ease;
}
.chapter-drawer-close:hover {
  opacity: 1;
  background: rgba(33, 28, 53, 0.06);
}

.cd-eyebrow {
  font-family: var(--font-ui);
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted, #8c88a3);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.2rem;
  margin-bottom: 0.5rem;
}
.cd-province-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.cd-headline {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 400;
  letter-spacing: 0.01em;
  margin: 0 0 0.25rem;
  color: var(--ink, #211c35);
  line-height: 1.18;
}
.cd-city {
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-style: italic;
  color: var(--ink-soft, #4a4360);
  margin-bottom: 0.65rem;
}
.cd-status {
  display: inline-block;
  font-family: var(--font-ui);
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 600;
  padding: 0.25rem 0.55rem;
  border-radius: 4px;
  margin-bottom: 1.2rem;
}
.cd-status-active {
  background: rgba(208, 183, 135, 0.32);
  color: #5a4a25;
}
.cd-status-colony {
  background: rgba(64, 58, 96, 0.85);
  color: #faf7f0;
}
.cd-status-inactive {
  background: rgba(140, 136, 163, 0.16);
  color: var(--muted, #8c88a3);
}
.cd-status-alumni {
  background: rgba(113, 193, 165, 0.22);
  color: #2a6a52;
}

.cd-link-inline {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: rgba(33, 28, 53, 0.30);
  text-underline-offset: 2px;
  word-break: break-all;
}
.cd-link-inline:hover, .cd-link-inline:focus { text-decoration-color: currentColor; }

.cd-supported-link {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: rgba(33, 28, 53, 0.30);
  text-underline-offset: 2px;
  cursor: pointer;
}
.cd-supported-link:hover, .cd-supported-link:focus { text-decoration-color: currentColor; }

.cd-meta {
  display: grid;
  grid-template-columns: 38% 1fr;
  column-gap: 1rem;
  row-gap: 0.55rem;
  margin: 0 0 1.2rem;
  padding: 0.9rem 0;
  border-top: 1px solid var(--rule-30, #c9c3b0);
  border-bottom: 1px solid var(--rule-30, #c9c3b0);
}
.cd-meta dt {
  font-family: var(--font-ui);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted, #8c88a3);
  font-weight: 500;
  align-self: baseline;
}
.cd-meta dd {
  margin: 0;
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: var(--ink, #211c35);
  line-height: 1.4;
  align-self: baseline;
}

.cd-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.4rem;
}
.cd-link {
  font-family: var(--font-ui);
  font-size: 0.78rem;
  font-weight: 500;
  padding: 0.45rem 0.9rem;
  border-radius: 6px;
  background: var(--paper, #ffffff);
  border: 1px solid var(--rule-30, #c9c3b0);
  color: var(--ink, #211c35);
  text-decoration: none;
  transition: background 120ms ease, border-color 120ms ease;
}
.cd-link:hover {
  background: rgba(33, 28, 53, 0.04);
  border-color: var(--ink-soft, #4a4360);
}

@media (max-width: 720px) {
  .chapter-drawer {
    width: 100vw;
    max-width: 100vw;
  }
}

/* =================================================================
   Mobile drawer layout (2026-05-17)

   When a drawer (state OR chapter) is open on a phone, the page
   restructures into a fixed top/bottom split:

     ┌─────────────────┐
     │      MAP        │ ← fixed at top, ~50vh
     │                 │
     ├─────────────────┤
     │     DRAWER      │ ← fixed at bottom, fills remaining
     │  (scrollable)   │
     └─────────────────┘

   Masthead, toolbar, stats, legends and footer hide so the map
   and drawer together fill the viewport.

   The MAP-page status pills + search are hidden via the existing
   body.state-drawer-open / body.chapter-drawer-open classes that
   map.js already sets on open/close.
   ================================================================= */
@media (max-width: 600px) {
  /* Hide non-essential chrome when any drawer is open */
  body.state-drawer-open .masthead,
  body.chapter-drawer-open .masthead,
  body.state-drawer-open .toolbar,
  body.chapter-drawer-open .toolbar,
  body.state-drawer-open .stats,
  body.chapter-drawer-open .stats,
  body.state-drawer-open .legend,
  body.chapter-drawer-open .legend,
  body.state-drawer-open .colophon,
  body.chapter-drawer-open .colophon,
  body.state-drawer-open .footer,
  body.chapter-drawer-open .footer {
    display: none !important;
  }

  /* Map fills the upper half — fixed so the drawer can sit beneath without
     pushing it offscreen. The "atlas" wrapper goes static so the .map-stage
     element controls its own placement. */
  body.state-drawer-open .atlas,
  body.chapter-drawer-open .atlas {
    padding: 0;
    gap: 0;
  }
  body.state-drawer-open .map-stage,
  body.chapter-drawer-open .map-stage {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 50vh;
    height: 50svh;
    z-index: 90;
    margin: 0;
    border-radius: 0;
  }

  /* State drawer: pinned to bottom, takes the lower half, scrolls internally.
     Override BOTH base and .is-open states so the slide animation interpolates
     within the new layout (previously the base state set transform:translateY(100%)
     on a 70vh height, then is-open went to translateY(0) — when our new positioning
     kicked in mid-animation the transform stuck at an in-between value). */
  body.state-drawer-open .state-drawer {
    position: fixed !important;
    top: 50vh !important;
    top: 50svh !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: auto !important;
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 16px 16px 0 0;
    border-left: 0;
    border-top: 1px solid var(--rule-30, #c9c3b0);
    box-shadow: 0 -16px 40px -12px rgba(33, 28, 53, 0.22);
    overflow-y: auto;
    padding-top: 1.6rem;
    z-index: 95;
    transform: translateY(100%) !important;
  }
  body.state-drawer-open .state-drawer.is-open {
    transform: translateY(0) !important;
  }

  /* Chapter drawer: same pattern. Sits above the state drawer (z-index higher)
     so clicking an entity in the state drawer surfaces this one on top. */
  body.chapter-drawer-open .chapter-drawer {
    position: fixed !important;
    top: 50vh !important;
    top: 50svh !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: auto !important;
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 16px 16px 0 0;
    border-left: 0;
    border-top: 1px solid var(--rule-30, #c9c3b0);
    box-shadow: 0 -16px 40px -12px rgba(33, 28, 53, 0.22);
    overflow-y: auto;
    z-index: 100;
    transform: translateY(100%) !important;
  }
  body.chapter-drawer-open .chapter-drawer.is-open {
    transform: translateY(0) !important;
  }
}

/* =================================================================
   Mobile tooltip "More ›" button — only rendered when a pin is
   tap-pinned on mobile (showTooltip in map.js handles that gate).
   ================================================================= */
.tip-more-btn {
  display: block;
  width: 100%;
  margin: 0.6rem 0 0;
  padding: 0.5rem 0.75rem;
  font-family: var(--type-ui-family);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-fg-accent, #fff);
  background: var(--color-fg, #211c35);
  border: 0;
  border-radius: 6px;
  text-align: center;
  cursor: pointer;
  letter-spacing: 0.02em;
}
.tip-more-btn:hover { opacity: 0.92; }
.tip-more-btn:active { transform: translateY(1px); }
