/* Reset and base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.6;
  color: #333;
  overflow-x: hidden;
}

/* Custom scrollbar */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
  background: #64748b;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #475569;
}

/* Firefox scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: #64748b #f1f5f9;
}

/* Loading animation */
body:not(.loaded) {
  overflow: hidden;
}

body:not(.loaded)::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #1e40af;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

body:not(.loaded)::after {
  content: '';
  position: fixed;
  top: 50%;
  left: 50%;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top: 4px solid #fff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  z-index: 10000;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Fade in animation professionale UI */
@keyframes uiReveal {
  0% { opacity: 0; transform: translateY(30px); }
  100% { opacity: 1; transform: translateY(0); }
}

.animate-ui-reveal {
  opacity: 0;
  will-change: transform, opacity;
  animation: uiReveal 1.2s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.reveal-delay-1 { animation-delay: 0.1s; }
.reveal-delay-2 { animation-delay: 0.2s; }
.reveal-delay-3 { animation-delay: 0.3s; }

/* Image optimization */
img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Lazy loading images */
img[loading="lazy"] {
  transition: opacity 0.3s;
}

img[loading="lazy"].loaded {
  opacity: 1;
}

/* Button hover effects */
.btn-hover {
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
}

.btn-hover::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s;
}

.btn-hover:hover::before {
  left: 100%;
}

/* Card hover effects */
.card-hover {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-hover:hover {
  transform: translateY(-8px);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

/* Parallax effect for hero section */
.parallax {
  background-attachment: fixed;
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
}

@media (max-width: 768px) {
  .parallax {
    background-attachment: scroll;
  }
}

/* Focus states for accessibility */
button:focus,
a:focus,
input:focus,
textarea:focus {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

/* Print styles */
@media print {
  .no-print {
    display: none !important;
  }
  body {
    font-size: 12pt;
    line-height: 1.4;
  }
  h1, h2, h3, h4, h5, h6 {
    page-break-after: avoid;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .bg-gray-50 {
    background-color: white;
  }
  .text-gray-600 {
    color: #000;
  }
  .border-gray-200 {
    border-color: #000;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-primary: #111827;
    --bg-secondary: #1f2937;
    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
  }
}

/* Performance optimizations */
.gpu-accelerated {
  transform: translateZ(0);
  will-change: transform;
}

/* Intersection observer fade in */
.fade-in-observer {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.fade-in-observer.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Mobile-first responsive design */
.container {
  width: 100%;
  padding-left: 1rem;
  padding-right: 1rem;
  margin-left: auto;
  margin-right: auto;
}

@media (min-width: 640px) { .container { max-width: 640px; padding-left: 1.5rem; padding-right: 1.5rem; } }
@media (min-width: 768px) { .container { max-width: 768px; } }
@media (min-width: 1024px) { .container { max-width: 1024px; padding-left: 2rem; padding-right: 2rem; } }
@media (min-width: 1280px) { .container { max-width: 1280px; } }
@media (min-width: 1536px) { .container { max-width: 1536px; } }

/* Utility classes */
.transform-gpu { transform: translateZ(0); }
.backface-hidden { backface-visibility: hidden; }
.perspective-1000 { perspective: 1000px; }

/* Loading states */
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
}

@keyframes loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Error / Success states */
.error-state {
  background-color: #fee2e2;
  border: 1px solid #fecaca;
  color: #dc2626;
  padding: 1rem;
  border-radius: 0.5rem;
}

.success-state {
  background-color: #dcfce7;
  border: 1px solid #bbf7d0;
  color: #16a34a;
  padding: 1rem;
  border-radius: 0.5rem;
}

/* Custom animations for service cards */
.service-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.service-card:hover {
  transform: translateY(-8px) scale(1.02);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

.service-card .icon-container {
  transition: all 0.3s ease;
}

.service-card:hover .icon-container {
  transform: scale(1.1) rotate(5deg);
}

/* Optimized font loading */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url('https://fonts.gstatic.com/s/inter/v12/UcCO3FwrK3iLTeHuS_fvQtMwCp50KnMw2boKoduKmMEVuLyeMZhrib2Bg-4.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* HERO BACKGROUND – versione CSS pura (Houdini rimosso) */
.hero-houdini {
  background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 50%, #0f172a 100%);
  background-image:
    linear-gradient(135deg, #1e3a8a 0%, #1e40af 50%, #0f172a 100%),
    radial-gradient(circle at 20% 30%, rgba(59, 130, 246, 0.12) 0%, transparent 45%),
    radial-gradient(circle at 80% 70%, rgba(251, 146, 60, 0.08) 0%, transparent 50%);
  background-blend-mode: overlay;
}

/* Navbar glass + transizioni */
.nav-glass {
  backdrop-filter: blur(14px);
  background-color: rgba(255, 255, 255, 0.85);
  transition: background-color 0.3s ease, box-shadow 0.3s ease, transform 0.2s ease;
}

.nav-glass.nav-scrolled {
  background-color: rgba(15, 23, 42, 0.96);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.45);
  transform: translateY(-1px);
}

/* Hero image float */
.hero-device {
  animation: floatDevice 5s ease-in-out infinite;
}

@keyframes floatDevice {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-10px) scale(1.01); }
}

/* Pulsanti principali con shine */
.btn-primary,
.btn-outline {
  position: relative;
  overflow: hidden;
}

.btn-primary::after,
.btn-outline::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, rgba(255, 255, 255, 0.25), transparent 40%, rgba(255, 255, 255, 0.25));
  transform: translateX(-120%);
  transition: transform 0.6s ease;
}

.btn-primary:hover::after,
.btn-outline:hover::after {
  transform: translateX(120%);
}

/* About image reveal */
.about-photo {
  position: relative;
  overflow: hidden;
  transform: translateZ(0);
}

.about-photo::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, #1e40af, transparent);
  transform: translateX(-100%);
  transition: transform 0.7s cubic-bezier(0.19, 1, 0.22, 1);
  mix-blend-mode: screen;
}

.about-photo.revealed::before {
  transform: translateX(100%);
}

/* CTA cards subtle hover */
.contact-card {
  transition: transform 0.3s ease, box-shadow 0.3s ease, background-color 0.3s ease;
}

.contact-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.35);
  background-color: rgba(30, 64, 175, 0.95);
}

/* GOOGLE MAPS - SEZIONE DOVE SIAMO */
.google-map-container {
  position: relative;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding-bottom: 56.25%;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

.google-map-container iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}