.crew-organization {
  overflow: hidden;
  background: #f7f1ec;
}

.crew-organization .section-head {
  align-items: flex-end;
}

.crew-organization-description {
  width: min(390px, 100%);
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.8;
}

.crew-org-chart {
  display: grid;
  width: min(1180px, 100%);
  margin: auto;
  gap: 34px;
}

.crew-org-region {
  display: grid;
  gap: 12px;
}

.crew-org-region-title {
  margin: 0;
  color: #77716e;
  font: 700 12px/1.3 var(--sans);
  letter-spacing: .12em;
}

.crew-org-region-body {
  display: grid;
  grid-template-columns: 242px minmax(0, 1fr);
  align-items: start;
  gap: 18px;
}

.crew-org-leads,
.crew-org-grid {
  display: grid;
  gap: 10px;
}

.crew-org-leads {
  width: min(100%, 196px);
  grid-template-columns: repeat(2, minmax(0, 93px));
}

.crew-org-grid {
  grid-template-columns: repeat(9, minmax(0, 1fr));
}

.crew-org-card {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  padding: 0;
  border: 1px solid #d8cbca;
  border-radius: 24px;
  background: #e8ded9;
  color: #fff;
  text-align: left;
  box-shadow: 0 10px 28px rgba(67, 43, 45, .08);
}

.crew-org-card.is-featured {
  box-shadow: 0 16px 38px rgba(74, 42, 49, .12);
}

.crew-org-card.is-lead {
  border-color: #c8afb5;
}

.crew-org-photo {
  position: absolute;
  inset: 0;
  display: block;
  border-radius: inherit;
  background-color: #e8ded9;
  background-position: var(--member-x) var(--member-y) !important;
  background-repeat: no-repeat !important;
  background-size: 900% auto !important;
  transition: transform .45s ease, filter .35s ease;
}

.crew-org-photo.has-uploaded-avatar {
  background-position: center !important;
  background-size: cover !important;
}

.crew-org-overlay {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 17px 14px;
  background: linear-gradient(180deg, rgba(31, 20, 21, .08) 10%, rgba(40, 22, 27, .94) 100%);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .25s ease, transform .25s ease;
}

.crew-org-overlay>small {
  margin-bottom: 5px;
  color: #e1b9c0;
  font-size: 7px;
  font-weight: 800;
  letter-spacing: .16em;
}

.crew-org-overlay>strong {
  font: 700 22px/1.15 var(--serif);
}

.crew-org-strength {
  display: block;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, .32);
  color: #f2eaea;
  font-size: 9px;
  line-height: 1.5;
  word-break: keep-all;
}

.crew-org-card:hover .crew-org-photo,
.crew-org-card:focus-visible .crew-org-photo,
.crew-org-card[aria-expanded="true"] .crew-org-photo {
  filter: saturate(.75) brightness(.66);
  transform: scale(1.035);
}

.crew-org-card:hover .crew-org-overlay,
.crew-org-card:focus-visible .crew-org-overlay,
.crew-org-card[aria-expanded="true"] .crew-org-overlay {
  opacity: 1;
  transform: none;
}

.crew-org-card:focus-visible {
  outline: 3px solid var(--wine);
  outline-offset: 3px;
}

.crew-organization-status {
  min-height: 18px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

@media (max-width: 1060px) {
  .crew-org-region-body {
    grid-template-columns: 242px minmax(0, 1fr);
  }

  .crew-org-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .crew-organization-description {
    margin-top: 22px;
    font-size: 12px;
  }

  .crew-org-chart {
    gap: 30px;
  }

  .crew-org-region {
    gap: 10px;
  }

  .crew-org-region-body {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .crew-org-leads {
    width: min(100%, 174px);
    grid-template-columns: repeat(2, minmax(0, 83px));
  }

  #crew-seoul-leads,
  #crew-incheon-leads,
  #crew-cheonan-leads,
  #crew-busan-leads {
    margin-inline: auto;
  }

  .crew-org-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
  }

  .crew-org-grid .crew-org-card {
    width: 80%;
    justify-self: center;
  }

  .crew-org-region .crew-profile-detail {
    margin-top: 0;
  }

  .crew-org-card {
    border-radius: 18px;
  }

  .crew-org-overlay {
    padding: 16px 13px;
  }

  .crew-org-overlay>strong {
    font-size: 21px;
  }

  .crew-org-strength {
    font-size: 9px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .crew-org-photo,
  .crew-org-overlay {
    transition: none;
  }
}

/* Center an incomplete lead row without changing the two-column card size. */
.crew-org-leads > .crew-org-card:nth-last-child(1):nth-child(2n + 1) {
  grid-column: 1 / -1;
  width: calc((100% - 10px) / 2);
  justify-self: center;
}

/* Double the grid tracks so every possible incomplete row can stay centered. */
.crew-org-grid {
  grid-template-columns: repeat(18, minmax(0, 1fr));
}

.crew-org-grid > .crew-org-card {
  grid-column-end: span 2;
}

@media (min-width: 1061px) {
  .crew-org-grid > .crew-org-card:nth-last-child(1):nth-child(9n + 1) { grid-column-start: 9; }
  .crew-org-grid > .crew-org-card:nth-last-child(2):nth-child(9n + 1) { grid-column-start: 8; }
  .crew-org-grid > .crew-org-card:nth-last-child(3):nth-child(9n + 1) { grid-column-start: 7; }
  .crew-org-grid > .crew-org-card:nth-last-child(4):nth-child(9n + 1) { grid-column-start: 6; }
  .crew-org-grid > .crew-org-card:nth-last-child(5):nth-child(9n + 1) { grid-column-start: 5; }
  .crew-org-grid > .crew-org-card:nth-last-child(6):nth-child(9n + 1) { grid-column-start: 4; }
  .crew-org-grid > .crew-org-card:nth-last-child(7):nth-child(9n + 1) { grid-column-start: 3; }
  .crew-org-grid > .crew-org-card:nth-last-child(8):nth-child(9n + 1) { grid-column-start: 2; }
}

@media (min-width: 681px) and (max-width: 1060px) {
  .crew-org-grid { grid-template-columns: repeat(10, minmax(0, 1fr)); }
  .crew-org-grid > .crew-org-card:nth-last-child(1):nth-child(5n + 1) { grid-column-start: 5; }
  .crew-org-grid > .crew-org-card:nth-last-child(2):nth-child(5n + 1) { grid-column-start: 4; }
  .crew-org-grid > .crew-org-card:nth-last-child(3):nth-child(5n + 1) { grid-column-start: 3; }
  .crew-org-grid > .crew-org-card:nth-last-child(4):nth-child(5n + 1) { grid-column-start: 2; }
}

@media (max-width: 680px) {
  .crew-org-grid { grid-template-columns: repeat(8, minmax(0, 1fr)); }
  .crew-org-grid > .crew-org-card:nth-last-child(1):nth-child(4n + 1) { grid-column-start: 4; }
  .crew-org-grid > .crew-org-card:nth-last-child(2):nth-child(4n + 1) { grid-column-start: 3; }
  .crew-org-grid > .crew-org-card:nth-last-child(3):nth-child(4n + 1) { grid-column-start: 2; }
}

/* Seoul and Cheonan start incomplete rows at the grid edge. */
#crew-seoul-grid > .crew-org-card,
#crew-cheonan-grid > .crew-org-card {
  grid-column-start: auto;
}

/* Cheonan follows Busan's card sizing. */
#crew-cheonan-grid > .crew-org-card {
  height: auto;
  aspect-ratio: 4 / 5;
}
