/* ========================================================
   MOBILE TOUCH OPTIMIZATION
   Fixes dead clicks and improves mobile user experience
   Based on Microsoft Clarity data showing 8.52% dead clicks
   ======================================================== */

/* TOUCH TARGET SIZING - WCAG 2.1 AAA Compliance */
.mobile-touch-optimized {
  /* All interactive elements should have minimum 44x44px touch targets */
  --touch-min: 44px;
  --touch-comfortable: 48px;
  --touch-spacious: 56px;
}

/* BUTTON TOUCH TARGETS */
button,
.button,
.btn,
.cta-button,
[role="button"],
input[type="submit"],
input[type="button"],
a[onclick] {
  min-height: var(--touch-min);
  min-width: var(--touch-min);
  padding: 12px 20px;
  position: relative;

  /* Prevent accidental zoom on double-tap */
  touch-action: manipulation;

  /* Better tap feedback */
  -webkit-tap-highlight-color: rgba(217, 119, 6, 0.2);
  transition: background-color 0.2s ease, transform 0.1s ease;
}

button:active,
.button:active,
.btn:active {
  transform: scale(0.98);
  background-color: rgba(217, 119, 6, 0.9);
}

/* LINK TOUCH TARGETS */
a {
  min-height: var(--touch-min);
  display: inline-flex;
  align-items: center;
  padding: 8px 4px;
  text-decoration: none;
}

/* Navigation Links */
nav a,
.menu-link,
.nav-link {
  min-height: var(--touch-comfortable);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  width: 100%;
}

/* FORM ELEMENTS - Mobile Optimization */
input,
select,
textarea {
  min-height: var(--touch-min);
  padding: 12px 16px;
  font-size: 16px !important; /* Prevents iOS zoom */
  touch-action: manipulation;
  border: 1px solid #d1d5db;
  border-radius: 8px;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid #d97706;
  outline-offset: 2px;
  border-color: #d97706;
}

/* CHECKBOXES AND RADIO BUTTONS */
input[type="checkbox"],
input[type="radio"] {
  width: 24px;
  height: 24px;
  min-width: 24px;
  min-height: 24px;
  margin: 10px;
  cursor: pointer;
}

/* LABEL TOUCH TARGETS */
label {
  display: flex;
  align-items: center;
  min-height: var(--touch-min);
  padding: 8px 0;
  cursor: pointer;
}

label:has(input[type="checkbox"]),
label:has(input[type="radio"]) {
  padding-left: 40px;
  position: relative;
}

label:has(input[type="checkbox"])::before,
label:has(input[type="radio"])::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
}

/* DROPDOWN MENUS - Mobile Optimization */
.select-wrapper,
.dropdown,
.select-menu {
  position: relative;
  min-height: var(--touch-comfortable);
}

.select-wrapper select,
.dropdown select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
}

/* MOBILE MENU TOGGLE */
.menu-toggle,
.hamburger,
.mobile-menu-button {
  width: var(--touch-comfortable);
  height: var(--touch-comfortable);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  background: transparent;
  padding: 0;
}

/* ICON BUTTONS - Enlarged touch targets */
.icon-button,
.button-icon,
social-icon,
.close-button {
  width: var(--touch-comfortable);
  height: var(--touch-comfortable);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: transparent;
  border: none;
  cursor: pointer;
  border-radius: 50%;
  transition: background-color 0.2s ease;
}

.icon-button:hover,
.icon-button:active {
  background-color: rgba(217, 119, 6, 0.1);
}

/* CARD INTERACTIVE ELEMENTS */
.tour-card,
.blog-card,
.service-card {
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.tour-card:active,
.blog-card:active,
.service-card:active {
  transform: scale(0.98);
}

/* ACCORDION AND EXPANDABLES */
.accordion-toggle,
.accordion-header,
.expand-trigger {
  min-height: var(--touch-comfortable);
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
}

/* TABS - Mobile Optimization */
.tab-button,
.tab-link {
  min-height: var(--touch-min);
  min-width: var(--touch-min);
  padding: 12px 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
}

/* SLIDERS AND CAROUSELS - Touch-friendly */
.slider-button,
.carousel-control,
.gallery-nav {
  width: var(--touch-comfortable);
  height: var(--touch-comfortable);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  touch-action: manipulation;
}

/* PAGINATION */
.pagination-link,
.page-number,
.paging-button {
  min-width: var(--touch-min);
  min-height: var(--touch-min);
  padding: 12px 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
}

/* MODAL AND DIALOG TRIGGERS */
.modal-trigger,
.dialog-open,
.lightbox-link {
  min-height: var(--touch-min);
  min-width: var(--touch-min);
  padding: 12px 16px;
  cursor: pointer;
  touch-action: manipulation;
}

/* CTA BUTTONS - Enhanced mobile experience */
.cta-primary,
.cta-secondary,
.action-button {
  min-height: var(--touch-spacious);
  padding: 16px 24px;
  font-size: 16px;
  font-weight: 600;
  border-radius: 12px;
  touch-action: manipulation;
  transition: all 0.2s ease;
}

.cta-primary:active,
.cta-secondary:active {
  transform: scale(0.96);
  box-shadow: none;
}

/* FORM SUBMIT BUTTONS */
form button[type="submit"],
form .submit-button {
  width: 100%;
  min-height: var(--touch-spacious);
  padding: 16px 24px;
  font-size: 16px;
  font-weight: 600;
  border-radius: 12px;
  margin-top: 16px;
  touch-action: manipulation;
}

/* GEOGRAPHIC CTAs - Mobile specific */
.geographic-ctas .cta-button {
  width: 100%;
  min-height: var(--touch-spacious);
  padding: 16px 20px;
  font-size: 16px;
  margin-bottom: 12px;
  touch-action: manipulation;
}

/* MOBILE-SPECIFIC FIXES */
@media (max-width: 768px) {
  /* Ensure adequate spacing between touch targets */
  .button + .button,
  .cta-button + .cta-button,
  a + a,
  button + button {
    margin-top: 12px;
  }

  /* Prevent text selection during interaction */
  .interactive-element {
    user-select: none;
    -webkit-user-select: none;
  }

  /* Better spacing for stacked elements */
  .stacked-interactive {
    display: flex;
    flex-direction: column;
    gap: 16px;
  }

  /* Enhanced touch feedback */
  * {
    -webkit-tap-highlight-color: rgba(217, 119, 6, 0.15);
  }

  /* Prevent accidental interactions */
  .prevent-double-tap-zoom {
    touch-action: manipulation;
  }

  /* Safe area for modern phones with notches */
  .safe-area-inset {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }

  .safe-area-inset-top {
    padding-top: env(safe-area-inset-top);
  }

  .safe-area-inset-bottom {
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* ACCESSIBILITY - Focus visible for keyboard navigation */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid #d97706;
  outline-offset: 2px;
  border-radius: 4px;
}

/* REDUCED MOTION - Respect user preferences */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* DARK MODE - Touch targets remain visible in dark mode */
@media (prefers-color-scheme: dark) {
  .icon-button:hover,
  .icon-button:active {
    background-color: rgba(217, 119, 6, 0.2);
  }
}

/* HIGH CONTRAST MODE */
@media (prefers-contrast: high) {
  button,
  a,
  input,
  select,
  textarea {
    border: 2px solid currentColor;
  }
}

/* CRITICAL: Prevent iOS Safari click delays */
* {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

input,
textarea,
[contenteditable] {
  -webkit-user-select: text;
  user-select: text;
}

/* Prevent text selection on buttons during interaction */
button,
.button,
.btn {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* FIXED: Mobile menu interaction issues */
.mobile-menu {
  touch-action: pan-y;
  overscroll-behavior: contain;
}

.mobile-menu a,
.mobile-menu button {
  width: 100%;
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(217, 119, 6, 0.2);
}

/* FIXED: Dead clicks on tour cards */
.tour-card,
.blog-card {
  -webkit-tap-highlight-color: rgba(217, 119, 6, 0.15);
  touch-action: manipulation;
}

.tour-card a,
.blog-card a {
  pointer-events: none; /* Prevent child link interference */
}

.tour-card > a,
.blog-card > a {
  pointer-events: auto; /* Re-enable main card link */
  display: block;
  min-height: var(--touch-min);
}

/* PERFORMANCE: Reduce repaint on scroll */
.position-sticky-below-header {
  will-change: transform;
}

/* SAFARI SPECIFIC FIXES */
@supports (-webkit-touch-callout: none) {
  /* Safari-specific touch target sizing */
  button,
  a,
  input,
  select {
    min-height: 44px;
  }
}

/* LANDSCAPE MODE - Better touch targets in landscape */
@media (max-height: 600px) and (orientation: landscape) {
  button,
  .cta-button,
  .action-button {
    min-height: 40px;
    padding: 10px 16px;
  }
}

/* DEBUG: Visual feedback for touch targets (remove in production) */
/*
.show-touch-targets button,
.show-touch-targets a,
.show-touch-targets input {
  outline: 2px dashed red;
  outline-offset: 2px;
}
*/