/* --------- People block (blocks/people) --------- */

.people-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.person {
  position: relative;
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 24px 21px clamp(24px, 0.75vw + 21.6px, 32px);
  border: 2px solid var(--wp--preset--color--outline);
  border-radius: 32px;
  color: var(--wp--preset--color--contrast);
  transition:
    background-color 0.2s ease,
    border-color 0.2s ease,
    color 0.2s ease;
}

/* The card's shape at every width, so the crop the photo was cut to (head
   room included) never changes. */
.person-photo {
  aspect-ratio: 357 / 339;
  overflow: hidden;
  border-radius: 16px;
  background-color: var(--wp--preset--color--surface);
}

.person-photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
}

/* In place of a photo not yet set (render.php); in the popup too. */
.person-silhouette {
  display: block;
  height: 100%;
  background-color: color-mix(in srgb, var(--wp--preset--color--primary) 16%, transparent);
  mask: url(../../assets/img/silhouette-male.png) no-repeat center bottom / auto 86%;
  -webkit-mask: url(../../assets/img/silhouette-male.png) no-repeat center bottom / auto 86%;
}

.person-silhouette--female {
  mask-image: url(../../assets/img/silhouette-female.png);
  -webkit-mask-image: url(../../assets/img/silhouette-female.png);
}

/* Style Black and white: the photos in grey (the Board on Our People). */
.is-style-black-and-white .person-photo img,
.person-modal--mono .person-modal-photo img {
  filter: grayscale(1);
}

.person-body {
  padding: 22px 16px 0;
}

.person .person-name {
  margin: 0;
  color: var(--wp--preset--color--primary);
  font-size: var(--wp--preset--font-size--xl);
  font-weight: 500;
  line-height: 1.2;
  transition: color 0.2s ease;
}

.person-role {
  margin: 6px 0 0;
  font-size: var(--wp--preset--font-size--small);
  line-height: 1.4;
}

/* Only a card that opens a popup has an arrow, and view.js makes it one:
   without the script there is nothing to open. */
.person-arrow {
  display: none;
  width: 10px;
  height: 10px;
  margin: 20px 16px 0;
  background-color: var(--wp--preset--color--primary);
  mask: url(../../assets/img/arrow-down-right.svg) no-repeat center / contain;
  -webkit-mask: url(../../assets/img/arrow-down-right.svg) no-repeat center / contain;
  transition:
    background-color 0.2s ease,
    translate 0.2s ease;
}

.person.is-interactive .person-arrow {
  display: block;
}

/* The name's button covers the whole card. */
.person-open {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  line-height: inherit;
  text-align: left;
  cursor: pointer;
}

.person-open::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
}

.person-open:focus-visible {
  outline: none;
}

.person:has(.person-open:focus-visible) {
  outline: 2px solid var(--wp--preset--color--primary);
  outline-offset: 2px;
}

@media (hover: hover) {
  .person.is-interactive:hover {
    border-color: var(--wp--preset--color--primary);
    background-color: var(--wp--preset--color--primary);
    color: var(--wp--preset--color--base);
  }

  .person.is-interactive:hover .person-name {
    color: var(--wp--preset--color--base);
  }

  .person.is-interactive:hover .person-arrow {
    background-color: var(--wp--preset--color--secondary);
    translate: 3px 3px;
  }
}

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

  .person-body {
    padding-inline: 8px;
  }

  .person-arrow {
    margin-inline: 8px;
  }
}

@media (max-width: 599px) {
  .people-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* --------- The popup --------- */

/* Not a <dialog>: the page under it has to stay still and dim, which
   AGENTS.md (JavaScript) explains. view.js moves it to the end of <body>
   and makes the rest of the page inert while it is open. */
.person-modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: grid;
  place-items: center;
  padding: var(--wp--preset--spacing--50);
  background-color: rgb(11 19 81 / 0.45);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.person-modal[hidden] {
  display: none;
}

.person-modal.is-open {
  opacity: 1;
}

.person-modal-panel {
  position: relative;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  column-gap: var(--wp--preset--spacing--60);
  box-sizing: border-box;
  width: min(100%, 1000px);
  max-height: min(680px, 100dvh - 2 * var(--wp--preset--spacing--50));
  padding: var(--wp--preset--spacing--60);
  border: 2px solid var(--wp--preset--color--outline);
  border-radius: 32px;
  background-color: var(--wp--preset--color--base);
  color: var(--wp--preset--color--contrast);
  translate: 0 12px;
  transition: translate 0.2s ease;
}

.is-open .person-modal-panel {
  translate: 0 0;
}

.person-modal-panel:focus {
  outline: none;
}

.person-modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background-color: var(--wp--preset--color--base);
  color: var(--wp--preset--color--primary);
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.person-modal-close:hover {
  background-color: var(--wp--preset--color--secondary);
}

.person-modal-close:focus-visible {
  outline: 2px solid var(--wp--preset--color--primary);
  outline-offset: 2px;
}

.person-modal-photo {
  grid-row: 1 / 3;
  align-self: start;
  aspect-ratio: 357 / 339;
  overflow: hidden;
  border-radius: 16px;
  background-color: var(--wp--preset--color--surface);
}

.person-modal-photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
}

.person-modal-head {
  padding: 8px 48px var(--wp--preset--spacing--40) 0;
  border-bottom: 2px solid var(--wp--preset--color--secondary);
}

.person-modal .person-modal-name {
  margin: 0;
  color: var(--wp--preset--color--primary);
  font-size: var(--wp--preset--font-size--xxl);
  font-weight: 500;
  line-height: 1.15;
}

.person-modal-role {
  margin: 8px 0 0;
  font-size: var(--wp--preset--font-size--normal);
  line-height: 1.4;
}

/* Scrolls inside the popup when the bio is longer than the room, with a
   thin gold thumb on a pale track. */
.person-modal-bio {
  min-height: 0;
  margin-top: var(--wp--preset--spacing--40);
  padding-right: 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
  font-size: var(--wp--preset--font-size--normal);
  line-height: 1.6;
}

/* Firefox only: Chrome ignores the ::-webkit-scrollbar rules below once
   these are set, and draws its thin scrollbar with arrow buttons. */
@supports not selector(::-webkit-scrollbar) {
  .person-modal-bio {
    scrollbar-width: thin;
    scrollbar-color: var(--wp--preset--color--outline) var(--wp--preset--color--surface);
  }
}

.person-modal-bio::-webkit-scrollbar {
  width: 6px;
}

.person-modal-bio::-webkit-scrollbar-track {
  border-radius: 3px;
  background-color: var(--wp--preset--color--surface);
}

.person-modal-bio::-webkit-scrollbar-thumb {
  border-radius: 3px;
  background-color: var(--wp--preset--color--outline);
}

.person-modal-bio:focus-visible {
  outline: 2px solid var(--wp--preset--color--primary);
  outline-offset: 4px;
  border-radius: 4px;
}

.person-modal-bio > :first-child {
  margin-top: 0;
}

.person-modal-bio > :last-child {
  margin-bottom: 0;
}

.person-modal-bio p {
  margin: 0 0 1em;
}

/* While a popup is open the page does not scroll; the gutter keeps the
   page from shifting sideways when its scrollbar goes. */
.is-modal-open {
  overflow: hidden;
  scrollbar-gutter: stable;
}

@media (max-width: 781px) {
  .person-modal {
    padding: 16px;
  }

  .person-modal-panel {
    grid-template-columns: 112px minmax(0, 1fr);
    column-gap: 16px;
    max-height: calc(100dvh - 32px);
    padding: 24px 20px;
    border-radius: 24px;
  }

  .person-modal-close {
    top: 8px;
    right: 8px;
  }

  .person-modal-photo {
    grid-row: auto;
    border-radius: 12px;
  }

  .person-modal-head {
    align-self: center;
    padding: 0 32px 0 0;
    border-bottom: 0;
  }

  .person-modal .person-modal-name {
    font-size: var(--wp--preset--font-size--large);
  }

  .person-modal-role {
    font-size: var(--wp--preset--font-size--x-small);
  }

  .person-modal-bio {
    grid-column: 1 / -1;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid var(--wp--preset--color--secondary);
    padding-right: 12px;
    font-size: var(--wp--preset--font-size--small);
  }
}

@media (prefers-reduced-motion: reduce) {
  .person,
  .person .person-name,
  .person-arrow,
  .person-modal,
  .person-modal-panel,
  .person-modal-close {
    transition: none;
  }
}
