/* ==========================================================================
   NEXTRA BTP / ÉTANCHÉITÉ PARIS - Premium Micro-Interactions & Styling
   ========================================================================== */

/* 1. Design Tokens & CSS Custom Properties */
:root {
  --primary-navy: #00152d;
  --primary-container: #062a4d;
  --deep-navy: #031b33;
  --cta-orange: #ff7417;
  --cta-orange-hover: #e6630f;
  --secondary-container: #fc7214;
  --surface: #f8f9ff;
  --surface-low: #eef4ff;
  --surface-border: #e2e8f0;
  --text-dark: #011d35;
  --text-muted: #43474e;
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-smooth: cubic-bezier(0.22, 1, 0.36, 1);
}

/* Typography & Zero-CLS System Font Fallbacks */
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
.font-display, .font-headline {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* 2. Page Subtle Fade-In */
@keyframes sitePageFadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
main {
  animation: sitePageFadeIn 400ms var(--ease-smooth) forwards;
}

/* 3. Reading Scroll Progress Bar */
.scroll-progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: var(--secondary-container);
  transform-origin: 0 50%;
  transform: scaleX(0);
  z-index: 9999;
  pointer-events: none;
  transition: transform 60ms linear;
  box-shadow: 0 1px 4px rgba(252, 114, 20, 0.4);
}

/* 4. Scroll Reveal Animations (IntersectionObserver) */
.reveal-on-scroll {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 700ms var(--ease-smooth), transform 700ms var(--ease-smooth);
  will-change: opacity, transform;
}
.reveal-on-scroll.is-revealed {
  opacity: 1;
  transform: translateY(0);
}

/* Staggered Children Reveal */
.reveal-stagger > * {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 700ms var(--ease-smooth), transform 700ms var(--ease-smooth);
  will-change: opacity, transform;
}
.reveal-stagger.is-revealed > *:nth-child(1) { transition-delay: 40ms; opacity: 1; transform: translateY(0); }
.reveal-stagger.is-revealed > *:nth-child(2) { transition-delay: 110ms; opacity: 1; transform: translateY(0); }
.reveal-stagger.is-revealed > *:nth-child(3) { transition-delay: 180ms; opacity: 1; transform: translateY(0); }
.reveal-stagger.is-revealed > *:nth-child(4) { transition-delay: 250ms; opacity: 1; transform: translateY(0); }
.reveal-stagger.is-revealed > *:nth-child(5) { transition-delay: 320ms; opacity: 1; transform: translateY(0); }
.reveal-stagger.is-revealed > *:nth-child(6) { transition-delay: 390ms; opacity: 1; transform: translateY(0); }
.reveal-stagger.is-revealed > *:nth-child(7) { transition-delay: 460ms; opacity: 1; transform: translateY(0); }
.reveal-stagger.is-revealed > *:nth-child(8) { transition-delay: 530ms; opacity: 1; transform: translateY(0); }

/* 5. Hero Parallax Background */
.hero-parallax-bg {
  transform: translate3d(0, 0, 0);
  will-change: transform;
  transition: transform 120ms cubic-bezier(0, 0, 0.2, 1);
}

/* 6. Navigation Bar on Scroll */
.site-header {
  transition: background-color 300ms ease, box-shadow 300ms ease, padding 300ms ease, border-color 300ms ease;
}
.site-header.nav-scrolled {
  background-color: rgba(255, 255, 255, 0.98) !important;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 4px 20px -2px rgba(0, 21, 45, 0.08);
  border-bottom-color: rgba(195, 198, 207, 0.45);
}
.site-header.nav-scrolled .header-inner {
  height: 4.25rem !important; /* smooth compact height */
}
.site-header.nav-scrolled .site-logo-img {
  transform: scale(0.94);
}
.site-logo-img {
  transition: transform 250ms var(--ease-smooth);
}

/* 7. Mobile Navigation Smooth Drawer */
#mobile-nav {
  display: none;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
  transform: translateY(-8px);
  transition: max-height 300ms var(--ease-smooth),
              opacity 240ms ease,
              transform 260ms var(--ease-smooth);
}
#mobile-nav.is-open {
  display: block !important;
  max-height: 550px;
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

/* 8. Project Gallery Hover Enhancements */
.project-card,
#projects-grid > div {
  transition: transform 380ms var(--ease-smooth),
              box-shadow 380ms var(--ease-smooth),
              border-color 300ms ease;
  will-change: transform, box-shadow;
}
.project-card:hover,
#projects-grid > div:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 32px -8px rgba(0, 21, 45, 0.12);
}
.project-card .project-img,
#projects-grid img {
  transition: transform 650ms var(--ease-smooth);
}
.project-card:hover .project-img,
#projects-grid > div:hover img {
  transform: scale(1.05);
}
.project-card .project-overlay {
  transition: opacity 350ms ease, background-color 350ms ease;
}

/* 9. Interactive Before / After Comparison Slider */
.ba-slider-container {
  position: relative;
  width: 100%;
  height: 420px;
  overflow: hidden;
  border-radius: 1rem;
  user-select: none;
  touch-action: pan-y;
  box-shadow: 0 10px 25px -5px rgba(3, 27, 51, 0.15);
  cursor: ew-resize;
}
.ba-slider-container:focus-visible {
  outline: 3px solid var(--secondary-container);
  outline-offset: 3px;
}

.ba-slider-img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.ba-slider-overlay {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 50%;
  overflow: hidden;
  border-right: 3px solid #ff7417;
  pointer-events: none;
  will-change: width;
}

.ba-slider-overlay .ba-slider-img {
  width: 100%;
  min-width: 100%;
}

.ba-slider-handle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 46px;
  height: 46px;
  background: #ff7417;
  color: #ffffff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(255, 116, 23, 0.55), 0 0 0 4px rgba(255, 255, 255, 0.25);
  cursor: ew-resize;
  z-index: 20;
  transition: transform 140ms ease, box-shadow 140ms ease;
  will-change: left, transform;
}
.ba-slider-handle:hover,
.ba-slider-handle:focus-visible,
.ba-slider-container.is-active .ba-slider-handle {
  transform: translate(-50%, -50%) scale(1.12);
  box-shadow: 0 6px 20px rgba(255, 116, 23, 0.65), 0 0 0 6px rgba(255, 255, 255, 0.35);
}
.ba-slider-handle:focus-visible {
  outline: none;
}

.ba-badge {
  position: absolute;
  bottom: 16px;
  padding: 6px 14px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  z-index: 10;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: opacity 200ms ease;
}
.ba-badge-before {
  left: 16px;
  background: rgba(3, 27, 51, 0.85);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.2);
}
.ba-badge-after {
  right: 16px;
  background: rgba(255, 116, 23, 0.9);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(255, 116, 23, 0.4);
}

/* 10. Process Timeline Animated Line */
.process-timeline {
  position: relative;
}
.timeline-track-line {
  position: absolute;
  top: 1.5rem;
  bottom: 1.5rem;
  left: 1.75rem;
  width: 2px;
  background: rgba(195, 198, 207, 0.35);
  z-index: 0;
  overflow: hidden;
  border-radius: 2px;
}
.timeline-progress-fill {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 0%;
  background: var(--secondary-container);
  box-shadow: 0 0 8px rgba(252, 114, 20, 0.6);
  transition: height 120ms ease-out;
  border-radius: 2px;
}
.timeline-step {
  transition: transform 300ms var(--ease-smooth), border-color 300ms ease;
}
.timeline-step.is-active-step {
  border-color: rgba(252, 114, 20, 0.5) !important;
  transform: translateX(4px);
}

/* 11. Buttons & CTA Micro-Interactions */
.btn-cta,
a[href*="#devis-form"],
button[type="submit"],
.bg-secondary-container {
  transition: transform 220ms var(--ease-smooth),
              box-shadow 220ms var(--ease-smooth),
              background-color 200ms ease,
              border-color 200ms ease;
  will-change: transform, box-shadow;
}

.btn-cta:hover,
a[href*="#devis-form"]:hover,
button[type="submit"]:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 22px -4px rgba(252, 114, 20, 0.38);
}

.btn-cta:active,
a[href*="#devis-form"]:active,
button[type="submit"]:active {
  transform: translateY(0) scale(0.99);
}

/* Icon forward micro-translation on button/card hover */
.btn-cta:hover .material-symbols-outlined,
a[href*="#devis-form"]:hover .material-symbols-outlined,
button[type="submit"]:hover .material-symbols-outlined,
.group:hover .group-hover\:translate-x-1,
.group:hover .material-symbols-outlined.icon-arrow-move {
  transform: translateX(4px);
  transition: transform 220ms var(--ease-smooth);
}

/* 12. Subtle Image Reveal Animation */
.image-reveal-wrapper {
  overflow: hidden;
  position: relative;
}
.image-reveal-wrapper img {
  transform: scale(1.06);
  clip-path: inset(0 0 3% 0);
  transition: transform 850ms var(--ease-smooth),
              clip-path 700ms var(--ease-smooth);
  will-change: transform, clip-path;
}
.image-reveal-wrapper.is-revealed img {
  transform: scale(1);
  clip-path: inset(0 0 0 0);
}

/* 13. Service Cards Micro-Interactions */
.service-card {
  transition: transform 340ms var(--ease-smooth),
              box-shadow 340ms var(--ease-smooth),
              border-color 280ms ease;
  will-change: transform, box-shadow;
}
.service-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 30px -8px rgba(0, 21, 45, 0.10);
  border-color: rgba(252, 114, 20, 0.45);
}

/* 14. Animated Counters Typography */
.stat-counter {
  font-variant-numeric: tabular-nums;
  display: inline-block;
  will-change: contents;
}

/* 15. Custom Scrollbar (Preserved) */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* 16. Cost Estimator Range Input (Preserved) */
.custom-range {
  -webkit-appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 5px;
  background: #e2e8f0;
  outline: none;
}
.custom-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #ff7417;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(255, 116, 23, 0.4);
  transition: transform 0.15s ease;
}
.custom-range::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

/* 17. Flash Message Animation (Preserved) */
@keyframes slideDownFade {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.flash-alert {
  animation: slideDownFade 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* 18. Architectural Grid (Preserved) */
.bg-architectural-grid {
  background-image: radial-gradient(rgba(6, 42, 77, 0.08) 1px, transparent 1px);
  background-size: 24px 24px;
}

/* 19. Accessibility: Respect prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
  *, ::before, ::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .reveal-on-scroll,
  .reveal-stagger > *,
  .image-reveal-wrapper img,
  main {
    opacity: 1 !important;
    transform: none !important;
    clip-path: none !important;
    animation: none !important;
  }
  .hero-parallax-bg {
    transform: none !important;
  }
  .scroll-progress-bar {
    display: none !important;
  }
}
