/* RED branch and method layout polish.
   Load after the existing styles. Scope classes belong only on the five
   named public pages (including their /en/ and /es/ equivalents):
   red-branch-layout: red-academy, red-media, red-living-laboratory,
                      red-consulting
   red-branch-media-layout: red-media (in addition to red-branch-layout)
   red-method-layout: red-methode
   Colors, landscape, typefaces, navigation and content remain inherited. */

body.red-branch-layout,
body.red-method-layout {
  --red-layout-gap: clamp(1rem, 2vw, 1.5rem);
  --red-layout-section-gap: clamp(1.8rem, 3.2vw, 2.8rem);
  --red-layout-padding: clamp(1.15rem, 2.6vw, 2rem);
}

/* A single outer rail and a consistent gap between the hero and body. */
body.red-branch-layout .red-content-hero {
  padding-block: clamp(2rem, 3.8vw, 3.25rem) 0;
}
body.red-branch-layout .red-content-page {
  padding-top: var(--red-layout-section-gap);
}
body.red-branch-layout .red-content-hero .red-content-wrap {
  align-items: stretch;
  gap: var(--red-layout-gap);
}
body.red-branch-layout .red-content-hero .red-content-wrap > * {
  box-sizing: border-box;
  min-width: 0;
}
body.red-branch-layout .red-hero-note {
  display: flex;
  flex-direction: column;
  justify-content: center;
}
body.red-branch-layout .red-content-hero p:last-child {
  margin-bottom: 0;
}

/* The introductory pair shares its upper and lower edges. The two short
   notes share the available height; their text stays at the top. */
body.red-branch-layout .red-content-page > .red-content-wrap > div.red-two-column {
  grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr);
  align-items: stretch;
  gap: var(--red-layout-gap);
}
body.red-branch-layout .red-content-page > .red-content-wrap > div.red-two-column > aside {
  grid-auto-rows: 1fr;
  align-content: stretch;
  gap: 1rem;
}
body.red-branch-layout .red-content-page > .red-content-wrap > div.red-two-column > aside > .red-info-card {
  box-sizing: border-box;
  margin: 0;
}

/* Section heading cards align with the complete card row below them.
   The copy has a readable measure without narrowing the card surface. */
body.red-branch-layout .red-detail-section {
  margin-top: var(--red-layout-section-gap);
}
body.red-branch-layout .red-detail-heading {
  box-sizing: border-box;
  width: 100%;
  max-width: none;
  margin: 0;
}
body.red-branch-layout .red-detail-heading > p {
  max-width: 88ch;
}
body.red-branch-layout .red-detail-heading > :last-child,
body.red-branch-layout .red-content-copy > :last-child,
body.red-branch-layout .red-split-panel > div > :last-child {
  margin-bottom: 0;
}
body.red-branch-layout .red-content-copy > .red-kicker + h2,
body.red-branch-layout .red-split-panel > div > .red-kicker + h2 {
  margin-top: .5rem;
}
body.red-branch-layout .red-card-grid {
  gap: 1rem;
  margin-top: var(--red-layout-gap);
}

/* A short quotation is a compact closing band after its long reading
   card. It no longer creates an empty column alongside three paragraphs. */
body.red-branch-layout .red-detail-section.red-two-column {
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
}
body.red-branch-layout .red-detail-section.red-two-column > .red-quote-panel {
  display: block;
  box-sizing: border-box;
  min-width: 0;
  padding: clamp(1.2rem, 2.4vw, 1.65rem) var(--red-layout-padding);
}
body.red-branch-layout .red-quote-panel small {
  margin-top: .65rem;
}

/* Media has an extended two-heading introduction. Its notes form a
   balanced second row instead of being stretched over the whole essay. */
body.red-branch-layout.red-branch-media-layout .red-content-page > .red-content-wrap > div.red-two-column {
  grid-template-columns: minmax(0, 1fr);
}
body.red-branch-layout.red-branch-media-layout .red-content-page > .red-content-wrap > div.red-two-column > aside {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* Preserve the existing single-card split composition, but avoid the
   empty top margin introduced by a list used as its first child. */
body.red-branch-layout .red-split-panel {
  gap: var(--red-layout-gap);
  padding: var(--red-layout-padding);
}
body.red-branch-layout .red-split-panel > * {
  min-width: 0;
}
body.red-branch-layout .red-split-panel > div > :first-child {
  margin-top: 0;
}

/* Five process steps remain one row on a wide screen. On tablets they
   become five compact rows, avoiding an incomplete three-plus-two grid. */
body.red-branch-layout .red-process-grid {
  margin-top: var(--red-layout-gap);
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: stretch;
}
body.red-branch-layout .red-process-step {
  box-sizing: border-box;
  min-width: 0;
  min-height: 0;
}

/* Method: hero, principles, contents and reading sections share a rail.
   Only the outer main wrapper loses its legacy extra 6vw side padding. */
body.red-method-layout > header.hero {
  padding-block: clamp(2rem, 3.8vw, 3.25rem) 0 !important;
}
body.red-method-layout > header.hero > .wrap,
body.red-method-layout > main.content > .wrap {
  box-sizing: border-box;
  width: min(900px, calc(100% - 2.6rem));
  max-width: none;
  margin-inline: auto;
}
body.red-method-layout > main.content {
  padding-top: var(--red-layout-section-gap);
}
body.red-method-layout > main.content > .wrap {
  padding-inline: 0;
}
body.red-method-layout .method-intro,
body.red-method-layout .method-principles,
body.red-method-layout .method-toc,
body.red-method-layout .method-section {
  margin-block: 0 var(--red-layout-section-gap);
}
body.red-method-layout .method-principles {
  gap: 1rem;
}
body.red-method-layout .method-intro > h2:first-child,
body.red-method-layout .method-toc > h2:first-child,
body.red-method-layout .method-principle > h2:first-child {
  margin-top: 0;
}
body.red-method-layout .method-intro > :last-child,
body.red-method-layout .method-principle > :last-child,
body.red-method-layout .method-section > :last-child {
  margin-bottom: 0;
}
body.red-method-layout .method-cycle > div {
  min-width: 0;
}

@media (max-width: 1000px) {
  body.red-branch-layout .red-process-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  body.red-branch-layout .red-process-step {
    display: grid;
    grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr);
    column-gap: 1.5rem;
    row-gap: .35rem;
    padding: 1.2rem 1.4rem;
  }
  body.red-branch-layout .red-process-step > span,
  body.red-branch-layout .red-process-step > h3 {
    grid-column: 1;
  }
  body.red-branch-layout .red-process-step > h3 {
    margin: 0;
  }
  body.red-branch-layout .red-process-step > p {
    grid-column: 2;
    grid-row: 1 / span 2;
    align-self: center;
  }
}

@media (max-width: 900px) {
  body.red-branch-layout .red-content-hero .red-content-wrap,
  body.red-branch-layout .red-content-page > .red-content-wrap > div.red-two-column {
    grid-template-columns: minmax(0, 1fr);
  }
  body.red-branch-layout .red-content-page > .red-content-wrap > div.red-two-column > aside {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: auto;
  }
  body.red-branch-layout .red-split-panel {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 580px) {
  body.red-branch-layout .red-content-wrap,
  body.red-method-layout > header.hero > .wrap,
  body.red-method-layout > main.content > .wrap {
    width: calc(100% - 1.5rem);
  }
  body.red-branch-layout .red-content-page > .red-content-wrap > div.red-two-column > aside,
  body.red-branch-layout.red-branch-media-layout .red-content-page > .red-content-wrap > div.red-two-column > aside {
    grid-template-columns: minmax(0, 1fr);
  }
  body.red-branch-layout .red-process-step {
    display: block;
    padding: 1.2rem;
  }
  body.red-branch-layout .red-process-step > h3 {
    margin-block: .45rem .6rem;
  }
}

/* Retain the shell's handheld fallback when a phone requests the wider
   desktop viewport; the page-specific selectors must not defeat it. */
html.red-handheld-device body.red-branch-layout .red-content-hero .red-content-wrap,
html.red-handheld-device body.red-branch-layout .red-content-page > .red-content-wrap > div.red-two-column,
html.red-handheld-device body.red-branch-layout .red-content-page > .red-content-wrap > div.red-two-column > aside,
html.red-handheld-device body.red-branch-layout.red-branch-media-layout .red-content-page > .red-content-wrap > div.red-two-column > aside,
html.red-handheld-device body.red-branch-layout .red-split-panel,
html.red-handheld-device body.red-branch-layout .red-process-grid {
  grid-template-columns: minmax(0, 1fr);
}
html.red-handheld-device body.red-branch-layout .red-process-step {
  display: block;
}
html.red-handheld-device body.red-branch-layout .red-process-step > h3 {
  margin-block: .45rem .6rem;
}
