/* ========================================
   CSS VARIABLES
   ======================================== */
:root {
  --main-bg: #f4f8fa;
  --card-bg: #ffffff;
  --text-color: #333333;
  --link-color: #2c5aa0;
  --btn-bg: #2c5aa0;
  --btn-bg-hover: #1e3f73;
  --border-color: #e0e6ed;
  --shadow-light: 0 2px 4px rgba(0,0,0,0.1);
  --shadow-medium: 0 4px 8px rgba(0,0,0,0.2);
  --shadow-heavy: 0 8px 16px rgba(0,0,0,0.3);

  /* Variabili aggiuntive per modali (compatibilitÃ  con scheda.css) */
  --color-bg: #ffffff;
  --color-text: #264159;
  --color-link: #295084;
  --color-border: #e1e6ec;
  --color-border-muted: #b5c1d1;
  --color-soft-bg: #f8fbfd;
  --color-hover-bg: #edf2f6;
  --color-hover-bg-strong: #d9e2ef;
  --color-muted: #3b5678;
  --accent: #6697c1;
  --shadow-2: 0 8px 32px rgba(20,30,60,0.15);
  --shadow-1: 0 4px 16px rgba(20,30,60,0.08);
  --overlay: rgba(20, 30, 60, 0.4);
}

/* ========================================
   RESET E STILI GLOBALI
   ======================================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  background-color: var(--main-bg);
  font-family: 'Georgia', serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-color);
  overflow-y: auto;
  width: 100%;
  max-width: none;
  /* Rimuovo min-height per pagine con molto contenuto */
  min-height: 100vh;
}

/* ========================================
   HOMEPAGE COMPONENTS
   ======================================== */
.home-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
  text-align: center;
  /* IMPORTANTE: nessun overflow che possa creare scrollbar */
  overflow: visible;
  height: auto;
  max-height: none;
}

.home-title {
  font-size: 3rem;
  color: var(--link-color);
  margin-bottom: 1rem;
  font-weight: bold;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
}

.home-subtitle {
  font-size: 1.5rem;
  color: var(--text-color);
  margin-bottom: 1rem;
  font-style: italic;
}

.home-intro {
  font-size: 1.1rem;
  color: var(--text-color);
  margin-bottom: 2rem;
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.7;
}

/* ========================================
   ANIMAL NAVIGATION CARDS - SENZA SCROLLBAR PROPRIA
   ======================================== */
.animal-links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 2rem;
  margin: 2rem 0;
  /* CRUCIALE: elimina ogni possibile scrollbar */
  overflow: visible !important;
  height: auto !important;
  max-height: none !important;
  list-style: none;
  padding: 0;
  /* Assicura che il contenuto possa espandersi liberamente */
  min-height: auto;
}

/* Stili per i <li> dentro .animal-links */
.animal-links li {
  list-style: none;
  margin: 0;
  padding: 0;
  /* Anche i li non devono avere scrollbar */
  overflow: visible;
  height: auto;
}

.animal-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  /* DIMENSIONI FISSE GRANDI COME PRIMA */
  width: 200px;
  height: 200px;
  padding: 1.5rem;
  background-color: var(--card-bg);
  border-radius: 12px;
  text-decoration: none;
  color: var(--text-color);
  box-shadow: var(--shadow-light);
  transition: all 0.3s ease;
  border: 2px solid transparent;
  /* Rimuove qualsiasi marker di lista */
  list-style: none;
  position: relative;
  /* Assicura che anche le singole card non abbiano overflow */
  overflow: visible;
}

/* Assicura che non ci siano puntini anche se interpretato come lista */
.animal-card:before,
.animal-links li:before {
  content: none !important;
  display: none !important;
}

.animal-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-medium);
  border-color: var(--link-color);
}

.animal-icon {
  width: 80px;
  height: 80px;
  margin-bottom: 1rem;
  border-radius: 8px;
  object-fit: cover;
}

.animal-label {
  font-size: 1.1rem;
  font-weight: 600;
  text-align: center;
  /* Assicura che il testo non crei puntini */
  list-style: none;
}

/* Stili per la section che contiene .animal-links */
section[aria-label="Species list"] {
  overflow: visible !important;
  height: auto !important;
  max-height: none !important;
  margin: 0;
  padding: 0;
}

/* ========================================
   FOOTER (AGGIORNATO PER ESSERE UGUALE A SCHEDA.CSS)
   ======================================== */
footer {
  text-align: center;
  padding: 1rem;
  background: var(--color-bg);
  border-radius: 12px;
  border: 2px solid var(--color-border);
  box-shadow: var(--shadow-1);
  margin: 2rem auto;
  max-width: 900px;
  color: var(--color-text);
  font-size: 1rem;
}

footer p {
  margin: 0.5rem 0;
  font-size: 0.9rem;
}

footer a {
  color: var(--link-color);
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

.info-link {
  color: var(--color-link);
  text-decoration: none;
  font-weight: 600;
  margin-left: 1rem;
  padding: 0.3rem 0.8rem;
  border: 1.5px solid var(--color-border-muted);
  border-radius: 8px;
  background: var(--color-soft-bg);
  transition: all 0.16s ease;
  cursor: pointer;
}

.info-link:hover {
  background: var(--color-hover-bg);
  border-color: var(--accent);
  transform: translateY(-1px);
  color: var(--color-link);
}

/* ========================================
   MODAL COMPONENTS (AGGIORNATO CON STILI DA SCHEDA.CSS)
   ======================================== */

/* Overlay generico */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  background: var(--overlay);
  z-index: 1000;
  backdrop-filter: blur(3px);
  align-items: center;
  justify-content: center;
}

/* Contenuto modale */
.modal-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--color-bg);
  border-radius: 18px;
  box-shadow: var(--shadow-2);
  border: 2px solid var(--color-border);
  padding: 2.5rem;
  width: 100%;
  max-width: 700px;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
}

.modal-header {
  text-align: center;
  margin-bottom: 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.modal-title {
  color: var(--color-text);
  font-size: 2rem;
  margin: 0;
  margin-bottom: 0.5rem;
  letter-spacing: 1px;
}

.close-button {
  position: absolute;
  top: 1rem;
  right: 1.5rem;
  background: none;
  border: none;
  font-size: 2rem;
  color: var(--color-muted);
  cursor: pointer;
  line-height: 1;
  padding: 0.5rem;
  border-radius: 50%;
  transition: all 0.16s ease;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.close-button:hover {
  background: var(--color-hover-bg);
  color: var(--color-text);
  transform: scale(1.1);
}

.modal-body {
  color: #234;
  line-height: 1.6;
  font-size: 1.05rem;
}

.modal-body h3 {
  color: var(--color-link);
  font-size: 1.4rem;
  margin: 1.5rem 0 1rem 0;
  border-bottom: 2px solid var(--color-border);
  padding-bottom: 0.5rem;
}

.modal-body p {
  margin-bottom: 1.2rem;
}

.modal-body a {
  color: var(--color-link);
  text-decoration: none;
  font-weight: 600;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  background: var(--color-hover-bg);
  transition: all 0.16s ease;
}

.modal-body a:hover {
  background: var(--color-hover-bg-strong);
  transform: translateY(-1px);
  text-decoration: none;
}

/* ========================================
   COOKIE BANNER
   ======================================== */
.cookie-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: var(--card-bg);
  border-top: 3px solid var(--link-color);
  padding: 1rem;
  box-shadow: var(--shadow-medium);
  z-index: 9999;
  display: none;
}

.cookie-options {
  max-width: 1200px;
  margin: 0 auto;
  font-size: 0.9rem;
  line-height: 1.4;
}

.cookie-options p {
  margin-bottom: 1rem;
}

.cookie-options label {
  display: block;
  margin: 0.5rem 0;
}

#cookie-save {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 6px;
  background-color: var(--btn-bg);
  color: white;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background-color 0.2s ease;
}

#cookie-save:hover {
  background-color: var(--btn-bg-hover);
}

/* ========================================
   SCROLL TO TOP BUTTON
   ======================================== */
#scrollToTopBtn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 50px;
  height: 50px;
  background-color: var(--btn-bg);
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
  z-index: 10001;
  box-shadow: var(--shadow-medium);
  transition: all 0.3s ease;
  pointer-events: auto;
  /* Rimuovo la forzatura di visibilitÃƒ  che era per debug */
  opacity: 1;
  visibility: visible;
}

#scrollToTopBtn:hover {
  background-color: var(--btn-bg-hover);
  transform: scale(1.1);
}

/* ========================================
   EMAIL PROTECTION (AGGIORNATO CON STILI DA SCHEDA.CSS)
   ======================================== */
.email-protected {
  color: var(--color-link);
  text-decoration: none;
  font-weight: 600;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  background: var(--color-hover-bg);
  cursor: pointer;
  transition: all 0.16s ease;
  font-family: monospace;
  font-size: 0.9rem;
}

.email-protected:hover {
  background: var(--color-hover-bg-strong);
  transform: translateY(-1px);
  color: var(--color-link);
}

/* ========================================
   UTILITY CLASSES
   ======================================== */
.text-center { text-align: center; }
.hidden { display: none; }

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

/* Tablet */
@media (max-width: 768px) {
  .home-container {
    padding: 1.5rem;
    overflow: visible !important;
  }
  
  .home-title {
    font-size: 2.5rem;
  }
  
  .home-subtitle {
    font-size: 1.3rem;
  }
  
  .animal-links {
    gap: 1.5rem;
    overflow: visible !important;
    max-height: none !important;
  }
  
  /* Card rimangono grandi anche su tablet */
  .animal-card {
    width: 180px;
    height: 180px;
    padding: 1rem;
  }
  
  .animal-icon {
    width: 70px;
    height: 70px;
  }
  
  .animal-label {
    font-size: 1rem;
  }
  
  #scrollToTopBtn {
    bottom: 15px;
    right: 15px;
    width: 45px;
    height: 45px;
    font-size: 18px;
  }

  /* Modali responsive */
  .modal-content {
    padding: 1.5rem;
    margin: 1rem;
    max-width: calc(100% - 2rem);
  }
  .modal-title { font-size: 1.6rem; }
  .modal-body { font-size: 1rem; }

  /* Footer link incolonnato su mobile medio */
  .info-link {
    display: block;
    margin: 1rem auto 0;
    width: fit-content;
  }
}

/* Mobile */
@media (max-width: 480px) {
  .home-container {
    padding: 1rem;
    overflow: visible !important;
  }
  
  .home-title {
    font-size: 2rem;
  }
  
  .home-subtitle {
    font-size: 1.1rem;
  }
  
  .home-intro {
    font-size: 1rem;
  }
  
  .animal-links {
    gap: 1rem;
    /* Su mobile mantieni griglia ma con dimensioni fisse */
    flex-direction: row;
    justify-content: center;
    overflow: visible !important;
    max-height: none !important;
  }
  
  .animal-card {
    /* Card fisse anche su mobile, ma piÃƒÂ¹ piccole */
    width: 140px;
    height: 140px;
    /* IMPORTANTE: rimuovi qualsiasi stile che possa creare puntini */
    flex-direction: column;
    text-align: center;
    padding: 1rem;
    /* Forza rimozione puntini */
    list-style: none !important;
    list-style-type: none !important;
  }
  
  .animal-card:before,
  .animal-card::before {
    content: none !important;
    display: none !important;
  }
  
  .animal-icon {
    width: 50px;
    height: 50px;
    margin-bottom: 0.5rem;
    margin-right: 0; /* Rimuovi margin destro per mobile */
  }
  
  .modal-content {
    margin: 1rem;
    padding: 1rem;
  }
  
  .modal-title {
    font-size: 1.3rem;
  }
  
  .close-button { 
    top: 0.5rem; 
    right: 1rem; 
    font-size: 1.8rem; 
  }
  
  #scrollToTopBtn {
    bottom: 10px;
    right: 10px;
    width: 40px;
    height: 40px;
    font-size: 16px;
  }
}

/* Print styles */
@media print {
  .cookie-banner,
  #scrollToTopBtn,
  .modal-overlay {
    display: none !important;
  }
  
  body {
    background-color: white;
    color: black;
  }
  
  .animal-card {
    box-shadow: none;
    border: 1px solid #ccc;
  }
}

/* Blocco scroll fondo pagina quando modale ÃƒÂ¨ attiva */
body.search-popup-open {
    overflow: hidden !important;
    touch-action: none !important;
}

/* Modal overlay */
.search-popup {
    position: fixed;
    left: 0; top: 0;
    width: 100vw; height: 100vh;
    background: rgba(36, 65, 89, 0.16);
    z-index: 9999;
    display: flex; align-items: center; justify-content: center;
    overscroll-behavior: contain;
}

/* Popup box vero e proprio */
.search-popup-content {
    background: #fff;
    border-radius: 18px;
    border: 2px solid #e1e6ec;
    box-shadow: 0 4px 18px rgba(40,60,120,0.13), 0 2px 10px rgba(98,165,111,0.06);
    padding: 2.3em 2.3em 1.2em 2.3em;
    max-width: 420px;
    width: 97%;
    max-height: 60vh;
    overflow-y: auto;
    font-family: 'Georgia', serif;
    color: #264159;
    text-align: left;
    animation: popup-fade-in 0.24s;
    position: relative;
    -webkit-overflow-scrolling: touch; /* scroll fluido su iOS */
    box-sizing: border-box;
}

/* Animazione di comparsa */
@keyframes popup-fade-in {
    from {transform: scale(.97) translateY(20px); opacity: 0;}
    to   {transform: scale(1)   translateY(0);   opacity: 1;}
}

/* Link stile card nel popup */
.search-popup-content a {
    display: block;
    margin-bottom: 1.18em;
    padding: 0.65em 0.85em;
    border-radius: 12px;
    color: #295084;
    background: #f8fbfd;
    border: 1.5px solid #b5c1d1;
    text-decoration: none !important;
    font-size: 1.09em;
    transition: background 0.13s, border 0.13s, color 0.13s;
    font-family: 'Georgia', serif;
}
.search-popup-content a:hover {
    background: #edf2f6;
    border-color: #6697c1;
    color: #206140;
    box-shadow: 0 2px 10px #62a56f2c;
}

/* Descrizione sintetica sotto il titolo */
.search-popup-content .desc {
    color: #3b5678;
    font-size: .96em;
    margin-top: 0.23em;
    display: block;
    line-height: 1.3;
}

/* Responsive popup mobile */
@media (max-width: 600px) {
  .search-popup-content {
    max-width: 97vw !important;
    padding: 1em 0.6em 0.8em 0.6em;
  }
  .search-popup-content a {
      font-size: .98em;
      padding: 0.5em;
  }
}