/**
 * Platform-wide responsive add-on (loaded after page styles).
 * Additive overrides only — does not replace existing rules unless needed for layout.
 */

/* Stable mobile viewport unit (set by platform-enhancements.js --jm-vh) */
:root {
  --jm-vh: 1vh;
}

/* Optional full-viewport sections (uses JS-updated --jm-vh) */
.jm-min-h-screen {
  min-height: calc(var(--jm-vh, 1vh) * 100);
}

/* ---------- Global ---------- */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* Anchor links land below fixed navbars */
  scroll-padding-top: 5.5rem;
}

@media (max-width: 900px) {
  html {
    /* Nav + trust rail (when present) */
    scroll-padding-top: 6.75rem;
  }
}

/* ---------- Sticky / fixed navigation (all pages using .navbar or .nav) ---------- */
.navbar,
.nav {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  width: 100% !important;
  max-width: 100vw !important;
  z-index: 100030 !important;
  box-sizing: border-box !important;
}

/* Ensure mobile full-screen menu overlays stay above page chrome */
.navbar .nav-links.active,
.nav .nav-links.active,
.nav-mobile.active {
  z-index: 100031 !important;
}

img,
video,
canvas {
  max-width: 100%;
  height: auto;
}

/* ---------- Fixed chrome: safe areas + touch-friendly ---------- */
@media (max-width: 992px) {
  .navbar,
  .nav {
    padding-left: max(1rem, env(safe-area-inset-left, 0px)) !important;
    padding-right: max(1rem, env(safe-area-inset-right, 0px)) !important;
  }

  .whatsapp-float {
    bottom: max(1rem, env(safe-area-inset-bottom, 0px)) !important;
    right: max(1rem, env(safe-area-inset-right, 0px)) !important;
  }
}

/* ---------- Home / index-style pages (shared class names) ---------- */
@media (max-width: 1200px) {
  .hero-gradient {
    max-width: min(800px, 95vw);
    max-height: min(800px, 95vw);
  }
}

@media (max-width: 768px) {
  .hero {
    padding-top: clamp(100px, 18vw, 120px) !important;
    padding-left: clamp(1rem, 5vw, 5%) !important;
    padding-right: clamp(1rem, 5vw, 5%) !important;
  }

  /* Hero: tighter vertical rhythm on tablet / mobile */
  .hero-stats {
    flex-direction: row !important;
    justify-content: space-between !important;
    gap: 0.5rem !important;
    align-items: flex-start !important;
    width: 100%;
    max-width: 24rem;
    margin-left: auto !important;
    margin-right: auto !important;
  }

  .hero-stats .stat-number {
    font-size: clamp(1.55rem, 5vw, 2.25rem) !important;
  }

  .hero-stats .stat-label {
    font-size: 0.7rem !important;
  }

  .hero-quick-links {
    gap: 0.45rem 0.75rem !important;
    font-size: 0.85rem !important;
  }

  .hero-promise {
    padding: 0.95rem 1rem !important;
    font-size: 0.85rem !important;
  }

  .portfolio-header {
    flex-direction: column;
    align-items: flex-start !important;
  }

  .testimonial-card {
    margin-left: 0 !important;
    margin-right: 0 !important;
  }
}

@media (max-width: 480px) {
  .hero-title {
    font-size: clamp(1.65rem, 9vw, 2.5rem) !important;
    word-wrap: break-word;
  }

  .section-title {
    font-size: clamp(1.45rem, 7vw, 2rem) !important;
    word-wrap: break-word;
  }

  .urgent-title {
    font-size: clamp(1.35rem, 6vw, 2rem) !important;
  }

  /* Keep stats on one compact row — less vertical crowding on small screens */
  .hero-stats {
    flex-direction: row !important;
    justify-content: space-between !important;
    gap: 0.35rem !important;
    align-items: flex-start !important;
    width: 100%;
    max-width: 22rem;
    margin-left: auto !important;
    margin-right: auto !important;
  }

  .hero-stats .stat-item {
    flex: 1;
    min-width: 0;
  }

  .hero-stats .stat-number {
    font-size: clamp(1.5rem, 7vw, 2rem) !important;
  }

  .hero-stats .stat-label {
    font-size: 0.65rem !important;
    line-height: 1.25;
  }

  .hero-quick-links {
    gap: 0.4rem 0.65rem !important;
    font-size: 0.8rem !important;
    justify-content: center !important;
  }

  .hero-promise {
    padding: 0.85rem 0.95rem !important;
    font-size: 0.8rem !important;
    gap: 0.45rem !important;
  }

  .hero-promise__item {
    line-height: 1.35 !important;
  }

  .stat-card .stat-number {
    font-size: clamp(2.25rem, 12vw, 3.5rem) !important;
  }

  .cta-title {
    font-size: clamp(1.45rem, 6vw, 2rem) !important;
  }

  .whatsapp-float {
    width: 52px !important;
    height: 52px !important;
    font-size: 1.45rem !important;
  }

  .preloader-logo {
    font-size: clamp(1.75rem, 8vw, 3rem) !important;
  }

  .trusted-logos {
    gap: 1.5rem !important;
  }
}

/* ---------- About page: mobile nav overlay (JS toggles .active on .nav-links) ---------- */
@media (max-width: 768px) {
  .navbar .nav-links.active {
    display: flex !important;
    flex-direction: column;
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    margin: 0;
    padding: max(5rem, env(safe-area-inset-top)) 1.5rem 2rem !important;
    background: rgba(10, 10, 15, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 10000;
    justify-content: flex-start;
    align-items: center;
    gap: 1.5rem;
    list-style: none;
    overflow-y: auto;
  }

  .navbar .nav-links.active a {
    font-size: 1.25rem !important;
  }

  .navbar .nav-container {
    position: relative;
    z-index: 10001;
  }

  .mobile-toggle {
    z-index: 10002;
    position: relative;
  }

  .story-highlights {
    grid-template-columns: 1fr !important;
  }

  .skill-header {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 0.35rem;
  }
}

/* ---------- Contact page ---------- */
@media (max-width: 1024px) {
  .contact-form-container {
    padding: clamp(1.5rem, 4vw, 3rem) !important;
  }

  div[style*="grid-template-columns:repeat(3,1fr)"] {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  div[style*="grid-template-columns:repeat(4,1fr)"] {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 600px) {
  div[style*="grid-template-columns:repeat(3,1fr)"],
  div[style*="grid-template-columns:repeat(4,1fr)"] {
    grid-template-columns: 1fr !important;
  }

  .page-hero h1 {
    font-size: clamp(1.6rem, 7vw, 2.2rem) !important;
  }

  .info-card a {
    font-size: clamp(0.95rem, 3.5vw, 1.1rem) !important;
    word-break: break-word;
  }
}

@media (max-width: 480px) {
  .map-info {
    padding: clamp(1.25rem, 4vw, 3rem) !important;
  }

  .map-frame {
    min-height: 280px !important;
  }

  .faq-question {
    padding: 1.25rem 1.25rem !important;
    font-size: 0.95rem !important;
  }
}

/* ---------- Services & Portfolio (nav + inline grids) ---------- */
@media (max-width: 1024px) {
  div[style*="grid-template-columns:repeat(4,1fr)"] {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  div[style*="grid-template-columns:repeat(3,1fr)"] {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 640px) {
  div[style*="grid-template-columns:repeat(4,1fr)"],
  div[style*="grid-template-columns:repeat(3,1fr)"] {
    grid-template-columns: 1fr !important;
  }

  .service-visual-card {
    padding: clamp(1.25rem, 4vw, 3rem) !important;
  }

  .service-visual-stat {
    flex-wrap: wrap !important;
    justify-content: center;
    gap: 1rem !important;
  }
}

@media (max-width: 480px) {
  .stats-bar .stats-grid,
  .stats-grid {
    grid-template-columns: 1fr !important;
    gap: 1.25rem !important;
  }

  .hero-stats {
    gap: 1rem !important;
  }

  .filter-bar {
    padding-left: clamp(0.75rem, 3vw, 2rem) !important;
    padding-right: clamp(0.75rem, 3vw, 2rem) !important;
  }

  .project-actions {
    flex-direction: column !important;
  }

  .project-actions a {
    width: 100%;
  }
}

/* ---------- Tables: ensure scroll wrapper can shrink on small screens ---------- */
@media (max-width: 768px) {
  [style*="overflow-x:auto"] {
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
  }

  .comparison-table {
    min-width: 520px;
  }
}

/* ---------- Landscape phones ---------- */
@media (max-height: 500px) and (orientation: landscape) {
  .page-hero,
  .hero {
    min-height: unset !important;
    padding-top: 5rem !important;
    padding-bottom: 2rem !important;
  }

  .mobile-menu {
    padding-top: 4rem !important;
  }
}

/* ---------- Coarse pointers: slightly larger tap targets ---------- */
@media (pointer: coarse) {
  .filter-btn,
  .btn,
  .burger,
  .mobile-toggle {
    min-height: 44px;
    min-width: 44px;
  }

  .nav-menu a,
  .mobile-nav a {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
}

/* ---------- Mobile gutters & overflow (prevents edge clipping / horizontal scroll) ---------- */
html {
  overflow-x: hidden;
}

body {
  overflow-x: hidden;
  /* 100vw includes scrollbar width on some browsers — causes horizontal jump */
  max-width: 100%;
}

/* Home / shared hero */
.hero {
  padding-left: max(1rem, env(safe-area-inset-left));
  padding-right: max(1rem, env(safe-area-inset-right));
  box-sizing: border-box;
}

.trusted {
  padding-left: max(1rem, env(safe-area-inset-left));
  padding-right: max(1rem, env(safe-area-inset-right));
  box-sizing: border-box;
}

.enterprise-proof {
  padding-left: max(1rem, env(safe-area-inset-left));
  padding-right: max(1rem, env(safe-area-inset-right));
  box-sizing: border-box;
}

.enterprise-inner {
  padding-left: 0.2rem;
  padding-right: 0.2rem;
}

@media (max-width: 768px) {
  .enterprise-proof {
    padding-top: clamp(3rem, 10vw, 5rem) !important;
    padding-bottom: clamp(3rem, 10vw, 5rem) !important;
  }

  .proof-metric {
    padding: 1.1rem 0.75rem !important;
  }

  .proof-metric span {
    font-size: 0.74rem !important;
    line-height: 1.35 !important;
  }

  .enterprise-cta {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
    max-width: 22rem;
    margin-left: auto !important;
    margin-right: auto !important;
  }

  .enterprise-cta .btn {
    width: 100%;
    justify-content: center;
    min-height: 48px;
  }

  .nav-container {
    padding-left: max(0.65rem, env(safe-area-inset-left)) !important;
    padding-right: max(0.65rem, env(safe-area-inset-right)) !important;
  }

  .page-hero {
    padding-left: max(1rem, env(safe-area-inset-left)) !important;
    padding-right: max(1rem, env(safe-area-inset-right)) !important;
  }
}

@media (max-width: 480px) {
  .footer-bottom {
    gap: 0.85rem !important;
  }

  .footer-bottom-left {
    min-width: 0 !important;
  }
}

/* Home hero: stacked CTAs on narrow phones */
@media (max-width: 640px) {
  .hero-buttons {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    max-width: 22rem;
    margin-left: auto;
    margin-right: auto;
    gap: 0.65rem !important;
  }

  .hero-buttons .btn {
    width: 100%;
    justify-content: center;
    min-height: 48px;
    box-sizing: border-box;
  }

  .hero-description,
  .hero-offer,
  .hero-promise {
    max-width: 100% !important;
  }
}
