/* ==========================================================================
   Funders and partners on the home page (_includes/home/partners-funders.html).
   Funder cards all share one size: the grid stretches every card to the
   tallest one and the project list opens as an overlay instead of growing
   the card. Partners run as an endless logo carousel.
   ========================================================================== */

/* ---- Funders ---- */
.funder-grid {
  display: grid;
  /* Six funders: two rows of three. */
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-rows: 1fr;
  gap: 1.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.funder-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 11rem;
  padding: 1.25rem 1.5rem 1.25rem;
  background: var(--color-white);
  border: 1px solid var(--color-line);
  border-top: 4px solid var(--color-primary);
  border-radius: var(--radius-lg);
}

.funder-body {
  display: flex;
  flex: 1;
  flex-direction: column;
}

.funder-head {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

/* Logos differ in shape (marks, flag, wordmark): a fixed box keeps the names aligned. */
.funder-logo {
  flex: 0 0 auto;
  width: 64px;
  height: 48px;
  object-fit: contain;
  object-position: left center;
}

.funder-body h3 {
  hyphens: auto;
  margin: 0;
  font-size: 1.05rem;
}

.funder-body h3 a {
  color: var(--color-heading);
}

.funder-body h3 a:hover {
  color: var(--color-primary);
}

.funder-programmes {
  margin: 0.4rem 0 0;
  font-size: 0.88rem;
  color: var(--color-text-light);
}

/* Pinned to the bottom of the card so the badges line up across a row. */
.funder-projects {
  margin-top: auto;
  padding-top: 0.9rem;
}

.funder-projects summary {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.2rem 0.75rem;
  border-radius: var(--radius-pill);
  background: var(--sky-100);
  color: var(--color-primary);
  font-size: 0.85rem;
  font-weight: var(--font-weight-bold);
  cursor: pointer;
  list-style: none;
}

.funder-projects summary::-webkit-details-marker {
  display: none;
}

.funder-projects summary::after {
  content: "\25BE";
  transition: transform 0.2s ease;
}

.funder-projects[open] summary::after {
  transform: rotate(180deg);
}

.funder-projects ul {
  position: absolute;
  z-index: 20;
  top: calc(100% - 0.75rem);
  left: -1px;
  right: -1px;
  max-height: 18rem;
  overflow-y: auto;
  margin: 0;
  padding: 0.9rem 1.25rem 0.9rem 2.2rem;
  background: var(--color-white);
  border: 1px solid var(--color-line-strong);
  border-radius: var(--radius-sm);
  box-shadow: 0 12px 28px rgba(15, 35, 60, 0.16);
  font-size: 0.9rem;
}

.funder-projects li {
  margin-bottom: 0.2rem;
}

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

@media (max-width: 640px) {
  .funder-grid {
    grid-template-columns: 1fr;
    grid-auto-rows: auto;
  }

  .funder-card {
    min-height: 0;
  }
}

/* ---- Partner carousel ---- */
.home-partners .section-head {
  margin-bottom: 1.5rem;
}

.partner-marquee {
  overflow: hidden;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent);
}

.partner-track {
  display: flex;
  width: max-content;
  /* About 60 px/s whatever the number of partners (tile + gap: 206px). */
  animation: partner-scroll calc(var(--partner-count, 100) * 3.4s) linear infinite;
}

.partner-marquee:hover .partner-track,
.partner-marquee:focus-within .partner-track {
  animation-play-state: paused;
}

.partner-list {
  display: flex;
  gap: 1rem;
  margin: 0;
  padding: 0.5rem 0.5rem 0.5rem 0.5rem;
  list-style: none;
}

.partner-tile {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 190px;
  height: 96px;
  padding: 0.9rem 1.1rem;
  background: var(--color-white);
  border: 1px solid var(--color-line);
  border-radius: var(--border-radius);
  color: var(--color-heading);
  text-align: center;
  text-decoration: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

a.partner-tile:hover,
a.partner-tile:focus-visible {
  border-color: var(--color-primary);
  box-shadow: 0 6px 18px rgba(15, 35, 60, 0.12);
}

.partner-tile img {
  /* Fill the tile: small SVGs (e.g. 46 x 17) would otherwise stay tiny. */
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: grayscale(1);
  opacity: 0.8;
  transition: filter 0.2s ease, opacity 0.2s ease;
}

a.partner-tile:hover img,
a.partner-tile:focus-visible img {
  filter: none;
  opacity: 1;
}


/* The track holds two identical lists; moving it by half its width lands
   the second list exactly where the first started. */
@keyframes partner-scroll {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

/* Keep the carousel moving even with "reduce motion": main.css shortens every
   animation to 0.01ms there, which would make the track jump. */
@media (prefers-reduced-motion: reduce) {
  .partner-marquee .partner-track {
    animation-duration: calc(var(--partner-count, 100) * 3.4s) !important;
  }
}
