/* Responsive rules are intentionally loaded last. */
html {
  /* Prevent transient animation transforms from creating a horizontal page scroll. */
  overflow-x: clip;
}
@media (min-width: 1600px) {
  :root { --content-max: 1760px; --page-gutter: 72px; }
  .hero-grid { grid-template-columns: minmax(0, 1.08fr) minmax(520px, 0.92fr); }
  .visual-core { width: min(100%, 600px); }
  .visual-orbit { width: 540px; height: 540px; }
}

@media (max-width: 1280px) {
  :root { --page-gutter: clamp(28px, 3.2vw, 48px); }
  .hero-grid { grid-template-columns: minmax(0, 1fr) minmax(420px, 0.88fr); gap: 42px; }
  .hero-visual { min-height: 510px; }
  .visual-core { width: min(100%, 520px); }
  .visual-orbit { width: 460px; height: 460px; }
  .site-header .nav-links { gap: 18px; }
  .site-header .nav-actions { margin-left: 0; }

  /* Service detail sections need more flexible columns before the tablet layout. */
  .service-feature {
    grid-template-columns: minmax(0, 1fr) minmax(0, 0.9fr);
    gap: clamp(32px, 4vw, 56px);
  }
}

@media (max-width: 1100px) {
  .cards,
  .industry-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .feature-split { gap: 36px; }
  .footer-grid { grid-template-columns: 1.2fr 0.9fr 0.9fr 1fr; }
  .footer-grid > div:last-child { grid-column: auto; }
  .service-feature {
    grid-template-columns: minmax(0, 1fr);
    gap: 30px;
  }
}

@media (max-width: 1024px) {
  :root { --page-gutter: 28px; }
  .hero-grid { grid-template-columns: 1fr; gap: 36px; }
  .hero-copy { max-width: 820px; }
  .hero-visual { width: 100%; max-width: 720px; min-height: 490px; margin: 0 auto; }
  .feature-split,
  .two-col,
  .contact-grid { grid-template-columns: 1fr; }
  .process { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .footer-grid { grid-template-columns: 1.2fr 1fr 1fr; }
  .footer-grid > div:nth-child(4),
  .footer-grid > div:nth-child(5) { grid-column: auto; }
}

@media (max-width: 900px) {
  :root { --page-gutter: 20px; }
  .site-header .container { padding-right: 18px; padding-left: 18px; }
  .nav-links {
    position: fixed;
    top: 86px;
    right: 16px;
    left: 16px;
    display: grid;
    gap: 6px;
    padding: 14px;
    pointer-events: none;
    background: rgba(6, 16, 29, 0.98);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: var(--shadow);
    opacity: 0;
    transform: translateY(-8px);
    transition: 0.2s ease;
    backdrop-filter: blur(18px);
  }
  .nav-links.open { pointer-events: auto; opacity: 1; transform: none; }
  .nav-links:not(.open) .nav-dropdown-menu { pointer-events: none; }
  .nav-links a { padding: 10px 12px; border-radius: 10px; }
  .nav-links a:hover { background: rgba(255, 255, 255, 0.04); }
  .nav-dropdown { display: grid; gap: 2px; }
  .nav-dropdown-menu {
    position: static;
    right: auto;
    left: auto;
    display: none;
    width: 100%;
    min-width: 0;
    gap: 2px;
    margin: 0;
    padding: 4px 0 8px;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    opacity: 1;
    pointer-events: none;
    transform: none !important;
    visibility: visible;
    backdrop-filter: none;
  }
  .nav-dropdown.is-touch-open .nav-dropdown-menu {
    display: grid;
    pointer-events: auto;
  }
  .nav-dropdown-menu a {
    width: 100%;
    padding: 10px 22px;
    font-size: 0.86rem;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .nav-dropdown::after { display: none; }
  .menu-toggle { display: block; }
  .nav-actions .btn { display: none; }
  .site-header .nav-actions { margin-left: 12px; }
  .hero { min-height: auto; padding-top: 54px; }
  .feature-split.reverse .aegis-panel { order: 2; }
  .cta { flex-direction: column; align-items: flex-start; }
  .footer-grid { grid-template-columns: 1.2fr 1fr; }
  .footer-grid > div:nth-child(n + 3) { grid-column: auto; }
}

@media (hover: none), (pointer: coarse) {
  /* Keep the smallest touch targets comfortably reachable on phones and tablets. */
  .carousel-dot { width: 44px; height: 44px; }
  .footer-social-link { flex-basis: 44px; width: 44px; height: 44px; }
  .footer-links a {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
  }
}

@media (max-width: 640px) {
  :root { --page-gutter: 14px; }
  .container { width: calc(100% - 28px); }
  .section { padding: 74px 0; }
  .section-sm { padding: 54px 0; }
  .nav-wrap { min-height: 68px; }
  .brand-logo { width: 180px; }
  .hero { padding: 46px 0 52px; }
  .hero-grid { gap: 28px; }
  h1 { font-size: clamp(2.55rem, 12vw, 3.65rem); }
  h2 { font-size: clamp(2rem, 9vw, 2.8rem); }
  .hero-actions { display: grid; grid-template-columns: 1fr; }
  .btn { width: 100%; }
  .services-hero .breadcrumb,
  .legal-hero .breadcrumb,
  .footer-links a { overflow-wrap: anywhere; }
  .services-hero h1,
  .legal-hero h1,
  .page-hero h1,
  .service-feature-copy h2 { overflow-wrap: anywhere; }
  .trust-row { gap: 10px 16px; }
  .hero-visual { min-height: 405px; }
  .visual-orbit { width: 330px; height: 330px; }
  .visual-core { width: 100%; min-height: 330px; border-radius: 22px; transform: none; }
  .visual-body { grid-template-columns: 1fr; padding: 12px; }
  .metric-stack { grid-template-columns: 1fr 1fr; }
  .event-card { grid-column: 1 / -1; }
  .float-chip { font-size: 0.72rem; }
  .float-chip.one { top: 60px; left: -4px; }
  .float-chip.two { right: -4px; bottom: 40px; }
  .logo-strip-grid { grid-template-columns: 1fr 1fr; }
  .logo-strip-item { border-bottom: 1px solid var(--line); }
  .logo-strip-item:nth-child(even) { border-right: 0; }
  .logo-strip-item:last-child { grid-column: 1 / -1; }
  .cards,
  .industry-grid,
  .product-grid,
  .process { grid-template-columns: 1fr; }
  .aegis-panel { min-height: 390px; }
  .cta { padding: 28px 20px; border-radius: 24px; }
  .form-card { padding: 22px; }
  .form-grid { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
  /* Phone footer: center every column while keeping desktop and tablet untouched. */
  .footer-grid {
    grid-template-columns: 1fr;
    gap: 22px;
    padding: 42px 0 30px;
    text-align: center;
  }
  .footer-grid > div { justify-items: center; }
  /* The Services column is redundant with the primary navigation on phones. */
  .footer-grid > div:nth-child(2) { display: none; }
  .footer-bottom { min-height: 68px; padding: 18px 0; }
  .footer-brand { max-width: none; }
  .footer-brand .brand { margin-right: 0; }
  .footer-brand p { margin-right: auto; margin-left: auto; }
  .footer-title { margin-bottom: 12px; }
  .footer-links { justify-items: center; gap: 4px; }
  .footer-social-links { justify-content: center; }
  .service-feature { padding: 24px 0; }
  .service-feature-media,
  .service-feature-media img {
    height: clamp(230px, 72vw, 300px);
    min-height: 0;
  }
}

@media (max-width: 380px) {
  :root { --page-gutter: 12px; }
  .container { width: calc(100% - 24px); }
  .brand-logo { width: 165px; }
  .hero-visual { min-height: 375px; }
  .visual-orbit { width: 290px; height: 290px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .js .reveal { opacity: 1; transform: none; }
}
