/* resources - "Data, reports and tools" resource grid + "Explore other key
   themes" band (MNCH key-theme redesign, design_resources.html). Section
   header and the light #EEF2F6 section card are master-twig chrome, not
   part of this component - see the twig docblock.

   Colors checked against base/color/color.css: #4D4D4D -> --clr-gray-dark,
   #21568C -> --clr-blue, #F8B323 -> --clr-yellow-orange, #FFFFFF ->
   --clr-white. Teal eyebrow ink #1D5C55 has no site token; same value is
   minted locally by the sibling mortality/snapshot widgets. */
.resources {
  --resources-ink: var(--clr-gray-dark, #4d4d4d);
  --resources-teal-ink: #1d5c55;
  --resources-blue: var(--clr-blue, #21568c);
  --resources-accent: var(--clr-yellow-orange, #f8b323);
  --resources-white: var(--clr-white, #ffffff);
  /* LINK/PDF badge colour on card hover/focus (QC 452631). */
  --resources-badge-hover: var(--clr-teal-500, #1fa29c);

  display: flex;
  flex-direction: column;
  gap: 30px;
  font-family: var(--primary-ff, 'Poppins', 'Segoe UI', system-ui, sans-serif);
  color: var(--resources-ink);
}

.page-main-chapter:nth-child(even) .resources__grid {
  --resources-teal-ink: var(--clr-white);
  --resources-ink: var(--clr-white);
  --resources-blue: var(--clr-yellow-orange);
  --resources-badge-hover: var(--clr-white);
}

.page-main-chapter:nth-child(odd) .resources__themes {
  --resources-accent: var(--clr-blue);
}

.page-main-chapter:nth-child(odd) .resources__themes-title {
  color: var(--section-title-clr, var(--clr-gray-dark));
}

.page-main-chapter:nth-child(odd) .resources__themes-all:hover {
  color: var(--clr-gray-dark);
}

/* ---------- resource grid ---------- */
.resources__grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-rows: 1fr;
  gap: 0;
}

.resources__item {
  position: relative;
  display: flex;
  margin: 0;
  padding: 0;
}

.resources__item::before {
  display: none;
  /* neutralise site-wide li bullets */
}

/* yellow rule between rows, inset 20px (design: 2.5pt) */
.resources__item::after {
  content: "";
  position: absolute;
  top: 0;
  left: 20px;
  right: 20px;
  pointer-events: none;
}

.resources__item:nth-child(n + 4)::after {
  border-top: 2.5pt solid var(--resources-accent);
}

.resources__card {
  flex: 1 1 auto;
  box-sizing: border-box;
  min-height: 128px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 24px 28px;
  text-decoration: none;
  color: var(--resources-ink);
  min-width: 0;
}

.resources__type {
  font-size: 12px;
  line-height: 1.5;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--resources-teal-ink);
}

.resources__title {
  font-size: 18px;
  line-height: 1.4;
  font-weight: 700;
  color: var(--resources-ink);
  overflow-wrap: anywhere;
}

.resources__badge {
  margin-top: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  line-height: 1.5;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--resources-blue);
  transition: color 0.2s ease;
}

.resources__badge svg {
  flex: 0 0 auto;
}

/* Badge (icon + LINK/PDF, svg uses currentColor) changes colour on hover:
   yellow -> white on the dark sections, blue -> teal on the light ones. */
a.resources__card:hover .resources__badge,
a.resources__card:focus-visible .resources__badge {
  color: var(--resources-badge-hover);
}

@media (prefers-reduced-motion: reduce) {
  .resources__badge {
    transition: none;
  }
}

a.resources__card:hover .resources__title,
a.resources__card:focus-visible .resources__title {
  text-decoration: underline;
  text-underline-offset: 3px;
}

a.resources__card:focus-visible,
.resources__theme:focus-visible,
.resources__themes-all:focus-visible {
  outline: 3px solid var(--resources-accent);
  outline-offset: 2px;
}

.resources__sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (max-width: 860px) {
  .resources__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .resources__item:nth-child(n + 4)::after {
    border-top: 0;
  }

  .resources__item:nth-child(n + 3)::after {
    border-top: 2.5pt solid var(--resources-accent);
  }
}

@media (max-width: 560px) {
  .resources__grid {
    grid-template-columns: minmax(0, 1fr);
    grid-auto-rows: auto;
  }

  .resources__item:nth-child(n + 2)::after {
    border-top: 2.5pt solid var(--resources-accent);
  }

  .resources__card {
    min-height: 0;
    padding: 20px 8px;
  }
}

/* ---------- explore other key themes ---------- */
.resources__themes {
  box-sizing: border-box;
  padding: 40px clamp(14px, 4.9vw, 70px);
  border-radius: 28px;
  background: var(--resources-blue);
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.resources__themes-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px 24px;
}

.resources__themes-title {
  margin: 0;
  font-size: 24px;
  line-height: 1.35;
  font-weight: 700;
  color: var(--resources-white);
}

.resources__themes-all {
  font-size: 15px;
  font-weight: 600;
  color: var(--resources-accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.resources__themes-all:hover {
  color: var(--resources-white);
}

.resources__themes-list {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
}

.resources__theme {
  flex: 1 1 240px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 22px;
  border-radius: 0 20px 0 20px;
  background: var(--resources-white);
  color: var(--resources-ink);
  text-decoration: none;
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* Hover colours per key theme (theme_type) - site tokens from
   components/redesign/base/color/color.css (hex = fallback for Storybook).
   Light tints, so the text stays dark on hover. */
.resources__theme--theme_1 {
  --resources-tc: var(--t2030-theme1-clr, #bee9e6);
}

.resources__theme--theme_2 {
  --resources-tc: var(--t2030-theme2-clr, #c3dbf1);
}

.resources__theme--theme_3 {
  --resources-tc: var(--t2030-theme3-clr, #ffe2d9);
}

.resources__theme--theme_4 {
  --resources-tc: var(--t2030-theme4-clr, #e5c9e2);
}

.resources__theme--alt {
  border-radius: 20px 0 20px 0;
}

.resources__theme:hover,
.resources__theme:focus-visible {
  background: var(--resources-tc, var(--t2030-theme1-clr, #bee9e6));
  color: var(--resources-ink);
}

.resources__theme-label {
  font-size: 12px;
  line-height: 1.5;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.85;
}

.resources__theme-title {
  font-size: 20px;
  line-height: 1.35;
  font-weight: 700;
}

.resources__theme-foot {
  margin-top: auto;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.resources__theme-icon {
  display: block;
  height: 44px;
  width: auto;
}

.resources__theme-icon--hover,
.resources__theme:hover .resources__theme-icon--rest,
.resources__theme:focus-visible .resources__theme-icon--rest {
  display: none;
}

.resources__theme:hover .resources__theme-icon--hover,
.resources__theme:focus-visible .resources__theme-icon--hover {
  display: block;
}

.resources__theme-arrow {
  margin-left: auto;
  font-size: 22px;
  line-height: 1;
  transition: transform 0.2s ease;
}

/* Bug #452633 - matches the same hover-slide already used elsewhere in
   this project (e.g. .cx-info-link-arrow). */
.resources__theme:hover .resources__theme-arrow,
.resources__theme:focus-visible .resources__theme-arrow {
  transform: translateX(4px);
}

@media (max-width: 560px) {
  .resources__themes {
    padding: 28px 18px;
  }

  .resources__themes-title {
    font-size: 20px;
  }

  .resources__theme {
    flex-basis: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .resources__theme,
  .resources__theme-arrow {
    transition: none;
  }
}
