/* ==========================================================================
   VARMA CONSTRUCTIONS - VISUAL ENHANCEMENTS & PERFORMANCE OPTIMIZATIONS
   ========================================================================== */

/* ==========================================================================
   1. SMOOTH SCROLL & PAGE TRANSITIONS
   ========================================================================== */
html {
  scroll-behavior: smooth;
  scroll-padding-top: 80px; /* Offset for sticky header */
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ==========================================================================
   2. LAZY LOADING IMAGE FADE-IN
   ========================================================================== */
img {
  opacity: 0;
  transition: opacity 0.4s ease-in-out;
}

img.loaded,
img[src*="logo"] {
  opacity: 1;
}

/* Blur placeholder for lazy images */
img[loading="lazy"] {
  background: linear-gradient(135deg, #1f2532 0%, #13171f 100%);
}

/* ==========================================================================
   3. ENHANCED FOCUS STATES (ACCESSIBILITY)
   ========================================================================== */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Remove default focus for mouse users */
:focus:not(:focus-visible) {
  outline: none;
}

/* ==========================================================================
   4. IMPROVED BUTTON INTERACTIONS
   ========================================================================== */
.btn {
  position: relative;
  overflow: hidden;
  transform: translateZ(0); /* Hardware acceleration */
}

.btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.btn:active::before {
  width: 300px;
  height: 300px;
}

/* Haptic feedback simulation */
.btn:active {
  transform: scale(0.97) translateY(1px);
}

/* ==========================================================================
   5. ENHANCED CARD HOVER EFFECTS
   ========================================================================== */
.service-card,
.portfolio-card,
.testimonial-card,
.project-info-card,
.contact-info-card {
  transform: translateZ(0);
  backface-visibility: hidden;
  will-change: transform;
}

.service-card:hover,
.portfolio-card:hover {
  transform: translateY(-6px) scale(1.01);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4),
              0 0 0 1px rgba(245, 158, 11, 0.2);
}

/* ==========================================================================
   6. LOADING STATES & SKELETONS
   ========================================================================== */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-card) 0%,
    var(--bg-card-hover) 40%,
    var(--bg-card) 80%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
  border-radius: 8px;
}

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ==========================================================================
   7. SMOOTH SCROLL REVEAL ANIMATIONS
   ========================================================================== */
[data-reveal] {
  opacity: 0;
  transform: translateY(40px);
  transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

[data-reveal].revealed {
  opacity: 1;
  transform: translateY(0);
}

/* Stagger delay for grid items */
[data-reveal]:nth-child(1) { transition-delay: 0.05s; }
[data-reveal]:nth-child(2) { transition-delay: 0.1s; }
[data-reveal]:nth-child(3) { transition-delay: 0.15s; }
[data-reveal]:nth-child(4) { transition-delay: 0.2s; }
[data-reveal]:nth-child(5) { transition-delay: 0.25s; }
[data-reveal]:nth-child(6) { transition-delay: 0.3s; }

/* ==========================================================================
   8. IMPROVED NAV MENU ANIMATION
   ========================================================================== */
.nav-links {
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1),
              opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.nav-item {
  opacity: 0;
  transform: translateX(20px);
  transition: opacity 0.3s, transform 0.3s;
}

.nav-links.open .nav-item {
  opacity: 1;
  transform: translateX(0);
}

.nav-links.open .nav-item:nth-child(1) { transition-delay: 0.05s; }
.nav-links.open .nav-item:nth-child(2) { transition-delay: 0.1s; }
.nav-links.open .nav-item:nth-child(3) { transition-delay: 0.15s; }
.nav-links.open .nav-item:nth-child(4) { transition-delay: 0.2s; }
.nav-links.open .nav-item:nth-child(5) { transition-delay: 0.25s; }

/* ==========================================================================
   9. ENHANCED FLOATING ACTION BUTTONS
   ========================================================================== */
.floating-actions {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 999;
}

.fab-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
}

.fab-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.3s;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.2), transparent);
}

.fab-btn:hover::before {
  opacity: 1;
}

.fab-btn:hover {
  transform: translateY(-4px) scale(1.08);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.fab-btn:active {
  transform: translateY(-2px) scale(1.05);
}

.fab-whatsapp {
  background: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
  color: white;
}

.fab-whatsapp:hover {
  box-shadow: 0 10px 30px rgba(37, 211, 102, 0.4);
}

.fab-quote {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: #000;
}

.fab-quote:hover {
  box-shadow: 0 10px 30px rgba(245, 158, 11, 0.5);
}

/* Pulse animation for attention */
.fab-btn.pulse {
  animation: fab-pulse 2s infinite;
}

@keyframes fab-pulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  }
  50% {
    transform: scale(1.08);
    box-shadow: 0 10px 30px rgba(245, 158, 11, 0.6);
  }
}

/* ==========================================================================
   10. ENHANCED STATS COUNTER ANIMATION
   ========================================================================== */
.stat-item {
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.stat-item:hover {
  transform: translateY(-4px);
  background: var(--bg-card-hover);
}

.stat-number {
  position: relative;
  display: inline-block;
}

.stat-count {
  display: inline-block;
  transform: translateZ(0);
}

/* ==========================================================================
   11. BETTER MODAL TRANSITIONS
   ========================================================================== */
.modal-overlay {
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1),
              visibility 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.lightbox-inner,
.quote-modal-inner {
  transform: scale(0.9) translateY(20px);
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.active .lightbox-inner,
.modal-overlay.active .quote-modal-inner {
  transform: scale(1) translateY(0);
  opacity: 1;
}

/* ==========================================================================
   12. IMPROVED FORM INPUTS
   ========================================================================== */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"],
textarea,
select {
  transition: border-color 0.3s, background-color 0.3s, box-shadow 0.3s;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="tel"]:focus,
input[type="password"]:focus,
textarea:focus,
select:focus {
  background-color: var(--bg-card-hover);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.1);
}

/* ==========================================================================
   13. ENHANCED PORTFOLIO FILTER TRANSITIONS
   ========================================================================== */
.portfolio-card {
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1),
              opacity 0.3s ease-in-out;
}

.portfolio-card[style*="display: none"] {
  opacity: 0;
  transform: scale(0.9);
}

/* ==========================================================================
   14. IMPROVED BEFORE/AFTER SLIDER
   ========================================================================== */
.ba-handle {
  cursor: ew-resize;
  transition: transform 0.2s ease-out;
}

.ba-handle:hover {
  transform: translate(-50%, -50%) scale(1.15);
}

.ba-handle:active {
  transform: translate(-50%, -50%) scale(1.05);
  cursor: grabbing;
}

/* ==========================================================================
   15. ENHANCED BREADCRUMB
   ========================================================================== */
.breadcrumb-nav a {
  position: relative;
}

.breadcrumb-nav a::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 1px;
  background: var(--accent);
  transition: width 0.3s;
}

.breadcrumb-nav a:hover::after {
  width: 100%;
}

/* ==========================================================================
   16. SCROLL TO TOP BUTTON (OPTIONAL - HIDDEN ON MOBILE)
   ========================================================================== */
.scroll-to-top {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 48px;
  height: 48px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 998;
  color: var(--text-secondary);
}

/* Hide on mobile to prevent overlap with FABs */
@media (max-width: 640px) {
  .scroll-to-top {
    display: none !important;
  }
}

.scroll-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.scroll-to-top:hover {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
  transform: translateY(-4px);
}

/* ==========================================================================
   17. IMPROVED LINK HOVER EFFECTS
   ========================================================================== */
.footer-links a,
.footer-contact-list a {
  transition: all 0.2s ease;
  position: relative;
  display: inline-block;
}

.footer-links a:hover,
.footer-contact-list a:hover {
  color: var(--accent);
  transform: translateX(4px);
}

/* ==========================================================================
   18. LOADING SPINNER
   ========================================================================== */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spinner-rotate 0.8s linear infinite;
}

@keyframes spinner-rotate {
  to { transform: rotate(360deg); }
}

/* ==========================================================================
   19. MOBILE-SPECIFIC PERFORMANCE OPTIMIZATIONS
   ========================================================================== */
@media (max-width: 868px) {
  /* Reduce animation complexity on mobile */
  [data-reveal] {
    transform: translateY(20px);
  }
  
  /* Optimize hover states for touch */
  .service-card:hover,
  .portfolio-card:hover {
    transform: none;
  }
  
  /* Make touch targets larger */
  .mobile-toggle,
  .fab-btn,
  .hero-dot,
  .filter-btn {
    min-width: var(--touch-target-min);
    min-height: var(--touch-target-min);
  }
  
  /* Improve tap response */
  button,
  a,
  .clickable {
    touch-action: manipulation;
  }
}

/* ==========================================================================
   20. PROGRESSIVE WEB APP SAFE AREAS
   ========================================================================== */
@supports (padding: env(safe-area-inset-bottom)) {
  .modern-navbar {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
  
  .floating-actions {
    bottom: calc(24px + env(safe-area-inset-bottom));
    right: calc(24px + env(safe-area-inset-right));
  }
  
  .nav-links.open {
    padding-bottom: calc(30px + env(safe-area-inset-bottom));
  }
}

/* ==========================================================================
   21. PRINT STYLES (BONUS)
   ========================================================================== */
@media print {
  .modern-navbar,
  .floating-actions,
  .hero-slider-controls,
  .top-bar,
  .mobile-toggle,
  .modal-overlay {
    display: none !important;
  }
  
  body {
    background: white;
    color: black;
  }
  
  .section-padding {
    padding: 20px 0;
  }
}

/* ==========================================================================
   22. HIGH CONTRAST MODE SUPPORT
   ========================================================================== */
@media (prefers-contrast: high) {
  .btn-primary {
    border: 2px solid var(--accent);
  }
  
  .nav-link {
    border-bottom: 1px solid transparent;
  }
  
  .nav-link:hover,
  .nav-item.active .nav-link {
    border-bottom-color: var(--accent);
  }
}

/* ==========================================================================
   23. SELECTION STYLING
   ========================================================================== */
::selection {
  background: rgba(245, 158, 11, 0.3);
  color: var(--text-primary);
}

::-moz-selection {
  background: rgba(245, 158, 11, 0.3);
  color: var(--text-primary);
}

/* ==========================================================================
   24. CUSTOM SCROLLBAR (WEBKIT)
   ========================================================================== */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--bg-card);
  border-radius: 5px;
  border: 2px solid var(--bg-secondary);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

/* Firefox scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--bg-card) var(--bg-secondary);
}
