:root {
  --brand: #16a34a;
  --brand-dark: #0f7a37;
  --brand-light: #4ade80;
  --lime: #a3e635;
  --ink-900: #0b1120;
  --ink-700: #33413a;
  --ink-500: #5b6b62;
  --surface: #ffffff;
  --surface-alt: #f3f7f3;
  --border: #e2e8e2;
  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 9px;
  --shadow-soft: 0 10px 30px -12px rgba(11, 17, 32, 0.25);
  --shadow-pop: 0 20px 50px -18px rgba(11, 17, 32, 0.35);
  --header-h: 76px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--ink-900);
  background: var(--surface-alt);
  overflow: hidden;
}

h1, h2, h3, .brand-word {
  font-family: 'Poppins', 'Inter', sans-serif;
}

a { color: inherit; }

/* ---------- Header ---------- */

.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-h);
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 22px;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  border-bottom: 1px solid rgba(15, 122, 55, 0.12);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  background: linear-gradient(140deg, var(--brand-light), var(--brand-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px -4px rgba(15, 122, 55, 0.55);
  flex-shrink: 0;
}

.brand-mark svg { width: 24px; height: 24px; }

.brand-text { line-height: 1.15; }

.brand-word {
  font-weight: 700;
  font-size: 1.08rem;
  letter-spacing: -0.01em;
}

.brand-word span { color: var(--brand-dark); }

.brand-sub {
  font-size: 0.72rem;
  color: var(--ink-500);
  font-weight: 500;
}

.header-stats {
  display: flex;
  gap: 10px;
  margin-left: 6px;
}

.stat-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 5px 14px;
  border-radius: 999px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  min-width: 64px;
}

.stat-pill strong {
  font-size: 0.95rem;
  color: var(--brand-dark);
  font-family: 'Poppins', sans-serif;
  line-height: 1.1;
}

.stat-pill span {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-500);
}

.header-spacer { flex: 1; }

.borough-filter {
  position: relative;
  display: flex;
  align-items: center;
}

.borough-filter select {
  appearance: none;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--ink-900);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 9px 34px 9px 16px;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  transition: border-color 0.15s ease;
}

.borough-filter select:hover { border-color: var(--brand); }

.borough-filter::after {
  content: '';
  position: absolute;
  right: 14px;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--ink-500);
  border-bottom: 2px solid var(--ink-500);
  transform: rotate(45deg);
  pointer-events: none;
  margin-top: -3px;
}

/* ---------- Map ---------- */

#map {
  position: absolute;
  top: var(--header-h);
  bottom: 0;
  left: 0;
  right: 0;
}

.leaflet-control-attribution {
  font-size: 10px !important;
  background: rgba(255,255,255,0.85) !important;
}

.leaflet-control-zoom {
  border: none !important;
  box-shadow: var(--shadow-soft) !important;
  margin-top: 14px !important;
}

.leaflet-control-zoom a {
  border-radius: var(--radius-sm) !important;
  color: var(--ink-900) !important;
}

/* custom marker */

.growth-marker {
  width: 34px;
  height: 34px;
  position: relative;
}

.growth-marker .pin {
  width: 34px;
  height: 34px;
  border-radius: 50% 50% 50% 0;
  background: linear-gradient(140deg, var(--brand-light), var(--brand-dark));
  transform: rotate(-45deg);
  box-shadow: 0 6px 14px -4px rgba(15, 122, 55, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  border: 2px solid #fff;
}

.growth-marker .pin svg {
  transform: rotate(45deg);
  width: 15px;
  height: 15px;
}

.growth-marker .ring {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  background: var(--brand);
  opacity: 0.35;
  animation: pulse-ring 2.6s ease-out infinite;
}

.growth-marker:hover .pin {
  transform: rotate(-45deg) scale(1.12);
  box-shadow: 0 10px 20px -4px rgba(15, 122, 55, 0.75);
}

@keyframes pulse-ring {
  0% { transform: scale(0.6); opacity: 0.45; }
  80% { transform: scale(1.7); opacity: 0; }
  100% { transform: scale(1.7); opacity: 0; }
}

.leaflet-popup-content-wrapper {
  border-radius: var(--radius-md) !important;
  box-shadow: var(--shadow-pop) !important;
  padding: 0 !important;
  overflow: hidden;
}

.leaflet-popup-content { margin: 0 !important; width: 220px !important; }
.leaflet-popup-tip { box-shadow: var(--shadow-soft) !important; }

.popup-card { font-family: 'Inter', sans-serif; }

.popup-thumb {
  width: 100%;
  height: 110px;
  object-fit: cover;
  display: block;
}

.popup-body { padding: 12px 14px 14px; }

.popup-body h3 {
  margin: 0 0 3px;
  font-size: 0.92rem;
  font-weight: 600;
}

.popup-body p {
  margin: 0 0 10px;
  font-size: 0.72rem;
  color: var(--ink-500);
}

.popup-author {
  font-size: 0.68rem !important;
  color: var(--brand-dark) !important;
  margin: -4px 0 10px !important;
}

.popup-author strong { color: var(--ink-900); }

.popup-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #fff;
  background: var(--brand-dark);
  border: none;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  width: 100%;
  justify-content: center;
  transition: background 0.15s ease;
}

.popup-btn:hover { background: var(--brand); }

/* ---------- Intro toast ---------- */

.intro-toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  z-index: 900;
  pointer-events: none;
  background: rgba(11, 17, 32, 0.88);
  color: #fff;
  padding: 11px 18px;
  border-radius: 999px;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-pop);
  backdrop-filter: blur(6px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.intro-toast.hidden {
  opacity: 0;
  transform: translate(-50%, 12px);
  pointer-events: none;
}

.intro-toast .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--lime);
  flex-shrink: 0;
  animation: pulse-ring 1.8s ease-out infinite;
}

/* ---------- Credits badge ---------- */

.credits-badge {
  position: fixed;
  bottom: 26px;
  left: 14px;
  z-index: 850;
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px) saturate(160%);
  -webkit-backdrop-filter: blur(10px) saturate(160%);
  border-radius: 999px;
  padding: 6px 14px 6px 6px;
  box-shadow: var(--shadow-soft);
}

.credit-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  overflow: hidden;
  display: block;
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(11, 17, 32, 0.28);
  margin-left: -10px;
  position: relative;
  transition: transform 0.18s ease;
}

.credit-avatar:first-child { margin-left: 0; }

.credit-avatar:hover,
.credit-avatar:focus-visible {
  transform: translateY(-3px) scale(1.1);
  z-index: 2;
}

.credit-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.credits-label {
  margin-left: 10px;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--ink-700);
  white-space: nowrap;
}

@media (max-width: 760px) {
  .credits-label { display: none; }
  .credits-badge { padding: 6px; }
}

/* ---------- Detail panel ---------- */

.overlay-scrim {
  position: fixed;
  inset: 0;
  background: rgba(11, 17, 32, 0.35);
  z-index: 1400;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.overlay-scrim.open { opacity: 1; pointer-events: auto; }

.detail-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(460px, 100%);
  background: var(--surface);
  z-index: 1500;
  box-shadow: -20px 0 50px -20px rgba(11, 17, 32, 0.4);
  transform: translateX(105%);
  transition: transform 0.32s cubic-bezier(.2,.9,.25,1);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.detail-panel.open { transform: translateX(0); }

.detail-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(11, 17, 32, 0.55);
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

.detail-close:hover { background: rgba(11, 17, 32, 0.8); }

.detail-body { padding: 24px 26px 40px; }

.detail-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--brand-dark);
  background: rgba(22, 163, 74, 0.1);
  padding: 5px 11px;
  border-radius: 999px;
  margin-bottom: 12px;
}

.detail-body h2 {
  margin: 0 0 6px;
  font-size: 1.5rem;
  letter-spacing: -0.01em;
}

.detail-desc {
  margin: 10px 0 18px;
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--ink-700);
}

.detail-meta {
  display: flex;
  gap: 22px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.detail-meta div { flex: 1; }

.detail-meta .label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-500);
  font-weight: 700;
  margin-bottom: 3px;
}

.detail-meta .value {
  font-size: 0.95rem;
  font-weight: 600;
}

.detail-meta .value.before-color { color: #94622f; }
.detail-meta .value.after-color { color: var(--brand-dark); }

/* ---------- Before/after slider ---------- */

.ba-slider {
  position: relative;
  width: 100%;
  aspect-ratio: 8 / 5;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
  cursor: ew-resize;
  background: #dfe6e0;
}

.ba-slider img { -webkit-user-drag: none; }

.ba-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

.ba-before {
  clip-path: inset(0 50% 0 0);
}

.ba-badge {
  position: absolute;
  bottom: 12px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #fff;
  padding: 5px 10px;
  border-radius: 999px;
  backdrop-filter: blur(4px);
  pointer-events: none;
  text-transform: uppercase;
}

.ba-badge-before { left: 12px; background: rgba(120, 84, 43, 0.75); }
.ba-badge-after { right: 12px; background: rgba(15, 122, 55, 0.82); }

.ba-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 0;
  transform: translateX(-50%);
  cursor: ew-resize;
}

.ba-handle-line {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 3px;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 0 1px rgba(11,17,32,0.15);
}

.ba-handle-circle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-pop);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--brand-dark);
}

.ba-handle-circle svg { width: 14px; height: 14px; }

.ba-fullscreen-btn {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: none;
  background: rgba(11, 17, 32, 0.52);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
  z-index: 3;
  backdrop-filter: blur(4px);
}

.ba-fullscreen-btn:hover { background: rgba(11, 17, 32, 0.82); }
.ba-fullscreen-btn svg { width: 16px; height: 16px; }

.ba-fullscreen-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(11, 17, 32, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.22s ease;
  backdrop-filter: blur(6px);
}

.ba-fullscreen-overlay.open { opacity: 1; }

.ba-fullscreen-inner {
  position: relative;
  width: min(92vw, 1100px);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ba-slider-fs {
  width: 100%;
  aspect-ratio: unset;
  height: min(75vh, 680px);
  border-radius: 16px;
  overflow: hidden;
}

.ba-fullscreen-title {
  color: #fff;
  font-family: 'Poppins', sans-serif;
  font-size: 1.1rem;
  font-weight: 600;
  text-align: center;
  opacity: 0.9;
}

.ba-fullscreen-close {
  position: absolute;
  top: -14px;
  right: -14px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
  backdrop-filter: blur(4px);
}

.ba-fullscreen-close:hover { background: rgba(255, 255, 255, 0.28); }

@media (max-width: 760px) {
  .ba-slider-fs { height: min(60vh, 420px); }
  .ba-fullscreen-inner { width: 96vw; }
}

/* ---------- Responsive ---------- */

.detail-close-mobile-wrap { display: none; }

@media (max-width: 760px) {
  .site-header { gap: 10px; padding: 0 14px; }
  .brand-sub { display: none; }
  .header-stats { display: none; }
  .borough-filter { min-width: 0; flex-shrink: 1; }
  .borough-filter select {
    padding: 8px 28px 8px 12px;
    font-size: 0.78rem;
    max-width: 42vw;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .detail-panel {
    width: 100%;
    top: auto;
    height: min(88vh, 640px);
    border-radius: 22px 22px 0 0;
    transform: translateY(105%);
    box-shadow: 0 -20px 50px -20px rgba(11,17,32,0.4);
    overflow: hidden;
  }

  .detail-panel.open { transform: translateY(0); }

  .detail-body {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
  }

  .intro-toast { width: calc(100% - 32px); justify-content: center; text-align: center; bottom: 18px; }

  .detail-close-mobile-wrap {
    display: flex;
    justify-content: center;
    padding: 16px 0 28px;
  }

  .detail-close-mobile-wrap {
    padding-bottom: max(28px, env(safe-area-inset-bottom));
  }

  .detail-close-mobile {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: none;
    background: var(--surface-alt);
    color: var(--ink-900);
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(11, 17, 32, 0.12);
    transition: background 0.15s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    z-index: 10;
  }

  .detail-close-mobile:active { background: var(--border); }
}
