/* 1. Centratura generale del corpo pagina */
body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  font-family: Georgia, serif;
  background-color: #bfbebe;
  background-image:
    radial-gradient(circle at 10% 20%, rgba(120,110,100,0.35), transparent 25%),
    radial-gradient(circle at 30% 60%, rgba(140,130,120,0.30), transparent 35%),
    radial-gradient(circle at 50% 40%, rgba(100,90,80,0.25), transparent 30%),
    radial-gradient(circle at 70% 70%, rgba(160,150,140,0.2), transparent 40%),
    radial-gradient(circle at 85% 15%, rgba(130,120,110,0.25), transparent 35%),
    linear-gradient(0deg, rgba(200,200,200,0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(200,200,200,0.03) 1px, transparent 1px);
  background-size: 250px 250px, 300px 300px, 200px 200px, 350px 350px, 150px 150px, 50px 50px, 50px 50px;
  background-repeat: repeat;
}

/* ========================================
   UTILITIES
   ======================================== */
.text-center { text-align: center; }
.text-bold { font-weight: bold; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.centrato { text-align: center; }

/* ========================================
   HEADER
   ======================================== */
@keyframes headerZoom {
  0%   { background-size: 105%; }
  100% { background-size: 115%; }
}

.page-header {
  width: 100%;
  min-height: 150px;
  padding: 15px 0;
  margin-bottom: 30px;
  background-size: 110%;
  background-position: center 25%;
  background-repeat: no-repeat;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  animation: headerZoom 18s ease-in-out infinite alternate;
}

.page-header::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1;
}

.page-header > * {
  position: relative;
  z-index: 2;
}

.page-header h1 {
  color: #fff;
  font-size: 2rem;
  text-transform: uppercase;
  margin: 0;
  text-shadow: 0 2px 6px rgba(0,0,0,0.6);
}

.page-header h2 {
  color: #fff;
  font-size: 1.2rem;
  margin-top: 0.5rem;
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}

/* ========================================
   BUTTONS
   ======================================== */
.button {
  display: block;
  padding: 12px;
  text-decoration: none;
  background-color: #ffffff;
  color: #333;
  border: 1px solid #ddd;
  border-radius: 6px;
  transition: background 0.3s;
  font-size: 0.9em;
}

.button:hover {
  background-color: #f0f0f0;
}

/* BUTTON HAS-NEWS - deve rimanere inline-block */
.button.has-news {
  display: inline-block;      /* ← IMPORTANTE */
  width: auto;                /* ← IMPORTANTE */
  background: linear-gradient(-45deg, #d01313, #ff9999, #d01313, #ff9999);
  background-size: 400% 400%;
  animation: gradientPulse 2.5s ease infinite;
  color: white;
  font-weight: bold;
  padding: 12px;
  text-decoration: none;
  border: none;
  border-radius: 6px;
  transition: transform 0.3s;
}

.button.has-news:hover {
  transform: scale(1.05);
}

.side-menu .button.has-news {
  display: inline-block;
  width: auto;
  background: linear-gradient(-45deg, #d01313, #ff9999, #d01313, #ff9999);
  background-size: 400% 400%;
  animation: gradientPulse 2.5s ease infinite;
  color: white;
  font-weight: bold;
}

@keyframes gradientPulse {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

a.internal {
  display: inline-block;
  padding: 6px 14px;
  background: #444;
  color: #fff;
  border-radius: 5px;
  text-decoration: none;
  margin: 2px;
  font-weight: bold;
  transition: background 0.3s;
}

a.internal:hover {
  background: #222;
}

a.external {
  display: inline-block;
  padding: 6px 14px;
  background: #0066cc;
  color: white;
  text-decoration: none;
  border-radius: 5px;
  font-weight: bold;
  transition: background 0.3s, transform 0.2s;
  margin: 2px;
}

a.external:hover {
  background: #004999;
  transform: scale(1.05);
}

a.external::after {
  content: " ↗";
  font-size: 0.9em;
}

/* ========================================
   MAIN LAYOUT
   ======================================== */
.main-container {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: flex-start;
  gap: 20px;
  width: 95%;
  max-width: 1500px;
  margin: 0 auto;
  padding-bottom: 50px;
}

/* ========================================
   SIDE MENU
   ======================================== */
.side-menu {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 160px;
  position: sticky;
  top: 20px;
  z-index: 100;
}

.side-menu a.button, 
.side-menu a.buttonB {
  display: block;
  padding: 0.6rem;
  text-align: center;
  background: #f0f0f0;
  color: #333;
  text-decoration: none;
  border-radius: 4px;
  font-weight: bold;
  transition: background 0.3s, color 0.3s;
}

.side-menu a.button:hover, 
.side-menu a.buttonB:hover {
  background: #333;
  color: #fff;
}

.side-menu .button.active {
  background-color: #b5b5b5;
  border-color: #6c6e6c;
  color: #fff;
}

.side-menu a.is-current {
  background: #333;
  color: #fff;
  font-weight: bold;
  pointer-events: none;
}

/* ========================================
   CONTENT
   ======================================== */
.content {
  flex: 2 1 440px;
  margin: 1rem;
  text-align: center;
}

.content-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 90%;
}

.content-column ul {
  align-self: stretch;
  text-align: left;
  padding-left: 1.2em;
}

.content p, 
.content h2, 
.content-intro p, 
.content-extra p {
  position: static;
  z-index: auto;
  margin: 20px auto;
  line-height: 1.6;
  color: #333;
  background-color: transparent;
}

.content-intro, 
.content-extra {
  display: block;
  width: 100%;
  margin-bottom: 20px;
}

.intro,
.text-block {
  background: rgba(255, 255, 255, 0.9);
  padding: 0.75rem 1rem;
  margin: 1rem 0;
  border-radius: 6px;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
  color: #222;
  font-weight: 600;
  font-size: 1rem;
  line-height: 1.5;
  text-align: center;
}

.author-sign {
  text-align: right;
  font-style: italic;
  font-weight: bold;
  margin-top: 20px;
  padding-right: 40px;
}

.slideshow {
  display: block;
  margin: 20px auto;
  max-width: 800px;
  padding: 0 15px;
  position: relative;
  z-index: 1;
}

.slideshow p {
  display: block;
  margin: 20px auto;
  line-height: 1.6;
  color: #333;
  font-size: 1.1rem;
  width: 100%;
}

.slideshow p a {
  color: #0056b3;
  text-decoration: underline;
}

.slideshow h2 {
  margin-top: 40px;
  color: #222;
  border-bottom: 2px solid #eee;
  padding-bottom: 10px;
}

.slideshow-credit {
  font-size: 0.8rem;
  margin-top: 0.5rem;
}

/* ========================================
   SLIDER
   ======================================== */
.slider {
  position: relative;
  width: 100%;
  max-width: 800px;
  height: 569px;
  margin: 20px auto;
  overflow: hidden;
}

.slider img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  transition: opacity 1.5s ease-in-out;
}

.slider img.active {
  opacity: 1;
}

/* ========================================
   SIDEBAR
   ======================================== */
.sidebar {
  width: 160px;
  min-width: 160px;
  padding: 10px;
  box-sizing: border-box;
  background-color: #f2f2f2;
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: sticky;
  top: 20px;
  flex-shrink: 0;
}

.sidebar a.active {
  font-weight: bold;
  color: red;
  text-decoration: underline;
}

.sidebar img {
  width: 100%;
  max-width: 105px;
  height: auto;
  display: block;
  margin: 0 auto;
}

.sidebar .button {
  display: block;
  width: 90%;
  margin: 10px auto;
  padding: 10px 0;
  background-color: #9f3c3c;
  color: #fff;
  text-align: center;
  text-decoration: none;
  border-radius: 8px;
  font-weight: bold;
  transition: background-color 0.3s;
}

.sidebar .button:hover {
  background-color: #0056b3;
}

.empty-column {
  width: 200px;
  flex-shrink: 0;
}

/* ========================================
   IMMAGINI
   ======================================== */
.decorative-image {
  position: absolute;
  max-width: 100%;
  height: auto;
}

.image-block {
  display: block;
  width: fit-content;
  max-width: 100%;
  margin: 20px auto;
  padding: 10px;
  background: #fff;
  box-shadow: 0 4px 8px rgba(0,0,0,0.05);
  border-radius: 6px;
  overflow: hidden;
  text-align: center;        /* ← AGGIUNTO */
}

.image-block img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto 20px auto;
}

.image-block figcaption {
  margin-bottom: 20px;
  text-align: center;        /* ← AGGIUNTO */
}

.image-block h2 {
  font-size: 1.4rem;
  margin-bottom: 15px;
  color: #333;
  text-align: center;        /* ← AGGIUNTO */
}

.image-block .gallery {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.image-row-bottom {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  max-width: 100%;
}

.image-row-bottom > * {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
  justify-items: center;
  align-items: start;
}

/* HOVER EFFECT */
.image-hover-wrapper {
  position: relative;
  display: block;
  width: fit-content;
  margin: 20px auto;
}

.table-image {
  display: block;
  margin: 0 auto;
  max-width: 100%;
  height: auto;
}

.table-image-hover {
  position: absolute;
  top: 0;
  left: 0;
  opacity: 0;
  transition: opacity 0.3s ease;
  cursor: pointer;
}

.image-hover-wrapper:hover .table-image-hover {
  opacity: 1;
}

.book-card {
  max-width: 100%;
  padding: 16px;
  box-sizing: border-box;
  background-color: #faf8f3;
  border-radius: 8px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.06);
}

/* ========================================
   VIDEO
   ======================================== */
.video-container {
  position: relative;
  width: 100%;
  max-width: 800px;
  aspect-ratio: 16 / 9;
  margin: 0 auto 20px auto;
  overflow: hidden;
}

.video-container iframe {
  border: 0;
  width: 100%;
  height: 100%;
}

/* ========================================
   CONTENT FOOTER
   ======================================== */
.content-footer {
  display: block;
  clear: both;
  margin-top: 20px;
  width: 100%;
}

/* ========================================
   PAGE FOOTER
   ======================================== */
.page-footer {
  width: 100%;
  text-align: center;
  padding: 20px 0;
  background: #f0f0f0;
  color: #333;
  margin-top: 2rem;
}

.page-footer p {
  margin: 0;
  line-height: 1.6;
}

/* ========================================
   WORD WRAP & TYPOGRAPHY
   ======================================== */
.contenuto, 
.image-block figcaption, 
.image-block p, 
.image-block h2, 
.image-block h3 {
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
}

hr {
  border: none;
  border-top: 2px dashed #999;
  margin-bottom: 20px;
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 700px) {
  .page-header {
    background-size: cover;
    background-position: center;
    animation: none;
  }
  
  .page-header h1 {
    font-size: 1.4rem;
  }
  
  .page-header h2 {
    font-size: 1rem;
  }
}

@media (max-width: 480px) {
  .slider {
    height: 200px;
    overflow: hidden;
  }
  
  .slider img {
    height: 100%;
    width: auto;
    object-fit: cover;
    margin: 0 auto;
  }
  
  .contact-link {
    flex-direction: column;
    gap: 4px;
  }
}

@media (max-width: 1300px) {
  .main-container {
    flex-direction: column;
    align-items: center;
  }
  
  .side-menu {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    top: 0;
  }
  
  .button {
    padding: 8px 12px;
    font-size: 0.8em;
  }
  
  .slideshow {
    width: 100%;
    max-width: 100%;
  }
}

@media (min-width: 768px) {
  .image-block img {
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
  }
}