/* Zoo Mondiale - Stile editoriale naturalista */

:root {
  --bg: #0f1412;
  --bg-card: #1a211c;
  --bg-elevated: #232d27;
  --text: #e8ebe6;
  --text-muted: #8a9589;
  --accent: #7cb87c;
  --accent-dim: #4a6b4a;
  --border: #2d3a30;
  --danger: #c45c5c;
  --radius: 6px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1rem 2rem;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: 0.02em;
}

.logo:hover {
  color: var(--text);
}

.search-form {
  display: flex;
  gap: 0.5rem;
}

.search-form input {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
  min-width: 200px;
}

.search-form input:focus {
  outline: none;
  border-color: var(--accent-dim);
}

.search-form button {
  padding: 0.5rem 1rem;
  background: var(--accent-dim);
  border: none;
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
}

.search-form button:hover {
  background: var(--accent);
}

/* Main */
.main-content {
  flex: 1;
  padding: 2rem;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

/* Hero */
.hero {
  margin-bottom: 2rem;
}

.hero h1 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 2.5rem;
  font-weight: 600;
  margin: 0 0 0.25rem 0;
  color: var(--text);
}

.hero-sub {
  color: var(--text-muted);
  font-size: 1.1rem;
  margin: 0;
}

/* Category nav */
.category-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.category-nav a {
  padding: 0.35rem 0.75rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
}
.category-nav a:hover,
.category-nav a.active {
  background: var(--accent-dim);
  color: var(--text);
  border-color: var(--accent-dim);
}

/* Group nav (Bovini, Ovini, etc. per farm / gruppi FCI per cani) */
.group-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.group-nav a {
  padding: 0.35rem 0.75rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.group-nav a:hover,
.group-nav a.active {
  background: var(--accent-dim);
  color: var(--text);
  border-color: var(--accent-dim);
}

/* Family nav */
.family-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.family-nav a {
  padding: 0.35rem 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
}

.family-nav a:hover,
.family-nav a.active {
  background: var(--accent-dim);
  color: var(--text);
  border-color: var(--accent-dim);
}

/* Species grid */
.species-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.5rem;
}

.species-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: transform 0.2s, border-color 0.2s;
  content-visibility: auto;
  contain-intrinsic-size: auto 280px;
}

.species-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent-dim);
}

.card-image {
  position: relative;
  aspect-ratio: 4/3;
  background: var(--bg-elevated);
  overflow: hidden;
}

.card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.no-image {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 2rem;
}

.conservation-badge,
.extinct-badge {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  padding: 0.2rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  border-radius: 4px;
  background: rgba(0,0,0,0.7);
}

.breed-badge {
  display: inline-block;
  padding: 0.15rem 0.4rem;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  background: var(--accent-dim);
  color: var(--text);
  border-radius: 4px;
}
.breed-badge.large {
  font-size: 0.8rem;
  padding: 0.3rem 0.6rem;
}

.conservation-badge.lc { color: #7cb87c; }
.conservation-badge.nt { color: #b8b87c; }
.conservation-badge.vu { color: #b8a07c; }
.conservation-badge.en { color: #b87c7c; }
.conservation-badge.cr { color: #c45c5c; }
.conservation-badge.ew,
.extinct-badge { color: var(--danger); }

.card-body {
  padding: 1rem;
}

.card-body h3 {
  margin: 0 0 0.25rem 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.card-body .scientific {
  font-style: italic;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 0 0 0.25rem 0;
}

.card-body .family {
  font-size: 0.8rem;
  color: var(--accent-dim);
  margin: 0;
}

/* Pagination */
.pagination {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}
.pagination-info {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0;
}
.pagination-links {
  display: flex;
  gap: 1rem;
}
.pagination-link {
  padding: 0.5rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9rem;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.pagination-link:hover {
  background: var(--accent-dim);
  color: var(--text);
  border-color: var(--accent-dim);
}

@media (max-width: 640px) {
  .pagination {
    flex-direction: column;
    gap: 0.75rem;
  }
}

/* Empty state */
.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 3rem;
}

/* Species detail */
.species-detail {
  max-width: 900px;
}

.back-link {
  display: inline-block;
  color: var(--text-muted);
  text-decoration: none;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

.back-link:hover {
  color: var(--accent);
}

.species-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 2rem;
}

.species-title h1 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 2.25rem;
  margin: 0 0 0.25rem 0;
}

.species-title .scientific-name {
  font-style: italic;
  color: var(--text-muted);
  margin: 0 0 0.25rem 0;
}

.species-title .alt-names {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0;
}

.conservation-badge.large,
.extinct-badge.large {
  position: static;
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
}

.species-layout {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 2rem;
}

@media (max-width: 768px) {
  .species-layout {
    grid-template-columns: 1fr;
  }
}

.gallery-main {
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-elevated);
  margin-bottom: 1rem;
}

.gallery-main img {
  width: 100%;
  display: block;
}

.gallery-thumbs {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.gallery-thumbs .thumb {
  width: 60px;
  height: 60px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  background: none;
  overflow: hidden;
}

.gallery-thumbs .thumb:hover,
.gallery-thumbs .thumb.active {
  border-color: var(--accent);
}

.gallery-thumbs .thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.no-gallery {
  aspect-ratio: 4/3;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
  color: var(--text-muted);
  border-radius: var(--radius);
}

.species-content h2 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.25rem;
  margin: 1.5rem 0 0.75rem 0;
  color: var(--accent);
}

.species-content h2:first-of-type {
  margin-top: 0;
}

.section-note {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: -0.5rem 0 0.75rem 0;
}

.description p {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.7;
}

.tax-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.25rem 1.5rem;
  margin: 0;
}

.tax-list dt {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.tax-list dd {
  margin: 0;
}

.video-list {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.video-card {
  display: flex;
  flex-direction: column;
  width: 160px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
}

.video-card img {
  aspect-ratio: 16/9;
  object-fit: cover;
}

.video-card span {
  padding: 0.5rem;
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.video-card:hover {
  border-color: var(--accent-dim);
}

.links ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.links a {
  color: var(--accent);
  text-decoration: none;
}

.links a:hover {
  text-decoration: underline;
}

/* Footer */
.site-footer {
  padding: 1.5rem 2rem;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.site-footer .credit {
  margin-top: 0.25rem;
  font-size: 0.8rem;
  opacity: 0.8;
}
.site-footer .footer-link {
  color: var(--accent);
  text-decoration: none;
}
.site-footer .footer-link:hover {
  text-decoration: underline;
}

/* Breadcrumb */
.breadcrumb {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}
.breadcrumb a {
  color: var(--accent);
  text-decoration: none;
}
.breadcrumb a:hover {
  text-decoration: underline;
}
.breadcrumb .sep {
  margin: 0 0.35rem;
  opacity: 0.7;
}

/* Focus visible - accessibilità */
a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Touch target minimo 44px */
.search-form button,
.family-nav a,
.group-nav a,
.gallery-thumbs .thumb {
  min-height: 44px;
  min-width: 44px;
}
.family-nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
}

/* Mobile - 640px */
@media (max-width: 640px) {
  .site-header {
    flex-wrap: wrap;
    padding: 1rem;
  }
  .search-form {
    width: 100%;
    order: 3;
  }
  .search-form input {
    flex: 1;
    min-width: 0;
  }
  .main-content {
    padding: 1rem;
  }
  .group-nav {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    padding-bottom: 0.5rem;
  }
  .group-nav a {
    flex-shrink: 0;
  }
  .family-nav {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    padding-bottom: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
  }
  .family-nav a {
    flex-shrink: 0;
  }
  .gallery-thumbs {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    padding-bottom: 0.25rem;
  }
  .gallery-thumbs .thumb {
    flex-shrink: 0;
  }
  .hero h1 {
    font-size: 1.75rem;
  }
}

/* Mobile - 480px */
@media (max-width: 480px) {
  .site-header {
    padding: 0.75rem 1rem;
  }
  .logo {
    font-size: 1.4rem;
  }
}

/* Mobile - 400px - grid compatto */
@media (max-width: 400px) {
  .species-grid {
    grid-template-columns: repeat(2, minmax(140px, 1fr));
    gap: 1rem;
  }
  .card-body {
    padding: 0.75rem;
  }
  .card-body h3 {
    font-size: 1rem;
  }
}
