/* === Animal/Plant Cards === */
.card {
  background: var(--color-card-bg);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  transition: transform var(--transition), box-shadow var(--transition);
  cursor: pointer;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
}

.card-image {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--safari-sand);
}

.card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 20%;
  transition: transform 0.6s ease;
}

.card:hover .card-image img { transform: scale(1.05); }

.card-image .tag {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
}

.card-body { padding: 1.25rem; }
.card-body h3 { margin-bottom: 0.25rem; }

.card-scientific {
  font-style: italic;
  color: var(--color-text-muted);
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

.card-body p {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-footer {
  padding: 0 1.25rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-type {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  font-weight: 600;
}

/* === Modal === */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition);
}

.modal-backdrop.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--color-card-bg);
  border-radius: var(--radius-lg);
  max-width: 700px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px);
  transition: transform var(--transition);
}

.modal-backdrop.active .modal { transform: translateY(0); }

.modal-hero {
  position: relative;
  aspect-ratio: 16 / 9;
  max-height: 400px;
  overflow: hidden;
}

.modal-hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.modal-hero .tag {
  position: absolute;
  top: 1rem;
  right: 1rem;
}

.modal-close {
  position: absolute;
  top: 1rem;
  left: 1rem;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(0,0,0,0.5);
  color: #fff;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
  z-index: 10;
}

.modal-close:hover { background: rgba(0,0,0,0.8); }

.modal-content { padding: 2rem; }
.modal-content h2 { margin-bottom: 0.25rem; }

.modal-scientific {
  font-style: italic;
  color: var(--color-text-muted);
  font-size: 1rem;
  margin-bottom: 1.5rem;
}

.modal-section { margin-bottom: 1.5rem; }
.modal-section h4 {
  font-family: var(--font-heading);
  margin-bottom: 0.75rem;
  color: var(--color-accent-dark);
  font-size: 1.1rem;
}

.fact-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.fact-list li {
  padding-left: 1.5rem;
  position: relative;
  font-size: 0.95rem;
  line-height: 1.6;
}

.fact-list li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.5rem;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-accent);
}

.modal-guide-note {
  background: var(--safari-sand);
  padding: 1rem 1.25rem;
  border-radius: var(--radius-sm);
  border-left: 4px solid var(--color-accent);
  font-size: 0.9rem;
  line-height: 1.6;
}

.modal-guide-note strong {
  display: block;
  margin-bottom: 0.25rem;
  color: var(--color-accent-dark);
}

.modal-links {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

/* === Modal Media Grid === */
.modal-media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.modal-media-item {
  width: 100%;
  height: 150px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: transform var(--transition);
}

.modal-media-item:hover {
  transform: scale(1.03);
}

/* === Progressive Image Loading === */
.progressive-img {
  filter: blur(20px);
  transform: scale(1.1);
  transition: filter 0.6s ease-out, transform 0.6s ease-out;
  will-change: filter, transform;
}

.progressive-img.loaded {
  filter: none;
  transform: none;
}

/* === Modal Hero Clickable === */
.modal-hero-clickable {
  cursor: pointer;
}

.modal-hero-zoom {
  position: absolute;
  bottom: 0.75rem;
  right: 0.75rem;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.modal-hero-clickable:hover .modal-hero-zoom {
  opacity: 1;
}

.modal-hero-clickable:hover img {
  filter: brightness(1.05);
  transition: filter 0.2s ease;
}

/* === Media placeholder === */
.media-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 200px;
  background: var(--safari-sand);
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  font-size: 0.9rem;
  border: 2px dashed var(--color-card-border);
}

.media-placeholder span { font-size: 2rem; margin-bottom: 0.5rem; }

/* === Lightbox === */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0, 0, 0, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.lightbox.active {
  opacity: 1;
  visibility: visible;
}

.lightbox-content {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 3.5rem 3rem 4rem;
}

.lightbox-media {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: var(--radius-sm);
}

video.lightbox-media {
  max-width: 100%;
  max-height: 100%;
}

.lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: none;
  font-size: 1.6rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  z-index: 2;
}

.lightbox-close:hover { background: rgba(255, 255, 255, 0.25); }

.lightbox-prev,
.lightbox-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: none;
  font-size: 2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  z-index: 2;
}

.lightbox-prev { left: 1rem; }
.lightbox-next { right: 1rem; }
.lightbox-prev:hover,
.lightbox-next:hover { background: rgba(255, 255, 255, 0.25); }

.lightbox-footer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  padding: 1rem;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.6));
  color: #fff;
  font-size: 0.9rem;
  z-index: 2;
}

.lightbox-counter {
  opacity: 0.7;
  font-variant-numeric: tabular-nums;
}

.lightbox-caption {
  opacity: 0.9;
}

/* === Gallery cursor for clickable items === */
.gallery-item { cursor: pointer; }
.modal-media-item { cursor: pointer; }

/* === Gallery Load More === */
.gallery-load-more-wrap {
  display: flex;
  justify-content: center;
  margin-top: 1.5rem;
}
.gallery-load-more {
  min-width: 180px;
}

/* === Responsive === */
@media (max-width: 768px) {
  /* Fullscreen modal on mobile */
  .modal-backdrop { padding: 0; }
  .modal {
    max-width: 100%;
    max-height: 100dvh;
    height: 100dvh;
    border-radius: 0;
  }
  .modal-hero { max-height: 240px; }
  .modal-content { padding: 1.25rem; }

  /* Sticky close button stays visible while scrolling */
  .modal-close {
    position: sticky;
    top: 0.75rem;
    margin-left: auto;
    margin-right: 0.75rem;
    margin-bottom: -44px;
    background: rgba(0,0,0,0.65);
  }

  .lightbox-prev,
  .lightbox-next { width: 36px; height: 36px; font-size: 1.5rem; }
  .lightbox-content { padding: 3rem 1rem 3.5rem; }
}
