/* 1. Variables for easy switching */
:root {
  --sidebar-width: 350px;
  --bg-main: #f4f4f4;
  --bg-sidebar: #ffffff;
  --bg-card: #ffffff;
  --text-primary: #333333;
  --text-secondary: #777777;
  --border-color: #cccccc;
  --map-filter: none;
  /* Map tiles stay normal in light mode */
}
  
  /* 2. Dark Mode Overrides */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-main: #1a1a1a;
    --bg-sidebar: #242424;
    --bg-card: #2d2d2d;
    --text-primary: #e0e0e0;
    --text-secondary: #aaaaaa;
    --border-color: #444444;
      /* This filter inverts the map tiles to make them dark */
    --map-filter: invert(100%) hue-rotate(180deg) brightness(95%) contrast(90%);
  }
}
body,
html {
  margin: 0;
  padding: 0;
  height: 100dvh;
  font-family: 'Segoe UI', Tahoma, sans-serif;
  overflow: hidden;
  background: var(--bg-main);
  color: var(--text-primary);
}
.container {
  display: flex;
  height: 100vh;
  height: 100dvh;
  flex-direction: row;
}
  
  /* Sidebar */
#sidebar {
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-color);
  background: var(--bg-main);
}
.search-container {
  padding: 15px;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border-color);
  z-index: 10;
}
#search-input {
  width: 100%;
  padding: 12px;
  box-sizing: border-box;
  border: 1px solid var(--border-color);
  border-radius: 20px;
  outline: none;
  background: var(--bg-main);
  color: var(--text-primary);
}
#duck-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
}
  
  /* Duck Card */
.duck-card {
  display: flex;
  align-items: flex-start;
  padding: 12px;
  margin-bottom: 10px;
  background: var(--bg-card);
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform 0.1s;
  position: relative;
}
.duck-card img {
  width: 65px;
  height: 65px;
  border-radius: 8px;
  object-fit: cover;
  margin-right: 15px;
  background: #444;
}
.duck-info h4 {
  margin: 0;
  font-size: 1rem;
  color: var(--text-primary);
}
.duck-info p {
  margin: 4px 0 0;
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.2;
}
  
  /* Map & Dark Mode Tile Filter */
#map {
  flex: 1;
  height: 100vh;
  height: 100dvh;
  width: 100%;
  position: relative;
  background: #242424;
    /* Prevents white flash during load */
}
  
  /* Applying the filter to the map tile layer only */
.leaflet-tile-container {
  filter: var(--map-filter);
}
  
  /* Markers should NOT be inverted, so we reverse the filter if in dark mode */
@media (prefers-color-scheme: dark) {
  .leaflet-marker-icon,
  .leaflet-marker-shadow,
  .duck-marker-container {
    filter: invert(100%) hue-rotate(180deg);
  }
}
@media (max-width: 768px) {
  .container {
    flex-direction: column;
  }
  #sidebar {
    width: 100%;
    height: 30vh !important;
    height: 30dvh !important;
    order: 2;
    border-right: none;
  }
  #map {
    height: 70vh !important;
    height: 70dvh !important;
    order: 1;
  }
  .leaflet-popup-content-wrapper {
    padding: 5px;
  }
  .popup-content img {
    max-width: 150px;
        /* Shrinks the image specifically for phones */
  }
  .leaflet-popup-content {
    width: 180px !important;
        /* Keeps the entire bubble narrow */
    margin: 10px;
  }
}
  
  /* Container for the circular marker */
.duck-marker-container {
  width: 45px;
  height: 45px;
  border-radius: 50%;
  border: 3px solid white;
    /* Adds a nice frame */
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
  overflow: hidden;
  background: white;
  transition: transform 0.2s;
}
  
  /* Ensure the image fills the circle */
.duck-marker-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
  
  /* Hover effect to make it feel interactive */
.duck-marker-container:hover {
  transform: scale(1.2);
  z-index: 1000 !important;
}
  
  /* Add a little triangle pointer at the bottom of the circle */
.duck-marker-container::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 15px;
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 10px solid white;
}
.duck-info .tag {
  padding-left: 2px;
  padding-right: 2px;
}
  
  /* Standard Desktop Popup Image */
.popup-content img {
  width: 100%;
  max-width: 250px;
    /* Limits size on big screens */
  height: auto;
  border-radius: 8px;
  display: block;
  margin: 0 auto 10px auto;
}
  
  /* Ensure the image container is the anchor for the pin */
.duck-card.is-mapped .duck-img,
.duck-card.not-mapped .duck-img {
  position: relative;
}
  
  /* Create the pin overlay using a pseudo-element */
.duck-card.is-mapped .duck-img::after {
  content: '📍';
  position: absolute;
  top: 5px;
  right: 5px;
  font-size: 1.2rem;
  background: rgba(255, 255, 255, 0.8);
    /* Slight background to make it pop */
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  pointer-events: none;
    /* Clicking the pin clicks the card */
}
  
  /* Create the pin overlay using a pseudo-element */
.duck-card.not-mapped .duck-img::after {
  content: '🖼️';
  position: absolute;
  top: 5px;
  right: 5px;
  font-size: 1.2rem;
  background: rgba(255, 255, 255, 0.8);
    /* Slight background to make it pop */
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  pointer-events: none;
    /* Clicking the pin clicks the card */
}
.lightbox {
  display: none;
  position: fixed;
  z-index: 9999;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.9);
  cursor: pointer;
  justify-content: center;
  align-items: center;
  flex-direction: column;
}
.lightbox img {
  max-width: 90%;
  max-height: 80%;
  border-radius: 8px;
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.2);
}
#lightbox-caption {
  color: white;
  margin-top: 15px;
  font-size: 1.2rem;
  text-align: center;
}
.close-lightbox {
  position: absolute;
  top: 20px;
  right: 35px;
  color: white;
  font-size: 40px;
  font-weight: bold;
}
.duck-img {
  position: relative; /* Essential for absolute positioning of the badge */
}
.new-badge {
  position: absolute;
  top: 5px;
  right: 5px;
  background: #ffcc00; /* Duck yellow! */
  color: #333;
  font-weight: bold;
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
  z-index: 10;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
  pointer-events: none;
  animation: pop-in 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes pop-in {
  0% {
    transform: scale(0);
  }
  100% {
    transform: scale(1);
  }
}
