:root {
  --forest-900: #16321f;
  --forest-800: #204a2c;
  --forest-700: #2c6339;
  --forest-500: #4c8a5a;
  --forest-100: #eaf3ec;
  --paper: #faf8f3;
  --paper-dim: #f1ede2;
  --ink: #262420;
  --ink-soft: #5c584f;
  --z1: #4c8a5a;
  --z2: #3d7fa6;
  --z3: #c07a2e;
  --confHigh: #2f7a44;
  --confMediumHigh: #6a9e3f;
  --confMedium: #c99a2e;
  --confLowMedium: #d4772e;
  --confLow: #c1462f;
  --radius: 14px;
  --shadow: 0 4px 18px rgba(30, 40, 25, 0.12);
  --shadow-lg: 0 20px 60px rgba(20, 25, 15, 0.35);
  font-size: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--ink);
  background: var(--paper);
  line-height: 1.55;
}

h1, h2, h3 {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 600;
  margin: 0 0 0.4em;
  color: var(--forest-900);
}

a { color: var(--forest-700); }

/* ---------- Header ---------- */
.site-header {
  background:
    linear-gradient(180deg, rgba(22,50,31,0.82), rgba(22,50,31,0.93)),
    url('images/thumb/IMG_9315.jpg') center 30% / cover;
  color: #f4f1e8;
  padding: 4.5rem 1.5rem 3rem;
  text-align: center;
}
.header-inner { max-width: 760px; margin: 0 auto; }
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.78rem;
  color: #cfe3d2;
  margin: 0 0 1rem;
}
.site-header h1 {
  color: #fff;
  font-size: clamp(2.2rem, 5.5vw, 3.4rem);
  line-height: 1.08;
  margin-bottom: 1rem;
}
.lede { font-size: 1.08rem; color: #e6e9dd; max-width: 600px; margin: 0 auto 1.8rem; }
.lede strong { color: #fff; }

.stat-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1.6rem;
  margin-bottom: 2.2rem;
}
.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.stat .num {
  font-family: 'Fraunces', serif;
  font-size: 1.7rem;
  font-weight: 600;
  color: #fff;
}
.stat .label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #cfe3d2;
}

.site-nav { display: flex; justify-content: center; gap: 2rem; }
.site-nav a {
  color: #f4f1e8;
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  padding-bottom: 4px;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}
.site-nav a:hover { border-color: #f4f1e8; }

/* ---------- Sections ---------- */
.section { padding: 4rem 1.5rem; }
.section.alt { background: var(--forest-100); }
.section-inner { max-width: 1180px; margin: 0 auto; }
.section h2 { font-size: clamp(1.7rem, 3.5vw, 2.3rem); }
.section-sub { color: var(--ink-soft); max-width: 640px; margin-bottom: 2rem; }

/* ---------- Controls ---------- */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  margin-bottom: 0.5rem;
}
.controls-secondary { margin-top: 0.6rem; }
.controls-label {
  font-size: 0.8rem;
  color: var(--ink-soft);
  font-weight: 500;
}
#search-box {
  flex: 1 1 240px;
  padding: 0.7rem 1rem;
  border-radius: 999px;
  border: 1px solid #d9d3c2;
  background: #fff;
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
#search-box:focus { border-color: var(--forest-500); box-shadow: 0 0 0 3px rgba(76,138,90,0.15); }

.filter-group { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip {
  border: 1px solid #d9d3c2;
  background: #fff;
  color: var(--ink-soft);
  padding: 0.5rem 1rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.chip:hover { border-color: var(--forest-500); color: var(--forest-700); }
.chip.active { background: var(--forest-800); border-color: var(--forest-800); color: #fff; }

.result-count { color: var(--ink-soft); font-size: 0.85rem; margin: 1rem 0 1.2rem; }

/* ---------- Gallery grid ---------- */
.masonry {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
  align-items: start;
}

.tile, .tile-cover {
  position: relative;
  aspect-ratio: 4 / 5;
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  box-shadow: var(--shadow);
  background: #ddd;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.tile:hover, .tile-cover:hover { transform: translateY(-4px) scale(1.015); box-shadow: 0 12px 30px rgba(20,30,15,0.22); }
.tile img, .tile-cover img { display: block; width: 100%; height: 100%; object-fit: cover; }

/* Grouped photos (same species) expand into a strip instead of opening the modal directly */
.tile-group { cursor: default; }
.tile-group.expanded {
  grid-column: 1 / -1;
  aspect-ratio: auto;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px;
  background: var(--paper-dim);
  border-radius: var(--radius);
  box-shadow: none;
}
.tile-group.expanded .tile-cover {
  flex: 0 0 160px;
  width: 160px;
  aspect-ratio: 4 / 5;
}
.group-badge {
  position: absolute;
  bottom: 10px; right: 10px;
  background: rgba(15,25,12,0.78);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
}
.group-strip { display: none; }
.tile-group.expanded .group-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex: 1 1 auto;
}
.sub-tile {
  position: relative;
  width: 110px;
  aspect-ratio: 4 / 5;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  flex: 0 0 auto;
  box-shadow: var(--shadow);
}
.sub-tile img { display: block; width: 100%; height: 100%; object-fit: cover; }
.sub-tile .conf-pill { top: 6px; left: 6px; font-size: 0.55rem; padding: 0.15rem 0.4rem; }

.tile-caption {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 0.9rem 0.8rem 0.7rem;
  background: linear-gradient(180deg, rgba(20,30,15,0) 0%, rgba(15,25,12,0.82) 90%);
  color: #fff;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.2s, transform 0.2s;
}
.tile-caption .common { font-family: 'Fraunces', serif; font-size: 0.98rem; font-weight: 600; display: block; }
.tile-caption .sci { font-size: 0.78rem; font-style: italic; color: #d8e4d3; }
.tile-zone-dot {
  position: absolute;
  top: 10px; right: 10px;
  width: 10px; height: 10px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.85);
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}
.z1 { background: var(--z1); }
.z2 { background: var(--z2); }
.z3 { background: var(--z3); }

.conf-pill {
  position: absolute;
  top: 10px; left: 10px;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  color: #fff;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.2s, transform 0.2s;
}

.conf-High, .conf-badge.conf-High { background: var(--confHigh); }
.conf-MediumHigh, .conf-badge.conf-MediumHigh { background: var(--confMediumHigh); }
.conf-Medium, .conf-badge.conf-Medium { background: var(--confMedium); }
.conf-LowMedium, .conf-badge.conf-LowMedium { background: var(--confLowMedium); }
.conf-Low, .conf-badge.conf-Low { background: var(--confLow); }

/* ---------- Map ---------- */
#leaflet-map {
  width: 100%;
  height: 560px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1.4rem;
  margin-top: 1.2rem;
  font-size: 0.85rem;
  color: var(--ink-soft);
}
.map-legend .dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  margin-right: 0.4em;
  vertical-align: middle;
}
.leaflet-popup-content { font-family: 'Inter', sans-serif; }
.leaflet-popup-content .popup-common { font-family: 'Fraunces', serif; font-weight: 600; font-size: 1rem; display: block; margin-bottom: 2px; }
.leaflet-popup-content .popup-sci { font-style: italic; color: #666; font-size: 0.82rem; }
.leaflet-popup-content img { width: 100%; border-radius: 8px; margin-bottom: 6px; cursor: pointer; }
.popup-conf {
  display: inline-block;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
}

/* ---------- About ---------- */
.about-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 3rem;
}
@media (max-width: 760px) { .about-grid { grid-template-columns: 1fr; } }
.about-grid p { color: var(--ink-soft); }
.safety {
  background: #fdf1e2;
  border-left: 3px solid var(--z3);
  padding: 0.8rem 1rem;
  border-radius: 6px;
  color: var(--ink) !important;
  font-size: 0.92rem;
}
.route-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 1.6rem 1.8rem;
  box-shadow: var(--shadow);
  height: fit-content;
}
.route-card h3 { font-size: 1.1rem; margin-bottom: 1rem; }
.route-card dl { margin: 0; }
.route-card dt { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-soft); margin-top: 0.9rem; }
.route-card dt:first-child { margin-top: 0; }
.route-card dd { margin: 0.1rem 0 0; font-weight: 600; color: var(--forest-900); }

/* ---------- Mobile refinements ---------- */
@media (max-width: 600px) {
  .site-header { padding: 2.8rem 1rem 2rem; }
  .site-header h1 { font-size: 1.8rem; }
  .lede { font-size: 0.95rem; }
  .stat .num { font-size: 1.3rem; }
  .stat-row { gap: 1rem; }
  .site-nav { gap: 1.2rem; }
  .site-nav a { font-size: 0.88rem; }

  .section { padding: 2.4rem 1rem; }
  .section h2 { font-size: 1.45rem; }
  .section-sub { font-size: 0.92rem; }

  .controls { gap: 0.6rem; }
  #search-box { flex: 1 1 100%; font-size: 1rem; padding: 0.8rem 1rem; }
  .filter-group { gap: 0.35rem; }
  .chip { padding: 0.55rem 0.85rem; font-size: 0.82rem; min-height: 44px; display: inline-flex; align-items: center; }
  .controls-label { width: 100%; }

  #leaflet-map { height: 340px; }
  .map-legend { gap: 0.6rem; font-size: 0.78rem; flex-direction: column; }

  .about-grid { gap: 1.6rem; }
  .route-card { padding: 1.2rem; }

  /* Kill hover effects on touch — they stick */
  .tile:hover, .tile-cover:hover { transform: none; box-shadow: var(--shadow); }
  .sub-tile { width: 90px; }

  /* Stack cover above strip instead of side-by-side on narrow screens */
  .tile-group.expanded { flex-direction: column; }
  .tile-group.expanded .tile-cover { width: 140px; }
}

/* Ensure smooth scroll for anchor nav */
html { scroll-behavior: smooth; }
section[id] { scroll-margin-top: 1rem; }

/* ---------- Footer ---------- */
.site-footer {
  text-align: center;
  padding: 2.2rem 1.5rem;
  color: #fff;
  background: var(--forest-900);
  font-size: 0.85rem;
}

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 12, 0.72);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.2rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
  z-index: 1000;
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--paper);
  border-radius: 18px;
  max-width: 920px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  box-shadow: var(--shadow-lg);
  transform: scale(0.96) translateY(10px);
  transition: transform 0.25s;
  position: relative;
}
.modal-overlay.open .modal { transform: scale(1) translateY(0); }
@media (max-width: 700px) { .modal { grid-template-columns: 1fr; } }

.modal-img-wrap { background: #111; display: flex; align-items: center; justify-content: center; }
.modal-img-wrap img { width: 100%; height: 100%; object-fit: cover; max-height: 90vh; }
@media (max-width: 700px) { .modal-img-wrap img { max-height: 45vh; } }

.modal-body { padding: 2.1rem 2rem; }
.modal-close {
  position: absolute;
  top: 12px; right: 12px;
  width: 34px; height: 34px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.5);
  color: #fff;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
}
.modal-close:hover { background: rgba(0,0,0,0.7); }

.badge-row { display: flex; gap: 0.5rem; margin-bottom: 0.8rem; }
.zone-badge, .conf-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  color: #fff;
}
.zone-badge.Z1 { background: var(--z1); }
.zone-badge.Z2 { background: var(--z2); }
.zone-badge.Z3 { background: var(--z3); }

.learn-more {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  margin-top: 1.2rem;
  padding: 0.55rem 1.1rem;
  border-radius: 999px;
  background: var(--forest-700);
  color: #fff !important;
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: background 0.15s, transform 0.15s;
}
.learn-more:hover { background: var(--forest-900); transform: translateY(-1px); }
.learn-more:active { transform: translateY(0); }

#modal-common { font-size: 1.55rem; margin-bottom: 0.15rem; }
.sci { font-style: italic; color: var(--ink-soft); margin: 0 0 1rem; font-size: 1.02rem; }
.modal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  font-size: 0.85rem;
  color: var(--ink-soft);
  border-top: 1px solid #e6e0d0;
  border-bottom: 1px solid #e6e0d0;
  padding: 0.7rem 0;
  margin-bottom: 1rem;
}
.modal-meta span::before { content: '•'; margin-right: 0.5em; color: var(--forest-500); }
.modal-meta span:first-child::before { content: ''; margin: 0; }
.modal-notes { color: var(--ink); }
.modal-coords { font-size: 0.78rem; color: #a39c8a; margin-top: 1rem; }

@media (max-width: 600px) {
  .modal { border-radius: 12px; max-height: 95vh; }
  .modal-body { padding: 1.4rem 1.2rem; }
  #modal-common { font-size: 1.25rem; }
  .modal-meta { font-size: 0.82rem; }
  .learn-more { width: 100%; justify-content: center; }
}
