/* Touch Device Enhancements */

/* Improve touch scrolling */
* {
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
}

a, button, input, textarea, select {
  -webkit-tap-highlight-color: rgba(176, 123, 58, 0.3);
}

/* Smooth scrolling for touch */
.scroll-container,
.overflow-scroll {
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

/* Better touch targets */
@media (max-width: 768px) {
  /* Minimum 44x44px touch targets */
  a:not(.no-touch-target),
  button:not(.no-touch-target),
  .clickable:not(.no-touch-target) {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* Increase spacing between interactive elements */
  .btn + .btn,
  a + a,
  button + button {
    margin-left: 8px;
  }

  /* Better form controls */
  input[type="checkbox"],
  input[type="radio"] {
    min-width: 24px;
    min-height: 24px;
    cursor: pointer;
  }

  /* Prevent double-tap zoom on buttons */
  button,
  .btn,
  input[type="submit"],
  input[type="button"] {
    touch-action: manipulation;
  }

  /* Better select dropdowns */
  select {
    min-height: 44px;
    padding: 12px;
    font-size: 16px;
  }

  /* Improve carousel/slider touch */
  .carousel,
  .slider,
  .gallery-carousel-panel {
    touch-action: pan-x pan-y;
    -webkit-overflow-scrolling: touch;
  }

  /* Better modal close buttons */
  .modal-close,
  .lightbox-close {
    min-width: 44px;
    min-height: 44px;
    font-size: 24px;
  }

  /* Improve table scrolling */
  .table-responsive {
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x;
  }

  /* Better video controls */
  video::-webkit-media-controls {
    transform: scale(1.2);
  }

  /* Improve image zoom/pinch */
  img {
    touch-action: manipulation;
  }

  /* Better horizontal scroll indicators */
  .scroll-container::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 40px;
    background: linear-gradient(to left, rgba(247, 239, 228, 0.9), transparent);
    pointer-events: none;
  }

  /* Sticky elements on mobile */
  .sticky-mobile {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg, #f3ece3);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  }

  /* Better focus states for accessibility */
  a:focus,
  button:focus,
  input:focus,
  textarea:focus,
  select:focus {
    outline: 2px solid var(--honey, #b07b3a);
    outline-offset: 2px;
  }

  /* Improve swipe gestures */
  .swipeable {
    touch-action: pan-y;
    user-select: none;
  }

  /* Better loading states */
  .loading {
    pointer-events: none;
    opacity: 0.6;
  }

  /* Improve pull-to-refresh */
  /* ОТКЛЮЧЕНО: может блокировать scroll на некоторых мобильных браузерах */
  /* body {
    overscroll-behavior-y: contain;
  } */

  /* Better safe area handling for notched devices */
  @supports (padding: max(0px)) {
    body {
      padding-left: max(0px, env(safe-area-inset-left));
      padding-right: max(0px, env(safe-area-inset-right));
    }

    .site-header,
    .admin-layout {
      padding-left: max(16px, env(safe-area-inset-left));
      padding-right: max(16px, env(safe-area-inset-right));
    }

    .sidebar {
      padding-left: max(20px, env(safe-area-inset-left));
    }
  }

  /* Improve landscape mode */
  @media (orientation: landscape) and (max-height: 500px) {
    .hero-poster-card {
      min-height: 80vh;
    }

    .modal-content {
      max-height: 90vh;
      overflow-y: auto;
    }

    .sidebar {
      height: 100vh;
      overflow-y: auto;
    }
  }

  /* Better dark mode support */
  @media (prefers-color-scheme: dark) {
    .scroll-container::after {
      background: linear-gradient(to left, rgba(43, 22, 18, 0.9), transparent);
    }
  }

  /* Reduce motion for accessibility */
  @media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
      scroll-behavior: auto !important;
    }
  }
}

/* iOS specific fixes */
@supports (-webkit-touch-callout: none) {
  /* Fix iOS input zoom */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="tel"],
  input[type="url"],
  textarea,
  select {
    font-size: 16px !important;
  }

  /* Fix iOS button appearance */
  button,
  input[type="submit"],
  input[type="button"] {
    -webkit-appearance: none;
    appearance: none;
  }

  /* Fix iOS select appearance */
  select {
    -webkit-appearance: none;
    appearance: none;
    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='%232b1612' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
  }

  /* Fix iOS sticky positioning */
  .sticky-mobile {
    position: -webkit-sticky;
    position: sticky;
  }
}

/* Android specific fixes */
@media (max-width: 768px) {
  /* Fix Android select appearance */
  select {
    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='%232b1612' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
  }

  /* Fix Android input appearance */
  input,
  textarea {
    -webkit-appearance: none;
    appearance: none;
  }
}

/* Neutralize contact link shifting from a + a */
.contact-link {
  margin-left: 0 !important;
}
