/* ─── 기본 설정 ─────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:             #F7F5F1;
  --white:          #FFFFFF;
  --primary:        #3D6B4F;
  --primary-hover:  #2F5440;
  --accent:         #C4975A;
  --text:           #252525;
  --muted:          #7B7B7B;
  --border:         #E2DDD7;

  --badge-farm-bg:    #EAF2EC;
  --badge-farm-text:  #3D6B4F;
  --badge-ptner-bg:   #FBF3E6;
  --badge-ptner-text: #8A5F1E;

  --header-h:  60px;
  --filter-h:  52px;
  --map-h:     calc(100dvh - var(--header-h) - var(--filter-h));

  --font:   'Noto Sans KR', -apple-system, 'Helvetica Neue', sans-serif;
  --r:      12px;
  --shadow: 0 4px 20px rgba(0,0,0,.10);
  --shadow-lg: 0 8px 40px rgba(0,0,0,.14);
}

html, body {
  height: 100%; overflow: hidden;
  font-family: var(--font); font-weight: 400;
  background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* iframe 임베드 모드: 헤더 숨김 */
body.embedded .site-header {
  display: none;
}
body.embedded {
  --map-h: calc(100dvh - var(--filter-h));
}

/* ─── 헤더 ─────────────────────────────── */
.site-header {
  height: var(--header-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  position: sticky; top: 0; z-index: 100;
}
.header-inner {
  max-width: 1200px; width: 100%;
  margin: 0 auto; padding: 0 24px;
  display: flex; align-items: center; gap: 16px;
}
.header-logo {
  display: flex; align-items: center; gap: 8px;
  text-decoration: none; color: var(--text); flex-shrink: 0;
}
.logo-img {
  height: 32px; width: auto; display: block;
}
.logo-wordmark {
  font-size: 18px; font-weight: 700;
  color: var(--primary); letter-spacing: -.03em;
}
.header-divider {
  width: 1px; height: 18px; background: var(--border); flex-shrink: 0;
}
.header-title {
  font-size: 15px; font-weight: 500;
  color: var(--text); letter-spacing: -.01em;
}
.header-sub {
  margin-left: auto;
  font-size: 11px; color: var(--muted);
  letter-spacing: .06em; text-transform: uppercase; font-weight: 300;
}

/* ─── 필터 바 ──────────────────────────── */
.filter-bar {
  height: var(--filter-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
}
.filter-inner {
  max-width: 1200px; width: 100%;
  margin: 0 auto; padding: 0 24px;
  display: flex; align-items: center; gap: 12px;
}
.filter-label {
  font-size: 11px; font-weight: 500;
  color: var(--muted); flex-shrink: 0; letter-spacing: .02em;
}
.filter-scroll {
  display: flex; gap: 6px;
  overflow-x: auto; flex: 1;
  -ms-overflow-style: none; scrollbar-width: none;
}
.filter-scroll::-webkit-scrollbar { display: none; }

.filter-btn {
  padding: 5px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--white); color: var(--muted);
  font-size: 13px; font-family: var(--font); font-weight: 400;
  cursor: pointer; white-space: nowrap;
  transition: all .18s ease; line-height: 1.6;
}
.filter-btn:hover { border-color: var(--primary); color: var(--primary); }
.filter-btn.active {
  background: var(--primary); border-color: var(--primary);
  color: #fff; font-weight: 500;
}

.farms-count {
  font-size: 12px; color: var(--muted);
  flex-shrink: 0; white-space: nowrap; min-width: 32px; text-align: right;
}

/* ─── 지도 ─────────────────────────────── */
.map-wrapper { position: relative; height: var(--map-h); }
#map { width: 100%; height: 100%; }

.map-legend {
  position: absolute; bottom: 24px; left: 24px;
  background: var(--white); border-radius: var(--r);
  padding: 12px 16px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 8px;
  font-size: 12px; z-index: 10;
}
.legend-item { display: flex; align-items: center; gap: 8px; color: var(--text); }
.legend-dot {
  width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0;
}

/* ─── 팝업 카드 ─────────────────────────── */
.popup-overlay {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: flex-end; justify-content: flex-end;
  padding: 20px; pointer-events: none;
}
.popup-overlay.hidden { display: none; }

.popup-card {
  background: var(--white); border-radius: var(--r);
  box-shadow: var(--shadow-lg);
  width: 360px; max-height: calc(100dvh - 140px);
  overflow-y: auto; pointer-events: all;
  animation: popIn .22s ease; position: relative;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.popup-card::-webkit-scrollbar { width: 4px; }
.popup-card::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

@keyframes popIn {
  from { opacity: 0; transform: translateY(12px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.popup-close {
  position: absolute; top: 10px; right: 10px; z-index: 10;
  width: 30px; height: 30px; border-radius: 50%;
  background: rgba(255,255,255,.88); backdrop-filter: blur(4px);
  border: 1px solid var(--border); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text); transition: background .15s;
}
.popup-close:hover { background: var(--bg); }

/* 이미지 영역 */
.popup-img-area {
  width: 100%; height: 190px;
  background: var(--bg);
  border-radius: var(--r) var(--r) 0 0;
  overflow: hidden; flex-shrink: 0;
}
.popup-img-area img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.popup-img-placeholder {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-size: 52px; color: var(--muted);
}

/* 본문 */
.popup-body { padding: 18px 20px 20px; }

.popup-badge {
  display: inline-block; padding: 3px 10px;
  border-radius: 20px; font-size: 11px; font-weight: 600;
  letter-spacing: .03em; margin-bottom: 10px;
}
.popup-badge.farm    { background: var(--badge-farm-bg); color: var(--badge-farm-text); }
.popup-badge.partner { background: var(--badge-ptner-bg); color: var(--badge-ptner-text); }

.popup-name {
  font-size: 20px; font-weight: 700;
  letter-spacing: -.03em; margin-bottom: 8px; line-height: 1.3;
}

.popup-location {
  display: flex; align-items: center; gap: 5px;
  font-size: 12px; color: var(--muted); margin-bottom: 14px;
}
.popup-location svg { flex-shrink: 0; }

.popup-intro {
  font-size: 14px; font-weight: 500; font-style: italic;
  color: var(--primary); line-height: 1.65; margin-bottom: 10px;
}
.popup-desc {
  font-size: 13px; color: var(--muted);
  line-height: 1.75; margin-bottom: 16px;
}

/* 링크 */
.popup-links { display: flex; flex-direction: column; gap: 8px; }

.popup-link {
  display: flex; align-items: center; gap: 9px;
  padding: 10px 14px; border-radius: 8px;
  text-decoration: none; font-size: 13px; font-weight: 500;
  transition: opacity .15s, border-color .15s, color .15s;
}
.popup-link svg { flex-shrink: 0; }

.popup-link.instagram {
  background: linear-gradient(130deg, #FFECD2 0%, #F5D0C8 55%, #E5C2D8 100%);
  color: #7C2BA4;
}
.popup-link.instagram:hover { opacity: .82; }

.popup-link.content {
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
}
.popup-link.content:hover { border-color: var(--primary); color: var(--primary); }

/* ─── 로딩 ─────────────────────────────── */
.loading-overlay {
  position: fixed; inset: 0; background: var(--bg); z-index: 300;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 16px;
  font-size: 13px; color: var(--muted);
}
.loading-overlay.hidden { display: none; }

.spinner {
  width: 34px; height: 34px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%; animation: spin .75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── 에러 / 빈 지도 ──────────────────── */
.map-error {
  height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 10px; color: var(--muted); font-size: 14px;
}
.map-error .icon { font-size: 36px; }
.map-error strong { color: var(--text); }

/* ─── 반응형 ────────────────────────────── */
@media (max-width: 640px) {
  :root { --header-h: 52px; --filter-h: 48px; }

  .header-sub { display: none; }
  .header-title { font-size: 14px; }
  .logo-wordmark { font-size: 16px; }

  .popup-overlay {
    align-items: flex-end; justify-content: stretch; padding: 0;
  }
  .popup-card {
    width: 100%; border-radius: var(--r) var(--r) 0 0;
    max-height: 72dvh;
  }
  .popup-img-area { height: 160px; }

  .map-legend { bottom: auto; top: 12px; left: 12px; }
}
