/**
 * Guide Post Overrides
 *
 * Hides Kadence's default post title/meta when the content contains a
 * guide-style wrapper (e.g. .morel-guide, .edible-guide, .morel-maps).
 * The custom HTML blocks include their own styled H1, so the Kadence
 * template title would be redundant and visually inconsistent.
 *
 * Uses :has() (97%+ browser support) to detect guide wrappers.
 */

/* ----------------------------------------
   Selector: any single post whose .entry-content
   contains a guide/hub wrapper class
   ---------------------------------------- */

/* Hide the hero title section (title displayed above content) */
body.single-post:has(.entry-content [class*='-guide']) .entry-hero,
body.single-post:has(.entry-content [class*='-hub']) .entry-hero,
body.single-post:has(.entry-content .morel-maps) .entry-hero {
  display: none;
}

/* Hide the in-content title header */
body.single-post:has(.entry-content [class*='-guide']) .entry-header.post-title,
body.single-post:has(.entry-content [class*='-hub']) .entry-header.post-title,
body.single-post:has(.entry-content .morel-maps) .entry-header.post-title {
  display: none;
}

/* Remove top padding that Kadence adds for the (now hidden) title */
body.single-post:has(.entry-content [class*='-guide']) .entry-content-wrap,
body.single-post:has(.entry-content [class*='-hub']) .entry-content-wrap,
body.single-post:has(.entry-content .morel-maps) .entry-content-wrap {
  padding-top: 0;
}

/* Let the guide wrapper's own max-width control layout */
body.single-post:has(.entry-content [class*='-guide']) .entry-content.single-content,
body.single-post:has(.entry-content [class*='-hub']) .entry-content.single-content,
body.single-post:has(.entry-content .morel-maps) .entry-content.single-content {
  max-width: none;
}

/* Hide post navigation prev/next for guide posts (guide pages don't have this) */
body.single-post:has(.entry-content [class*='-guide']) .post-navigation,
body.single-post:has(.entry-content [class*='-hub']) .post-navigation,
body.single-post:has(.entry-content .morel-maps) .post-navigation {
  display: none;
}

/* Hide author box on guide posts */
body.single-post:has(.entry-content [class*='-guide']) .author-section,
body.single-post:has(.entry-content [class*='-hub']) .author-section,
body.single-post:has(.entry-content .morel-maps) .author-section {
  display: none;
}

/* ----------------------------------------
   Mobile Responsive Overrides (≤768px)
   Centralised fixes so individual page HTML
   blocks don't all need to duplicate them.
   ---------------------------------------- */

@media (max-width: 768px) {
  /* Ensure guide/hub wrappers never exceed the viewport */
  [class*='-guide'],
  [class*='-hub'] {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
  }

  /* Collapse multi-column grids to single column */
  .species-grid,
  .mushroom-grid,
  .resource-grid {
    grid-template-columns: 1fr !important;
  }

  /* Tables: scroll horizontally rather than overflow the viewport */
  [class*='-guide'] table,
  [class*='-hub'] table,
  .entry-content table {
    display: block;
    overflow-x: auto;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
  }

  /* Prefooter: guarantee fluid layout on narrow screens */
  .sm-prefooter,
  .sm-prefooter-inner,
  .sm-prefooter-grid,
  .sm-prefooter-bottom {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
  }
}
