/* Page List → "Milo Service Cards Square".
   Base card styles are the same as milo_service_cards/view.css (so this
   template works on its own); the square rules at the end are scoped to
   .milo-service-cards--square so they never affect the regular template when
   both are used on one page. */

#pagewrap .milo-service-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 31px;
  margin-top: 24px;
	margin-bottom: 24px;
}

#pagewrap .milo-service-card {
  position: relative;
  container-type: inline-size; /* the title sizes to the card width (cqi) */
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 24px;
  min-height: 458px;
  padding: 30px;
  overflow: hidden;
  border-radius: 8px;
  background-color: #516374;
  /* Resized thumbnails set inline by view.php; only the one in use is downloaded */
  background-image: var(--card-bg, none);
  background-size: cover;
  background-position: center;
  text-decoration: none;
}
#pagewrap .milo-service-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .4);
  transition: background-color .25s;
}
#pagewrap .milo-service-card:hover::before,
#pagewrap .milo-service-card:focus-visible::before { background: rgba(7, 86, 165, .55); }

/* Extra shade at the bottom so the description / button read on bright photos */
#pagewrap .milo-service-card.has-body::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, .65) 0%, rgba(0, 0, 0, 0) 55%);
  pointer-events: none;
}

/* Bottom of the card: description and/or button */
#pagewrap .milo-service-card__body {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 24px;
}

/* Same formatting as the project slider's details (.milo-project-slide__details),
   but in the body font */
#pagewrap .milo-service-card__description {
  max-width: 30em;
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 600;
  line-height: 24px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--main-subtle);
}

/* The card is the link, so the button's hover follows the card's */
#pagewrap .milo-service-card__button { color: var(--white); }
#pagewrap .milo-service-card:hover .milo-service-card__button,
#pagewrap .milo-service-card:focus-visible .milo-service-card__button {
  background: var(--main-lighter);
  border-color: var(--main-lighter);
}

/* Same heading fix as checkpoint-box / one-two-three: the title scales with
   the card (7.5% of its text width, 15–26px) so long single words such as
   REFRIGERATION (291px at 26px vs ~279px available) fit; a word that's still
   too long wraps. Fallback without container units: the theme size. */
#pagewrap .milo-service-card__title {
  position: relative;
  z-index: 1;
  font-family: var(--font-display);
  font-size: var(--fs-display-3);
  font-size: clamp(15px, 7.5cqi, 26px);
  font-weight: 700;
  line-height: 1.3;
  overflow-wrap: break-word;
  hyphens: auto;
  text-transform: uppercase;
  color: var(--main-subtle);
}

@media (max-width: 1023px) {
  #pagewrap .milo-service-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 599px) {
  #pagewrap .milo-service-cards { grid-template-columns: minmax(0, 1fr); gap: 20px; margin-top: 40px; }
  #pagewrap .milo-service-card {
    min-height: 280px;
    padding: 24px;
    background-image: var(--card-bg-sm, var(--card-bg, none));
  }
}

/* ---- Square cards ----
   aspect-ratio keeps every card square at any width; min-height: auto (not
   the regular template's fixed heights) lets a card grow taller only if its
   description/button wouldn't otherwise fit. */
#pagewrap .milo-service-cards--square .milo-service-card {
  aspect-ratio: 1 / 1;
  min-height: auto; /* also overrides the 280px phone height above */
}

/* Project type pills ("project_type" Topics attribute). Only output when the
   page has topics selected. Same styles in milo_service_cards,
   milo_service_cards_square and milo_project_slider (keep in sync). */
#pagewrap .milo-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
}
#pagewrap .milo-pill {
  display: inline-flex;
    align-items: center;
    margin: 0;
    padding: 5px 10px;
    border: 1px solid rgba(235, 245, 255, .45);
    border-radius: 999px;
    background: rgba(23, 24, 25, .35);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    font-family: var(--font-body);
    font-size: 10px;
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    white-space: nowrap;
    color: var(--main-subtle);
}
/* Sit closer to the description above (body gap is 24px) */
#pagewrap .milo-service-card__description + .milo-pills { margin-top: -10px; }

/* Project location / other ("project_location", "project_other" attributes):
   same text style as the description, set as extra lines directly under it */
#pagewrap .milo-service-card__meta {
  display: block;
  max-width: 30em;
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 600;
  line-height: 24px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--main-subtle);
}
#pagewrap .milo-service-card__meta p { margin: 0; }
/* The body has a 24px gap: pull these lines up so they read as one block */
#pagewrap .milo-service-card__description + .milo-service-card__meta,
#pagewrap .milo-service-card__meta + .milo-service-card__meta { margin-top: -18px; }
#pagewrap .milo-service-card__meta + .milo-pills { margin-top: -10px; }
