:root {
  --obsidian: #050304;
  --paper-white: #fdfcf7;
  --ember-bright: #f36d21;
  --ember-copper: #c24a12;
  --ember-clay: #f0b562;
  --ember-shadow: #7a4b33;
  --charcoal: #1e1210;
  --map-neutral: #f3eee3;
}

body {
  font-family: "Source Sans 3", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  margin: 1.5rem;
  background-color: var(--paper-white);
  color: var(--obsidian);
}

body.embed-mode {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--paper-white);
}

body.theme-dark {
  background-color: #000000;
  color: var(--paper-white);
}

body.theme-dark.embed-mode {
  background-color: #000;
}

/* overlay/embed tokens */
body.legend-overlay.embed-mode {
  --map-shell-pad-x: 1.25rem;
  --map-shell-pad-y: 1.25rem;
  --legend-safe: 2.25rem;       /* ~36px gap to glow */
  --legend-offset-x: 0.75rem;   /* ~12px from content edge */
  --legend-offset-y: 6.5rem;    /* clear toolbar */
  --legend-max: 160px;
}

body.legend-overlay .layout {
  position: relative;
}

.hero {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

body.embed-mode .hero {
  display: none;
}

.hero-logo {
  width: 72px;
  height: auto;
  border-radius: 8px;
  object-fit: contain;
}

h1 {
  font-family: "Barlow Semi Condensed", "Source Sans 3", sans-serif;
  font-weight: 600;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
  text-transform: uppercase;
}

.subtitle {
  margin-top: 0;
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
  color: rgba(8, 5, 6, 0.8);
}

body.theme-dark .subtitle {
  color: rgba(253, 252, 247, 0.8);
}

.layout {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  align-items: flex-start;
}

body.embed-mode .layout {
  width: 100%;
  max-width: 960px;
  padding: 1rem;
  box-sizing: border-box;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.map-panel {
  flex: 1 1 520px;
  display: flex;
  justify-content: center;
  position: relative;
}

body.embed-mode .map-panel {
  width: 100%;
  flex: 0 1 auto;
}

.map-shell {
  width: 100%;
  max-width: 520px;
  position: relative;
  padding: 1.25rem 1.75rem 1.25rem 1.25rem;
  overflow: hidden;
  border-radius: 16px;
  border: 1px solid rgba(30, 18, 16, 0.12);
  background-color: var(--paper-white);
  box-shadow: 0 12px 28px rgba(5, 3, 4, 0.08);
}

body.embed-mode .map-shell {
  max-width: 960px;
  margin: 0 auto;
}

body.legend-overlay .map-shell {
  padding: var(--map-shell-pad-y)
    calc(var(--legend-offset-x) + var(--legend-safe))
    var(--map-shell-pad-y)
    var(--map-shell-pad-x);
}

body.theme-dark .map-shell {
  background-color: var(--obsidian);
  border-color: rgba(253, 252, 247, 0.18);
  box-shadow: 0 0 32px rgba(243, 109, 33, 0.35);
}

.map-stage {
  position: relative;
}

.map-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.map-toolbar-hint {
  font-size: 0.8rem;
  color: rgba(30, 18, 16, 0.7);
  flex: 1 1 auto;
  text-align: right;
}

body.theme-dark .map-toolbar-hint {
  color: rgba(253, 252, 247, 0.75);
}

body.is-mobile .map-toolbar-hint {
  display: none;
}

.map-btn {
  background-color: var(--ember-bright);
  color: var(--paper-white);
  border: none;
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: background-color 0.2s ease-in-out;
}

.map-btn:hover,
.map-btn:focus-visible {
  background-color: var(--ember-copper);
  outline: none;
}

.legend-toggle-btn {
  display: none;
  border: 1px solid rgba(30, 18, 16, 0.2);
  background-color: transparent;
  color: inherit;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
}

body.theme-dark .legend-toggle-btn {
  border-color: rgba(253, 252, 247, 0.35);
  color: var(--paper-white);
}

body.legend-overlay .legend-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.fts-mark {
  position: absolute;
  bottom: 12px;
  right: 12px;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-family: "Barlow Semi Condensed", "Source Sans 3", sans-serif;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  font-weight: 600;
  background-color: rgba(8, 5, 6, 0.8);
  color: var(--ember-bright);
  border: 1px solid rgba(253, 252, 247, 0.25);
  pointer-events: none;
}

.legend-panel {
  flex: 0 0 260px;
  padding: 1rem 1.25rem;
  background-color: var(--paper-white);
  border: 1px solid rgba(30, 18, 16, 0.12);
  border-radius: 8px;
  font-size: 0.95rem;
}

body.embed-mode .legend-panel {
  width: 100%;
  max-width: 900px;
}

body.legend-overlay .legend-panel {
  position: absolute;
  flex: none;
  left: auto;
  right: var(--legend-offset-x, 1rem);
  top: var(--legend-offset-y, 6.25rem);
  z-index: 3;
  box-sizing: border-box;
  width: auto;
  max-width: min(var(--legend-max, 160px), calc(100% - (var(--legend-safe, 2.25rem) * 2)));
  max-height: none;
  overflow: visible;
  box-shadow: 0 8px 18px rgba(5, 3, 4, 0.2);
  align-self: flex-start;
}

body.legend-overlay.embed-mode .legend-panel {
  width: auto;
  max-width: min(var(--legend-max, 160px), calc(100% - (var(--legend-safe, 2.25rem) * 2)));
  position: absolute;
  right: var(--legend-offset-x, 0.75rem);
  top: var(--legend-offset-y, 6.5rem);
  max-height: none;
  overflow: visible;
}

body.legend-overlay .legend-panel.legend-hidden {
  display: none;
}

body.theme-dark .legend-panel {
  background-color: #151010;
  border-color: rgba(253, 252, 247, 0.15);
  color: var(--paper-white);
}

.legend-panel h2 {
  margin: 0 0 0.5rem 0;
  font-family: "Barlow Semi Condensed", "Source Sans 3", sans-serif;
  font-size: 1.15rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

body.theme-dark .legend-panel h2 {
  color: rgba(253, 252, 247, 0.9);
}

.legend-list {
  list-style: none;
  padding: 0;
  margin: 0 0 0.75rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.legend-list li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.legend-swatch {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1px solid rgba(30, 18, 16, 0.2);
}

body.theme-dark .legend-swatch {
  border-color: rgba(253, 252, 247, 0.2);
}

.legend-swatch[data-state="resident-online"] {
  background-color: var(--ember-bright);
}

.legend-swatch[data-state="resident-inperson"] {
  background-color: var(--ember-copper);
}

.legend-swatch[data-state="nonresident-only"] {
  background-color: var(--ember-clay);
}

.legend-swatch[data-state="resident-denied"] {
  background-color: var(--ember-shadow);
}

.legend-swatch[data-state="no-data"] {
  background-color: var(--map-neutral);
  border-style: dashed;
}

@media (max-width: 900px) {
  body.legend-overlay:not(.embed-mode) .legend-panel {
    position: fixed;
    right: 14px;
    top: 110px;
    width: auto;
    max-width: calc(100vw - 52px);
    max-height: 50vh;
    box-sizing: border-box;
  }
}

.legend-note {
  margin: 0;
  color: rgba(30, 18, 16, 0.75);
  line-height: 1.4;
}

body.theme-dark .legend-note {
  color: rgba(253, 252, 247, 0.75);
}

#county-map {
  width: 100%;
  max-width: 520px;
  height: auto;
  background-color: var(--paper-white);
}

body.theme-dark #county-map {
  background-color: var(--obsidian);
}

body.embed-mode #county-map {
  max-width: 100%;
}

#county-map:focus-visible {
  outline: 2px solid var(--ember-clay);
  outline-offset: 4px;
}

.county {
  fill: var(--map-neutral);
  stroke: var(--paper-white);
  stroke-width: 1.8;
  cursor: pointer;
  transition: transform 0.18s ease-out, filter 0.18s ease-out;
  transform-origin: center;
  transform-box: fill-box;
}

.county-active {
  stroke: var(--ember-bright);
  stroke-width: 2.4;
}

.county[data-state="resident-online"] {
  fill: var(--ember-bright);
}

.county[data-state="resident-inperson"] {
  fill: var(--ember-copper);
}

.county[data-state="nonresident-only"] {
  fill: var(--ember-clay);
}

.county[data-state="resident-denied"] {
  fill: var(--ember-shadow);
}

.county[data-state="no-data"] {
  fill: var(--map-neutral);
}

.county:hover,
.county:focus-visible {
  transform: scale(1.05);
  filter: brightness(1.05);
  outline: none;
}

.county-borders {
  fill: none;
  stroke: rgba(5, 3, 4, 0.25);
  stroke-width: 1;
  pointer-events: none;
}

.tooltip {
  position: fixed;
  min-width: 220px;
  max-width: 320px;
  padding: 0.9rem 1rem 1rem 1rem;
  background-color: var(--obsidian);
  color: var(--paper-white);
  font-size: 0.95rem;
  border-radius: 12px;
  border: 1px solid rgba(253, 252, 247, 0.15);
  box-shadow: 0 12px 32px rgba(8, 5, 6, 0.35);
  pointer-events: auto;
  z-index: 9999;
}

.tooltip-hidden {
  display: none;
}

.tooltip-header {
  font-family: "Barlow Semi Condensed", "Source Sans 3", sans-serif;
  font-size: 1.05rem;
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tooltip-subtitle {
  font-size: 0.8rem;
  margin-bottom: 0.35rem;
  color: rgba(253, 252, 247, 0.75);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tooltip-summary {
  font-size: 0.85rem;
  margin: 0 0 0.4rem 0;
  color: rgba(253, 252, 247, 0.9);
  line-height: 1.3;
}

.tooltip-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.cta-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.4rem;
}

.cta-button {
  background-color: var(--ember-bright);
  color: var(--paper-white);
  padding: 0.3rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  text-decoration: none;
  font-weight: 600;
  letter-spacing: 0.04em;
  transition: background-color 0.2s ease-in-out;
}

.cta-button:hover,
.cta-button:focus-visible {
  background-color: var(--ember-copper);
  outline: none;
}

.tooltip-close {
  position: absolute;
  top: 0.4rem;
  right: 0.5rem;
  background: transparent;
  border: none;
  color: rgba(253, 252, 247, 0.85);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
}

.tooltip-handle {
  width: 40px;
  height: 4px;
  border-radius: 999px;
  background: rgba(253, 252, 247, 0.35);
  margin: 0 auto 0.4rem auto;
  display: none;
}


.tooltip-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.85rem;
  min-width: 0;
}

.tooltip-label {
  flex: 1 1 auto;
  min-width: 0;
  white-space: normal;
  color: rgba(253, 252, 247, 0.9);
}

.tooltip-value {
  font-weight: 600;
  flex-shrink: 0;
}

.tooltip-value.yes {
  color: var(--ember-bright);
}

.tooltip-value.no {
  color: #e46a63;
}

.tooltip-value.na {
  color: rgba(253, 252, 247, 0.6);
}

.tooltip-notes {
  margin-top: 0.45rem;
  padding-top: 0.35rem;
  border-top: 1px solid rgba(253, 252, 247, 0.12);
}

.tooltip-notes-title {
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(253, 252, 247, 0.7);
  margin: 0 0 0.25rem 0;
}

.tooltip-note {
  margin: 0;
  color: rgba(253, 252, 247, 0.88);
  font-size: 0.82rem;
  line-height: 1.35;
}

@media (max-width: 768px) {
  .hero {
    flex-direction: column;
    align-items: flex-start;
  }

  body {
    margin: 1rem;
  }

  .layout {
    flex-direction: column;
  }

  .legend-panel {
    order: -1;
    width: 100%;
  }

  body.legend-overlay .legend-panel {
    order: initial;
    width: auto;
    max-width: calc(100% - 2.75rem);
  }
}

body.sheet-open {
  overflow: hidden;
}

body.is-mobile .tooltip-handle {
  display: block;
}

body.is-mobile .tooltip {
  width: calc(100% - 2rem);
  max-width: 520px;
  left: 50%;
  transform: translateX(-50%);
  top: auto;
  bottom: 16px;
  right: auto;
  max-height: 70vh;
  overflow-y: auto;
}

body.is-mobile .tooltip-close {
  top: 0.2rem;
  right: 0.4rem;
}

body.is-mobile .cta-buttons {
  flex-direction: column;
}

body.is-mobile .cta-button {
  width: 100%;
  text-align: center;
}
