/* Custom styles for Dott. Gabriele Lo Cicero - Fisioterapista a Domicilio */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Outfit:wght@500;600;700;800&display=swap');

:root {
  --primary-navy: #0f172a;
  --primary-blue: #0284c7;
  --medical-dark-blue: #0369a1;
  --accent-cyan: #38bdf8;
  --soft-sky: #f0f9ff;
  --card-border: rgba(186, 230, 253, 0.55);
  --whatsapp-dark: #075E54;
  --whatsapp-teal: #128C7E;
}

html, body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  font-size: 16px;
  color: #1e293b;
  background-color: #f8fafc;
  scroll-behavior: smooth;
  overflow-x: clip;
  -webkit-text-size-adjust: 100%;
}

/* REGOLA FONDAMENTALE DI LEGGIBILITÀ: NESSUN TESTO SOTTO GLI 0.95rem (15.2px) */
.text-xs, 
.text-sm, 
small, 
input, 
select, 
textarea, 
label,
.font-min-readability {
  font-size: 0.95rem !important;
  line-height: 1.5 !important;
}

h1, h2, h3, h4, .brand-font {
  font-family: 'Outfit', sans-serif;
}

/* Smooth background mesh */
.hero-mesh {
  background: 
    radial-gradient(at 0% 0%, rgba(56, 189, 248, 0.18) 0px, transparent 55%),
    radial-gradient(at 100% 0%, rgba(2, 132, 199, 0.15) 0px, transparent 55%),
    radial-gradient(at 50% 100%, rgba(224, 242, 254, 0.7) 0px, transparent 55%);
}

.gradient-text {
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 50%, #1e3a8a 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Glassmorphism cards */
.glass-card {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--card-border);
  box-shadow: 0 10px 30px -5px rgba(2, 132, 199, 0.08), 0 4px 12px -2px rgba(15, 23, 42, 0.04);
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.glass-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 20px 40px -10px rgba(2, 132, 199, 0.15), 0 8px 20px -4px rgba(15, 23, 42, 0.06);
  border-color: rgba(56, 189, 248, 0.85);
}

/* Navbar Links: No-wrap & Clean Modern Hover Pills */
.nav-link {
  position: relative;
  white-space: nowrap;
  padding: 0.5rem 0.85rem;
  border-radius: 0.75rem;
  font-size: 0.95rem !important;
  font-weight: 600;
  color: #334155;
  transition: color 0.2s cubic-bezier(0.16, 1, 0.3, 1),
              background-color 0.2s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.2s cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  display: inline-flex;
  align-items: center;
  border: 1px solid transparent;
}

.nav-link:hover {
  color: #0284c7;
  background-color: rgba(240, 249, 255, 0.9);
  border-color: rgba(186, 230, 253, 0.6);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.08);
}

.nav-link.nav-link-active {
  color: #0369a1 !important;
  background-color: #e0f2fe !important;
  border-color: #38bdf8 !important;
  box-shadow: 0 2px 10px rgba(2, 132, 199, 0.16) !important;
  font-weight: 700 !important;
}

.nav-link.nav-link-active::after {
  content: '';
  position: absolute;
  bottom: 0px;
  left: 50%;
  transform: translateX(-50%);
  width: 18px;
  height: 3px;
  border-radius: 9999px;
  background: #0284c7;
  box-shadow: 0 0 8px rgba(2, 132, 199, 0.8);
}

/* Custom button states */
.btn-primary {
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  color: #ffffff;
  box-shadow: 0 4px 15px rgba(2, 132, 199, 0.3);
  transition: all 0.25s ease;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem !important;
  font-weight: 700;
  padding: 0.75rem 1.5rem;
  border-radius: 0.85rem;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #0369a1 0%, #1e3a8a 100%);
  box-shadow: 0 6px 20px rgba(2, 132, 199, 0.45);
  transform: translateY(-1px);
}

/* WhatsApp button with WCAG AAA Contrast (Deep Teal Green #075E54) */
.btn-whatsapp {
  background: linear-gradient(135deg, #075E54 0%, #128C7E 100%);
  color: #ffffff !important;
  box-shadow: 0 4px 16px rgba(7, 94, 84, 0.35);
  transition: all 0.25s ease;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem !important;
  font-weight: 700;
  padding: 0.75rem 1.35rem;
  border-radius: 0.85rem;
  white-space: nowrap;
}

.btn-whatsapp:hover {
  background: linear-gradient(135deg, #054c44 0%, #0d685c 100%);
  box-shadow: 0 8px 24px rgba(7, 94, 84, 0.5);
  transform: translateY(-2px);
}

/* Floating WhatsApp Button with Mobile Safe Area */
.floating-whatsapp {
  position: fixed !important;
  bottom: max(20px, env(safe-area-inset-bottom, 20px)) !important;
  right: max(20px, env(safe-area-inset-right, 20px)) !important;
  left: auto !important;
  z-index: 99 !important;
  display: inline-flex !important;
  width: auto !important;
  max-width: fit-content !important;
  align-items: center;
  gap: 10px;
  background: #075E54;
  color: #ffffff !important;
  padding: 14px 22px;
  border-radius: 9999px;
  box-shadow: 0 10px 25px -3px rgba(7, 94, 84, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.1);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  font-weight: 700;
  font-size: 0.95rem !important;
  min-height: 52px;
  overflow: hidden;
}

.floating-whatsapp:hover, .floating-whatsapp:active {
  background: #054c44;
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 16px 30px -3px rgba(7, 94, 84, 0.65);
}

/* Mobile Menu & Drawer styles are defined in the dedicated MOTION DESIGN section below */

/* Touch targets >= 44px for chips */
.city-chip {
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  font-size: 0.95rem !important;
  font-weight: 600;
  border-radius: 9999px;
}

.city-chip:hover {
  background-color: #0284c7;
  color: #ffffff;
  border-color: #0284c7;
  transform: translateY(-1px);
}

/* Triage Step Transition */
.triage-step {
  display: none;
  animation: fadeInScale 0.25s ease-out forwards;
}

.triage-step.active {
  display: block;
}

@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.98) translateY(6px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.animate-pop-in {
  animation: fadeInScale 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
  background: #93c5fd;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #3b82f6;
}

/* ==========================================================================
   MOTION DESIGN & UI/UX NAVIGATION (MEDICAL SERENITY)
   ========================================================================== */

/* 1. Offset anti-copertura per tutte le sezioni con id */
section[id] {
  scroll-margin-top: 5.5rem; /* 88px, previene coperture da parte dell'header sticky */
}
@media (max-width: 768px) {
  section[id] {
    scroll-margin-top: 4.5rem; /* 72px per mobile */
  }
}

/* 2. Header Dinamico & Glassmorphism su Scroll */
.site-header {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  width: 100% !important;
  z-index: 50 !important;
  transition: background-color 0.3s cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 0.3s cubic-bezier(0.16, 1, 0.3, 1),
              border-color 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: height, background-color, box-shadow;
}

.site-header.header-scrolled {
  background-color: rgba(255, 255, 255, 0.9) !important;
  backdrop-filter: blur(16px) saturate(180%) !important;
  -webkit-backdrop-filter: blur(16px) saturate(180%) !important;
  border-bottom-color: rgba(186, 230, 253, 0.65) !important;
  box-shadow: 0 10px 25px -5px rgba(2, 132, 199, 0.09), 0 4px 10px -2px rgba(15, 23, 42, 0.04) !important;
}

.site-header.header-scrolled .header-content {
  height: 4rem !important; /* Transizione fluida da 80px (h-20) a 64px (h-16) */
}

.site-header.header-scrolled #header-logo {
  height: 2.5rem !important; /* Da 48px a 40px senza scatti */
}

/* Barra di Progresso Lettura/Scroll Integrata */
.scroll-progress-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2.5px;
  width: 0%;
  background: linear-gradient(90deg, #38bdf8 0%, #06b6d4 50%, #10b981 100%);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.6), 0 0 4px rgba(16, 185, 129, 0.4);
  transition: width 0.08s ease-out;
  z-index: 55;
  pointer-events: none;
}

/* 3. Badge Beacon '💻 Consulenza Online' */
.nav-link-online {
  background: rgba(240, 249, 255, 0.85);
  color: #0369a1 !important;
  font-weight: 700;
  border: 1px solid rgba(186, 230, 253, 0.75);
}

.nav-link-online:hover {
  background: #e0f2fe;
  border-color: rgba(56, 189, 248, 0.9);
  box-shadow: 0 4px 14px rgba(14, 165, 233, 0.2);
}

.online-beacon {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 10px;
  height: 10px;
}

.beacon-ring {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 9999px;
  background-color: #0284c7;
  animation: beaconPulse 2s cubic-bezier(0, 0, 0.2, 1) infinite;
}

.beacon-dot {
  position: relative;
  width: 6px;
  height: 6px;
  border-radius: 9999px;
  background-color: #0284c7;
  box-shadow: 0 0 6px #38bdf8;
}

@keyframes beaconPulse {
  0% { transform: scale(0.9); opacity: 0.8; }
  70% { transform: scale(2.6); opacity: 0; }
  100% { transform: scale(2.6); opacity: 0; }
}

/* 4. Effetto Sheen / Shimmer su Pulsanti WhatsApp */
.btn-whatsapp {
  position: relative;
  overflow: hidden;
}

.btn-whatsapp::before,
.floating-whatsapp::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -100%;
  width: 50%;
  height: 200%;
  background: linear-gradient(
    115deg,
    transparent 0%,
    rgba(255, 255, 255, 0) 30%,
    rgba(255, 255, 255, 0.24) 50%,
    rgba(255, 255, 255, 0) 70%,
    transparent 100%
  );
  transform: rotate(25deg);
  pointer-events: none;
  animation: sheenLoop 6s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes sheenLoop {
  0%, 75% { left: -100%; }
  90%, 100% { left: 180%; }
}

.btn-whatsapp:hover::before,
.floating-whatsapp:hover::before {
  animation: sheenHover 0.85s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes sheenHover {
  0% { left: -100%; }
  100% { left: 180%; }
}

/* 5. Mobile Drawer, Stagger & Backdrop */
body.menu-lock-scroll {
  overflow: hidden !important;
}

.mobile-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 45;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.mobile-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

#mobile-menu {
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: max-height 0.4s cubic-bezier(0.16, 1, 0.3, 1),
              opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  max-height: calc(100vh - 4.5rem);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

#mobile-menu.menu-closed {
  max-height: 0;
  opacity: 0;
  transform: translateY(-12px);
  pointer-events: none;
  visibility: hidden;
  padding-top: 0;
  padding-bottom: 0;
}

#mobile-menu.menu-open {
  max-height: calc(100vh - 4.5rem);
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
  visibility: visible;
  box-shadow: 0 25px 40px -15px rgba(2, 132, 199, 0.15), 0 10px 20px -5px rgba(15, 23, 42, 0.08);
}

/* Staggered Fade-in Mobile Links */
#mobile-menu.menu-open .mobile-link,
#mobile-menu.menu-open .mobile-cta-wrapper {
  animation: mobileLinkStagger 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
}

#mobile-menu.menu-closed .mobile-link,
#mobile-menu.menu-closed .mobile-cta-wrapper {
  opacity: 0;
  transform: translateY(8px);
  animation: none;
}

#mobile-menu.menu-open nav .mobile-link:nth-child(1) { animation-delay: 0.04s; }
#mobile-menu.menu-open nav .mobile-link:nth-child(2) { animation-delay: 0.08s; }
#mobile-menu.menu-open nav .mobile-link:nth-child(3) { animation-delay: 0.12s; }
#mobile-menu.menu-open nav .mobile-link:nth-child(4) { animation-delay: 0.16s; }
#mobile-menu.menu-open nav .mobile-link:nth-child(5) { animation-delay: 0.20s; }
#mobile-menu.menu-open nav .mobile-link:nth-child(6) { animation-delay: 0.24s; }
#mobile-menu.menu-open nav .mobile-link:nth-child(7) { animation-delay: 0.28s; }
#mobile-menu.menu-open .mobile-cta-wrapper           { animation-delay: 0.32s; }

@keyframes mobileLinkStagger {
  0% {
    opacity: 0;
    transform: translateY(10px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.mobile-link.mobile-link-active {
  background: linear-gradient(90deg, rgba(240, 249, 255, 0.95) 0%, rgba(224, 242, 254, 0.7) 100%) !important;
  color: #0284c7 !important;
  border-left: 4px solid #0284c7;
  padding-left: calc(0.75rem - 4px);
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.08);
}

/* Hamburger to 'X' Morphing Icon */
.hamburger-line {
  display: block;
  width: 22px;
  height: 2px;
  background-color: #334155;
  border-radius: 9999px;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1),
              opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1),
              background-color 0.2s ease;
  transform-origin: center;
}

#mobile-menu-btn:hover .hamburger-line {
  background-color: #0284c7;
}

#mobile-menu-btn[aria-expanded="true"] .hamburger-line-1 {
  transform: translateY(7px) rotate(45deg);
  background-color: #0284c7;
}

#mobile-menu-btn[aria-expanded="true"] .hamburger-line-2 {
  opacity: 0;
  transform: scaleX(0);
}

#mobile-menu-btn[aria-expanded="true"] .hamburger-line-3 {
  transform: translateY(-7px) rotate(-45deg);
  background-color: #0284c7;
}

/* 6. Pulsante Floating 'Torna su' (Back to Top) */
.floating-back-to-top {
  position: fixed !important;
  bottom: calc(max(20px, env(safe-area-inset-bottom, 20px)) + 64px) !important;
  right: max(20px, env(safe-area-inset-right, 20px)) !important;
  left: auto !important;
  z-index: 90 !important;
  width: 48px;
  height: 48px;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(186, 230, 253, 0.85);
  box-shadow: 0 8px 25px -4px rgba(2, 132, 199, 0.22), 0 3px 8px -2px rgba(15, 23, 42, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #0284c7;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: translateY(14px) scale(0.88);
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.3s cubic-bezier(0.16, 1, 0.3, 1),
              background-color 0.2s ease,
              border-color 0.2s ease,
              box-shadow 0.2s ease;
}

.floating-back-to-top.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.floating-back-to-top:hover {
  background: #ffffff;
  border-color: #0284c7;
  color: #0369a1;
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 14px 30px -4px rgba(2, 132, 199, 0.35), 0 4px 12px -2px rgba(15, 23, 42, 0.1);
}

.floating-back-to-top:active {
  transform: translateY(0) scale(0.96);
}

.progress-ring {
  position: absolute;
  top: 0;
  left: 0;
  width: 48px;
  height: 48px;
  pointer-events: none;
}

.progress-ring-bg {
  stroke: rgba(224, 242, 254, 0.8);
}

.progress-ring-fill {
  stroke: #0284c7;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.1s linear;
}

.floating-back-to-top .arrow-icon {
  width: 20px;
  height: 20px;
  position: relative;
  z-index: 2;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.floating-back-to-top:hover .arrow-icon {
  transform: translateY(-2px);
}

/* 7. Accessibilità & Reduced Motion */
@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;
  }
}
