/* Header */
header {
  background: var(--white);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 1000;
  transition: var(--transition);
}

/* iOS safe-area and performance tweaks */
:root {
  /* ensure we can use safe-area-inset variables on iOS */
  --safe-top: env(safe-area-inset-top, 0px);
}

.header-container {
  /* max-width: 1200px; */
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(5px + var(--safe-top)) 20px 5px 20px;
  -webkit-backface-visibility: hidden;
  /* improve rendering on iOS */
  backface-visibility: hidden;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  flex-wrap: nowrap;
  /* prevent automatic wrapping on some iOS widths */
}

/* Logo */
.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  min-width: 0;
  /* allow flex children to shrink correctly on iOS */
  white-space: nowrap;
  /* keep logo text on one line */
}


.logo-icon {
  /* fixed square container for the logo image to avoid layout jumps */
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  flex: 0 0 50px;
  /* do not allow the icon to shrink or grow */
}

.logo-img {
  /* preserve intrinsic aspect ratio and avoid stretching */
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
  -webkit-user-drag: none;
}

.logo-text {
  font-size: 24px;
  font-weight: bolder;
  color: var(--primary);
  letter-spacing: -0.5px;
  /* keep the logo text from forcing layout expansion */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.logo-text span {
  color: var(--secondary);
  font-weight: bold;
}

/* Navigation */
nav {
  display: flex;
  align-items: center;
  gap: 30px;
  min-width: 0;
  /* prevents flex children from forcing overflow on iOS */
  white-space: nowrap;
  /* keep nav items in a single row unless collapsed */
}

nav a {
  text-decoration: none;
  color: var(--dark);
  font-weight: 500;
  font-size: 16px;
  position: relative;
  padding: 8px 0;
  transition: var(--transition);
}

nav a::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--primary);
  transition: var(--transition);
}

nav a:hover {
  color: var(--primary);
}

nav a:hover::after {
  width: 100%;
}

nav a.active {
  color: var(--primary);
}

nav a.active::after {
  width: 100%;
}

/* CTA Button (shared) */
.cta-btn {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: var(--white);
  padding: 10px 24px;
  border-radius: 30px;
  text-decoration: none;
  font-weight: 600;
  font-size: 15px;
  transition: var(--transition);
  box-shadow: 0 4px 15px rgba(139, 69, 19, 0.2);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.cta-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(139, 69, 19, 0.3);
}

/* Mobile Menu */
.menu-btn {
  display: none;
  background: none;
  border: none;
  font-size: 24px;
  color: var(--primary);
  cursor: pointer;
  transition: var(--transition);
  -webkit-tap-highlight-color: transparent;
  /* remove tap highlight on iOS */
}

/* Ensure flex children can shrink and avoid overflow issues on iOS */
.header-container>* {
  min-width: 0;
}

.menu-btn:hover {
  color: var(--secondary);
}

.mobile-menu {
  display: none;
  flex-direction: column;
  background: var(--white);
  padding: 20px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
  animation: slideDown 0.3s ease-out;
  width: 100%;
  box-sizing: border-box;
}

.mobile-menu a {
  padding: 12px 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  text-decoration: none;
  color: var(--dark);
  font-weight: 500;
  transition: var(--transition);
}

.mobile-menu a:hover {
  color: var(--primary);
  padding-left: 10px;
}

.mobile-menu a:last-child {
  border-bottom: none;
  margin-top: 10px;
}

/* Animations */
@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Footer */
footer {
  background: var(--dark);
  color: var(--white);
  padding: 60px 20px 30px;
}

.footer-content {
  /* max-width: 1200px; */
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 40px;
  margin-bottom: 40px;
}

.footer-column h3 {
  font-size: 1.3rem;
  margin-bottom: 20px;
  position: relative;
  padding-bottom: 10px;
}

.footer-column h3::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  width: 40px;
  height: 2px;
  background: var(--accent);
}

.footer-column p {
  margin-bottom: 20px;
  opacity: 0.8;
}

.footer-links {
  list-style: none;
}

.footer-links li {
  margin-bottom: 12px;
}

.footer-links a {
  color: var(--white);
  text-decoration: none;
  opacity: 0.8;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 8px;
}

.footer-links a:hover {
  opacity: 1;
  padding-left: 5px;
}

.social-links {
  display: flex;
  gap: 15px;
  margin-top: 20px;
}

.social-links a {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  text-decoration: none;
  transition: var(--transition);
}

.social-links a:hover {
  background: var(--primary);
  transform: translateY(-3px);
}

.footer-bottom {
  /* max-width: 1200px; */
  margin: 0 auto;
  text-align: center;
  padding-top: 30px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  opacity: 0.7;
  font-size: 14px;
}

/* Scroll to Top Button */
.scroll-to-top {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 55px;
  height: 55px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: var(--white);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 20px;
  box-shadow: 0 8px 25px rgba(139, 69, 19, 0.4);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  opacity: 0;
  visibility: hidden;
  transform: translateY(30px) scale(0.8);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(10px);
  border: 2px solid rgba(255, 255, 255, 0.1);
}

.scroll-to-top.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.scroll-to-top:hover {
  transform: translateY(-5px) scale(1.05);
  box-shadow: 0 12px 35px rgba(139, 69, 19, 0.5);
  background: linear-gradient(135deg, var(--secondary), var(--primary));
  border-color: rgba(255, 255, 255, 0.2);
}

.scroll-to-top:active {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 8px 25px rgba(139, 69, 19, 0.6);
}

.scroll-to-top i {
  transition: transform 0.3s ease;
}

.scroll-to-top:hover i {
  transform: translateY(-2px);
}

/* Pulse animation for attention */
@keyframes pulse {
  0% {
    box-shadow: 0 8px 25px rgba(139, 69, 19, 0.4);
  }

  50% {
    box-shadow: 0 8px 25px rgba(139, 69, 19, 0.6), 0 0 0 10px rgba(139, 69, 19, 0.1);
  }

  100% {
    box-shadow: 0 8px 25px rgba(139, 69, 19, 0.4);
  }
}

.scroll-to-top.pulse {
  animation: pulse 2s infinite;
}

/* Responsive */
@media (max-width: 768px) {
  nav {
    display: none;
  }

  .menu-btn {
    display: block;
  }

  .mobile-menu.show {
    display: flex;
  }

  .scroll-to-top {
    bottom: 25px;
    right: 25px;
    width: 50px;
    height: 50px;
    font-size: 18px;
    box-shadow: 0 6px 20px rgba(139, 69, 19, 0.4);
  }
}

/* Extra small screens (phones) - ensure logo does not stretch and text scales down */
@media (max-width: 480px) {
  .logo-icon {
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
  }

  .logo-text {
    font-size: 18px;
    /* allow a little breathing room but still prevent wrapping */
    max-width: calc(100vw - 140px);
  }

  .header-container {
    padding-left: 12px;
    padding-right: 12px;
    gap: 8px;
  }

  /* ensure menu button has room without pushing logo */
  .menu-btn {
    font-size: 22px;
  }
}

/* Tighten header for very narrow/small phones (iPhone SE / narrow Safari views) */
@media (max-width: 420px) {
  .header-container {
    padding: calc(8px + var(--safe-top)) 12px 8px 12px;
    gap: 8px;
  }

  .logo {
    gap: 8px;
    white-space: nowrap;
    flex: 0 0 auto;
    /* don't allow logo to grow */
    align-items: center;
  }

  .logo-icon {
    height: 40px;
    min-width: 40px;
    max-width: 40px;
  }

  .logo-text {
    font-size: 18px;
    line-height: 1;
    font-weight: 800;
    letter-spacing: -0.4px;
  }

  .logo-text span {
    font-size: 16px;
  }

  /* Ensure nav is hidden and menu visible earlier if needed */
  nav {
    display: none;
  }

  .menu-btn {
    display: block;
  }

  /* Reduce the header icons and controls size so the layout stays on one line */
  .menu-btn i {
    font-size: 20px;
  }
}

/* Prevent iOS from auto-sizing text unexpectedly */
html,
body {
  -webkit-text-size-adjust: 100%;
}