/* Custom styles to complement Tailwind CSS */

/* Custom animations for slider and header elements */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes scaleIn {
  from {
    transform: scale(0.9);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* How We Do It section animations */
@keyframes float {
  0% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-10px);
  }
  100% {
    transform: translateY(0px);
  }
}

@keyframes pulse {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.05);
    opacity: 0.8;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

#how-we-do-it .grid > div:hover .w-12 {
  animation: pulse 1s ease-in-out;
}

#how-we-do-it .absolute.-top-5 .w-10 {
  animation: float 3s ease-in-out infinite;
}

.fade-in {
  animation: fadeIn 0.8s ease-in-out;
}

/* Header styles */
header.bg-gradient-to-r {
  position: relative;
  overflow: hidden;
}

/* Skyline background filter */
.skyline-background {
  filter: opacity(0.2) brightness(1.3) grayscale(0.6);
  background-size: auto 100% !important;
  background-repeat: repeat-x !important;
}

header.bg-gradient-to-r::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M11 18c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm48 25c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm-43-7c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm63 31c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM34 90c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm56-76c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM12 86c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm28-65c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm23-11c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-6 60c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm29 22c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zM32 63c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm57-13c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-9-21c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM60 91c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM35 41c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM12 60c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2z' fill='%238b4513' fill-opacity='0.03' fill-rule='evenodd'/%3E%3C/svg%3E");
  pointer-events: none;
  opacity: 0.7;
}

header h1 {
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

header .w-24.h-1.bg-primary {
  box-shadow: 0 1px 3px rgba(139, 69, 19, 0.3);
  animation: scaleIn 1s ease-out forwards;
}

header p {
  animation: slideUp 0.8s ease-out 0.3s both;
}

header .mt-8 {
  animation: slideUp 0.8s ease-out 0.5s both;
}

header .absolute.rounded-full {
  animation: scaleIn 1.5s ease-out both;
}

@media (max-width: 640px) {
  header .w-24.h-1.bg-primary {
    width: 60px;
  }
}

/* Custom variables */
:root {
  --primary-color: #8b4513;
  --primary-hover: rgba(139, 69, 19, 0.9);
  --secondary-color: #2a6041;
  --accent-color: #d66853;
  --white: #ffffff;
  --transition-speed: 0.3s;
  --nav-height: 70px;
}

/* Fix for dropdown hover gap issue */
.group:hover .group-hover\:visible {
  display: block;
  visibility: visible !important;
}

.group:hover .group-hover\:opacity-100 {
  opacity: 1 !important;
}

/* Add a padding overlay to prevent mouse leaving dropdown during gap */
.relative.group .absolute::before {
  content: '';
  position: absolute;
  top: -10px;
  left: 0;
  right: 0;
  height: 10px;
}

/* No special handling for city dropdown */

/* Ensure dropdown menu item formatting */
.city-link, .state-link {
  display: block;
  width: 100%;
}

/* Fix for button layout - specifically targeting homepage navigation */
nav button {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
}

nav button span {
  display: inline-block !important;
  margin-right: 8px !important;
}

nav button i, 
nav button svg {
  display: inline-block !important;
  vertical-align: middle !important;
}

/* Fix for hamburger menu showing on desktop */
@media (min-width: 768px) {
  .md\:flex {
    display: flex !important;
  }
  
  .md\:hidden {
    display: none !important;
  }
  
  .md\:inline-block {
    display: inline-block !important;
  }
  
  .hidden.md\:flex {
    display: flex !important;
  }
}

/* Nav responsive sizing is now handled by Tailwind responsive classes in
   templates/partials/header.php (whitespace-nowrap + lg:/xl:/2xl: utilities).
   The 1024-1279 font/padding shrink hack that used to live here has been removed. */

/* Large screen breakpoint for full navigation */
@media (min-width: 1024px) {
  #mobile-menu-button {
    display: none !important;
  }
  
  .lg\:flex {
    display: flex !important;
  }
  
  .lg\:hidden {
    display: none !important;
  }
  
  .hidden.lg\:flex {
    display: flex !important;
  }
}

/* Large-screen nav reset previously lived here; it was a companion to the
   1024-1279 shrink hack that has been removed in favor of Tailwind
   responsive classes in templates/partials/header.php. */

/* Slider styles */
.slider-container {
  position: relative;
  overflow: hidden;
  border-radius: 0.5rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.slider-wrapper {
  display: flex;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  height: 100%;
}

.slider-slide {
  min-width: 100%;
  position: relative;
}

.slider-indicators {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 0.5rem;
  z-index: 10;
}

.slider-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  transition: all var(--transition-speed) ease;
  border: 1px solid rgba(255, 255, 255, 0.8);
}

.slider-indicator.active {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
  transform: scale(1.2);
  box-shadow: 0 0 8px rgba(139, 69, 19, 0.3);
}

.slider-nav-button {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background-color: var(--primary-color);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  font-size: 1.2rem;
  cursor: pointer;
  transition: all var(--transition-speed) ease;
  z-index: 10;
  border: none;
  outline: none;
}

.slider-nav-button:hover {
  background-color: var(--primary-hover);
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
  transform: translateY(-50%) scale(1.05);
}

.slider-nav-button:focus {
  box-shadow: 0 0 0 3px rgba(139, 69, 19, 0.3);
}

.slider-nav-button.prev {
  left: 1rem;
}

.slider-nav-button.next {
  right: 1rem;
}

@media (max-width: 640px) {
  .slider-nav-button {
    width: 32px;
    height: 32px;
  }

  .slider-indicator {
    width: 8px;
    height: 8px;
  }
}

/* Popup styles */
.popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}

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

.popup-content {
  background-color: white;
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
  padding: 2rem;
  border-radius: 0.5rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  position: relative;
  transform: translateY(-20px);
  transition: transform 0.3s;
}

.popup-overlay.active .popup-content {
  transform: translateY(0);
}

.popup-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  font-size: 1.5rem;
  color: var(--primary-color);
  cursor: pointer;
  background: none;
  border: none;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition-speed);
}

.popup-close:hover {
  color: var(--accent-color);
}

@media (max-width: 640px) {
  .popup-content {
    width: 95%;
    padding: 1.5rem;
  }
}

/* Custom scrollbar for webkit browsers */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
  background: var(--primary-color);
  border-radius: 4px;
}

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

/* Custom styling for focus states */
input:focus,
button:focus,
a:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* Mobile navigation separators */
@media (max-width: 768px) {
  #mobile-menu-scrollable .py-1 {
    position: relative;
    border-bottom: 1px solid rgba(139, 69, 19, 0.1);
  }

  #mobile-menu-scrollable .py-1:last-child {
    border-bottom: none;
  }

  #mobile-menu-scrollable .py-1 a {
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
  }
}

/* Mobile optimizations */
@media (max-width: 640px) {
  .container {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  #slider .min-w-full {
    min-height: 50vh;
  }

  .flex-wrap-mobile {
    flex-wrap: wrap;
  }

  .footer-links {
    flex-direction: column;
    gap: 1rem;
  }
}

/* Additional print styles */
@media print {
  nav,
  footer,
  button,
  .bg-primary,
  .bg-secondary {
    display: none !important;
  }

  body {
    color: #000;
    background: #fff;
  }

  .container {
    width: 100%;
    max-width: 100%;
  }

  h1,
  h2,
  h3,
  h4,
  h5,
  h6 {
    page-break-after: avoid;
  }

  p,
  li {
    orphans: 3;
    widows: 3;
  }
}

/* Enhanced accessibility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Custom underline animation for links */
.hover-underline {
  position: relative;
  text-decoration: none;
}

.hover-underline:after {
  content: "";
  position: absolute;
  width: 0;
  height: 2px;
  bottom: -2px;
  left: 0;
  background-color: var(--primary-color);
  transition: width 0.3s ease;
}

.hover-underline:hover:after {
  width: 100%;
}

/* Mobile Menu Styles */
#mobile-menu-overlay {
  transition: opacity 0.3s ease-in-out;
  opacity: 0;
  backdrop-filter: blur(2px);
  position: fixed;
  top: var(--nav-height, 70px);
  left: 0;
  right: 0;
  bottom: 0;
}

#mobile-menu-overlay.menu-open {
  opacity: 1;
}

#mobile-menu-overlay.menu-closing {
  opacity: 0;
}

#mobile-menu {
  transition: transform 0.3s ease-in-out, opacity 0.3s ease-in-out;
  opacity: 0;
  transform: translateY(-10px);
  pointer-events: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 60;
  /* Fallback for browsers that don't support dynamic viewport units */
  height: calc(100vh - var(--nav-height, 70px) - 80px);
  /* For browsers that support env() */
  height: calc(
    100vh - var(--nav-height, 70px) - env(safe-area-inset-bottom, 0px) - 70px
  );
  /* For browsers that support svh (small viewport height - accounts for URL bar shown) */
  height: calc(100svh - var(--nav-height, 70px) - 70px);
  background: white;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1),
    0 2px 4px -1px rgba(0, 0, 0, 0.06);
  border-top: 1px solid rgba(0, 0, 0, 0.15);
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#mobile-menu.menu-open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: all;
}

#mobile-menu.menu-closing {
  opacity: 0;
  transform: translateY(-10px);
  pointer-events: none;
}

#mobile-menu.hidden {
  display: none;
}

/* Scrollable content area */
#mobile-menu-scrollable {
  overflow-y: auto;
  flex: 1;
  -webkit-overflow-scrolling: touch;
  /* Make scrollable area have bottom padding to accommodate fixed login button */
  padding-bottom: 70px;
}

/* Fixed login button container */
#mobile-menu-login {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: white;
  z-index: 61;
  box-shadow: 0 -2px 6px -1px rgba(0, 0, 0, 0.1);
  /* Add padding to account for iOS Safari toolbar */
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-bottom: max(env(safe-area-inset-bottom, 0px), 10px);
}

/* Additional iOS-specific adjustments */
@supports (-webkit-touch-callout: none) {
  #mobile-menu {
    /* iOS-specific height adjustment */
    height: calc(100vh - var(--nav-height, 70px) - 100px);
  }

  #mobile-menu-scrollable {
    /* Extra padding for iOS */
    padding-bottom: 90px;
  }

  #mobile-menu-login {
    /* Ensure button stays above the toolbar */
    bottom: env(safe-area-inset-bottom, 0px);
  }
}

/* Custom scrollbar styling for the mobile menu */
#mobile-menu-scrollable::-webkit-scrollbar {
  width: 6px;
}

#mobile-menu-scrollable::-webkit-scrollbar-track {
  background: #f1f1f1;
}

#mobile-menu-scrollable::-webkit-scrollbar-thumb {
  background: var(--primary-color);
  border-radius: 3px;
}

/* Custom scrollbar styling for the mobile menu */
#mobile-menu > div::-webkit-scrollbar {
  width: 6px;
}

#mobile-menu > div::-webkit-scrollbar-track {
  background: #f1f1f1;
}

#mobile-menu > div::-webkit-scrollbar-thumb {
  background: var(--primary-color);
  border-radius: 3px;
}

/* Improved dropdown menu animations */
#mobile-state-dropdown,
#mobile-city-dropdown {
  padding: 0.5rem 0;
  transform-origin: top center;
  transition: transform 200ms cubic-bezier(0.34, 1.56, 0.64, 1),
    opacity 180ms ease-out;
  opacity: 1;
  transform: scaleY(1) translateY(0);
  will-change: transform, opacity;
}

#mobile-state-dropdown.hidden,
#mobile-city-dropdown.hidden {
  display: block !important;
  opacity: 0;
  transform: scaleY(0.95) translateY(-10px);
  pointer-events: none;
  position: absolute;
  clip: rect(0, 0, 0, 0);
  height: 1px;
  width: 1px;
  overflow: hidden;
}

/* State and city links hover effect */
#mobile-state-dropdown a,
#mobile-city-dropdown a {
  transition: all 0.15s ease;
  display: block;
  transform: translateX(0);
  padding: 0.5rem 0.75rem;
  border-radius: 0.25rem;
}

#mobile-state-dropdown a:hover,
#mobile-city-dropdown a:hover {
  color: var(--primary-color);
  transform: translateX(5px);
  background-color: rgba(139, 69, 19, 0.05);
}

/* Mobile menu buttons */
#mobile-state-button,
#mobile-city-button {
  transition: all 0.15s ease;
  border-radius: 0.25rem;
  padding: 0.5rem 0.75rem;
  position: relative;
  z-index: 1;
}

#mobile-state-button:hover,
#mobile-city-button:hover {
  background-color: rgba(139, 69, 19, 0.05);
}

#mobile-state-button i,
#mobile-city-button i {
  transition: transform 300ms cubic-bezier(0.34, 1.56, 0.64, 1);
  will-change: transform;
  display: inline-block;
}

#mobile-state-button.text-primary i,
#mobile-city-button.text-primary i {
  transform: rotate(180deg);
}

#mobile-menu > div {
  max-height: 100%;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--primary-color) #f1f1f1;
}
