/* ==========================================================================
   RESZON INFRASTRUCTURE - COMPREHENSIVE RESPONSIVE STYLESHEET
   Full Device Coverage: Foldables (280px) -> Phones (320px-430px) -> 
   Phablets (540px) -> Tablets (768px-1024px) -> Laptops (1280px) -> 4K (1920px+)
   ========================================================================== */

/* --------------------------------------------------------------------------
   0. Base Fluid Reset & Anti-Overflow Shield
   -------------------------------------------------------------------------- */
html,
body {
  width: 100%;
  max-width: 100%;
  overflow-x: clip !important;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html {
  scroll-behavior: smooth;
}

body {
  -webkit-overflow-scrolling: touch;
  position: relative;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Fluid Media Resets */
img,
svg,
video,
canvas,
audio,
iframe,
embed,
object {
  max-width: 100%;
  height: auto;
  vertical-align: middle;
}

/* Offset for Sticky Header */
section[id] {
  scroll-margin-top: 100px;
}

@media (max-width: 768px) {
  section[id] {
    scroll-margin-top: 80px;
  }
}

/* --------------------------------------------------------------------------
   1. Ultra-Wide & 4K Displays (1920px and above)
   -------------------------------------------------------------------------- */
@media (min-width: 1920px) {
  :root {
    --max-content-width: 1440px;
  }

  .site-container {
    max-width: var(--max-content-width);
    margin-left: auto;
    margin-right: auto;
  }
}

/* --------------------------------------------------------------------------
   2. Desktop (1440px to 1919px)
   -------------------------------------------------------------------------- */
@media (min-width: 1440px) and (max-width: 1919px) {
  :root {
    --max-content-width: 1360px;
  }

  .site-container {
    max-width: var(--max-content-width);
  }
}

/* --------------------------------------------------------------------------
   3. Laptop & Small Desktop (1024px to 1366px)
   -------------------------------------------------------------------------- */
@media (min-width: 1024px) and (max-width: 1366px) {
  .site-container {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }

  /* Safe boundary for mega menu dropdowns on 13" laptops / iPad Pro */
  .mega-menu-wrapper {
    max-width: min(720px, calc(100vw - 3rem)) !important;
  }
}

/* --------------------------------------------------------------------------
   4. Tablet & Medium Screens (768px to 1023px)
   -------------------------------------------------------------------------- */
@media (max-width: 1023px) {

  /* Desktop Menu Hidden */
  .desktop-nav-menu {
    display: none !important;
  }

  /* Mobile Toggle Hamburger Visible */
  #mobileToggleBtn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
  }

  .site-container {
    padding-left: 1.25rem;
    padding-right: 1.25rem;
  }

  /* Tablet Grids: Balanced 2-columns */
  .hero-grid {
    grid-template-columns: 1fr !important;
    gap: 2.5rem !important;
    text-align: center;
  }

  .hero-actions {
    justify-content: center;
  }

  .hero-metrics {
    justify-content: center;
  }
}

/* --------------------------------------------------------------------------
   5. Mobile Drawer Navigation Panel (Phones & Tablets <=1023px)
   -------------------------------------------------------------------------- */
@media (max-width: 1023px) {
  .mobile-drawer {
    position: fixed;
    top: 0;
    right: 0;
    left: auto;
    width: min(340px, 86vw);
    height: 100vh;
    height: 100dvh;
    background-color: var(--color-white, #ffffff);
    z-index: 1100 !important;
    transform: translateX(100%);
    visibility: hidden;
    pointer-events: none;
    transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.32s;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: max(1.25rem, env(safe-area-inset-top)) 1.25rem max(2rem, env(safe-area-inset-bottom)) 1.25rem;
    box-shadow: -8px 0 32px rgba(11, 31, 58, 0.15);
  }

  .mobile-drawer.is-open {
    transform: translateX(0);
    visibility: visible;
    pointer-events: auto;
  }

  .mobile-nav-link {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-primary-navy, #0B1F3A);
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--color-border, #E2E8F0);
    display: flex;
    align-items: center;
    justify-content: space-between;
    text-decoration: none;
    min-height: 48px;
    transition: color 0.15s ease;
  }

  .mobile-nav-link:hover,
  .mobile-nav-link.is-active {
    color: var(--color-primary-blue, #013D83);
  }

  .mobile-submenu {
    display: none;
    padding: 0.375rem 0.75rem;
    background-color: #F8FAFC;
    border-radius: 0.625rem;
    margin: 0.375rem 0;
    border: 1px solid var(--color-border, #E2E8F0);
  }

  .mobile-submenu.is-expanded {
    display: block;
  }

  .mobile-submenu-item {
    display: flex;
    align-items: center;
    min-height: 42px;
    padding: 0.45rem 0;
    font-size: 0.875rem;
    color: var(--color-text-secondary, #64748B);
    text-decoration: none;
    border-bottom: 1px dashed #E2E8F0;
    transition: color 0.15s ease;
  }

  .mobile-submenu-item:last-child {
    border-bottom: none;
  }

  .mobile-submenu-item:hover {
    color: var(--color-primary-blue, #013D83);
  }
}

/* --------------------------------------------------------------------------
   6. General Mobile (Phones <= 767px)
   -------------------------------------------------------------------------- */
@media (max-width: 767px) {
  :root {
    --header-height: 64px;
  }

  .site-container {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  /* Universal Text Wrap & Anti-Overflow on Mobile */
  h1, h2, h3, h4, h5, h6, p, div {
    overflow-wrap: break-word;
    word-break: break-word;
  }

  .grid,
  .flex {
    min-width: 0 !important;
  }

  .grid > *,
  .flex > * {
    min-width: 0 !important;
    max-width: 100% !important;
  }

  /* Fluid Responsive Typography */
  h1 {
    font-size: clamp(1.5rem, 5.2vw, 2.1rem) !important;
    line-height: 1.22 !important;
    letter-spacing: -0.02em !important;
    margin-bottom: 0.75rem !important;
  }

  h2 {
    font-size: clamp(1.25rem, 4.4vw, 1.7rem) !important;
    line-height: 1.25 !important;
  }

  /* Navbar Logo Size */
  .navbar-logo {
    height: 34px !important;
    max-width: 175px !important;
  }

  /* Domain Search Form Stacking */
  #domainSearchForm {
    flex-direction: column !important;
    padding: 0.5rem !important;
    gap: 0.5rem !important;
    border-radius: 0.875rem !important;
  }

  #domainSearchForm input {
    font-size: 0.9rem !important;
    padding-left: 2.25rem !important;
    padding-top: 0.625rem !important;
    padding-bottom: 0.625rem !important;
    width: 100% !important;
  }

  .domain-search-btn {
    width: 100% !important;
    min-height: 46px !important;
    justify-content: center !important;
    font-size: 0.9rem !important;
    padding: 0.625rem 1rem !important;
  }

  /* TLD Extension Badges */
  .tld-badges {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.5rem !important;
    width: 100% !important;
  }

  .tld-badges > span {
    grid-column: span 2 !important;
    text-align: center !important;
    margin-bottom: 0.25rem !important;
    font-size: 0.75rem !important;
  }

  .tld-chip {
    width: 100% !important;
    justify-content: center !important;
    min-height: 38px !important;
    padding: 0.4rem 0.5rem !important;
    font-size: 0.8rem !important;
  }

  /* Hero Actions Full-Width */
  .hero-actions {
    flex-direction: column !important;
    width: 100% !important;
    gap: 0.625rem !important;
    margin-bottom: 1.75rem !important;
  }

  .hero-actions .btn-primary,
  .hero-actions .btn-secondary {
    width: 100% !important;
    min-height: 46px !important;
    justify-content: center !important;
    font-size: 0.9rem !important;
  }

  /* Trust Metrics Grid: 2 columns on mobile */
  .hero-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 0.75rem !important;
    text-align: center !important;
    padding-top: 1.25rem !important;
  }

  /* Card and Provider Padding */
  .provider-card,
  .service-card {
    padding: 1.25rem 1rem !important;
  }

  /* Floating Action Buttons */
  .floating-actions {
    bottom: max(1rem, env(safe-area-inset-bottom)) !important;
    right: 0.75rem !important;
    gap: 0.5rem !important;
    z-index: 50 !important;
    align-items: flex-end !important;
  }

  .btn-floating {
    width: 44px !important;
    height: 44px !important;
  }

  .btn-floating svg {
    width: 20px !important;
    height: 20px !important;
  }

  .btn-phone-contact {
    width: 44px !important;
    min-width: 44px !important;
    height: 44px !important;
    padding: 0 !important;
    border-radius: 9999px !important;
    justify-content: center !important;
  }

  /* Footer on Mobile */
  footer .grid {
    grid-template-columns: 1fr !important;
    gap: 2rem !important;
  }

  .footer-logo {
    height: 48px !important;
  }
}

/* --------------------------------------------------------------------------
   7. Very Small Displays & Compact Phones (<= 375px: iPhone SE, Galaxy Fold cover, etc.)
   -------------------------------------------------------------------------- */
@media (max-width: 375px) {
  .site-container {
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
  }

  /* Compact Typography */
  h1 {
    font-size: 1.4rem !important;
    line-height: 1.22 !important;
    margin-bottom: 0.5rem !important;
  }

  h2 {
    font-size: 1.2rem !important;
    line-height: 1.25 !important;
  }

  #home {
    padding-top: 1.25rem !important;
    padding-bottom: 2rem !important;
  }

  /* Navbar Logo Scale on Tiny Screens */
  .navbar-logo {
    height: 30px !important;
    max-width: 155px !important;
  }

  /* Buttons Compact */
  .btn-primary,
  .btn-secondary {
    font-size: 0.825rem !important;
    padding: 0.5rem 0.75rem !important;
  }

  .tld-badges {
    grid-template-columns: 1fr !important;
  }

  .tld-badges > span {
    grid-column: span 1 !important;
  }

  .service-card,
  .provider-card {
    padding: 1rem 0.75rem !important;
  }

  .hero-metrics {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.5rem !important;
  }

  .hero-metrics > div {
    padding: 0.25rem 0.1rem !important;
  }

  .hero-metrics .text-xl {
    font-size: 1.1rem !important;
  }

  .hero-metrics .text-xs {
    font-size: 0.68rem !important;
  }
}

/* --------------------------------------------------------------------------
   8. Responsive Tables & Comparison Matrix (Swipe Enhancement)
   -------------------------------------------------------------------------- */
.overflow-x-auto {
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: #CBD5E1 transparent;
  max-width: 100%;
}

.overflow-x-auto::-webkit-scrollbar {
  height: 5px;
}

.overflow-x-auto::-webkit-scrollbar-track {
  background: transparent;
}

.overflow-x-auto::-webkit-scrollbar-thumb {
  background-color: #CBD5E1;
  border-radius: 9999px;
}

.overflow-x-auto::-webkit-scrollbar-thumb:hover {
  background-color: #94A3B8;
}

/* --------------------------------------------------------------------------
   9. Touch & Pointer Optimization (Eliminates Sticky Hover on Touchscreens)
   -------------------------------------------------------------------------- */
@media (hover: hover) and (pointer: fine) {
  .service-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-card-hover, 0 12px 30px -4px rgba(1, 61, 131, 0.14));
    border-color: rgba(1, 61, 131, 0.35);
  }

  .provider-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-card-hover, 0 12px 30px -4px rgba(1, 61, 131, 0.14));
    border-color: rgba(1, 61, 131, 0.35);
  }

  .btn-primary:hover {
    background: #002D62;
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(1, 61, 131, 0.32);
  }

  .btn-secondary:hover {
    border-color: var(--color-primary-blue, #013D83);
    color: var(--color-primary-blue, #013D83);
    background-color: #F0F6FF;
    transform: translateY(-1px);
  }

  .btn-floating:hover {
    transform: scale(1.08);
  }
}

/* Touch Active Feedback */
@media (hover: none) {
  .service-card:active,
  .provider-card:active,
  .btn-primary:active,
  .btn-secondary:active {
    transform: scale(0.985);
  }
}

/* --------------------------------------------------------------------------
   10. Touch Target Accessibility (Targeted Correctly, No Global <a> Bloat)
   -------------------------------------------------------------------------- */
button,
.btn-primary,
.btn-secondary,
.btn-outline-sm,
.nav-link,
.mobile-nav-link,
.mobile-submenu-item,
input[type="submit"],
input[type="button"],
.clickable {
  min-height: 44px;
}

/* --------------------------------------------------------------------------
   11. Print Mode Optimization
   -------------------------------------------------------------------------- */
@media print {
  .header-sticky,
  .floating-actions,
  #mobileToggleBtn,
  .mobile-drawer,
  #site-preloader,
  .toast-notice {
    display: none !important;
  }

  body {
    background: #FFF;
    color: #000;
  }

  .service-card,
  .provider-card {
    box-shadow: none !important;
    border: 1px solid #CCC !important;
    page-break-inside: avoid;
  }
}
