/*
 * @file: home.css
 * @description: Stili specifici per la homepage del sito UCOI/UCOIM
 * @author: Altoprofilo Studio
 * @last-updated: 2025-10-14
 * @version: V.2.0 (OTTIMIZZATO - rimossi duplicati, fix encoding, CSS variables)
 */

/* ==========================================================================
   CSS CUSTOM PROPERTIES (Variables)
   ========================================================================== */
:root {
  /* Colors - centralizzate */
  --color-primary: #003366;
  --color-primary-hover: #00254d;
  --color-secondary: #0066cc;
  --color-accent: #f57c02;
  --color-text: #222;
  --color-text-muted: #6b7280;
  
  /* Backgrounds */
  --bg-white: #fff;
  --bg-light: #f5f9fc;
  --bg-gray-100: #f9f9f9;
  --bg-gray-200: #f3f3f3;
  
  /* Spacing */
  --space-xs: 0.5rem;
  --space-sm: 1rem;
  --space-md: 1.5rem;
  --space-lg: 2rem;
  --space-xl: 4rem;
  
  /* Borders */
  --border-radius-sm: 8px;
  --border-radius-md: 12px;
  --border-light: 1px solid rgba(0, 0, 0, 0.08);
  --border-medium: 1px solid rgba(0, 0, 0, 0.15);
  
  /* Shadows */
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 6px 18px rgba(0, 0, 0, 0.12);
  
  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.2s ease;
  
  /* Z-indexes */
  --z-header: 1000;
  --z-leaflet: 500;
  --z-overlay: 1;
  --z-badge: 2;
  
  /* Typography */
  --font-family-display: 'DM Serif Display', serif;
  --font-size-xs: 0.7rem;
  --font-size-sm: 0.85rem;
  --font-size-base: 0.95rem;
  --font-size-lg: 1.05rem;
  --font-size-xl: 1.25rem;
}

/* ==========================================================================
   1) FIX HOMEPAGE
   ========================================================================== */

/* Breadcrumbs: nascosti in home */
body#home #breadcrumb-nav {
  display: none;
}

/* Leaflet: UI sotto lo sticky header */
.leaflet-top,
.leaflet-bottom {
  z-index: var(--z-leaflet);
}

/* Leaflet: evitare ridimensionamento tiles */
.leaflet-container img {
  max-width: none;
}

/* Sticky header */
.site-header {
  z-index: var(--z-header);
}

/* VIDEO: disattivare overlay custom se presente */
.video-overlay,
.play-button {
  display: none;
  pointer-events: none;
}

/* ==========================================================================
   2) HERO (layout, tipografia, responsive)
   ========================================================================== */

.hero-box {
  position: relative;
  min-height: 56vh;
  background: url('../../img/hero/home-hero.webp') center / cover no-repeat;
  border-radius: var(--border-radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: flex-end;
}

.hero-box::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.25), rgba(0, 0, 0, 0));
}

.hero-box__overlay {
  position: relative;
  z-index: var(--z-overlay);
  width: 100%;
  text-align: center;
  color: var(--bg-white);
  padding: clamp(16px, 3vw, 24px) clamp(16px, 4vw, 32px) clamp(28px, 10vh, 64px);
}

.hero-box__title {
  margin-bottom: var(--space-xs);
  color: var(--bg-white);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.35);
}

.hero-box__actions {
  margin-top: var(--space-sm);
}

.hero-box .lead {
  color: var(--bg-white);
  text-transform: uppercase;
  letter-spacing: -0.05em;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.35);
}

/* Contenitore contenuti hero */
.content-wrap {
  width: 70%;
  margin: 0 auto;
  text-align: center;
}

/* Didascalia presidenza */
.presidenza-compact {
  font-size: var(--font-size-xs);
  line-height: 1.4;
  color: #444;
  margin-top: var(--space-xs);
  padding: 0 var(--space-xs);
  text-align: center;
}

/* Gestione <br> condizionale */
.br-mobile {
  display: none;
}

/* ==========================================================================
   3) AVVISO ISTITUZIONALE
   ========================================================================== */

#avviso-istituzionale {
  background-color: var(--color-accent);
  padding: 0.75rem var(--space-sm);
  margin-bottom: var(--space-sm);
}

.avviso-istituzionale {
  text-align: center;
  color: var(--color-text);
  font-size: var(--font-size-sm);
  font-weight: 500;
}

.avviso-istituzionale strong {
  color: var(--color-primary);
}

/* ==========================================================================
   4) SEZIONE LE DUE UNIONI (UCOI/UCOIM)
   ========================================================================== */

.ucoi-box {
  border-right: 4px solid var(--color-primary);
}

.ucoim-box {
  border-left: 4px solid var(--color-secondary);
}

.column {
  padding: var(--space-lg);
  text-align: center;
  background: var(--bg-white);
  box-shadow: var(--shadow-sm);
  border-radius: var(--border-radius-sm);
  transition: var(--transition-normal);
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 350px;
  justify-content: space-between;
}

.column:hover {
  box-shadow: var(--shadow-md);
}

.column .lucide,
.column [data-lucide] {
  width: clamp(32px, 2vw, 40px);
  height: clamp(32px, 2vw, 40px);
  stroke-width: 1.75;
  margin-bottom: 1.25rem;
  flex-shrink: 0;
}

.column h3 {
  margin-bottom: var(--space-sm);
  flex-shrink: 0;
}

.column p {
  flex-grow: 1;
  margin-bottom: var(--space-md);
  text-align: center;
}

.column .btn {
  margin-top: auto;
  align-self: center;
}

/* ==========================================================================
   5) SEZIONE NUMERI (statistiche)
   ========================================================================== */

#numeri {
  padding: var(--space-xl) var(--space-sm);
}

#numeri h2 {
  text-align: center;
  margin-bottom: var(--space-lg);
}

/* Gradiente background per statistiche */
#numeri .row > .col-6:nth-child(1) .stat-item { background-color: var(--bg-white); }
#numeri .row > .col-6:nth-child(2) .stat-item { background-color: var(--bg-gray-100); }
#numeri .row > .col-6:nth-child(3) .stat-item { background-color: var(--bg-gray-200); }
#numeri .row > .col-6:nth-child(4) .stat-item { background-color: var(--bg-light); }

.stats-grid {
  margin-top: var(--space-lg);
}

.stat-item {
  padding: var(--space-md) var(--space-sm);
  transition: transform var(--transition-normal);
}

.stat-item:hover {
  transform: translateY(-4px);
}

.stat-number {
  font-family: var(--font-family-display);
  font-size: 3rem;
  font-weight: 600;
  color: var(--color-primary);
  line-height: 1;
  margin-bottom: var(--space-xs);
}

.stat-label {
  font-size: var(--font-size-base);
  line-height: 1.4;
  color: var(--color-text-muted);
  margin: 0;
}

/* Counter animation */
.stat-number.counting .number {
  display: inline-block;
  animation: pulse 0.5s ease-in-out;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

/* ==========================================================================
   6) SEZIONE CONTENUTI ISTITUZIONALI
   ========================================================================== */

#sezioni {
  padding: var(--space-xl) var(--space-lg);
  text-align: center;
}

.cta-buttons {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
  justify-content: center;
  margin-top: var(--space-sm);
}

.card-istituzionale .lucide,
.card-istituzionale [data-lucide] {
  width: clamp(32px, 2vw, 40px);
  height: clamp(32px, 2vw, 40px);
  margin-bottom: var(--space-sm);
  stroke: var(--color-primary);
}

.card-istituzionale h3 {
  font-size: var(--font-size-xl);
  line-height: 1.4;
  margin-bottom: var(--space-xs);
}

.card-istituzionale p {
  font-size: var(--font-size-base);
  color: var(--color-text-muted);
  margin-bottom: var(--space-sm);
}

.card-istituzionale .btn {
  margin-top: auto;
  transition: var(--transition-fast);
}

.card-istituzionale .btn:hover {
  transform: translateY(-2px);
}

/* Button group per card con doppi bottoni */
.btn-group {
  display: flex;
  justify-content: center;
  gap: var(--space-xs);
  flex-wrap: wrap;
  margin-top: var(--space-sm);
}

.btn-group .btn {
  flex: 0 1 auto;
  min-width: auto;
}

/* ==========================================================================
   7) SEZIONE NOTIZIE
   ========================================================================== */

.news-section {
  padding: var(--space-xl) var(--space-sm);
  text-align: center;
  background-color: var(--bg-white);
}

.archive-link {
  margin-top: var(--space-lg);
}

/* Badge appartenenza */
.news-card .badge-appartenenza {
  position: absolute;
  right: 0.75rem;
  top: 0.75rem;
  padding: 0.35rem 0.75rem;
  border-radius: 30px;
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--bg-white);
  z-index: var(--z-badge);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  text-decoration: none;
  transition: var(--transition-fast);
  display: inline-block;
}

.news-card .badge-appartenenza:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.news-card .badge-appartenenza.active {
  box-shadow: 0 0 0 2px var(--bg-white), 0 0 0 4px var(--color-primary);
}

.badge-ucoi { background-color: var(--color-primary); }
.badge-ucoim { background-color: var(--color-secondary); }
.badge-entrambe { background-color: var(--color-accent); }

/* ==========================================================================
   8) SEZIONE CONTATTI E MAPPE
   ========================================================================== */

.contatti-section {
  padding: var(--space-xl) var(--space-sm);
  background-color: var(--bg-light);
}

.contatto-box {
  padding: var(--space-lg);
  background: var(--bg-white);
  box-shadow: var(--shadow-md);
  border-radius: var(--border-radius-sm);
  height: 100%;
  transition: var(--transition-normal);
  display: flex;
  flex-direction: column;
}

.contatto-box:hover {
  box-shadow: var(--shadow-lg);
}

.contatto-title {
  margin-bottom: var(--space-md);
  text-align: center;
  color: var(--color-primary);
}

.contatti-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  flex-grow: 1;
}

.contatti-list li {
  display: flex;
  gap: var(--space-sm);
  align-items: flex-start;
}

.contatti-list a {
  color: var(--color-primary);
  text-decoration: underline;
  transition: var(--transition-fast);
}

.contatti-list a:hover {
  color: var(--color-primary-hover);
  text-decoration-thickness: 2px;
}

.contact-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}

.contact-actions .btn {
  flex: 0 1 auto;
}

/* MAPPE LEAFLET */
.map-block {
  background: var(--bg-white);
  border: var(--border-medium);
  border-radius: var(--border-radius-md);
  padding: 1.25rem;
  height: 100%;
  transition: box-shadow var(--transition-normal);
  box-shadow: var(--shadow-sm);
  min-height: 420px;
}

.map-block:hover {
  box-shadow: var(--shadow-md);
}

.map-title {
  margin: 0 0 0.75rem 0;
  font-size: var(--font-size-lg);
  line-height: 1.2;
  font-weight: 600;
  font-family: var(--font-family-display);
  color: var(--color-primary);
}

.leaflet-map {
  width: 100%;
  height: 360px; /* Può essere sovrascritto da inline style */
  border-radius: 10px;
  overflow: hidden;
  border: var(--border-light);
  cursor: pointer;
  background: #e5e7eb;
}

.leaflet-map:focus {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

.leaflet-map:focus-visible {
  outline: 3px solid #2563eb;
  outline-offset: 4px;
}

/* Leaflet popup customization */
.leaflet-popup-content {
  margin: 8px 12px;
  line-height: 1.4;
}

.leaflet-popup-content-wrapper {
  border-radius: var(--border-radius-sm);
}

/* ==========================================================================
   9) VIDEO COMPONENT
   ========================================================================== */

.video-container {
  margin: var(--space-lg) 0;
  text-align: center;
}

.video-wrapper {
  position: relative;
  display: inline-block;
  border-radius: var(--border-radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.video-wrapper video {
  width: 100%;
  height: auto;
  display: block;
}

.video-caption {
  margin: var(--space-sm) 0;
  font-size: 0.9rem;
  color: var(--color-text-muted);
  font-style: italic;
}

/* ==========================================================================
   10) RESPONSIVE - MOBILE
   ========================================================================== */

@media (max-width: 768px) {
  /* Hero */
  .hero-box {
    min-height: 48vh;
    background-position: 50% 30%;
  }
  
  .content-wrap {
    width: 100%;
  }
  
  /* Colonne */
  .column {
    min-height: 300px;
  }
  
  /* Card */
  .card-istituzionale {
    padding: 2.5rem var(--space-sm);
  }
  
  /* Stats */
  .stat-number {
    font-size: 2.5rem;
  }
  
  /* Badge */
  .news-card .badge-appartenenza {
    padding: 0.4rem 0.8rem;
    font-size: 0.65rem;
  }
  
  /* Buttons */
  .cta-buttons {
    flex-direction: column;
    align-items: center;
  }
  
  .btn-group,
  .contact-actions {
    flex-direction: column;
  }
  
  .btn-group .btn,
  .contact-actions .btn {
    width: 100%;
  }
  
  /* Mappe */
  .leaflet-map {
    height: 280px;
  }
  
  .map-block {
    padding: 0.75rem;
  }
  
  .contatto-media {
    order: -1;
    min-height: 300px;
  }
}

@media (max-width: 576px) {
  .stat-number {
    font-size: 2rem;
  }
  
  .stat-label {
    font-size: var(--font-size-sm);
  }
}

/* Large screens */
@media (min-width: 1200px) {
  .hero-box {
    min-height: 60vh;
    background-position: 50% 24%;
  }
}

@media (min-width: 1600px) {
  .hero-box__title {
    font-size: clamp(2.8rem, 2.2vw + 1rem, 4rem);
    line-height: 1.15;
  }

  .hero-box .lead {
    font-size: clamp(1.3rem, 1vw + 0.8rem, 1.8rem);
    line-height: 1.6;
    max-width: 70ch;
    margin-left: auto;
    margin-right: auto;
  }
  
  .br-mobile {
    display: inline;
  }
}

/* ==========================================================================
   11) ACCESSIBILITÀ
   ========================================================================== */

/* High contrast mode */
@media (prefers-contrast: high) {
  .map-block {
    border-width: 2px;
    border-color: #000;
  }
  
  .stat-number {
    color: var(--color-primary);
    font-weight: 700;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .stat-item {
    transition: none;
  }
  
  .stat-item:hover {
    transform: none;
  }
  
  .stat-number.counting .number {
    animation: none;
  }
  
  .column,
  .card-istituzionale .btn,
  .contatto-box {
    transition: none;
  }
}

/* Print styles */
@media print {
  .leaflet-map {
    height: 200px;
    border: 1px solid #000;
  }
  
  .map-block {
    page-break-inside: avoid;
  }
  
  .btn-group,
  .contact-actions,
  .cta-buttons {
    display: none;
  }
}