/*
 * Oncafactory exact coverage v1
 * Homepage-only layout correction. Existing content, assets, links and DOM stay authoritative.
 */

/* The custom homepage template does not carry Mercury's no-title body class. */
body.home.codex-visual-system .space-page-section-ins {
  padding-top: 0;
}

/* Header geometry already matches the measured reference; only stabilize its current controls. */
body.home.codex-visual-system .space-header-height.enable-top-bar,
body.home.codex-visual-system .space-header-height.enable-top-bar .space-header-wrap {
  min-height: 109px;
}

/* The fixed inner header is 80px; do not carry the desktop placeholder height into sticky mode. */
body.home.codex-visual-system .space-header-height.enable-top-bar .space-header-wrap.fixed {
  height: 80px;
  min-height: 80px;
}

body.home.codex-visual-system .space-header-top {
  min-height: 29px;
}

body.home.codex-visual-system .space-header,
body.home.codex-visual-system .space-header-ins,
body.home.codex-visual-system .space-header-menu,
body.home.codex-visual-system .space-header-menu > ul.main-menu {
  min-height: 80px;
}

body.home.codex-visual-system .space-header-logo img {
  display: block;
  width: 173px;
  height: 40px;
  max-width: 100%;
  object-fit: contain;
}

body.home.codex-visual-system .space-header-menu > ul.main-menu > li > a {
  min-height: 80px;
  padding: 31px 15px;
  line-height: 16px;
  white-space: nowrap;
}

body.home.codex-visual-system .space-header-top-soc a,
body.home.codex-visual-system .space-header-top-soc .fab,
body.home.codex-visual-system .space-header-top-soc .fa-brands {
  min-width: 12px;
  min-height: 29px;
  line-height: 29px;
}

body.home.codex-visual-system .space-header-search,
body.home.codex-visual-system .space-header-search .desktop-search-button {
  width: 21.328px;
  height: 21.328px;
  line-height: 21.328px;
}

/* All three existing top-level covers use their own current images and copy. */
body.home.codex-visual-system .space-page-content > .wp-block-cover.alignfull {
  position: relative;
  display: flex;
  width: 100vw;
  max-width: 100vw;
  margin-right: calc(50% - 50vw);
  margin-left: calc(50% - 50vw);
  padding: 0;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  color: #fff;
}

body.home.codex-visual-system .space-page-content > .wp-block-cover.alignfull > .wp-block-cover__image-background {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  object-position: 50% 50%;
}

body.home.codex-visual-system .space-page-content > .wp-block-cover.alignfull > .wp-block-cover__background {
  position: absolute;
  inset: 0;
  z-index: 1;
}

body.home.codex-visual-system .space-page-content > .wp-block-cover.alignfull > .wp-block-cover__inner-container {
  position: relative;
  z-index: 2;
  width: 100%;
  color: inherit;
}

body.home.codex-visual-system .space-page-content > .wp-block-cover.alignfull h1,
body.home.codex-visual-system .space-page-content > .wp-block-cover.alignfull h2,
body.home.codex-visual-system .space-page-content > .wp-block-cover.alignfull h3,
body.home.codex-visual-system .space-page-content > .wp-block-cover.alignfull p {
  color: inherit;
}

/* First cover: the existing flow produces the measured 684.6px desktop height once the image leaves flow. */
body.home.codex-visual-system .space-page-content > .wp-block-cover:first-child .wp-block-cover__inner-container {
  width: 1200px;
  max-width: calc(100% - 30px);
  margin-inline: auto;
}

body.home.codex-visual-system .space-page-content > .wp-block-cover:first-child p.has-medium-font-size {
  line-height: 37px;
}

body.home.codex-visual-system .space-page-content > .wp-block-cover:first-child + .wp-block-spacer {
  height: 14px !important;
}

/* Match the measured gap before the first existing organization list without adding content. */
body.home.codex-visual-system .space-page-content > .wp-block-cover:first-child + .wp-block-spacer + h2 + .space-shortcode-11 {
  padding-top: 23.2px;
}

/* The two later existing banners carry min-height:600px inline. */
body.home.codex-visual-system .space-page-content > .wp-block-cover.alignfull[style*="min-height:600px"] {
  min-height: 600px;
}

/* Restore the missing generated layout behavior, but only for homepage top-level column blocks. */
@media (min-width: 782px) {
  body.home.codex-visual-system .space-page-content > .wp-block-columns {
    display: flex;
    flex-wrap: nowrap;
    gap: 32px;
  }

  body.home.codex-visual-system .space-page-content > .wp-block-columns > .wp-block-column {
    min-width: 0;
    flex: 1 1 0;
  }
}

/* Existing images are only constrained inside the nine measured top-level column groups. */
body.home.codex-visual-system .space-page-content > .wp-block-columns > .wp-block-column .wp-block-image {
  max-width: 100%;
}

body.home.codex-visual-system .space-page-content > .wp-block-columns > .wp-block-column .wp-block-image img {
  display: block;
  max-width: 100%;
  height: auto;
}

body.home.codex-visual-system .space-page-content > .wp-block-columns > .wp-block-column .wp-block-image .aligncenter,
body.home.codex-visual-system .space-page-content > .wp-block-columns > .wp-block-column figure.aligncenter {
  margin-right: auto;
  margin-left: auto;
}

body.home.codex-visual-system .space-page-content > .wp-block-columns > .wp-block-column figure.aligncenter {
  display: table;
  width: fit-content;
  max-width: 100%;
}

body.home.codex-visual-system .space-page-content > .wp-block-columns > .wp-block-column figure.aligncenter > a {
  display: inline-block;
}

/* Restore the theme's reference reading rhythm while preserving every text node. */
body.home.codex-visual-system .space-page-content p {
  line-height: 1.85em;
}

/* Existing CTA wrappers lost their generated center-justification rule. */
body.home.codex-visual-system .space-page-content > .wp-block-buttons.is-content-justification-center {
  display: flex;
  justify-content: center;
}

/* Existing organization cards keep every item and natural wrapper height. */
body.home.codex-visual-system .space-shortcode-11 .space-organizations-8-archive-item {
  min-width: 0;
}

body.home.codex-visual-system .space-shortcode-11 .space-organizations-8-archive-item img {
  object-fit: cover;
}

body.home.codex-visual-system .space-shortcode-11 .star-rating,
body.home.codex-visual-system .space-shortcode-11 .space-organizations-8-archive-item-stars-rating {
  white-space: nowrap;
}

/* Tablet and phone: retain the existing DOM and let every measured group flow without overflow. */
@media (max-width: 781px) {
  body.home.codex-visual-system .space-header-height.enable-top-bar,
  body.home.codex-visual-system .space-header-height.enable-top-bar .space-header-wrap,
  body.home.codex-visual-system .space-header,
  body.home.codex-visual-system .space-header-ins {
    min-height: 60px;
  }

  body.home.codex-visual-system .space-header-top {
    display: none;
  }

  /* Prevent the inline-block page section from creating a 20px baseline gap below the header. */
  body.home.codex-visual-system .space-page-section {
    display: inline-block;
    vertical-align: top;
  }

  body.home.codex-visual-system .space-header-logo img {
    width: min(173px, 60vw);
    height: auto;
    max-height: 40px;
  }

  body.home.codex-visual-system .space-page-content > .wp-block-cover.alignfull {
    width: 100vw;
    max-width: 100vw;
    margin-right: calc(50% - 50vw);
    margin-left: calc(50% - 50vw);
  }

  body.home.codex-visual-system .space-page-content > .wp-block-cover:first-child .wp-block-cover__inner-container {
    width: calc(100% - 30px);
  }

  body.home.codex-visual-system .space-page-content > .wp-block-cover:first-child h1 {
    font-size: clamp(28px, 8vw, 36px);
    line-height: 1.1;
  }

  body.home.codex-visual-system .space-page-content > .wp-block-cover:first-child p.has-medium-font-size {
    font-size: 20px !important;
    line-height: 1.85;
  }

  /* The source heading contains indentation whitespace; keep the existing text on one measured line. */
  body.home.codex-visual-system .space-page-content > .wp-block-cover:first-child + .wp-block-spacer + h2 {
    white-space: nowrap;
    letter-spacing: -0.5px;
  }

  body.home.codex-visual-system .space-page-content > .wp-block-columns {
    display: block;
  }

  body.home.codex-visual-system .space-page-content > .wp-block-columns > .wp-block-column {
    width: 100%;
    max-width: 100%;
    margin-bottom: 24px;
  }
}
