/* Custom styles for Oxnard Village Apartment */

/* Smooth scrolling */
html {
  scroll-behavior: smooth;
}

/* Custom scrollbar */
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: #f3f0e0;
}
::-webkit-scrollbar-thumb {
  background: #357035;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #265226;
}

/* Geometric shape animations */
@keyframes float {
  0%, 100% { transform: translateY(0px) rotate(0deg); }
  50% { transform: translateY(-20px) rotate(5deg); }
}

@keyframes float-reverse {
  0%, 100% { transform: translateY(0px) rotate(45deg); }
  50% { transform: translateY(20px) rotate(40deg); }
}

@keyframes pulse-soft {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 0.8; }
}

.geo-circle {
  animation: float 8s ease-in-out infinite;
}

.geo-square {
  animation: float-reverse 10s ease-in-out infinite;
}

.geo-circle:nth-child(odd) {
  animation-delay: -2s;
}

.geo-square:nth-child(even) {
  animation-delay: -3s;
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  .geo-circle,
  .geo-square {
    animation: none;
  }
  html {
    scroll-behavior: auto;
  }
}

/* Scroll reveal animations (below the fold only) */
.reveal {
  opacity: 1;
  transform: none;
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.reveal[data-animate] {
  opacity: 0;
  transform: translateY(30px);
}

@media (prefers-reduced-motion: no-preference) {
  .reveal[data-animate] {
    opacity: 0;
    transform: translateY(30px);
  }
  .reveal.visible[data-animate] {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Staggered delays for grid items */
.reveal[data-animate] {
  transition-delay: calc(var(--stagger, 0) * 0.1s);
}

/* Navbar styles */
#navbar.scrolled {
  background: rgba(253, 252, 248, 0.95);
  backdrop-filter: blur(10px);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* Button focus styles */
button:focus-visible,
a:focus-visible {
  outline: 2px solid #357035;
  outline-offset: 2px;
  border-radius: 4px;
}

/* Image loading placeholder */
img {
  background: linear-gradient(135deg, #d5e8d5 0%, #f3f0e0 100%);
}

/* Selection color */
::selection {
  background: #357035;
  color: white;
}
</style>
<sm-file path="script.js">
// Oxnard Village Apartment - Interactive Scripts

document.addEventListener('DOMContentLoaded', function () {
  // Mobile menu
  const mobileMenuBtn = document.getElementById('mobile-menu-btn');
  const mobileMenu = document.getElementById('mobile-menu');
  const menuOpen = document.getElementById('menu-open');
  const menuClose = document.getElementById('menu-close');

  if (mobileMenuBtn && mobileMenu && menuOpen && menuClose) {
    mobileMenuBtn.addEventListener('click', function () {
      const isOpen = !mobileMenu.classList.contains('hidden');
      mobileMenu.classList.toggle('hidden');
      menuOpen.classList.toggle('hidden');
      menuClose.classList.toggle('hidden');
    });

    // Close mobile menu when clicking a link
    mobileMenu.querySelectorAll('a').forEach(function (link) {
      link.addEventListener('click', function () {
        mobileMenu.classList.add('hidden');
        menuOpen.classList.remove('hidden');
        menuClose.classList.add('hidden');
      });
    });
  }

  // Navbar scroll effect
  const navbar = document.getElementById('navbar');
  let lastScroll = 0;

  function handleScroll() {
    const currentScroll = window.pageYOffset;

    if (currentScroll > 50) {
      navbar.classList.add('scrolled');
    } else {
      navbar.classList.remove('scrolled');
    }

    lastScroll = currentScroll;
  }

  window.addEventListener('scroll', handleScroll, { passive: true });
  handleScroll();

  // Scroll reveal for below-the-fold content
  const prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;

  if (!prefersReducedMotion && 'IntersectionObserver' in window) {
    const revealElements = document.querySelectorAll('[data-animate]');

    const revealObserver = new IntersectionObserver(function (entries) {
      entries.forEach(function (entry) {
        if (entry.isIntersecting) {
          entry.target.classList.add('visible');
          revealObserver.unobserve(entry.target);
        }
      });
    }, {
      threshold: 0.1,
      rootMargin: '0px 0px -50px 0px'
    });

    revealElements.forEach(function (el) {
      revealObserver.observe(el);
    });
  }

  // Contact form
  const contactForm = document.getElementById('contact-form');
  const formSuccess = document.getElementById('form-success');

  if (contactForm && formSuccess) {
    contactForm.addEventListener('submit', function (e) {
      e.preventDefault();

      // Simulate form submission
      const submitBtn = contactForm.querySelector('button[type="submit"]');
      const originalText = submitBtn.innerHTML;
      submitBtn.innerHTML = '<svg class="animate-spin w-5 h-5" viewBox="0 0 24 24" fill="none"><circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4" stroke-dasharray="31.4 31.4" stroke-linecap="round"></circle></svg>';
      submitBtn.disabled = true;

      setTimeout(function () {
        contactForm.reset();
        contactForm.classList.add('hidden');
        formSuccess.classList.remove('hidden');
        submitBtn.innerHTML = originalText;
        submitBtn.disabled = false;
      }, 1200);
    });
  }

  // Smooth scroll for anchor links
  document.querySelectorAll('a[href^="#"]').forEach(function (anchor) {
    anchor.addEventListener('click', function (e) {
      const targetId = this.getAttribute('href');
      if (targetId === '#') return;

      const target = document.querySelector(targetId);
      if (target) {
        e.preventDefault();
        const navHeight = navbar ? navbar.offsetHeight : 0;
        const targetPosition = target.getBoundingClientRect().top + window.pageYOffset - navHeight - 20;

        window.scrollTo({
          top: targetPosition,
          behavior: 'smooth'
        });
      }
    });
  });
});
