/* ============================================================
   Safari & Cross-Browser Compatibility Fixes
   Getap Resort & Spa
   ============================================================ */

/* ── Smooth Scroll & Scrollbar Polish ────────────────────────────── */

/* Prevent overscroll bounce on Chrome/Firefox (Safari keeps its
   native rubber-band which feels intentional on iOS) */
html:not([data-safari]) {
  overscroll-behavior: none;
}

/* Reserve space so fixed nav doesn't overlap anchor targets */
html {
  scroll-padding-top: 80px;
}

/* Sections get a scroll-margin fallback for the same reason */
section {
  scroll-margin-top: 72px;
}

/* Custom gold scrollbar — only shown on non-touch, non-Safari browsers
   where the scrollbar is visible by default */
@media (hover: hover) and (pointer: fine) {
  html:not([data-safari]) ::-webkit-scrollbar {
    width: 5px;
  }
  html:not([data-safari]) ::-webkit-scrollbar-track {
    background: transparent;
  }
  html:not([data-safari]) ::-webkit-scrollbar-thumb {
    background: rgba(212, 175, 53, 0.35);
    border-radius: 3px;
    transition: background 0.2s ease;
  }
  html:not([data-safari]) ::-webkit-scrollbar-thumb:hover {
    background: rgba(212, 175, 53, 0.65);
  }
}

/* Firefox scrollbar styling */
html:not([data-safari]) {
  scrollbar-width: thin;
  scrollbar-color: rgba(212, 175, 53, 0.35) transparent;
}

/* Smoother image transitions — prevent layout shift during lazy load */
img {
  display: block;
  max-width: 100%;
}
img[loading="lazy"] {
  content-visibility: auto;
}

/* 1. iOS Safari: fix 100vh to account for browser chrome */
@supports (-webkit-touch-callout: none) {
  /* Using -webkit-fill-available can cause 0px height if parents are not explicitly sized.
     We rely on default 100vh or newer svh/dvh units in the main CSS instead. */
}

/* 2. Safari: position sticky with webkit prefix */
.sticky {
  position: -webkit-sticky;
  position: sticky;
}

/* 3. Safari: inset shorthand expansion for class-based usage */
.inset-0 {
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
}

/* 4. Safari: -webkit-backdrop-filter alongside backdrop-filter */
.backdrop-blur-2xl {
  -webkit-backdrop-filter: blur(40px);
  backdrop-filter: blur(40px);
}
.backdrop-blur-xl {
  -webkit-backdrop-filter: blur(24px);
  backdrop-filter: blur(24px);
}
.backdrop-blur-md {
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}
.backdrop-blur-sm {
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

/* 5. Safari: smooth scroll */
html {
  -webkit-overflow-scrolling: touch;
}

/* 6. Safari: aspect-ratio fallback for older versions */
@supports not (aspect-ratio: 4/3) {
  [style*="aspect-ratio"] {
    position: relative;
    width: 100%;
  }
  [style*="aspect-ratio"]::before {
    content: '';
    display: block;
    padding-top: 75%; /* 4:3 ratio fallback */
  }
  [style*="aspect-ratio"] > * {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
  }
}

/* 7. Safari: flex gap fallback for Safari < 14.1 */
@supports not (gap: 1rem) {
  .flex > * + * { margin-left: 1rem; }
  .flex-col > * + * { margin-top: 1rem; margin-left: 0; }
}

/* 8. iOS: remove tap highlight color */
* {
  -webkit-tap-highlight-color: transparent;
}

/* 9. Safari: text rendering */
body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* 10. Safari: animation with -webkit prefix */
@-webkit-keyframes igDot {
  0%, 100% { opacity: 1; -webkit-transform: scale(1); transform: scale(1); }
  50% { opacity: 0.35; -webkit-transform: scale(0.7); transform: scale(0.7); }
}
@keyframes igDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.7); }
}

@-webkit-keyframes barTickerAnim {
  from { -webkit-transform: translateX(0); transform: translateX(0); }
  to { -webkit-transform: translateX(-50%); transform: translateX(-50%); }
}
@keyframes barTickerAnim {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

/* 11. Safari: fix position fixed inside transformed elements */
[data-fixed-nav] {
  position: fixed;
  -webkit-transform: none;
  transform: none;
}

/* 12. Safari: mix-blend-mode compatibility */
[style*="mix-blend-mode"] {
  isolation: isolate;
}

/* 13. iOS: momentum scrolling for scroll containers */
.overflow-y-auto,
.overflow-auto,
.overflow-scroll {
  -webkit-overflow-scrolling: touch;
}

/* 14. Safari: ensure parallax hero containers clip correctly
   NOTE: Only applied to specific parallax containers — NOT to all sections.
   Applying translate3d to all sections caused GPU compositing layer conflicts
   that rendered sections as solid black in Safari. */
[data-parallax-container] {
  -webkit-mask-image: -webkit-radial-gradient(white, black);
}
