:root {
  --brand: #0ea5e9;
  --font-sans: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  --font-display: 'Fraunces', 'Times New Roman', Times, serif;
}

/* -------------------------------------------------------
   TIPOGRAFIA E STRUTTURA BASE
------------------------------------------------------- */
body {
  font-family: var(--font-sans);
  letter-spacing: 0.1px;
  line-height: 1.6;
}
.lead { font-weight: 300; }

h1, h2, h3, .display-1, .display-2, .display-3,
.navbar-brand, .card-title {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.2px;
  font-variation-settings: 'opsz' 64, 'wght' 700;
}
.navbar-brand { font-weight: 800; }

/* -------------------------------------------------------
   LOGO
------------------------------------------------------- */
.brand-logo { display: block; height: auto; max-height: 42px; width: auto; }
.brand-logo-dark { display: none; }
[data-bs-theme="dark"] .brand-logo-light { display: none; }
[data-bs-theme="dark"] .brand-logo-dark { display: block; }

/* -------------------------------------------------------
   HERO SECTION
------------------------------------------------------- */
.hero {
  background: #000;
  position: relative;
  overflow: hidden;
}

.hero-video {
  display: block;
  width: 100%;
  height: auto;
  max-height: 85vh;
  object-fit: cover;
}

.hero-overlay {
  background: linear-gradient(180deg, rgba(0,0,0,.45), rgba(0,0,0,.65) 90%);
  padding-top: 6rem;
  color: #fff;
  text-shadow: 0 2px 16px rgba(0,0,0,.45);
}

.hero-overlay .container,
.hero-overlay .btn { pointer-events: auto; }

.hero-overlay h6 {
  letter-spacing: 2px;
  font-size: 0.9rem;
  color: rgba(255,255,255,0.7);
  text-transform: uppercase;
}

.hero-overlay .btn {
  font-size: 1rem;
  padding: 0.65rem 1.25rem;
  border-radius: 0.4rem;
}

.hero-overlay .btn-lg {
  font-size: 1.05rem;
  padding: 0.7rem 1.4rem;
}

.btn-outline-light {
  border-color: rgba(255,255,255,.6);
  color: #fff;
}

/* --- HERO Mobile --- */
@media (max-width: 576px) {
  .hero-video { max-height: 60vh; }

  .hero-overlay {
    background: linear-gradient(180deg, rgba(0,0,0,.6), rgba(0,0,0,.85) 80%);
    text-align: center;
    padding: 2rem 1.5rem 4rem;
  }

  .hero-overlay h6 {
    font-size: 0.85rem;
    letter-spacing: 1.5px;
    margin-bottom: 0.6rem;
  }

  .hero-overlay h1 {
    font-size: 1.85rem;
    line-height: 1.3;
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    text-shadow: 0 3px 10px rgba(0,0,0,0.6);
  }

  .hero-overlay p {
    font-size: 1rem;
    line-height: 1.5;
    color: rgba(255,255,255,0.9);
    margin-bottom: 1.4rem;
  }

  .hero-overlay .btn {
    font-size: 0.95rem;
    padding: 0.65rem 1.25rem;
    border-radius: 8px;
    font-weight: 600;
    letter-spacing: 0.3px;
  }

  .hero-overlay .btn-secondary {
    background: linear-gradient(90deg, #c96c2b, #d88042);
    border: none;
  }

  .hero-overlay .btn-secondary:hover {
    background: linear-gradient(90deg, #d88042, #c96c2b);
    transform: translateY(-2px);
  }

  .hero-overlay a[href="#servizi"] {
    display: none !important;
  }
}

/* Animazione HERO fade-in */
.hero-content {
  opacity: 0;
  transform: translateY(30px);
  animation: heroFadeIn 1.2s ease-out forwards;
  animation-delay: 0.3s;
}

.hero-content h6,
.hero-content h1,
.hero-content p,
.hero-content .btn {
  opacity: 0;
  transform: translateY(20px);
  animation: heroFadeIn 1.2s ease-out forwards;
}

.hero-content h6 { animation-delay: 0.1s; }
.hero-content h1 { animation-delay: 0.4s; }
.hero-content p { animation-delay: 0.7s; }
.hero-content .btn { animation-delay: 1s; }

@keyframes heroFadeIn {
  to { opacity: 1; transform: translateY(0); }
}

/* -------------------------------------------------------
   SEZIONI GLOBALI
------------------------------------------------------- */
section {
  padding: 3rem 0;
}
@media (max-width: 576px) {
  section { padding: 3rem 1rem; }
}

/* -------------------------------------------------------
   SERVIZI – ZIG-ZAG
------------------------------------------------------- */
.container-narrow { max-width: 1024px; }

#servizi .row { transition: transform 0.3s ease, opacity 0.3s ease; }
#servizi .service-img-wrapper img { transition: transform 0.5s ease; }
#servizi .service-img-wrapper:hover img { transform: scale(1.05); }
#servizi .service-text { max-width: 600px; }
#servizi h3 { font-weight: 600; }
#servizi .bi { color: #c96c2b; }

.service-img-wrapper {
  height: 300px;
  overflow: hidden;
}
.service-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}
.service-img-wrapper:hover .service-img { transform: scale(1.05); }

@media (max-width: 991px) {
  #servizi .service-text { padding: 0; text-align: center; }
  .service-img-wrapper { height: 220px; }
}

/* -------------------------------------------------------
   NAVBAR – versione con colore arancio solare + logo 460x52
------------------------------------------------------- */
.navbar {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  letter-spacing: 0.4px;
  transition: background-color 0.4s ease, box-shadow 0.4s ease;
  background: linear-gradient(90deg, #ffb347 0%, #ffcc33 100%) !important; /* 🌞 arancio solare sfumato */
  border: none;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

/* ===== LOGO ===== */
.brand-logo {
  display: block;
  height: auto;
  max-height: 52px !important; /* altezza ideale per logo 460x52 */
  width: auto;
  object-fit: contain;
}

/* Logo dark/light */
.brand-logo-dark { display: none; }
[data-bs-theme="dark"] .brand-logo-light { display: none; }
[data-bs-theme="dark"] .brand-logo-dark { display: block; }

/* Quando navbar si restringe (scroll) */
.navbar-shrink .brand-logo {
  max-height: 42px !important;
  transition: max-height 0.3s ease;
}

/* Testo e link su navbar chiara */
.navbar .nav-link,
.navbar .navbar-brand,
.navbar .btn-outline-secondary {
  color: #3b2e00 !important; /* marrone caldo leggibile su arancio */
}

.navbar .nav-link:hover,
.navbar .nav-link.active {
  color: #000 !important;
  text-shadow: 0 0 6px rgba(255,255,255,0.3);
}

/* Stato sticky / shrink */
.navbar.sticky-top {
  background: linear-gradient(90deg, #ffb347 0%, #ffcc33 100%) !important;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}

/* Effetto "shrink" quando si scrolla */
.navbar-shrink {
  padding: 0.25rem 0 !important;
}
.navbar-shrink .navbar-brand img { max-height: 42px !important; }

/* Tema scuro */
[data-bs-theme="dark"] .navbar {
  background: linear-gradient(90deg, #ff9800 0%, #ffb74d 100%) !important;
}
[data-bs-theme="dark"] .navbar .nav-link,
[data-bs-theme="dark"] .navbar .navbar-brand {
  color: #fff8e1 !important;
}
[data-bs-theme="dark"] .navbar .nav-link:hover {
  color: #fff !important;
}

/* Link menu */
.navbar-nav .nav-link {
  position: relative;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  padding: 0.5rem 0.75rem;
  transition: color 0.3s ease;
}
.navbar-nav .nav-link::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 2px;
  width: 0;
  height: 2px;
  background-color: #3b2e00;
  transition: width 0.3s ease;
}
.navbar-nav .nav-link:hover::after,
.navbar-nav .nav-link.active::after {
  width: 100%;
}

/* Pulsante cambio tema */
#themeToggle {
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  border-color: #3b2e00 !important;
  color: #3b2e00 !important;
}
#themeToggle:hover {
  background-color: #3b2e00;
  color: #fff !important;
  transform: rotate(10deg);
}

/* Brand */
.navbar-brand {
  font-family: 'Fraunces', serif;
  font-weight: 800;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  transition: opacity 0.3s ease;
}
.navbar-brand:hover { opacity: 0.85; }

/* Toggler */
.navbar-toggler {
  border: none;
  transition: transform 0.3s ease;
}
.navbar-toggler:focus { box-shadow: none; }
.navbar-toggler:hover { transform: scale(1.1); }

/* ===== VERSIONE MOBILE ===== */
@media (max-width: 991px) {
  .navbar {
    padding: 0.5rem 0;
    text-align: center;
  }

  .navbar .container {
    display: flex;
    align-items: center;
    justify-content: center; /* centrato logo */
    flex-direction: column;
  }

  .navbar-brand {
    width: 100%;
    margin-bottom: 0.4rem;
  }

  .navbar-brand img {
    max-height: 56px !important;
    height: auto;
    width: auto;
    transition: max-height 0.3s ease;
  }

  .navbar-toggler {
    font-size: 1.9rem;
    margin-bottom: 0.4rem;
  }

  .navbar-collapse {
    margin-top: 0.8rem;
    animation: fadeDown 0.4s ease forwards;
  }

  .navbar-nav .nav-link {
    padding: 0.6rem 0;
    font-size: 1.05rem;
  }
}

/* Animazione fadeDown */
@keyframes fadeDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* -------------------------------------------------------
   FOOTER
------------------------------------------------------- */
.footer-elegant {
  font-size: 1rem;
  color: rgba(255, 255, 255, 0.9);
}
.footer-elegant .footer-heading {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--bs-body-color);
  opacity: 0.9;
  font-weight: 600;
  margin-bottom: 0.5rem;
}
.footer-elegant a {
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
  transition: color 0.3s ease;
}
.footer-elegant a:hover {
  color: #c96c2b;
  text-decoration: underline;
}
.footer-elegant .social-icons a {
  font-size: 1.2rem;
  margin-right: 0.8rem;
  color: rgba(255,255,255,0.9);
  transition: transform 0.3s ease, color 0.3s ease;
}
.footer-elegant .social-icons a:hover {
  color: #c96c2b;
  transform: translateY(-3px);
}

@media (min-width: 768px) {
  .footer-columns > [class*='col-'] { position: relative; }
  .footer-columns > [class*='col-']:not(:last-child)::after {
    content: "";
    position: absolute;
    top: 0; right: 0;
    height: 100%; width: 1px;
    background: rgba(255,255,255,0.15);
  }
}

@media (max-width: 767px) {
  .footer-columns {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
  }
  .footer-columns > [class*='col-'] {
    margin-bottom: 1.8rem;
  }
}

.footer-bottom {
  border-top: 1px solid rgba(255,255,255,0.1);
  margin-top: 1.5rem;
  padding-top: 1rem;
  text-align: center;
  font-size: 0.75rem;
}

/* -------------------------------------------------------
   LINK SPECIALI, COOKIE, BACK TO TOP
------------------------------------------------------- */
.link-apploading {
  color: inherit;
  text-decoration: none;
  position: relative;
  transition: color 0.3s ease;
}
.link-apploading::after {
  content: "";
  position: absolute;
  left: 0; bottom: -2px;
  width: 0; height: 2px;
  background-color: #c96c2b;
  transition: width 0.3s ease;
}
.link-apploading:hover { color: #c96c2b; }
.link-apploading:hover::after { width: 100%; }

#openCookiePrefs i {
  cursor: pointer;
  transition: color 0.2s ease;
}
#openCookiePrefs i:hover { color: #c96c2b; }

#backToTop {
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s ease, visibility 0.4s ease, transform 0.3s ease;
}
#backToTop.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
#backToTop:hover {
  background-color: #6c757d;
  transform: translateY(-3px);
  box-shadow: 0 4px 10px rgba(0,0,0,0.25);
}

/* -------------------------------------------------------
   LEAD TEXT
------------------------------------------------------- */
section .lead { font-size: 1.1rem; }
@media (max-width: 576px) {
  section .lead { font-size: 1rem; }
  section img { margin-top: 1rem; }
}

/* -------------------------------------------------------
   HERO SECTION – versione corretta con compensazione navbar
------------------------------------------------------- */
.hero {
  position: relative;
  overflow: hidden;
  background: #000;
}

/* Video */
.hero-video {
  display: block;
  width: 100%;
  height: 100vh;              /* copre intera viewport */
  object-fit: cover;
  object-position: center;
}

/* Overlay */
.hero-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg, rgba(0,0,0,.45), rgba(0,0,0,.65) 90%);
  display: flex;
  align-items: center;
  z-index: 1;
  padding-top: var(--navbar-offset, 80px); /* offset dinamico */
}

/* Contenuto */
.hero-overlay h6 {
  letter-spacing: 2px;
  font-size: 0.9rem;
  color: rgba(255,255,255,0.7);
  text-transform: uppercase;
}
.hero-overlay h1, .hero-overlay p {
  color: #fff;
  text-shadow: 0 2px 16px rgba(0,0,0,.45);
}
.hero-overlay .btn {
  font-size: 1rem;
  padding: 0.65rem 1.25rem;
  border-radius: 0.4rem;
}
.btn-outline-light {
  border-color: rgba(255,255,255,.6);
  color: #fff;
}

/* --- Mobile --- */
@media (max-width: 991px) {
  .hero-video { height: 80vh; } /* altezza minore su mobile */
  .hero-overlay {
    text-align: center;
    padding-top: var(--navbar-offset, 70px);
    padding-left: 1.5rem;
    padding-right: 1.5rem;
    background: linear-gradient(180deg, rgba(0,0,0,.6), rgba(0,0,0,.85) 85%);
  }
  .hero-overlay a[href="#servizi"] {
    display: none !important;
  }
}

/* -------------------------------------------------------
   FOOTER – Ottimizzazione versione mobile
------------------------------------------------------- */
@media (max-width: 767px) {

  /* Centra Privacy & Cookie */
  .footer-bottom {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
  }

  .footer-bottom a {
    display: inline-block;
    margin: 0 auto;
  }

  /* Nasconde link Modifica preferenze cookie */
  #openCookiePrefs {
    display: none !important;
  }

  /* Rende più leggibile il testo finale */
  .footer-bottom div {
    text-align: center;
    line-height: 1.4;
  }
}

/* -------------------------------------------------------
   SEZIONE SERVIZI – Allineamento con header e footer
------------------------------------------------------- */
.section-servizi {
  max-width: 1400px;            /* limita la larghezza massima */
  margin-left: auto;
  margin-right: auto;
  padding-left: clamp(1rem, 4vw, 4rem);
  padding-right: clamp(1rem, 4vw, 4rem);
}

#servizi {
  padding-top: 4rem;
  padding-bottom: 4rem;
}

#servizi .row {
  margin-left: 0;
  margin-right: 0;
}

#servizi .col-12,
#servizi .col-sm-6,
#servizi .col-lg-6 {
  padding-left: 0;
  padding-right: 0;
}

@media (max-width: 991px) {
  .section-servizi {
    padding-left: 1.25rem;
    padding-right: 1.25rem;
  }
}

/* -------------------------------------------------------
   MINI BAR CONTATTI + METEO
------------------------------------------------------- */
.topbar {
  background-color: #f8f9fa; /* sfondo chiaro come il tema */
  color: #212529;
  font-family: var(--font-sans);
  font-size: 0.75rem;        /* 🔹 Font più piccolo */
  line-height: 1.3;
  padding-top: 0.25rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid rgba(0,0,0,0.08);
}

.topbar a {
  color: inherit;
  text-decoration: none;
  transition: color 0.3s ease;
}

.topbar a:hover {
  color: #c96c2b;            /* tono coerente col brand */
}

.topbar i {
  vertical-align: middle;
  font-size: 0.95rem;
}

@media (max-width: 575.98px) {
  .topbar { display: none !important; }
}


#weather {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

#weather i {
  color: #f0ad4e;            /* icona sole */
}

@media (max-width: 576px) {
  .topbar {
    flex-direction: column;
    text-align: center;
    font-size: 0.8rem;
  }
  .topbar .container {
    flex-direction: column;
    gap: 0.25rem;
  }
}

/* 🔧 Ottimizzazione mobile definitiva */
@media (max-width: 576px) {
  .section-servizi {
    padding-left: 2.5rem !important;
    padding-right: 2.5rem !important;
  }

  #servizi .service-text {
    font-size: 1.1rem;
    line-height: 1.7;
  }

  #servizi h3 {
    font-size: 1.35rem;
    margin-bottom: 0.8rem;
  }

  .service-img-wrapper {
    height: auto;
    max-height: 350px;
    margin-bottom: 1.25rem;
  }

  .service-img {
    object-fit: cover;
    border-radius: 0.75rem;
  }

  .section-servizi .row {
    margin-left: -0.25rem;
    margin-right: -0.25rem;
  }

  .hero-content {
    padding: 0 2rem;
  }

  .hero-content h1 {
    font-size: 2.1rem;
    line-height: 1.3;
  }

  .hero-content p {
    font-size: 1.05rem;
    line-height: 1.7;
  }

  .btn.btn-lg {
    font-size: 1rem;
    padding: 0.75rem 1.5rem;
  }
}

/* 🔧 Pulsante Torna su – visibile e proporzionato anche su mobile */
#backToTop {
  position: fixed;
  bottom: 25px;
  right: 25px;
  width: 50px;
  height: 50px;
  background-color: #555;
  border: none;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1050;
  opacity: 0;
  transition: all 0.3s ease;
}

#backToTop.show {
  opacity: 1;
}

#backToTop i {
  color: #fff;
  font-size: 1.6rem;
}

/* 📱 versione mobile: più piccola e leggermente spostata */
@media (max-width: 576px) {
  #backToTop {
    width: 42px;
    height: 42px;
    bottom: 20px;
    right: 20px;
    background-color: #444;
  }

  #backToTop i {
    font-size: 1.3rem;
  }
}

/* ===== Navbar ottimizzata e animata ===== */
@media (max-width: 991.98px) {
  .navbar {
    text-align: center;
  }

  .navbar-brand {
    margin-bottom: 0.3rem;
    width: 100%;
  }

  .navbar-brand img {
    max-height: 80px !important;
  }

  .navbar-toggler {
    font-size: 1.9rem;
    margin-bottom: 0.3rem;
    z-index: 1060;
  }

  .navbar-collapse {
    margin-top: 0.8rem;
    animation: fadeDown 0.4s ease forwards;
    position: relative;
    z-index: 1070;
  }

  .navbar-nav .nav-link {
    padding: 0.6rem 0;
    font-size: 1.05rem;
  }

  /* Effetto fade-down */
  .fade-down {
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
  }

  .fade-down.show {
    opacity: 1;
    transform: translateY(0);
  }

  /* Overlay mobile */
  .mobile-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(20, 20, 20, 0.55);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 1050;
  }

  .mobile-overlay.active {
    opacity: 1;
    visibility: visible;
  }
}

/* Fade animazione base */
@keyframes fadeDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ✅ Regola mobile: limita la larghezza del logo a massimo 380px */
@media (max-width: 991px) {
  .brand-logo {
    max-width: 360px;
    width: 100%;
    height: auto;
    object-fit: contain;
  }
}

/* 🔧 Nasconde il pulsante cambio tema su schermi piccoli */
@media (max-width: 991px) {
  #themeToggle {
    display: none !important;
  }
}

/* === PORTFOLIO / Lavori realizzati – immagini uniformi === */
section .card-img-top {
  width: 100%;
  aspect-ratio: 1 / 1;          /* quadrato perfetto */
  object-fit: cover;            /* riempie lo spazio senza deformarsi */
  border-top-left-radius: 0.5rem;
  border-top-right-radius: 0.5rem;
  transition: transform 0.4s ease;
}

/* effetto hover leggero */
section .card:hover .card-img-top {
  transform: scale(1.05);
}

/* armonizza la card */
section .card {
  border: none;
  border-radius: 0.75rem;
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
  overflow: hidden;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

section .card:hover {
  transform: translateY(-4px);
  box-shadow: 0 4px 14px rgba(0,0,0,0.12);
}

/* testo centrato e coerente */
section .card-body {
  text-align: center;
  padding: 1rem;
}

/* === LIGHTBOX elegante === */
.lightbox-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 10, 10, 0.85);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.lightbox-overlay.active {
  opacity: 1;
  visibility: visible;
}

.lightbox-img {
  max-width: 90%;
  max-height: 85vh;
  border-radius: 12px;
  border: 5px solid #fff;
  box-shadow: 0 0 25px rgba(255,255,255,0.2);
  transition: transform 0.3s ease;
}

.lightbox-img:hover {
  transform: scale(1.02);
}

/* Pulsante chiusura */
.lightbox-close {
  position: absolute;
  top: 25px;
  right: 35px;
  font-size: 2.5rem;
  color: #fff;
  cursor: pointer;
  transition: color 0.3s ease, transform 0.3s ease;
  z-index: 2100;
}

.lightbox-close:hover {
  color: #ffb347;
  transform: rotate(90deg);
}

/* Mobile friendly */
@media (max-width: 576px) {
  .lightbox-img {
    max-width: 95%;
    max-height: 80vh;
  }
  .lightbox-close {
    font-size: 2rem;
    top: 15px;
    right: 20px;
  }
}