/* AM Solutions - Immersive 3D Scroll Background & Preloader Stylesheet (Light Theme V17.1) */

/* Body scroll lock during loading */
body.loading {
  overflow: hidden !important;
  height: 100vh !important;
}

/* Lenis Smooth Scroll Resets */
html.lenis, html.lenis body {
  height: auto;
}

.lenis.lenis-smooth {
  scroll-behavior: auto !important;
}

.lenis.lenis-smooth [data-lenis-prevent] {
  overscroll-behavior: contain;
}

.lenis.lenis-stopped {
  overflow: hidden;
}

.lenis.lenis-scrolling iframe {
  pointer-events: none;
}

/* 1. Fullscreen Preloader - Light Theme Premium */
#loading-screen {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  background-color: #ffffff;
  z-index: 110000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading), 'Segoe UI', Roboto, sans-serif;
  transition: opacity 1s cubic-bezier(0.25, 1, 0.5, 1), visibility 1s;
  pointer-events: all;
}

#loading-screen.fade-out {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

.loader-container {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
}

.loader-logo-gif {
  max-width: 150px;
  height: auto;
  mix-blend-mode: multiply;
  margin-bottom: 15px;
}

.loader-logo {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: #1d1d1f;
  margin-bottom: 24px;
  background: linear-gradient(135deg, #1d1d1f 30%, #6e6e73 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: logoPulse 2.5s ease-in-out infinite;
}

.loader-title {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--color-primary, #0071e3);
  margin-bottom: 8px;
}

.loader-percent {
  font-size: 4rem;
  font-weight: 900;
  font-family: 'Outfit', monospace;
  background: linear-gradient(135deg, #0071e3, #682bd8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 15px rgba(0, 113, 227, 0.15));
  margin-bottom: 20px;
  line-height: 1;
}

.loader-bar-bg {
  width: 240px;
  height: 2px;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 2px;
  position: relative;
  overflow: hidden;
}

.loader-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #0071e3, #682bd8);
  box-shadow: 0 0 6px rgba(0, 113, 227, 0.5);
  transition: width 0.1s cubic-bezier(0.1, 0.8, 0.25, 1);
}

.loader-subtitle {
  font-size: 0.65rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: #86868b;
  margin-top: 16px;
}

/* 2. Particles Canvas Background */
.particles-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw !important;
  height: 100vh !important;
  z-index: -1;
  pointer-events: none;
}

/* Explicitly enforce dark charcoal text color for all headings and paragraphs in light theme sections */
.section .section-title h2,
.section h2.display,
.about h2,
.about h3,
.about h4 {
  color: var(--text-primary) !important;
}

.section .section-title p,
.about p {
  color: var(--text-secondary) !important;
}

@media (min-width: 992px) {
  .section {
    position: sticky !important;
    top: 0;
    height: 100vh !important;
    width: 100%;
    display: flex !important;
    flex-direction: column;
    justify-content: center !important; /* Perfect vertical centering inside the 100vh viewport */
    padding-top: 85px !important; /* Space to clear the 80px sticky header */
    padding-bottom: 25px !important;
    overflow: visible !important;
    box-sizing: border-box;
  }

  /* On desktop, we let sections center vertically in 100vh, clearing the header padding.
     This prevents sections from being pushed low/down by excessive top padding. */
  #works, #features, #chatbot-inline-section, #solutions-lab, #strengths, #contact {
    padding-top: 85px !important;
  }

  /* #problems è la prima sezione dopo l'hero: le serve lo stesso respiro di #about */
  #problems, #about {
    padding-top: 130px !important; /* Clears fading Hero content on scroll transition */
  }

  /* Ogni sezione resta agganciata finché la successiva le scorre sopra.
     L'ultima (#contact) non ha una sezione dopo di sé. Un elemento sticky è
     vincolato al CONTENT BOX del contenitore: un padding su #main non darebbe
     alcun margine di scorrimento. Serve quindi un blocco reale nel flusso,
     che è .sticky-tail qui sotto. */
  .sticky-tail {
    display: block;
    height: 70vh;
    pointer-events: none;
  }
}

@media (max-width: 991px) {
  #problems, #works, #features, #chatbot-inline-section, #solutions-lab, #strengths, #contact {
    padding-top: 130px !important; /* Increased space post-About on mobile */
  }
}

/* Laptop-height safety overrides for the chatbot section */
@media (min-width: 992px) and (max-height: 850px) {
  #chatbot-inline-section {
    padding-top: 75px !important;
    padding-bottom: 15px !important;
  }
  #chatbot-inline-section .section-title {
    margin-bottom: 8px !important;
    padding-bottom: 0 !important;
  }
  #chatbot-inline-section .section-title h2 {
    font-size: 2.0rem !important;
    margin-top: 0 !important;
  }
  #chatbot-inline-section .section-title p {
    margin-bottom: 0 !important;
    font-size: 0.9rem !important;
  }
}

/* Section solid color backgrounds & Stacking context layers (with a subtle white overlay for readability and contrast) */
/* Lo z-index DEVE crescere nello stesso ordine in cui le sezioni compaiono nel DOM:
   è così che ogni sezione copre la precedente mentre si scorre. Se si aggiunge o si
   sposta una sezione, va aggiornato anche l'array sectionIds in immersive.js. */
#problems {
  background: transparent !important;
  position: relative;
  z-index: 10;
}

#about {
  background: transparent !important;
  position: relative;
  z-index: 20;
}

#works {
  background: transparent !important;
  position: relative;
  z-index: 30;
}

#features {
  background: transparent !important;
  position: relative;
  z-index: 40;
}

#chatbot-inline-section {
  background: transparent !important;
  position: relative;
  z-index: 50;
}

#solutions-lab {
  background: transparent !important;
  position: relative;
  z-index: 60;
}

#strengths {
  background: transparent !important;
  position: relative;
  z-index: 70;
}

#contact {
  background: transparent !important;
  position: relative;
  z-index: 80;
}

#footer {
  background: var(--bg-primary) !important; /* Sitting flat at body background color */
  position: relative;
  z-index: 90;
}

/* Ensure content container is in front of the wave backgrounds */
.section > .container,
.section > .container-fluid,
.footer > .footer-top,
.footer > .copyright {
  position: relative;
  z-index: 5 !important;
  will-change: transform, opacity; /* GPU acceleration to prevent layout repaints during sticky transitions */
}

.hero-content {
  will-change: transform, opacity; /* GPU acceleration for hero scroll opacity/translate transition */
}


/* Text contrast overrides removed to restore dark readable text on light glass backgrounds */

/* Make main content wrapper transparent so background layers show through */
#main {
  position: relative;
  z-index: 1; /* Page content flows at z-index 1 */
  background: transparent !important;
}

/* 3. Hero video styling overrides */
.video-background {
  /* Mantieni il comportamento originale del video */
}

/* Smooth transition fade mask at the bottom of the Hero */
.hero-bottom-fade {
  position: absolute;
  bottom: -2px; /* cover overlap perfectly */
  left: 0;
  width: 100%;
  height: 200px;
  background: linear-gradient(to bottom, transparent 0%, var(--bg-primary, #f5f5f7) 100%);
  z-index: 2;
  pointer-events: none;
}

/* Animations */
@keyframes logoPulse {
  0%, 100% { transform: scale(1); opacity: 0.9; }
  50% { transform: scale(1.02); opacity: 1; }
}

/* 4. Desktop spacing optimizations for Features section to prevent vertical cutoff in 100vh viewport */
@media (min-width: 992px) {
  #features .services-abstract-grid {
    grid-template-columns: repeat(4, 1fr) !important; /* 4 columns on desktop to fit all cards in a single row */
    margin-top: 25px !important;
    gap: 16px !important;
  }
  
  #features .service-abstract-card {
    padding: 24px 20px !important; /* more compact padding */
  }
  
  #features .services-abstract-grid .service-abstract-card:nth-child(even),
  #features .services-abstract-grid .service-abstract-card:nth-child(odd) {
    margin-top: 0 !important; /* align all cards on the same horizontal row */
    margin-bottom: 0 !important;
  }

  #features .section-title {
    margin-bottom: 0 !important;
    padding-bottom: 10px !important;
  }
  
  #features .section-title h2 {
    font-size: 2.2rem !important;
    margin-top: 5px !important;
  }
  
  #features .section-title p {
    margin-bottom: 0 !important;
    font-size: 0.95rem !important;
  }
  
  #features .service-abstract-header {
    margin-bottom: 10px !important;
  }
  
  #features .service-abstract-header i {
    font-size: 1.8rem !important;
  }
  
  #features .service-abstract-header h3 {
    font-size: 1.25rem !important;
  }
  
  #features .service-abstract-tagline {
    font-size: 0.92rem !important;
    margin-bottom: 12px !important;
  }
  
  #features .service-abstract-list {
    margin-bottom: 12px !important;
    gap: 6px !important;
  }
  
  #features .service-abstract-list li {
    font-size: 0.85rem !important;
  }
  
  #features .pane-case-pricing-story {
    margin-top: 12px !important;
    padding: 15px !important; /* more compact padding */
    flex-direction: column !important; /* stack study & pricing inside the narrow card */
    gap: 12px !important;
  }

  #features .pane-case-pricing-story .pricing-block {
    border-left: none !important;
    border-top: 1px solid var(--border-color) !important;
    padding-left: 0 !important;
    padding-top: 12px !important;
  }
}

/* 5. Additional laptop-height safety scaling for shorter viewports */
@media (min-width: 992px) and (max-height: 850px) {
  #features .services-abstract-grid {
    margin-top: 15px !important;
    gap: 12px !important;
  }
  
  #features .service-abstract-card {
    padding: 16px 14px !important;
  }
  
  #features .service-abstract-header h3 {
    font-size: 1.15rem !important;
  }
  
  #features .service-abstract-tagline {
    font-size: 0.85rem !important;
    margin-bottom: 8px !important;
  }
  
  #features .service-abstract-list {
    margin-bottom: 8px !important;
    gap: 4px !important;
  }
  
  #features .service-abstract-list li {
    font-size: 0.8rem !important;
  }
  
  #features .pane-case-pricing-story {
    margin-top: 8px !important;
    padding: 10px !important;
    gap: 8px !important;
  }
  
  #features .pane-case-pricing-story .pricing-block {
    padding-top: 8px !important;
  }
}

/* La sezione Assistente contiene due card alte più il pulsante del preventivatore:
   in 100vh sforava, mandando l'occhiello sotto l'header e tagliando la didascalia
   finale. Qui viene compattata quel tanto che basta per rientrare nella schermata. */
@media (min-width: 992px) {
  #chatbot-inline-section .section-title {
    margin-bottom: 10px !important;
  }
  #chatbot-inline-section .section-title p {
    margin-bottom: 0 !important;
  }
  #chatbot-inline-section .chatbot-inline-container,
  #chatbot-inline-section .chatbot-inline-info-card {
    max-height: 440px;
  }
  #chatbot-inline-section .chatbot-body {
    min-height: 0;
  }
  #chatbot-inline-section .row.justify-content-center.mt-4 {
    margin-top: 12px !important;
  }
}

