/* ═══════════════════════════════════════════════════════════
   COMPREHENSIVE RESPONSIVE FIXES
   Addressing low-resolution displays and cross-browser issues
   ═══════════════════════════════════════════════════════════ */

/* Critical viewport fixes */
html {
  scroll-behavior: smooth;
  max-width: 100%;
  overflow-x: clip;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html, body {
  overflow-x: hidden;
  max-width: 100vw;
}

body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  overscroll-behavior-x: none;
}

* {
  box-sizing: border-box;
}

/* Prevent layout shift */
img, video, iframe, embed, object {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Container improvements */
.container {
  width: min(var(--container, 1180px), calc(100% - clamp(24px, 4vw, 64px)));
  margin-inline: auto;
  padding-inline: clamp(16px, 3vw, 24px);
}

/* Section spacing */
.section {
  padding-block: clamp(36px, 6vw, 72px);
}

/* Typography improvements */
body {
  font-size: clamp(0.9rem, 1.5vw, 1rem);
  line-height: 1.75;
}

h1, h2, h3, h4, h5, h6 {
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
  line-height: 1.3;
}

h1 {
  font-size: clamp(1.75rem, 4vw, 3rem);
}

h2 {
  font-size: clamp(1.5rem, 3.5vw, 2.4rem);
}

h3 {
  font-size: clamp(1.25rem, 2.5vw, 1.8rem);
}

p {
  max-width: 75ch;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* Touch target improvements */
a, button, .btn, input[type="submit"], input[type="button"] {
  min-height: 44px;
  min-width: 44px;
  -webkit-tap-highlight-color: rgba(94, 163, 255, 0.2);
}

.btn {
  min-height: 48px;
  padding: clamp(12px, 1.5vw, 16px) clamp(20px, 3vw, 32px);
  font-size: clamp(0.9rem, 1.5vw, 1rem);
  border-radius: clamp(12px, 1.5vw, 16px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
}

/* Header improvements */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(9, 17, 31, 0.96);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.nav-shell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(12px, 2vw, 20px);
  padding-block: clamp(12px, 2vw, 16px);
  flex-wrap: nowrap;
}

.brand {
  flex-shrink: 0;
  max-width: min(100%, 400px);
}

.site-logo {
  max-height: clamp(32px, 5vw, 42px);
  width: auto;
  height: auto;
}

/* Navigation improvements */
@media (max-width: 980px) {
  .nav-shell > .nav-actions {
    display: none;
  }

  .nav-toggle {
    margin-inline-start: auto;
    flex-shrink: 0;
  }

  .brand {
    max-width: calc(100% - 80px);
  }
}

/* Site banner improvements */
.site-banner {
  position: relative;
  width: 100%;
  padding: clamp(8px, 1.5vw, 12px) 0;
  background: linear-gradient(135deg, rgba(47, 125, 240, 0.18), rgba(68, 215, 182, 0.12)), rgba(15, 26, 47, 0.95);
  border-bottom: 1px solid rgba(94, 163, 255, 0.18);
  z-index: 48;
}

.site-banner-inner {
  display: flex;
  align-items: center;
  gap: clamp(10px, 2vw, 16px);
  flex-wrap: nowrap;
  min-height: 42px;
}

.site-banner-copy {
  display: flex;
  align-items: center;
  gap: clamp(8px, 1.5vw, 12px);
  flex: 1;
  min-width: 0;
}

.site-banner-text {
  font-size: clamp(0.85rem, 1.5vw, 0.95rem);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.site-banner-close {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
}

/* Home hero improvements */
.home-hero {
  padding-block: clamp(32px, 5vw, 64px);
}

.home-hero-shell {
  display: grid;
  grid-template-columns: 1fr;
  gap: clamp(28px, 5vw, 48px);
  align-items: start;
}

@media (min-width: 1025px) {
  .home-hero-shell {
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
    align-items: center;
  }
}

.home-hero-copy h1 {
  font-size: clamp(1.75rem, 4vw, 3.2rem);
  line-height: 1.35;
  margin: 0 0 clamp(12px, 2vw, 20px) 0;
}

.home-hero-copy .lead {
  font-size: clamp(1rem, 1.8vw, 1.15rem);
  line-height: 1.75;
  margin: 0 0 clamp(16px, 3vw, 24px) 0;
}

/* Hero actions */
.hero-actions {
  display: flex;
  gap: clamp(12px, 2vw, 16px);
  flex-wrap: wrap;
  margin-bottom: clamp(20px, 3vw, 32px);
}

.hero-actions .btn {
  padding: clamp(12px, 1.5vw, 16px) clamp(24px, 3vw, 36px);
  font-size: clamp(0.95rem, 1.5vw, 1.05rem);
}

/* Hero visual improvements */
.hero-logo-stage {
  position: relative;
  min-height: auto;
  padding: clamp(24px, 4vw, 48px);
  border-radius: clamp(24px, 3vw, 44px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(20px, 3vw, 32px);
}

.hero-logo-core {
  position: relative;
  width: clamp(120px, 18vw, 200px);
  height: clamp(120px, 18vw, 200px);
  flex-shrink: 0;
}

.hero-floating-card,
.hero-curved-panel {
  position: static;
  width: 100%;
  max-width: 100%;
  padding: clamp(16px, 2.5vw, 22px);
  margin: 0;
}

/* Grid improvements */
.home-proof-grid,
.featured-home-plans,
.plans-grid,
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
  gap: clamp(18px, 3vw, 28px);
}

.home-proof-card,
.plan-card,
.feature-card {
  padding: clamp(18px, 3vw, 28px);
  border-radius: clamp(18px, 2.5vw, 24px);
}

/* Form improvements */
input, select, textarea {
  min-height: 48px;
  padding: clamp(12px, 1.5vw, 16px);
  font-size: clamp(0.9rem, 1.5vw, 1rem);
  border-radius: clamp(12px, 1.5vw, 14px);
  border: 1.5px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  color: #edf3ff;
  width: 100%;
}

input:focus, select:focus, textarea:focus {
  outline: 0;
  border-color: #5ea3ff;
  background: rgba(255, 255, 255, 0.07);
  box-shadow: 0 0 0 4px rgba(94, 163, 255, 0.15);
}

/* Table responsiveness */
table {
  width: 100%;
  border-collapse: collapse;
  overflow-x: auto;
  display: block;
}

@media (max-width: 768px) {
  table {
    font-size: 0.9rem;
  }
}

/* Footer improvements */
.site-footer {
  padding-block: clamp(32px, 5vw, 56px);
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr));
  gap: clamp(24px, 4vw, 40px);
}

/* Low resolution specific fixes (1366x768 and below) */
@media (max-width: 1366px) {
  .container {
    width: min(var(--container, 1180px), calc(100% - 40px));
  }

  .pricing-grid {
    grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
  }

  .home-hero-shell {
    gap: 32px;
  }
}

/* Tablet landscape (1024px) */
@media (max-width: 1024px) {
  .container {
    width: min(var(--container, 1180px), calc(100% - 32px));
  }

  .section {
    padding-block: clamp(32px, 5vw, 56px);
  }

  .home-hero-shell {
    grid-template-columns: 1fr;
    gap: 28px;
  }

  .pricing-grid,
  .featured-home-plans {
    grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
    gap: 22px;
  }
}

/* Tablet portrait (768px) */
@media (max-width: 768px) {
  .container {
    width: calc(100% - 24px);
    padding-inline: 12px;
  }

  .section {
    padding-block: clamp(28px, 5vw, 48px);
  }

  .home-hero {
    padding-block: clamp(24px, 4vw, 40px);
  }

  .hero-actions {
    flex-direction: column;
    width: 100%;
  }

  .hero-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .home-proof-grid,
  .featured-home-plans,
  .pricing-grid {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .nav-shell {
    padding-block: 12px;
  }

  .site-logo {
    max-height: 36px;
  }
}

/* Mobile (480px and below) */
@media (max-width: 480px) {
  .container {
    width: calc(100% - 16px);
    padding-inline: 8px;
  }

  .section {
    padding-block: clamp(24px, 5vw, 40px);
  }

  .home-hero {
    padding-block: 20px;
  }

  .home-hero-copy h1 {
    font-size: clamp(1.5rem, 6vw, 2rem);
  }

  .home-hero-copy .lead {
    font-size: 0.95rem;
  }

  .btn {
    min-height: 46px;
    padding: 12px 20px;
    font-size: 0.92rem;
  }

  .hero-actions .btn {
    padding: 13px 24px;
  }

  .home-proof-card,
  .plan-card,
  .feature-card {
    padding: 16px;
    border-radius: 18px;
  }

  .site-logo {
    max-height: 32px;
  }

  .site-banner-text {
    font-size: 0.82rem;
  }

  input, select, textarea {
    min-height: 46px;
    padding: 11px 14px;
    font-size: 0.92rem;
  }
}

/* Very small screens (360px and below) */
@media (max-width: 360px) {
  .container {
    width: calc(100% - 12px);
    padding-inline: 6px;
  }

  .home-hero-copy h1 {
    font-size: 1.4rem;
  }

  .btn {
    min-height: 44px;
    padding: 11px 18px;
    font-size: 0.9rem;
  }
}

/* Accessibility improvements */
:focus-visible {
  outline: 2px solid #5ea3ff;
  outline-offset: 3px;
  border-radius: 4px;
}

@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;
  }
}

/* Print styles */
@media print {
  .site-header,
  .site-footer,
  .site-banner,
  .nav-toggle,
  .back-to-top {
    display: none !important;
  }

  body {
    background: white;
    color: black;
  }

  .container {
    width: 100%;
    max-width: 100%;
  }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }
}
