/* =============================================================
   barrio_npm_prototype — /mai MAI-groups tile grid + modal

   Reskin of the mai_groups view (block_1 on /mai + page_1 at
   mai/mai-groups — both inherit the default display) as a 3-col
   responsive tile grid, matching the shipped landing chassis. Each
   tile is a modal-opening anchor (barrioNpmMaiModal, family-1
   template-clone modal registered in ModalRegistry).

   Sibling of css/partners.css — same grid/tile/modal shape, plus a
   contact block the partner modal doesn't carry.

   Ships Phase B of documentation/mai-groups-tile-grid-plan.md.
   ============================================================= */

/* ---------- responsive grid ----------
   Horizontal (image-left) cards read best wider, so fit as many
   ~380px-min columns as the container allows (≈3 on a wide desktop,
   2 on mid widths, 1 on narrow) rather than a hard 3-col split. The
   min(380px, 100%) idiom keeps a single card from overflowing very
   small screens. */
.np-mai-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(380px, 100%), 1fr));
  gap: 22px;
  margin: 24px 0 40px;
}
.np-mai-grid-item { display: flex; }

/* Flex-passthrough for the .contextual-region wrapper that carries the
   per-tile edit pen — added 2026-09-10 with the pens-on-every-tile
   convention (memory feedback_contextual_pens_on_every_tile). Without
   this rule the wrapper would collapse and the card would lose its full
   width inside the grid cell. Mirrors partners.css's
   .np-partner-grid-item > .np-partner-tile-region rule. */
.np-mai-grid-item > .np-mai-tile-region {
  display: flex;
  width: 100%;
}

/* ---------- tile (horizontal media object) ---------- */
.np-mai-card {
  display: flex; flex-direction: row;
  width: 100%; height: 100%;
  min-height: 138px;
  background: #fff;
  border: 1px solid #e4e0d8;
  border-top: 6px solid var(--np-mai);
  border-radius: 8px;
  overflow: hidden;
  text-decoration: none; color: inherit;
  box-shadow: 0 1px 2px rgba(40,40,40,.05), 0 6px 18px rgba(40,40,40,.06);
  transition: transform .18s, box-shadow .18s, border-color .18s;
}
.np-mai-card:hover {
  transform: translateY(-3px);
  color: inherit;
  border-top-color: var(--np-mai-dk);
  box-shadow: 0 4px 10px rgba(40,40,40,.09), 0 16px 44px rgba(40,40,40,.10);
}

/* Image column — fixed SQUARE panel on the LEFT. The image is a square
   scale-and-crop derivative (300_x_300px style, built in MaiGroupRowBuilder)
   and fills the square edge-to-edge via object-fit: cover, so every tile
   shows a crisp, uniform square. A neutral backdrop covers the fallback
   glyph + any transparent-logo padding. */
.np-mai-media {
  flex: 0 0 138px;
  align-self: stretch;
  display: flex; align-items: center; justify-content: center;
  background: #f6f4ef;
  border-right: 1px solid #ece8e0;
  overflow: hidden;
}
.np-mai-img {
  width: 138px; height: 138px;   /* the square — filled by the 300x300 crop */
  object-fit: cover;
  object-position: center;
  display: block;
}
.np-mai-media-fallback {
  font-weight: 700; letter-spacing: .16em;
  font-size: 22px; color: #cfc7b7;
}

.np-mai-body {
  display: flex; flex-direction: column; justify-content: center;
  padding: 16px 20px;
  gap: 8px;
  flex: 1;
  min-width: 0; /* let long words wrap instead of forcing overflow */
}
.np-mai-name {
  /* font-weight !important defeats typography.css `h* { font-weight:100
     !important }` (see CLAUDE.md), which otherwise renders the title as a
     washed-out hairline. Colour forced to the MAI teal so it reads as
     branded, not as a generic blue link inheriting from the card anchor. */
  font-weight: 700 !important;
  font-size: 17px; line-height: 1.25;
  color: var(--np-mai-dk) !important;
  margin: 0;
}
.np-mai-body-teaser {
  font-size: 13.5px; color: #6c675f; line-height: 1.45;
  margin: 0;
}

/* Narrow screens — stack back to image-on-top so the horizontal card
   doesn't get cramped. */
@media (max-width: 460px) {
  .np-mai-card { flex-direction: column; min-height: 0; }
  .np-mai-media {
    flex: 0 0 auto;
    padding: 16px 0;            /* full-width neutral band, square centered */
    border-right: 0;
    border-bottom: 1px solid #ece8e0;
  }
  .np-mai-body { justify-content: flex-start; }
}

/* =============================================================
   Modal — shared #np-mai-modal body (populated on show via
   template-clone by barrioNpmMaiModal). Sibling of the partner modal
   with an added contact block.
   ============================================================= */
.np-mai-modal-content { color: #2c2c2b; }

/* ---------- two-column header ---------- */
.np-mai-modal-top {
  display: flex;
  gap: 26px;
  align-items: flex-start;
  margin: 2px 0 20px;
}

/* LEFT — square image + outbound CTA. */
.np-mai-modal-aside {
  flex: 0 0 200px;
  display: flex; flex-direction: column;
  gap: 14px;
}
.np-mai-modal-media {
  display: block;
  width: 200px; height: 200px;
  border-radius: 10px;
  overflow: hidden;
  background: #f6f4ef;
}
.np-mai-modal-media--empty {
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; letter-spacing: .16em;
  font-size: 30px; color: #cfc7b7;
}
.np-mai-modal-img {
  width: 100%; height: 100%;
  object-fit: cover; object-position: center;
  display: block;
}
.np-mai-modal-cta {
  display: block; text-align: center;
  padding: 9px 18px;
  border-radius: 999px;
  background: var(--np-mai);
  color: #fff; font-weight: 600; font-size: 14px;
  text-decoration: none;
  transition: background .15s;
}
.np-mai-modal-cta:hover {
  background: var(--np-mai-dk);
  color: #fff;
}

/* RIGHT — region kicker, title, contact block. */
.np-mai-modal-head { flex: 1; min-width: 0; }
.np-mai-modal-kicker {
  display: block;
  font-size: 10.5px; font-weight: 700;
  letter-spacing: .07em; text-transform: uppercase;
  color: var(--np-mai-dk);
  margin: 2px 0 6px;
}
.np-mai-modal-title {
  /* !important defeats typography.css h* { font-weight:100 !important }. */
  font-weight: 700 !important;
  font-size: clamp(21px, 2.4vw, 27px);
  letter-spacing: -.2px; line-height: 1.15;
  margin: 0 0 4px; color: #2c2c2b;
}

/* ---------- full-width body ---------- */
.np-mai-modal-body {
  font-size: 14.5px; color: #2c2c2b; line-height: 1.5;
  border-top: 1px solid #ece8e0;
  padding-top: 20px;
}
.np-mai-modal-body p { margin: 0 0 12px; }
.np-mai-modal-body p:last-child { margin-bottom: 0; }
.np-mai-modal-body a { color: var(--np-mai-dk); text-decoration: underline; }
/* Editor-embedded Google map (+ any other iframe) — keep inside the modal. */
.np-mai-modal-body iframe {
  max-width: 100%;
  border: 0;
  border-radius: 8px;
}

/* ---------- contact block ---------- */
.np-mai-contact {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 16px;
  margin: 18px 0 0;
  padding: 16px 0 0;
  border-top: 1px solid #ece8e0;
  font-size: 14px; line-height: 1.45;
}
.np-mai-contact dt {
  font-weight: 700; font-size: 10.5px;
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--np-mai-dk);
  padding-top: 2px;
}
.np-mai-contact dd {
  margin: 0;
  color: #2c2c2b;
}
.np-mai-contact dd a { color: var(--np-mai-dk); text-decoration: underline; }
.np-mai-contact-address p { margin: 0 0 4px; }
.np-mai-contact-address p:last-child { margin-bottom: 0; }

@media (max-width: 480px) {
  .np-mai-contact { grid-template-columns: 1fr; gap: 2px 0; }
  .np-mai-contact dd { margin-bottom: 10px; }
}

/* Stack the modal header (image over text) on narrow screens. */
@media (max-width: 560px) {
  .np-mai-modal-top { flex-direction: column; }
  .np-mai-modal-aside { flex: 0 0 auto; }
  .np-mai-modal-media {
    width: 100%; max-width: 220px; height: auto; aspect-ratio: 1 / 1;
  }
  .np-mai-modal-cta { max-width: 220px; }
}

/* -------------------------------------------------------------------
   Related people section — grouped by MAI-group role (Academic Lead
   / Co-ordinator / Member) with small round portraits. Sibling of
   .np-partner-researchers in partners.css; adds a role-sub-heading
   layer since MAI groups have a mixed roster. Each row is a data-api
   trigger that opens #np-researcher-modal via the Family-1 → Family-
   1 handoff (BS5 auto-hide branch). See mai-group-people-plan.md §4.4.
   ------------------------------------------------------------------- */
.np-mai-modal-people { margin-top: 24px; }
.np-mai-modal-people-head {
  /* !important defeats typography.css h1..h6 hairline weight override
     — same pattern .np-partner-researchers-head uses. */
  font-size: 13px !important;
  font-weight: 700 !important;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: #4a4a4a;
  margin: 0 0 12px;
}
.np-mai-modal-people-role {
  font-size: 14px !important;
  font-weight: 600 !important;
  color: var(--np-mai-dk, #4a4a4a);
  margin: 12px 0 6px;
}
.np-mai-modal-people-role:first-of-type { margin-top: 0; }
.np-mai-modal-people-list {
  list-style: none;
  padding: 0;
  margin: 0 0 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
/* Each <li> is a row that carries the main person anchor + the per-
   person edit pen (editor-only) side-by-side. Flex layout keeps the
   pen right-aligned; the anchor claims all remaining width. */
.np-mai-modal-people-list li {
  display: flex;
  align-items: center;
  gap: 4px;
}
.np-mai-modal-person {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 8px;
  border-radius: 6px;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .12s ease;
  flex: 1 1 auto;   /* claim all remaining width so the pen sits right */
  min-width: 0;
}
.np-mai-modal-person:hover,
.np-mai-modal-person:focus-visible {
  background: rgba(0, 0, 0, .04);
  color: inherit;
  text-decoration: none;
}
.np-mai-modal-person-portrait {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  background: #e8e5df;   /* placeholder tint behind silhouette SVG */
  flex-shrink: 0;
}
.np-mai-modal-person-name {
  font-size: 15px;
  font-weight: 600 !important;
  line-height: 1.3;
}
/* Per-person edit pen — editor-only (rendered by the twig only when
   the person's edit access resolves). Subtle by default so it doesn't
   compete with the main click target (the .np-mai-modal-person anchor
   opens the researcher modal); brightens on hover so editors can find
   it easily. Sits right-aligned via the parent <li>'s flex layout. */
.np-mai-modal-person-edit {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: #6a6a6a;
  text-decoration: none;
  opacity: .55;
  transition: opacity .12s ease, background-color .12s ease, color .12s ease;
}
.np-mai-modal-person-edit:hover,
.np-mai-modal-person-edit:focus-visible {
  background: rgba(0, 0, 0, .06);
  color: var(--np-mai-dk, #2c2c2b);
  opacity: 1;
  text-decoration: none;
}
