/*
 * EAM redesign: Grants (page 1786, /activities/grants/). Rulebook P-26.
 * RS: clone:src/app/grants/search/grant-listings/page.tsx (light hero, card grid) and
 * RSC/shared/Card.tsx (card: image well, kicker, title, text; no status tag or deadline, EAM
 * states neither), recipients as an RS dated list (the Workshops pattern, P-23).
 *
 * Hybrid page: Kadence blocks + the EAM section block ([eam_grants], eam-activities
 * templates/grants.php, whose redesign branch prints the .rd-grants-* recipients markup).
 * Page layout only. Everything else comes from the shared files:
 *   1786_hero01-aa   hero: light tint hero, breadcrumb, eyebrow "Support", H1, lead,
 *                    "Grant types" -> indigo HeroCard (components.css, templates.css)
 *   1786_intro01-aa  "EAM Grants": H2 + intro (RS BlogSection text column)
 *   1786_grid01-aa   the two grant types as RS cards (.eam-tier-card, components.css section 5);
 *                    the congress card carries the last-congress picture (R-42, block
 *                    1786_card1g-gg from scripts/redesign/pages/01786-grants.mjs) as a side image
 *   .eam-act--grants "Calls and recipients" band (#f5f6fa), one card per programme, recipients
 *                    by year
 *   1786_note01-aa   "New grant calls are announced under News ...": closes the recipients band
 *                    on the same tint (it is about the calls), when the band is there
 *   1786_cta01-aa    "Questions about a grant?": shared closing CTA band (components.css `_cta01-`)
 *
 * Every row after the hero carries an explicit white background (.kt-row-has-bg), so base.css
 * cannot collapse their paddings (48 + 48 = 96px). Section 1 sets the gaps by uniqueID; an editor
 * who adds the class rd-keep-spacing to a row gets the original spacing back.
 */

/* 1. Rhythm ------------------------------------------------------------------------------- */

/* Intro -> cards: the cards belong to the intro (40px, 24px <= 820). */
body.eam-redesign.page-id-1786 .kb-row-layout-id1786_intro01-aa:not(.rd-keep-spacing) > .kt-row-column-wrap {
  padding-bottom: 0;
}

body.eam-redesign.page-id-1786 .kb-row-layout-id1786_grid01-aa:not(.rd-keep-spacing) > .kt-row-column-wrap {
  padding-top: var(--rd-space-l);
}

/* Card gutter: the RS grid gap, the same as the recipient cards below (block setting: 28px). */
body.eam-redesign.page-id-1786 .kb-row-layout-id1786_grid01-aa > .kt-row-column-wrap {
  gap: var(--rd-space-base);
}

/* Recipients band: its closing line (the note row) follows on the same tint. */
body.eam-redesign.page-id-1786 .eam-act--grants .eam-act-section--embedded {
  padding-bottom: var(--rd-space-l);
}

body.eam-redesign.page-id-1786 .entry-content > .eam-act--grants ~ .kb-row-layout-id1786_note01-aa:not(.rd-keep-spacing) {
  background-color: var(--rd-color-surface-muted);
}

body.eam-redesign.page-id-1786 .entry-content > .eam-act--grants ~ .kb-row-layout-id1786_note01-aa:not(.rd-keep-spacing) > .kt-row-column-wrap {
  padding-top: 0;
  padding-bottom: calc(var(--rd-space-section) * 1.5);
}

/* Without the band (no recipients and no calls yet) the note is a plain line under the cards. */
body.eam-redesign.page-id-1786 .kb-row-layout-id1786_note01-aa:not(.rd-keep-spacing) > .kt-row-column-wrap {
  padding-top: 0;
}

/* Note -> CTA band: one section space. */
body.eam-redesign.page-id-1786 .kb-row-layout-id1786_cta01-aa:not(.rd-keep-spacing) > .kt-row-column-wrap {
  padding-top: var(--rd-space-section);
}

/* 2. Intro text: RS ink instead of Kadence palette4 (#2b2b2b, not remapped on purpose,
 * DESIGN-SYSTEM 9; .has-theme-palette-4-color is !important, so the preset is repointed on this
 * page's content, as on Workshops and Summer schools), on the article measure. */
body.eam-redesign.page-id-1786 .entry-content {
  --wp--preset--color--theme-palette-4: var(--rd-color-text);
}

body.eam-redesign.page-id-1786 .wp-block-kadence-advancedheading.kt-adv-heading1786_intro04-dd[data-kb-block] {
  max-width: var(--rd-measure);
}

/* 3. Grant type cards ------------------------------------------------------------------------
 * Congress card: the picture on the left, edge to edge (RS card image well, here beside the
 * text so the two cards keep a similar height); the text column on the right. The block saves a
 * 16:9 Kadence ratio image, which is what shows with the redesign off and on phones. */
body.eam-redesign.page-id-1786 .kadence-column1786_card1a-aa:has(.kb-image1786_card1g-gg) > .kt-inside-inner-col {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
  grid-auto-rows: auto;
  align-content: start;
  column-gap: var(--rd-space-base);
}

body.eam-redesign.page-id-1786 .kadence-column1786_card1a-aa:has(.kb-image1786_card1g-gg) > .kt-inside-inner-col > * {
  grid-column: 2;
  min-width: 0;
}

body.eam-redesign.page-id-1786 .kadence-column1786_card1a-aa > .kt-inside-inner-col > .wp-block-kadence-image.kb-image1786_card1g-gg {
  grid-column: 1;
  grid-row: 1 / span 20;
  align-self: stretch;
  margin: calc(-1 * var(--rd-space-base)) 0 calc(-1 * var(--rd-space-base)) calc(-1 * var(--rd-space-base));
  overflow: hidden;
  background-color: var(--rd-color-surface-muted);
}

body.eam-redesign.page-id-1786 .kb-image1786_card1g-gg .kb-is-ratio-image {
  position: relative;
  height: 100%;
  min-height: calc(var(--rd-grid-col) * 3);
  padding-bottom: 0;
}

body.eam-redesign.page-id-1786 .entry-content .kb-image1786_card1g-gg img.kb-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 34%; /* the banner's EAM 2025 logo and congress name */
  transition: transform var(--rd-dur-slow) var(--rd-ease-out-cubic);
}

/* RS card hover: the image zooms inside its well (S-13). */
body.eam-redesign.page-id-1786 .kadence-column1786_card1a-aa:hover .kb-image1786_card1g-gg img.kb-img {
  transform: scale(1.03); /* as components.css section 5 */
}

/* The button sits at the bottom of the text column (card buttons are pinned to the bottom). */
body.eam-redesign.page-id-1786 .kadence-column1786_card1a-aa:has(.kb-image1786_card1g-gg) > .kt-inside-inner-col > .wp-block-kadence-advancedbtn {
  align-self: end;
}

/* The last block in a card ends on the card padding (the text blocks carry a Kadence "sm" bottom
 * margin, 24px of extra space under the mobility card text). */
body.eam-redesign.page-id-1786 :is(.kadence-column1786_card1a-aa, .kadence-column1786_card2a-aa) > .kt-inside-inner-col > :last-child {
  margin-bottom: 0;
}

/* Below desktop the two cards stack, so the congress card keeps its side picture at full width. */
@media (max-width: 1080px) {
  body.eam-redesign.page-id-1786 .kb-row-layout-id1786_grid01-aa > .kt-row-column-wrap {
    grid-template-columns: minmax(0, 1fr);
    grid-auto-rows: auto; /* Kadence's equal-height rows (minmax(0, 1fr)) would stretch the shorter card */
  }
}

@media (max-width: 820px) {
  body.eam-redesign.page-id-1786 .kb-row-layout-id1786_grid01-aa:not(.rd-keep-spacing) > .kt-row-column-wrap {
    padding-top: var(--rd-space-base);
  }

  body.eam-redesign.page-id-1786 .kadence-column1786_card1a-aa > .kt-inside-inner-col > .wp-block-kadence-image.kb-image1786_card1g-gg {
    margin: calc(-1 * var(--rd-space-s)) 0 calc(-1 * var(--rd-space-s)) calc(-1 * var(--rd-space-s));
  }
}

/* Phones: one column, the picture on top of the card as a 16:9 well, edge to edge. */
@media (max-width: 480px) {
  body.eam-redesign.page-id-1786 .kadence-column1786_card1a-aa:has(.kb-image1786_card1g-gg) > .kt-inside-inner-col {
    grid-template-columns: minmax(0, 1fr);
  }

  body.eam-redesign.page-id-1786 .kadence-column1786_card1a-aa:has(.kb-image1786_card1g-gg) > .kt-inside-inner-col > * {
    grid-column: 1;
  }

  body.eam-redesign.page-id-1786 .kadence-column1786_card1a-aa > .kt-inside-inner-col > .wp-block-kadence-image.kb-image1786_card1g-gg {
    grid-row: auto;
    margin: calc(-1 * var(--rd-space-s)) calc(-1 * var(--rd-space-s)) var(--rd-space-s);
  }

  body.eam-redesign.page-id-1786 .kb-image1786_card1g-gg .kb-is-ratio-image {
    height: auto;
    min-height: 0;
    aspect-ratio: 16 / 9;
  }
}

/* 4. Calls and recipients band ------------------------------------------------------------- */

/* Two programme cards, equal height; text cards are not links, so no lift (components.css). */
body.eam-redesign.page-id-1786 .eam-act--grants .rd-grants-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--rd-space-base);
  margin-top: var(--rd-space-m);
}

body.eam-redesign.page-id-1786 .eam-act--grants .rd-grants-card {
  display: flex;
  flex-direction: column;
  padding: var(--rd-space-base);
}

body.eam-redesign.page-id-1786 .eam-act--grants .rd-grants-card .eam-act-card__title {
  margin: 0 0 var(--rd-space-xs);
}

/* Call documents (shown once an editor uploads the call PDF): under the title. */
body.eam-redesign.page-id-1786 .eam-act--grants .rd-grants-card .eam-act-calls {
  margin: 0 0 var(--rd-space-xs);
}

/* One band per year: the year on the left, the names stacked on the right, hairlines between. */
body.eam-redesign.page-id-1786 .eam-act--grants .rd-grants-year {
  display: grid;
  grid-template-columns: minmax(var(--rd-space-xl), auto) minmax(0, 1fr); /* wider only for a year-less "Recipients" label */
  column-gap: var(--rd-space-s);
  padding: var(--rd-space-s) 0;
  border-top: var(--rd-border-width) solid var(--rd-border-light);
}

body.eam-redesign.page-id-1786 .eam-act--grants .rd-grants-year:last-child {
  padding-bottom: 0;
}

body.eam-redesign.page-id-1786 .eam-act--grants .rd-grants-year__label {
  margin: 0;
  font-family: var(--rd-font);
  font-size: var(--rd-fs-large);
  font-weight: var(--rd-fw-semibold);
  line-height: var(--rd-lh-body);
  letter-spacing: var(--rd-ls-heading);
  text-transform: none;
  color: var(--rd-color-primary);
}

body.eam-redesign.page-id-1786 .eam-act--grants .rd-grants-names {
  margin: 0;
  padding: 0;
  list-style: none;
}

body.eam-redesign.page-id-1786 .eam-act--grants .rd-grants-name {
  display: flex;
  align-items: center;
  gap: var(--rd-space-xs);
  margin: 0;
  padding: 0;
  font-size: var(--rd-fs-large);
  line-height: var(--rd-lh-body);
  color: var(--rd-color-text);
}

body.eam-redesign.page-id-1786 .eam-act--grants .rd-grants-name + .rd-grants-name {
  margin-top: var(--rd-space-2xs);
}

body.eam-redesign.page-id-1786 .eam-act--grants .rd-grants-name__text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

body.eam-redesign.page-id-1786 .eam-act--grants .rd-grants-name__affil {
  font-size: var(--rd-fs-small);
  line-height: var(--rd-lh-body);
  color: var(--rd-color-text-70);
}

/* Optional recipient photo (Activities Content photo picker): small square portrait. */
body.eam-redesign.page-id-1786 .eam-act--grants .rd-grants-name__photo {
  flex: none;
  width: calc(var(--rd-space-base) * 2); /* 48px */
  height: calc(var(--rd-space-base) * 2);
  border-radius: var(--rd-radius);
  object-fit: cover;
  background-color: var(--rd-color-surface-muted);
}

@media (max-width: 820px) {
  body.eam-redesign.page-id-1786 .eam-act--grants .rd-grants-grid {
    gap: var(--rd-space-s);
    margin-top: var(--rd-space-base);
  }

  body.eam-redesign.page-id-1786 .eam-act--grants .rd-grants-card {
    padding: var(--rd-space-s);
  }

  body.eam-redesign.page-id-1786 .eam-act--grants .rd-grants-name {
    font-size: var(--rd-fs-body);
  }
}

@media (max-width: 480px) {
  body.eam-redesign.page-id-1786 .eam-act--grants .rd-grants-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  body.eam-redesign.page-id-1786 .entry-content .kb-image1786_card1g-gg img.kb-img {
    transition: none;
  }
}
