/* ============================================================
   Map page styles — county-seats interactive map
   Palette from DESIGN.md:
     page yellow: #fcc541
     completed green: #34A853
     underway orange: #f38a26
     logo/accent red: #d9001d
     muted gray: #d0d0d0
   ============================================================ */

/* ── Page layout ─────────────────────────────────────────── */

body.map-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

body.map-layout header {
  flex-shrink: 0;
}

/* ── Progress headline ───────────────────────────────────── */

.map-headline-bar {
  flex-shrink: 0;
  text-align: center;
  padding: 0.875rem 1rem 2.375rem;
}

.map-headline {
  display: inline-block;
  margin: 0;
  font-size: clamp(2rem, 5vw, 4rem);
  font-feature-settings: "kern" 1, "liga" 1;
  font-weight: 850;
  letter-spacing: 0;
  line-height: 1;
  color: #000;
  transform: scaleX(0.9);
  transform-origin: center;
}

/* Tighten the map-page header — the homepage logo has generous margins
   that are too tall for a full-screen map layout */
body.map-layout .site-logo .custom-logo {
  margin-top: 0.6rem !important;
  margin-bottom: 0.6rem !important;
  max-width: 36px !important;
  max-height: 36px !important;
}

body.map-layout footer {
  flex-shrink: 0;
  margin-top: 3rem;
}

.map-layout .map-main {
  flex: 0 0 auto;
  padding: 0;
  max-width: none;
  position: relative;
  height: 90vh;
  min-height: 400px;
}

#map-page {
  display: flex;
  height: 100%;
  position: relative;
}

/* ── Map container ───────────────────────────────────────── */

#map-container {
  flex: 1 1 auto;
  position: relative;
  background: #fcc541; /* page yellow — matches site brand */
}

#leaflet-map {
  width: 100%;
  height: 100%;
  background: #fcc541 !important; /* override Leaflet's default gray tile bg */
}

.leaflet-container {
  background: #fcc541 !important;
}

.leaflet-left .leaflet-control {
  margin-left: 0.6rem;
}

.leaflet-top .leaflet-control {
  margin-top: 0;
}

.leaflet-top.leaflet-left {
  display: grid;
  gap: 0.45rem;
  left: 0.75rem;
  top: 0.75rem;
}

.leaflet-top.leaflet-left .leaflet-control {
  margin-left: 0;
}

.leaflet-control-zoom {
  border: 0 !important;
  box-shadow: none;
  display: grid;
  grid-template-columns: 40px;
  width: 40px;
}

.leaflet-control-zoom a,
.county-search-toggle,
.map-reset-btn,
.legend-toggle {
  align-items: center;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(0, 0, 0, 0.18);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
  color: #111;
  display: flex;
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 800;
  height: 40px;
  justify-content: center;
  line-height: 1;
  text-decoration: none;
  transition: background-color 0.18s cubic-bezier(0.2, 0, 0, 1), border-color 0.18s cubic-bezier(0.2, 0, 0, 1), box-shadow 0.18s cubic-bezier(0.2, 0, 0, 1), color 0.18s cubic-bezier(0.2, 0, 0, 1), transform 0.18s cubic-bezier(0.2, 0, 0, 1);
  width: 40px;
}

.leaflet-control-zoom a:hover,
.county-search-toggle:hover,
.map-reset-btn:hover,
.legend-toggle:hover,
.leaflet-control-zoom a:focus,
.county-search-toggle:focus,
.map-reset-btn:focus,
.legend-toggle:focus {
  background: #fff8e5;
  border-color: rgba(0, 0, 0, 0.32);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.14);
  color: #000;
}

.leaflet-control-zoom a:active,
.county-search-toggle:active,
.map-reset-btn:active,
.legend-toggle:active {
  transform: scale(0.96);
}

.leaflet-control-zoom a:first-child {
  border-bottom: 0;
  border-radius: 5px 5px 0 0;
}

.leaflet-control-zoom a:last-child {
  border-radius: 0 0 5px 5px;
  margin-top: 0;
}

.leaflet-touch .leaflet-bar a {
  height: 40px;
  line-height: 40px;
  width: 40px;
}

/* Remove Leaflet's default blue focus ring — replace with brand yellow */
.leaflet-container a:focus,
.leaflet-interactive:focus {
  outline: 2px solid #fcc541;
  outline-offset: 1px;
}

/* Leaflet attribution — keep it readable but unobtrusive */
.leaflet-control-attribution {
  font-size: 10px;
  background: rgba(255, 255, 255, 0.8) !important;
}

/* ── County tooltip ──────────────────────────────────────── */

.county-tip {
  background: #fff;
  border: 1px solid #000;
  border-radius: 2px;
  color: #333;
  font-family: var(--font-sans);
  font-size: 12px;
  padding: 3px 7px;
  white-space: nowrap;
  box-shadow: none;
}

.county-tip--visited {
  border-color: #34A853;
  font-weight: 600;
}

/* Override Leaflet tooltip defaults */
.leaflet-tooltip.county-tip::before {
  border-top-color: #000;
}

/* ── County search control ───────────────────────────────── */

.county-search-control {
  background: transparent;
  border: 0 !important;
  box-shadow: none !important;
  font-family: var(--font-sans);
  position: relative;
}

.county-search-toggle {
  border-radius: 5px;
  cursor: pointer;
  padding: 0;
}

.county-search-toggle svg {
  fill: none;
  height: 18px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.3;
  width: 18px;
}

.map-reset-control {
  background: transparent;
  border: 0 !important;
  box-shadow: none !important;
}

.map-reset-btn {
  border-radius: 5px;
  cursor: pointer;
  padding: 0;
}

.map-reset-btn svg {
  fill: none;
  height: 18px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
  width: 18px;
}

.county-search-panel {
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 6px;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.18);
  left: calc(100% + 0.6rem);
  min-width: min(78vw, 320px);
  padding: 0.65rem;
  position: absolute;
  top: 0;
}

.county-search-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 800;
  margin: 0 0 0.35rem;
  text-transform: uppercase;
}

.county-search-input {
  border: 1px solid rgba(0, 0, 0, 0.28);
  border-radius: 4px;
  font: inherit;
  height: 40px;
  padding: 0.45rem 0.55rem;
  width: 100%;
}

.county-search-input:focus {
  outline: 2px solid #fcc541;
  outline-offset: 1px;
}

.county-search-results {
  display: grid;
  gap: 0.35rem;
  margin-top: 0.55rem;
  max-height: min(52vh, 360px);
  overflow-y: auto;
}

.county-search-empty {
  color: #666;
  font-size: 0.82rem;
  margin: 0;
  padding: 0.35rem 0.1rem;
}

.county-search-result {
  align-items: center;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.14);
  border-radius: 5px;
  color: #111;
  cursor: pointer;
  display: flex;
  font: inherit;
  gap: 0.75rem;
  justify-content: space-between;
  min-height: 48px;
  padding: 0.45rem 0.55rem;
  text-align: left;
  transition: background-color 0.16s cubic-bezier(0.2, 0, 0, 1), transform 0.16s cubic-bezier(0.2, 0, 0, 1);
  width: 100%;
}

.county-search-result:hover,
.county-search-result:focus {
  background: #fff6dd;
  outline: none;
}

.county-search-result:active {
  transform: scale(0.96);
}

.county-search-result strong,
.county-search-result small {
  display: block;
}

.county-search-result strong {
  font-size: 0.9rem;
  line-height: 1.15;
}

.county-search-result small,
.county-search-result em {
  color: #666;
  font-size: 0.72rem;
  font-style: normal;
}

.county-search-result em {
  flex: 0 0 auto;
}

/* ── Side panel ──────────────────────────────────────────── */

#county-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 340px;
  height: 100vh;
  background: #fff;
  border-left: 1px solid #e0e0e0;
  overflow-y: auto;
  z-index: 2000;
  padding: 2rem 1.5rem 2rem 1.5rem;
  box-sizing: border-box;

  transform: translateX(100%);
  transition: transform 0.24s cubic-bezier(0.2, 0, 0, 1);
}

#county-panel.is-open {
  transform: translateX(0);
}

#county-panel.is-closing {
  transform: translateX(100%);
}

/* When panel is open, shrink the map slightly on the right so
   the panel overlays without covering content the user needs */
#map-page.panel-open #map-container {
  /* The panel overlays; nothing to do for now — panel is absolute */
}

/* Close button */
#panel-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  color: #333;
  line-height: 1;
  padding: 0.25rem 0.4rem;
  border-radius: 2px;
}

#panel-close:hover {
  background: #f5f4f0;
  color: #000;
}

#panel-close:focus {
  outline: 2px solid #fcc541;
  outline-offset: 1px;
}

/* Panel typography */
#panel-content h2 {
  font-size: 1.25rem;
  margin: 0 0 0.25rem 0;
  padding-right: 2rem; /* don't overlap close button */
  line-height: 1.3;
}

.panel-state {
  font-size: 0.875rem;
  color: #666;
  margin: 0 0 0.25rem 0;
}

.panel-seat {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: #000;
  margin: 0 0 1.25rem 0;
}

.panel-seat-pin {
  flex-shrink: 0;
  width: 14px;
  height: 16px;
  position: relative;
  top: -1px; /* optical alignment with text baseline */
}

#panel-body {
  font-size: 0.9375rem;
  line-height: 1.5;
}

#panel-body p {
  max-width: none;
  margin: 0 0 0.75rem 0;
}

.panel-loading {
  color: #666;
  font-style: italic;
}

.county-meta-list {
  border-top: 1px solid #e0e0e0;
  border-bottom: 1px solid #e0e0e0;
  margin: 1rem 0;
  padding: 0.7rem 0;
}

.county-meta-list div {
  align-items: baseline;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.county-meta-list dt {
  color: #666;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.county-meta-list dd {
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  margin: 0;
}

.county-notes {
  margin-top: 1rem;
}

.county-notes h2,
.county-notes h3 {
  font-size: 1rem;
  line-height: 1.2;
  margin: 1rem 0 0.45rem;
  text-wrap: balance;
}

.county-notes ul {
  margin: 0 0 0.9rem 1.1rem;
  padding: 0;
}

.county-notes li + li {
  margin-top: 0.25rem;
}

.county-notes a {
  color: #000;
  text-decoration: underline;
  text-decoration-color: #d9001d;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.county-photo-grid {
  display: grid;
  gap: 0.5rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 1rem;
}

.county-photo {
  aspect-ratio: 1;
  background: #f5f4f0;
  display: block;
  overflow: hidden;
}

.county-photo img {
  display: block;
  height: 100%;
  object-fit: cover;
  outline: 1px solid rgba(0, 0, 0, 0.1);
  width: 100%;
}

.not-visited {
  color: #888;
  font-style: italic;
}

/* Share button */
.panel-share-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: auto;
  padding: 0.5rem 0.9rem;
  background: none;
  border: 1px solid #000;
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  cursor: pointer;
  color: #333;
  transition: background 0.12s;
}
.panel-share-btn:hover {
  background: #fcc541;
  color: #000;
  border-color: #000;
}
.panel-share-btn:focus {
  outline: 2px solid #fcc541;
  outline-offset: 1px;
}

/* Share tooltip */
.share-copied-tip {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #222;
  color: #fff;
  font-size: 0.75rem;
  padding: 3px 8px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
}
.share-copied-tip.show { opacity: 1; }

#panel-share-wrap {
  position: relative;
  display: inline-flex;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid #e0e0e0;
  width: 100%;
}

/* ── Map legend ──────────────────────────────────────────── */

.map-legend {
  position: absolute;
  left: 0.75rem;
  top: calc(0.75rem + 40px + 0.45rem + 80px + 0.45rem);
  z-index: 900;
  font-size: 0.75rem;
  font-family: var(--font-sans);
  line-height: 1.6;
}

#map-page.reset-visible .map-legend {
  top: calc(0.75rem + 40px + 0.45rem + 80px + 0.45rem + 40px + 0.45rem);
}

.legend-toggle {
  border-radius: 999px;
  cursor: pointer;
  padding: 0;
}

.legend-panel {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 6px;
  bottom: auto;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.14);
  left: calc(100% + 0.6rem);
  min-width: 164px;
  padding: 0.6rem 0.75rem;
  position: absolute;
  top: 0;
  white-space: nowrap;
}

.legend-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 1px;
  margin-right: 5px;
  vertical-align: middle;
  border: 1px solid rgba(0,0,0,0.15);
}

/* ── Map error state ─────────────────────────────────────── */

.map-error {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #888;
  font-size: 0.9rem;
}

/* ── Alaska & Hawaii inset maps ──────────────────────────── */

#inset-alaska,
#inset-hawaii {
  position: absolute;
  z-index: 800;
  border: 1px solid rgba(0, 0, 0, 0.18);
  background: #fcc541;
  /* Leaflet needs an explicit size */
  pointer-events: auto;
}

#inset-alaska {
  bottom: 0;
  left: 0;
  width: 220px;
  height: 150px;
}

#inset-hawaii {
  bottom: 0;
  left: 220px;      /* flush right of Alaska */
  width: 140px;
  height: 110px;
}

/* hide Leaflet attribution — no tile layer, nothing to credit */
.leaflet-control-attribution {
  display: none !important;
}

/* suppress Leaflet UI chrome on tiny insets */
#inset-alaska .leaflet-control-zoom,
#inset-alaska .leaflet-control-attribution,
#inset-hawaii .leaflet-control-zoom,
#inset-hawaii .leaflet-control-attribution {
  display: none !important;
}

@media (prefers-reduced-motion: reduce) {
  #county-panel {
    transition: none;
  }

  .leaflet-control-zoom a,
  .county-search-toggle,
  .map-reset-btn,
  .legend-toggle,
  .county-search-result {
    transition: none;
  }
}

@media (max-width: 640px) {
  .county-search-panel {
    left: 0;
    min-width: min(84vw, 320px);
    top: calc(100% + 0.45rem);
  }
}
