/* =====================================================
   CATHOLICG33K CORE 0.7.4 — SHELL POSITIONING
   Header is top:0 by default.
   Only a positively detected, visibly hit-testable WordPress
   toolbar may move it down.
===================================================== */

:root {
  --cg33k-toolbar-offset: 0px;
}

html,
body {
  /* Do not let a hidden WordPress front-end toolbar reserve space. */
  --wp-admin--admin-bar--height: 0px;
}

body .cg-header {
  top: var(--cg33k-toolbar-offset, 0px) !important;
  margin-top: 0 !important;
}

/*
 * When Core has positively confirmed a visible toolbar, JS supplies
 * the actual offset and marks the document accordingly.
 */
html.cg33k-toolbar-visible {
  --wp-admin--admin-bar--height: var(--cg33k-toolbar-offset, 0px);
}

/*
 * Hidden/missing toolbar state.
 * Deliberately do NOT hide #wpadminbar here; doing so would make
 * visibility detection self-referential and prevent later re-detection.
 */
html:not(.cg33k-toolbar-visible),
html.cg33k-toolbar-hidden {
  margin-top: 0 !important;
  padding-top: 0 !important;
  --wp-admin--admin-bar--height: 0px !important;
}

body:not(.cg33k-toolbar-visible),
body.cg33k-toolbar-hidden,
body.admin-bar.cg33k-toolbar-hidden {
  margin-top: 0 !important;
  padding-top: 0 !important;
}


/* =====================================================
   MAJOR RESOURCE / SPIRITUALITY HERO ALIGNMENT
===================================================== */

:root {
  --cg33k-major-hero-gap-fix: 32px;
}

/*
 * MAJOR RESOURCE / SPIRITUALITY HUBS
 *
 * Move the entire redesign wrapper upward so the hero
 * sits directly beneath the global CatholicG33k header.
 */
body :is(
  .cg-devotions-redesign,
  .cg-councils-redesign,
  .cg-history-redesign,
  .cg-liturgy-redesign,
  .cg-scripture-redesign,
  .cg-prayer-redesign,
  .cg-traditions-redesign,
  .cg-sw-redesign,
  .cg-summa-redesign,
  .cg-catechism-redesign,
  .cg-fathers-redesign,
  .cg-church-fathers-redesign,
  .cg-popes-redesign
) {
  margin-block-start:
    calc(-1 * var(--cg33k-major-hero-gap-fix)) !important;

  margin-top:
    calc(-1 * var(--cg33k-major-hero-gap-fix)) !important;
}

/*
 * Only the OUTER redesign wrapper should move.
 *
 * Reset inner heroes so older CSS or cached rules cannot
 * apply a second negative margin.
 */
body :is(
  .cg-devotions-redesign,
  .cg-councils-redesign,
  .cg-history-redesign,
  .cg-liturgy-redesign,
  .cg-scripture-redesign,
  .cg-prayer-redesign,
  .cg-traditions-redesign,
  .cg-sw-redesign,
  .cg-summa-redesign,
  .cg-catechism-redesign,
  .cg-fathers-redesign,
  .cg-church-fathers-redesign,
  .cg-popes-redesign
) :is(
  .cg-devotions-hero,
  .cg-councils-hero,
  .cg-history-hero,
  .cg-liturgy-hero,
  .cg-scripture-hero,
  .cg-prayer-hero,
  .cg-traditions-hero,
  .cg-sw-hero,
  .cg-summa-hero,
  .cg-catechism-hero,
  .cg-fathers-hero,
  .cg-church-fathers-hero,
  .cg-popes-hero
) {
  margin-block-start: 0 !important;
  margin-top: 0 !important;
  margin-block-end: 0 !important;
  margin-bottom: 0 !important;
}

/*
 * Neutralize common WordPress page-content spacing.
 */
body .wp-block-post-content,
body .entry-content,
body .page-content {
  padding-block-start: 0 !important;
  padding-top: 0 !important;
}

/*
 * Prevent first-child spacing from reintroducing
 * a visible gap above the redesign wrapper.
 */
body .wp-block-post-content > :first-child,
body .entry-content > :first-child,
body .page-content > :first-child {
  margin-block-start: 0;
  margin-top: 0;
}

/*
 * Mobile keeps the same flush offset.
 */
@media (max-width: 780px) {
  :root {
    --cg33k-major-hero-gap-fix: 32px;
  }
}
