/**
 * Disney Holiday Transfer - Responsive Design & Mobile Viewport Rules
 * Calibrated across 360px, 390px, 480px, 768px, 1024px, 1280px, 1440px, and 1920px.
 * Eliminates horizontal page overflow, clipped dropdowns, and broken card layouts.
 */

/* =========================================================================
   1. Global Overflow Prevention
   ========================================================================= */
html, body {
  overflow-x: hidden !important;
  max-width: 100vw !important;
  position: relative;
}

*, *::before, *::after {
  max-width: 100%;
}

/* Allow auto max-width on structural table elements and flex items */
table, tr, td, th, img, svg, iframe, canvas {
  max-width: 100%;
}

/* =========================================================================
   2. Responsive Grid Layouts
   ========================================================================= */
.dht-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-lg);
}

.dht-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-lg);
}

.dht-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-lg);
}

/* =========================================================================
   3. Breakpoint: Large Screens (1440px - 1920px+)
   ========================================================================= */
@media (min-width: 1440px) {
  .site-container,
  .dht-container,
  .dht-shell,
  .dht-footer-container {
    width: 1280px !important;
  }
}

@media (min-width: 861px) {
  .dht-mobile-menu {
    display: none !important;
  }
}

/* =========================================================================
   4. Breakpoint: Laptops & Tablets Landscape (max-width: 1024px)
   ========================================================================= */
@media (max-width: 1024px) {
  .dht-grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-md);
  }

  .dht-grid-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-md);
  }

  .dht-cta-banner {
    flex-direction: column;
    text-align: center;
    align-items: center;
  }

  .dht-cta-banner__actions {
    justify-content: center;
  }
}

/* =========================================================================
   5. Breakpoint: Tablets Portrait & Large Mobile (max-width: 860px / 768px)
   ========================================================================= */
@media (max-width: 860px) {
  /* Header adjustments */
  .dht-header-spacer {
    height: 93px;
  }

  .dht-topbar {
    height: 32px;
    line-height: 32px;
    padding: 0;
    margin: 0;
    font-size: 11.5px;
  }

  .dht-nav {
    padding: 10px 0;
    margin: 0;
  }

  .dht-topbar__address {
    display: none !important;
  }

  .dht-topbar__email a {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
    vertical-align: middle;
  }

  /* Desktop Menu hidden, Hamburger visible */
  .dht-menu {
    display: none !important;
  }

  .dht-hamburger {
    display: flex !important;
  }

  /* Mobile menu dropdown */
  .dht-mobile-menu {
    display: block;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    width: 100%;
    background-color: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--color-border);
    box-shadow: 0 16px 36px rgba(16, 27, 44, 0.14);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    pointer-events: none;
    transition: opacity 0.16s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.16s cubic-bezier(0.16, 1, 0.3, 1),
                visibility 0.16s ease;
    will-change: opacity, transform;
    max-height: calc(100vh - 75px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    z-index: 999;
  }

  .dht-mobile-menu.is-active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
  }

  .dht-mobile-menu__inner {
    padding: 16px 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 4px;
  }

  .dht-mobile-link {
    display: flex;
    align-items: center;
    padding: 12px 14px;
    font-family: var(--font-heading);
    font-size: 15px;
    font-weight: var(--fw-semibold);
    color: var(--color-brand-navy);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    text-decoration: none;
  }

  .dht-mobile-link:hover,
  .dht-mobile-link:active {
    background-color: var(--color-surface-subtle);
    color: var(--color-brand-primary);
    padding-left: 18px;
  }

  .dht-mobile-menu__cta {
    margin-top: 12px;
    padding-top: 14px;
    border-top: 1px solid var(--color-border);
  }

  /* Footer stacking */
  #dht-custom-footer .dht-footer-grid {
    grid-template-columns: 1fr !important;
    gap: 36px !important;
  }

  #dht-custom-footer .dht-footer-bottom-inner {
    flex-direction: column;
    gap: 12px;
    text-align: center;
  }
}

@media (max-width: 768px) {
  /* Grids collapse to single column */
  .dht-grid-4,
  .dht-grid-3,
  .dht-grid-2 {
    grid-template-columns: 1fr;
    gap: var(--space-md);
  }

  /* Section Spacing on tablet */
  .dht-section {
    padding: clamp(40px, 7vw, 60px) 0;
  }

  .dht-section-header {
    margin-bottom: var(--space-xl);
  }

  /* Buttons on tablet/mobile */
  .dht-btn-group {
    flex-direction: column;
    width: 100%;
  }

  .dht-btn-group .dht-btn {
    width: 100%;
  }

  /* Booking form container */
  .jb-wrapper {
    margin: 12px auto !important;
    border-radius: var(--radius-lg) !important;
    border-left: none !important;
    border-right: none !important;
  }

  .jb-steps {
    padding: 14px 18px 12px !important;
  }

  .jb-steps::before {
    left: 36px !important;
    right: 36px !important;
  }

  .jb-step-name {
    font-size: 10px !important;
  }

  .jb-step {
    padding: 16px 14px !important;
  }
}

/* =========================================================================
   6. Breakpoint: Standard Mobile (max-width: 480px)
   ========================================================================= */
@media (max-width: 480px) {
  :root {
    --container-gutter: 16px;
    --site-container: min(1280px, calc(100% - 32px));
  }

  /* Typography downscaling for small devices */
  h1, .dht-h1, .dht-title-hero {
    font-size: clamp(1.75rem, 6.5vw, 2.2rem) !important;
    line-height: 1.18 !important;
  }

  h2, .dht-h2, .dht-section-title {
    font-size: clamp(1.4rem, 5.2vw, 1.75rem) !important;
    line-height: 1.25 !important;
  }

  h3, .dht-h3, .dht-card-title {
    font-size: clamp(1.15rem, 4.2vw, 1.35rem) !important;
  }

  /* Touch buttons expand to comfortable tap size */
  .dht-btn {
    width: 100%;
    min-height: 48px;
    padding: 12px 20px;
    font-size: 14.5px;
  }

  .dht-logo img {
    height: 40px !important;
    max-width: 180px !important;
  }

  /* Booking steps compact view */
  .jb-step-name {
    display: none !important; /* Icons/numbers only on mobile to prevent overlapping */
  }

  .jb-step-number {
    width: 30px !important;
    height: 30px !important;
    font-size: 12px !important;
  }

  /* Table wrapper padding */
  .dht-table-responsive {
    margin-inline: -16px;
    width: calc(100% + 32px);
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  .dht-table th,
  .dht-table td {
    padding: 10px 14px;
    font-size: 13px;
  }

  /* Floating WhatsApp icon */
  a[aria-label="Contact on WhatsApp"] {
    width: 48px !important;
    height: 48px !important;
    bottom: 18px !important;
    right: 18px !important;
  }

  a[aria-label="Contact on WhatsApp"] svg {
    width: 26px !important;
    height: 26px !important;
  }
}

/* =========================================================================
   7. Breakpoint: Compact Mobile (360px & 390px - e.g. iPhone SE, Galaxy S)
   ========================================================================= */
@media (max-width: 390px) {
  :root {
    --container-gutter: 14px;
    --site-container: min(1280px, calc(100% - 28px));
  }

  .dht-topbar {
    font-size: 10.5px;
  }

  .dht-topbar__email a {
    max-width: 135px;
  }

  .dht-logo img {
    height: 36px !important;
    max-width: 155px !important;
  }

  /* Form inputs fit nicely (16px prevents iOS Safari auto-zoom; exclude tel input to preserve dial-code padding) */
  input:not([type="tel"]), select, textarea,
  .dht-input, .dht-select, .dht-textarea {
    font-size: 16px !important;
    height: 44px !important;
    min-height: 44px !important;
    padding: 8px 12px !important;
  }

  .dht-card {
    padding: 18px 14px !important;
  }
}
