/* Diagnostics-only corrections after service-gutenberg.css. */

/* service-universal.css assumes an older Group inner wrapper and turns the
   outer section-head into a block. These saved core/groups have no wrapper. */
.dc-gutenberg-content.service-universal.service-diagnostic .section-head.wp-block-group:not(:has(> .wp-block-group__inner-container)) {
  display: grid;
}

.dc-gutenberg-content.service-universal.service-diagnostic .diagnostics-hero.wp-block-group .diagnostics-hero__note {
  max-width: 760px;
}

/* Gutenberg auto-margins center narrow text blocks inside wide Groups; the
   diagnostics design keeps those headings and paragraphs left-aligned. */
.dc-gutenberg-content:is(.diagnostics-page, .service-universal.service-diagnostic) .wp-block-group > :where(h1, h2, h3, h4, p, ul, ol) {
  margin-inline: 0 !important;
}

/* A standalone core/image is also a direct constrained child. Keep the
   narrower editorial figure measure defined by diagnostics.css. */
.dc-gutenberg-content:is(.diagnostics-page, .service-universal.service-diagnostic) .diagnostics-editorial--decision.wp-block-image {
  max-width: 1120px;
  margin-inline: auto !important;
}

/* The editable deliverables figure is a Group containing core/image and a
   figcaption Group. Their Gutenberg margins must not insert extra space. */
.dc-gutenberg-content:is(.diagnostics-page, .service-universal.service-diagnostic) .diagnostics-editorial--deliverables.wp-block-group > .wp-block-image,
.dc-gutenberg-content:is(.diagnostics-page, .service-universal.service-diagnostic) .diagnostics-editorial--deliverables.wp-block-group figcaption.wp-block-group > :where(*) {
  max-width: none;
  margin: 0 !important;
}
.dc-gutenberg-content:is(.diagnostics-page, .service-universal.service-diagnostic) .diagnostics-editorial--deliverables.wp-block-group figcaption.wp-block-group > .wp-block-image {
  width: 40px;
  flex: 0 0 auto;
}

/* Gutenberg may constrain and auto-center the children of every Group. Grid/flex
   children must instead fill their tracks, as they do in the PHP renderer. */
.dc-gutenberg-content:is(.diagnostics-page, .service-universal.service-diagnostic) :is(
  .diagnostics-hero__grid,
  .section-head,
  .hero-actions,
  .diagnostic-answer__box,
  .diagnostic-table,
  .diagnostic-cards,
  .scope-layout,
  .scope-stack,
  .outcomes-editorial-grid,
  .outcome-list,
  .diagnostic-process,
  .exclusion-grid,
  .next-grid,
  .diagnostic-final-cta__box,
  .faq-list
).wp-block-group > :where(:not(.wp-block-group__inner-container)),
.dc-gutenberg-content:is(.diagnostics-page, .service-universal.service-diagnostic) :is(
  .diagnostics-hero__grid,
  .section-head,
  .hero-actions,
  .diagnostic-answer__box,
  .diagnostic-table,
  .diagnostic-cards,
  .scope-layout,
  .scope-stack,
  .outcomes-editorial-grid,
  .outcome-list,
  .diagnostic-process,
  .exclusion-grid,
  .next-grid,
  .diagnostic-final-cta__box,
  .faq-list
).wp-block-group > .wp-block-group__inner-container > :where(*) {
  min-width: 0;
  max-width: none;
  margin-inline: 0 !important;
}

/* Cards are Groups too; WordPress must not center their editable headings and copy. */
.dc-gutenberg-content:is(.diagnostics-page, .service-universal.service-diagnostic) :is(
  .diagnostic-table,
  .diagnostic-cards,
  .scope-stack,
  .outcome-list,
  .diagnostic-process,
  .next-grid
) article.wp-block-group > :where(*),
.dc-gutenberg-content:is(.diagnostics-page, .service-universal.service-diagnostic) :is(
  .diagnostic-table,
  .diagnostic-cards,
  .scope-stack,
  .outcome-list,
  .diagnostic-process,
  .next-grid
) article.wp-block-group > .wp-block-group__inner-container > :where(*) {
  min-width: 0;
  max-width: none;
  margin-inline: 0 !important;
}

/* Transfer existing diagnostics layouts to older Group inner wrappers. */
.dc-gutenberg-content:is(.diagnostics-page, .service-universal.service-diagnostic) :is(
  .diagnostics-hero__grid,
  .section-head,
  .hero-actions,
  .diagnostic-answer__box,
  .diagnostic-table,
  .diagnostic-cards,
  .scope-layout,
  .scope-stack,
  .outcomes-editorial-grid,
  .outcome-list,
  .diagnostic-process,
  .exclusion-grid,
  .next-grid,
  .diagnostic-final-cta__box,
  .faq-list
).wp-block-group > .wp-block-group__inner-container {
  display: inherit;
  grid-column: 1 / -1;
  grid-template-columns: inherit;
  gap: inherit;
  align-items: inherit;
}

/* WordPress can insert another inner wrapper inside each scope card. It must
   span the article and carry the same two-track grid, not occupy the icon track. */
.dc-gutenberg-content .scope-stack article.wp-block-group > .wp-block-group__inner-container {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: inherit;
  gap: inherit;
  align-items: inherit;
}
.dc-gutenberg-content .scope-stack article.wp-block-group > .wp-block-group__inner-container > img {
  width: 44px;
  height: 44px;
  padding: 8px;
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-accent-soft);
  object-fit: contain;
}

/* diagnostics.css styles `.exclusion-grid > div` as the left card. With the
   WordPress inner wrapper that selector paints the wrapper instead. */
.dc-gutenberg-content .exclusion-grid.wp-block-group > .wp-block-group__inner-container {
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0;
  background: transparent !important;
  box-shadow: none;
}
.dc-gutenberg-content .exclusion-grid.wp-block-group > .wp-block-group__inner-container > .wp-block-group:first-child {
  padding: var(--space-7);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
}
.dc-gutenberg-content :is(.seo-audit-evidence, .diagnostic-compact-dark) .exclusion-grid.wp-block-group > .wp-block-group__inner-container > .wp-block-group:first-child {
  border-color: color-mix(in srgb, var(--color-text-inverse) 18%, transparent);
  background: color-mix(in srgb, var(--color-text-inverse) 5%, transparent);
}

@media (max-width: 767px) {
  /* The preparation lead has a larger min-content width in the PHP grid.
     Preserve that natural track sizing rather than forcing a new wrap. */
  .dc-gutenberg-content.service-universal.service-diagnostic--preparation .diagnostics-hero__grid.wp-block-group > :first-child {
    min-width: auto;
  }
}

@media (max-width: 1180px) {
  /* Gutenberg's child max-width otherwise overrides the editorial image
     measures already present in diagnostics.css when grids stack. */
  .dc-gutenberg-content:is(.diagnostics-page, .service-universal.service-diagnostic) .diagnostics-editorial--hero:is(.wp-block-group, .wp-block-image) {
    max-width: 880px;
  }
  .dc-gutenberg-content:is(.diagnostics-page, .service-universal.service-diagnostic) :is(.diagnostics-editorial--priority, .diagnostics-editorial--deliverables):is(.wp-block-group, .wp-block-image) {
    max-width: 760px;
  }
  .dc-gutenberg-content:is(.diagnostics-page, .service-universal.service-diagnostic) :is(.seo-audit-deliverables__figure, .diagnostic-compact-hero__figure):is(.wp-block-group, .wp-block-image) {
    max-width: 860px;
  }
  .dc-gutenberg-content:is(.service-universal.service-diagnostic--seo-audit, .service-universal.service-diagnostic--compact, .service-universal.service-diagnostic--regional, .service-universal.service-diagnostic--link-building) .diagnostics-editorial--hero:is(.wp-block-group, .wp-block-image) {
    max-width: 860px;
  }
}

@media (max-width: 760px) {
  .dc-gutenberg-content .scope-stack article.wp-block-group > .wp-block-group__inner-container > img {
    width: 40px;
    height: 40px;
    padding: 7px;
  }
  .dc-gutenberg-content .exclusion-grid.wp-block-group > .wp-block-group__inner-container > .wp-block-group:first-child {
    padding: var(--space-5);
  }
}
