/**
 * Bailey Engineering - UX Enhancement Styles
 * Modern, accessible, and performant user experience improvements
 */

/* ===== PERFORMANCE & LOADING STATES ===== */

/* Loading skeleton animations */
.loading-skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading-shimmer 1.5s infinite;
}

@keyframes loading-shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* Smooth loading states for images and videos - only apply to lazy-loaded content */
img[data-src], video[data-src] {
  transition: opacity 0.3s ease;
}

img[data-src]:not(.loaded), video[data-src]:not(.loaded) {
  opacity: 0;
}

img[data-src].loaded, video[data-src].loaded {
  opacity: 1;
}

/* Ensure logo images are always visible */
.bailey-logo {
  opacity: 1 !important;
}

/* ===== PROJECT DETAILS VISIBILITY FIXES ===== */

/* Ensure project details are always visible */
.project-details {
  opacity: 1 !important;
  visibility: visible !important;
  display: block !important;
}

.project-details .fw-semibold {
  color: #212529 !important;
  opacity: 1 !important;
  visibility: visible !important;
}

.project-details .text-muted {
  color: #6c757d !important;
  opacity: 1 !important;
  visibility: visible !important;
}

/* ===== HERO BACKGROUND IMAGE FIXES ===== */

/* Force hero background images to display - highest specificity */
section.py-5.bg-primary.text-white.position-relative.overflow-hidden.hero-navbar-spacing {
  background-image: url('hero.png') !important;
  background-size: cover !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
  background-color: transparent !important;
}

/* Ensure gradient overlay allows background image to show through */
section.py-5.bg-primary.text-white.position-relative.overflow-hidden.hero-navbar-spacing > .position-absolute {
  background: linear-gradient(135deg, rgba(37, 48, 106, 0.5) 0%, rgba(37, 48, 106, 0.3) 100%) !important;
  opacity: 0.8 !important;
}

/* Add hero background to index.html fullwidth-hero on mobile */
@media (max-width: 768px) {
  .fullwidth-hero {
    background-image: url('hero.png') !important;
    background-size: cover !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
  }
  
  /* Hide video on mobile to show background image */
  .fullwidth-hero video {
    display: none !important;
  }
  
  /* Ensure background image shows through any overlay */
  .fullwidth-hero::before {
    background: linear-gradient(
      to bottom,
      rgba(0, 0, 0, 0.3) 0%,
      rgba(0, 0, 0, 0.15) 40%,
      rgba(0, 0, 0, 0.3) 100%
    ) !important;
  }
}


/* Ensure all project information is visible */
.project-content .fw-semibold {
  opacity: 1 !important;
  visibility: visible !important;
  color: #212529 !important;
}

.project-content .text-muted {
  opacity: 1 !important;
  visibility: visible !important;
  color: #6c757d !important;
}

.project-content small {
  opacity: 1 !important;
  visibility: visible !important;
  color: #6c757d !important;
}

/* Ensure project titles are visible */
.project-content h3 {
  opacity: 1 !important;
  visibility: visible !important;
  color: #113b6f !important;
}

/* Ensure project descriptions are visible */
.project-content p {
  opacity: 1 !important;
  visibility: visible !important;
  color: #6c757d !important;
}

/* ===== ENHANCED NAVIGATION ===== */

/* Smart navbar hiding on scroll */
.navbar {
  transition: transform 0.3s ease, background-color 0.3s ease, box-shadow 0.3s ease;
}

.navbar-hidden {
  transform: translateY(-100%);
}

.navbar.scrolled {
  background-color: rgba(255, 255, 255, 0.95) !important;
  backdrop-filter: blur(10px);
  box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
}

/* Active navigation states */
.nav-link.active {
  color: var(--primary-color) !important;
  font-weight: 600;
  position: relative;
}

.nav-link.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 2px;
  background: var(--secondary-color);
  border-radius: 1px;
}

/* ===== ENHANCED TOUCH INTERACTIONS ===== */

/* Touch feedback */
.touch-active {
  transform: scale(0.98);
  transition: transform 0.1s ease;
}

/* Improved button interactions */
.btn {
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
}

.btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.3s ease, height 0.3s ease;
}

.btn:active::before {
  width: 300px;
  height: 300px;
}

/* Enhanced card interactions */
.card, .feature-card, .project-card, .service-overview-card {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
}

.card:hover, .feature-card:hover, .project-card:hover, .service-overview-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15) !important;
}

/* ===== ACCESSIBILITY ENHANCEMENTS ===== */

/* Skip link */
.skip-link {
  position: absolute;
  top: -40px;
  left: 6px;
  background: var(--primary-color);
  color: white;
  padding: 8px 16px;
  text-decoration: none;
  border-radius: 0 0 4px 4px;
  z-index: 9999;
  transition: top 0.3s ease;
}

.skip-link:focus {
  top: 0;
}

/* Enhanced focus states */
.keyboard-navigation *:focus {
  outline: 2px solid var(--secondary-color);
  outline-offset: 2px;
  border-radius: 4px;
}

.keyboard-navigation .btn:focus {
  outline-offset: 4px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .btn-outline-light {
    border-width: 2px;
  }
  
  .card, .feature-card, .project-card {
    border-width: 2px;
  }
}

/* ===== ENHANCED ANIMATIONS ===== */

/* Smooth page transitions */
.page-transition {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

/* Only apply transition effect when JavaScript is available */
.js .page-transition {
  opacity: 0;
  transform: translateY(20px);
}

.js .page-transition.loaded {
  opacity: 1;
  transform: translateY(0);
}

/* Scroll-triggered animations */
.fade-in-on-scroll {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.fade-in-on-scroll.animate-in {
  opacity: 1;
  transform: translateY(0);
}

/* Staggered animations for lists */
.animate-in:nth-child(1) { transition-delay: 0.1s; }
.animate-in:nth-child(2) { transition-delay: 0.2s; }
.animate-in:nth-child(3) { transition-delay: 0.3s; }
.animate-in:nth-child(4) { transition-delay: 0.4s; }
.animate-in:nth-child(5) { transition-delay: 0.5s; }
.animate-in:nth-child(6) { transition-delay: 0.6s; }

/* ===== ENHANCED FORM EXPERIENCE ===== */

/* Floating labels */
.form-floating {
  position: relative;
}

.form-floating.focused label {
  transform: scale(0.85) translateY(-0.5rem) translateX(0.15rem);
  color: var(--primary-color);
}

/* Enhanced validation states */
.form-control.is-valid {
  border-color: var(--success);
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3e%3cpath fill='%23198754' d='m2.3 6.73.94-.94 1.48 1.48L7.6 4.4l.94.94L4.72 9.16z'/%3e%3c/svg%3e");
}

.form-control.is-invalid {
  border-color: var(--error);
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23dc3545'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath d='m5.8 4.6 2.4 2.4M8.2 4.6l-2.4 2.4'/%3e%3c/svg%3e");
}

/* ===== RESPONSIVE IMPROVEMENTS ===== */

/* Better mobile spacing */
@media (max-width: 768px) {
  /* Improved touch targets */
  .btn {
    min-height: 44px;
    padding: 0.75rem 1.5rem;
  }
  
  /* Better mobile navigation */
  .navbar-collapse {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    border-radius: 0 0 12px 12px;
    margin-top: 1px;
  }
  
  .navbar-nav .nav-link {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  }
  
  .navbar-nav .nav-link:last-child {
    border-bottom: none;
  }
  
  /* Improved mobile cards */
  .card, .feature-card, .project-card {
    margin-bottom: 1.5rem;
  }
  
  /* Better mobile hero */
  .fullwidth-hero {
    min-height: 70vh;
  }
  
  .fullwidth-hero .display-4 {
    font-size: 2rem;
    line-height: 1.3;
  }
}

/* ===== PERFORMANCE OPTIMIZATIONS ===== */

/* GPU acceleration for animations */
.card, .feature-card, .project-card, .btn, .navbar {
  will-change: transform;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .navbar-hidden {
    transform: none;
  }
}

/* ===== DARK MODE SUPPORT - DISABLED ===== */
/* Dark mode temporarily disabled to prevent form styling conflicts */
/*
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1a1a;
    --surface: #2d2d2d;
    --ink: #ffffff;
    --muted: #a0a0a0;
    --border: #404040;
  }
  
  .navbar.scrolled {
    background-color: rgba(26, 26, 26, 0.95) !important;
  }
  
  .card, .feature-card, .project-card {
    background-color: var(--surface);
    color: var(--ink);
  }
}
*/

/* ===== PRINT STYLES ===== */
@media print {
  .navbar, .btn, .cta-group, video, .play-overlay {
    display: none !important;
  }
  
  .card, .feature-card, .project-card {
    break-inside: avoid;
    box-shadow: none !important;
    border: 1px solid #ccc !important;
  }
  
  a[href^="http"]:after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: #666;
  }
}
