/* =============================================================
   NC County Map — Frontend Styles
   All rules scoped to .cmap-wrap to avoid Divi conflicts
============================================================= */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Playfair+Display:wght@600&display=swap');

/* ── Wrapper ─────────────────────────────────────────────── */
.cmap-wrap {
  position: relative;
  width: 100%;
  font-family: 'Inter', system-ui, sans-serif;
  background: #f4f1ec;
  border-radius: 10px;
  overflow: hidden;
}

.cmap-wrap svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* ── County paths ────────────────────────────────────────── */
.cmap-wrap .cmap-county {
  fill: #d6cfc3;
  stroke: #b8b0a3;
  stroke-width: 0.5px;
  cursor: default;
  transition: fill .18s ease;
}

.cmap-wrap .cmap-partner {
  fill: #4a7c59;
  stroke: #2e5c3a;
  stroke-width: 0.8px;
  cursor: pointer;
  filter: drop-shadow(0 1px 3px rgba(74,124,89,.25));
  transition: fill .18s ease, filter .18s ease;
}

.cmap-wrap .cmap-partner:hover {
  fill: #3a6147;
  filter: drop-shadow(0 2px 8px rgba(74,124,89,.45));
}

/* ── Loading spinner ─────────────────────────────────────── */
.cmap-wrap .cmap-loader {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  pointer-events: none;
  z-index: 5;
}

.cmap-wrap .cmap-loader p {
  font-size: .78rem;
  color: #6b7280;
  margin: 0;
}

.cmap-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #d6cfc3;
  border-top-color: #4a7c59;
  border-radius: 50%;
  animation: cmap-spin .7s linear infinite;
}

@keyframes cmap-spin { to { transform: rotate(360deg); } }

/* ── Tooltip ─────────────────────────────────────────────── */
.cmap-tooltip {
  position: fixed;
  z-index: 9990;
  background: rgba(20,20,20,.82);
  backdrop-filter: blur(4px);
  color: #fff;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: .72rem;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 6px;
  pointer-events: none;
  white-space: nowrap;
  opacity: 0;
  transition: opacity .14s ease;
}

.cmap-tooltip--visible { opacity: 1; }

/* ── Popup card ──────────────────────────────────────────── */
.cmap-popup {
  position: fixed;
  z-index: 9999;
  width: min(340px, calc(100vw - 28px));
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,.17), 0 4px 16px rgba(0,0,0,.09);
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
  transform: scale(.94) translateY(6px);
  transition: opacity .2s ease, transform .2s ease;
  font-family: 'Inter', system-ui, sans-serif;
}

.cmap-popup--visible {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: auto;
}

/* Image area */
.cmap-popup-img-wrap {
  position: relative;
  width: 100%;
  height: 140px;
  overflow: hidden;
  background: #c8dece;
}

.cmap-popup-img-area { width: 100%; height: 100%; }

.cmap-popup-img-area img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cmap-popup-img-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background: linear-gradient(135deg, #4a7c59, #2e5c3a);
}

.cmap-popup-img-placeholder span { font-size: 28px; }
.cmap-popup-img-placeholder small { color: rgba(255,255,255,.7); font-size: .7rem; }


.cmap-popup-close {
  position: absolute;
  top: 8px; right: 8px;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: rgba(0,0,0,.32);
  border: none;
  cursor: pointer;
  color: #fff;
  font-size: 15px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}
.cmap-popup-close:hover { background: rgba(0,0,0,.55); }

/* Body */
.cmap-popup-body { padding: 14px 16px 16px; }

.cmap-popup-county {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.1rem;
  color: #1a1a1a;
  line-height: 1.2;
  margin-bottom: 1px;
}

.cmap-popup-farm {
  font-size: .78rem;
  color: #4a7c59;
  font-weight: 600;
  margin-bottom: 8px;
}

.cmap-popup-divider { border: none; border-top: 1px solid #e8e4df; margin: 8px 0; }

/* Base label: layout only — no color/weight/transform so presets win */
.cmap-popup-lbl {
  font-size: .7rem;
  margin-bottom: 3px;
  display: block;
}
/* Default appearance when no preset overrides */
.cmap-popup-lbl:not([style]) {
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: #6b7280;
}

/* Base value: layout only */
.cmap-popup-val {
  font-size: .85rem;
  line-height: 1.4;
  margin-bottom: 8px;
  display: block;
}
/* Default appearance when no preset overrides */
.cmap-popup-val:not([style]) {
  font-size: .8rem;
  color: #1a1a1a;
}

.cmap-popup-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}

.cmap-popup-tag {
  background: #e8f0eb;
  color: #4a7c59;
  font-size: .68rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  border: 1px solid #c5dbc9;
}

.cmap-popup-fieldday {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fdf8f0;
  border: 1px solid #e8dcc8;
  border-radius: 8px;
  padding: 7px 10px;
  margin-top: 6px;
}

.cmap-popup-fd-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.cmap-popup-fieldday strong {
  display: block;
  font-size: .76rem;
  color: #1a1a1a;
}

.cmap-popup-fieldday span {
  font-size: .72rem;
  color: #6b7280;
}

/* ==========================================================
   v1.2.0 — Farm navigation bar in popup
========================================================== */
.cmap-popup-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f4f7f5;
  border: 1px solid #d1e4d8;
  border-radius: 8px;
  padding: 4px 6px;
  margin: 6px 0 8px;
  gap: 6px;
}

.cmap-popup-nav-label {
  font-size: .72rem;
  font-weight: 600;
  color: #4a7c59;
  white-space: nowrap;
  flex: 1;
  text-align: center;
}

.cmap-popup-nav-btn {
  width: 26px; height: 26px;
  border-radius: 6px;
  border: 1.5px solid #c5dbc9;
  background: #fff;
  color: #4a7c59;
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .12s, border-color .12s;
  flex-shrink: 0;
}
.cmap-popup-nav-btn:hover:not(:disabled) { background: #e8f0eb; border-color: #4a7c59; }
.cmap-popup-nav-btn:disabled { opacity: .3; cursor: default; }

/* ==========================================================
   Step 4 — Field style presets (popup + admin preview)
   Applied as: cmap-field-preset-{name}
========================================================== */
.cmap-field-preset-default  { /* inherits popup base */ }
.cmap-field-preset-bold     { font-weight: 700; }
.cmap-field-preset-muted    { color: #6b7280; font-size: .82em; }
.cmap-field-preset-accent   { color: #4a7c59; font-weight: 600; }
.cmap-field-preset-highlight {
  background: rgba(74,124,89,.1);
  padding: 2px 8px; border-radius: 4px;
  display: inline-block;
}
.cmap-field-preset-large    { font-size: 1.12em; }
.cmap-field-preset-featured { font-size: 1.15em; font-weight: 700; color: #2a5240; }
.cmap-field-preset-monospace{ font-family: 'Courier New', monospace; font-size: .9em; }
.cmap-field-preset-allcaps  { text-transform: uppercase; letter-spacing: .08em; }

/* popup field label / value wrappers (used in Step 8 dynamic popup) */
.cmap-popup-field-label { display: block; }
.cmap-popup-field-value { display: block; }

/* ==========================================================
   Slim header — when show_header_image is false
========================================================== */
.cmap-popup-img-wrap.cmap-popup-slim-header {
  height: 42px !important;
  min-height: 42px !important;
  background: linear-gradient(135deg, #2a5240, #4a7c59) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: flex-end !important;
  padding: 0 !important;
  overflow: hidden !important;
}
.cmap-popup-img-wrap.cmap-popup-slim-header #cmap-popup-img-area { display: none; }
.cmap-popup-img-wrap.cmap-popup-slim-header .cmap-popup-close {
  position: static !important;
  background: transparent !important;
  border: none !important;
  color: rgba(255,255,255,.85) !important;
  font-size: 1.1rem !important;
  width: 42px; height: 42px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  margin: 0 !important;
  box-shadow: none !important;
}
.cmap-popup-img-wrap.cmap-popup-slim-header .cmap-popup-close:hover { color: #fff !important; }

/* ==========================================================
   Popup — multi-card layout & display modes
========================================================== */

/* County name row (always visible below header) */
.cmap-popup-county-row {
  padding: 10px 20px 0;
}
.cmap-popup-county {
  font-size: 1.12rem; font-weight: 700; color: #2a5240;
}

/* Card pagination nav bar */
.cmap-popup-nav {
  display: flex; align-items: center; justify-content: space-between;
  gap: 4px; padding: 6px 14px;
  background: rgba(42,82,64,.06);
  border-bottom: 1px solid rgba(42,82,64,.1);
  margin-bottom: 2px;
}
.cmap-popup-nav-prev,
.cmap-popup-nav-next {
  background: rgba(42,82,64,.12); border: none; border-radius: 6px;
  width: 28px; height: 28px; font-size: 1rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #2a5240; transition: background .15s;
}
.cmap-popup-nav-prev:hover:not(:disabled),
.cmap-popup-nav-next:hover:not(:disabled) { background: rgba(42,82,64,.24); }
.cmap-popup-nav-prev:disabled,
.cmap-popup-nav-next:disabled { opacity: .35; cursor: default; }
.cmap-popup-nav-label {
  font-size: .75rem; font-weight: 600; color: #4a7c59; flex: 1; text-align: center;
}

/* Tab bar */
.cmap-popup-tabs {
  display: flex; gap: 2px; padding: 8px 14px 0;
  border-bottom: 1px solid rgba(42,82,64,.15);
  overflow-x: auto;
}
.cmap-popup-tab {
  background: transparent; border: none;
  padding: 5px 14px; border-radius: 6px 6px 0 0;
  font-size: .78rem; font-weight: 600; color: #4a7c59;
  cursor: pointer; white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: background .15s, border-color .15s;
}
.cmap-popup-tab:hover { background: rgba(74,124,89,.1); }
.cmap-popup-tab--active {
  background: rgba(74,124,89,.14);
  border-bottom-color: #4a7c59;
  color: #2a5240;
}

/* Card body */
.cmap-popup-card-body {
  padding: 12px 20px 6px;
}

/* Scroll mode */
.cmap-popup-cards--scroll {
  max-height: 280px; overflow-y: auto;
  scrollbar-width: thin; scrollbar-color: rgba(74,124,89,.4) transparent;
}
.cmap-popup-cards--scroll::-webkit-scrollbar { width: 5px; }
.cmap-popup-cards--scroll::-webkit-scrollbar-thumb { background: rgba(74,124,89,.4); border-radius: 3px; }

/* Card divider in scroll mode */
.cmap-card-divider {
  border: none; border-top: 1px solid rgba(42,82,64,.15);
  margin: 10px 0;
}

/* Mini card image in scroll mode */
.cmap-popup-card-img { margin-bottom: 10px; }
.cmap-popup-card-img img {
  width: 100%; max-height: 100px; object-fit: cover; border-radius: 6px;
}

/* Field day — ensure it stays at bottom */
.cmap-popup-fieldday { margin: 0 20px 14px; }

/* ==========================================================
   Popup — schema-driven field types
========================================================== */
.cmap-popup-val--para { white-space: pre-wrap; line-height: 1.55; }

.cmap-popup-field-img { margin: 6px 0; }
.cmap-popup-field-img img {
  width: 100%; max-height: 140px; object-fit: cover; border-radius: 6px;
}

.cmap-popup-color-swatch {
  display: inline-block; width: 14px; height: 14px;
  border-radius: 3px; border: 1px solid rgba(0,0,0,.2);
  vertical-align: middle; margin-right: 4px;
}

/* Dynamic fields subsection — single-column layout */
.cmap-dynamic-fields { display: flex; flex-direction: column; gap: 10px; }
