/* KX_TOP_SPACING_NORMALIZER_V1
   Purpose: normalize and minimize vertical spacing between navbar/top bar and page content.
   Scope: layout spacing only. Does not alter navbar menu items, links, language selector, theme selector, or content.
*/

:root {
  --kx-topbar-content-gap: 0px;
  --kx-first-section-gap: 8px;
  --kx-hero-top-padding: 12px;
}

/* Remove default document gaps. */
html,
body {
  margin-top: 0 !important;
}

body {
  padding-top: 0 !important;
}

/* Normalize common content wrappers immediately after nav/header. */
body > main:first-of-type,
body > .main:first-of-type,
body > .page:first-of-type,
body > .page-shell:first-of-type,
body > .content:first-of-type,
body > .app:first-of-type,
body > #app:first-of-type,
body > #root:first-of-type {
  margin-top: var(--kx-topbar-content-gap) !important;
  padding-top: var(--kx-topbar-content-gap) !important;
}

/* If page shell follows navbar/header directly, compress the gap. */
nav + main,
nav + section,
nav + div,
header + main,
header + section,
header + div,
.navbar + main,
.navbar + section,
.navbar + div,
.site-navbar + main,
.site-navbar + section,
.site-navbar + div,
.site-header + main,
.site-header + section,
.site-header + div,
.topbar + main,
.topbar + section,
.topbar + div {
  margin-top: var(--kx-topbar-content-gap) !important;
  padding-top: var(--kx-first-section-gap) !important;
}

/* Normalize hero/top page sections across pages. */
.hero,
.hero-section,
.platform-hero,
.landing-hero,
.page-hero,
.kx-hero,
.kernex-hero,
section.hero,
main > section:first-child,
main > .section:first-child,
main > .hero:first-child,
main > .page-hero:first-child,
main > .platform-hero:first-child {
  margin-top: 0 !important;
  padding-top: var(--kx-hero-top-padding) !important;
}

/* Reduce accidental oversized spacer blocks after navbars. */
nav + .spacer,
header + .spacer,
.navbar + .spacer,
.site-navbar + .spacer,
.site-header + .spacer,
.topbar + .spacer {
  height: 0 !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* Avoid double gap from fixed/sticky navbar helper classes. */
body.navbar-fixed,
body.has-navbar,
body.has-header,
body.with-navbar,
body.with-header,
body.kip-global-navbar-active {
  padding-top: 0 !important;
}

/* Keep top navigation compact without changing menu contents. */
nav,
header,
.navbar,
.site-navbar,
.site-header,
.topbar {
  margin-bottom: 0 !important;
}

/* Mobile gap normalization. */
@media (max-width: 900px) {
  :root {
    --kx-first-section-gap: 4px;
    --kx-hero-top-padding: 8px;
  }

  body > main:first-of-type,
  body > .main:first-of-type,
  body > .page:first-of-type,
  body > .content:first-of-type,
  body > #app:first-of-type,
  body > #root:first-of-type {
    margin-top: 0 !important;
    padding-top: 0 !important;
  }

  .hero,
  .hero-section,
  .platform-hero,
  .landing-hero,
  .page-hero,
  .kx-hero,
  .kernex-hero,
  main > section:first-child {
    margin-top: 0 !important;
    padding-top: 8px !important;
  }
}
