.village-guide {
  position: relative;
}

.village-guide .collection-heading {
  display: block;
  margin-bottom: 18px;
}

.village-guide .collection-heading p {
  margin-top: 5px;
}

friend-cards.friend-list {
  position: relative;
  display: block;
  color: var(--ink);
}

.friend-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  align-items: end;
}

.friend-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 48px;
  padding: 5px 14px 6px;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: 9px 9px 0 0;
  background: none;
  color: var(--muted);
  font: 700 .93rem/1.3 var(--font-body);
}

.friend-tab:hover,
.friend-tab[aria-selected="true"] {
  color: var(--ink);
  background: var(--friend-sheet);
}

.friend-tab[aria-selected="true"] {
  border-color: var(--friend-line);
}

.friend-tab[aria-selected="true"]::after {
  position: absolute;
  inset: auto -1px 0;
  height: 3px;
  background: var(--ink);
  content: "";
}

.friend-tab:focus-visible {
  z-index: 1;
  outline-offset: -3px;
}

.friend-tab-face {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.friend-stamp:not([hidden]) {
  position: absolute;
  top: 0;
  right: 4px;
  width: 18px;
  height: 18px;
  overflow: hidden;
  border: 1px solid #9f2c51;
  border-radius: 50%;
  background: #fff6e8 url("assets/brand/friends/logo-paw.svg") center / 72% no-repeat;
  color: transparent;
  font-size: 0;
  transform: rotate(9deg);
}

.friend-list {
  --friend-sheet: var(--paper);
  --friend-line: var(--line);
}

.friend-list > .friend {
  /* Plate colors are sampled from the object kit's objects-overview.png. */
  --plate: #f6f6d8;
  --pose-x: 27%;
  --pose-width: 49%;
  --pose-height: 87%;
  --scene-x: 7%;
  --scene-y: 10%;
  --scene-width: 25%;
  --scene-height: 47%;
  --object-x: 74%;
  --object-y: 9%;
  --object-width: 15%;
  --object-height: 38%;
  position: relative;
  display: grid;
  grid-template-columns: 1.08fr 1fr;
  align-items: stretch;
  min-height: clamp(225px, 23vw, 290px);
  border-block: 1px solid var(--friend-line);
  background: var(--friend-sheet);
}

.friend[data-friend="dog"] {
  --plate: #fce4f3;
  --pose-x: 12%;
  --pose-width: 52%;
  --scene-x: 61%;
  --scene-y: 5%;
  --scene-width: 29%;
  --scene-height: 45%;
  --object-x: 65%;
  --object-width: 21%;
  --object-height: 40%;
}

.friend[data-friend="sheep"] {
  --plate: #e1f8e8;
  --pose-x: 40%;
  --pose-width: 53%;
  --pose-height: 82%;
  --scene-x: 8%;
  --scene-y: 3%;
  --scene-width: 33%;
  --scene-height: 55%;
  --object-x: 20%;
  --object-y: 2%;
  --object-width: 27%;
  --object-height: 46%;
}

.friend[data-friend="rabbit"] {
  --plate: #ffe8ea;
  --pose-x: 35%;
  --pose-width: 46%;
  --pose-height: 92%;
  --scene-x: 63%;
  --scene-y: 46%;
  --scene-width: 34%;
  --scene-height: 54%;
  --object-x: 14%;
  --object-y: 17%;
  --object-width: 21%;
  --object-height: 44%;
}

.friend-list > .friend:focus-visible {
  z-index: 1;
  outline-offset: 2px;
}

.friend-art {
  position: relative;
  overflow: hidden;
  background: var(--plate);
}

.friend-portrait,
.friend-object,
.friend-scene {
  position: absolute;
  object-fit: contain;
}

.friend-portrait {
  left: var(--pose-x);
  width: var(--pose-width);
  height: var(--pose-height);
  bottom: 6%;
  object-position: center bottom;
}

.friend-scene {
  left: var(--scene-x);
  top: var(--scene-y);
  width: var(--scene-width);
  height: var(--scene-height);
}

.friend-object {
  left: var(--object-x);
  bottom: var(--object-y);
  width: var(--object-width);
  height: var(--object-height);
  transform: rotate(-8deg);
}

.friend[data-friend="rabbit"] .friend-object { transform: rotate(8deg); }

.friend-content {
  align-self: center;
  padding: clamp(20px, 3.1vw, 46px) clamp(20px, 4.2vw, 64px);
}

.friend-content :is(h3,h4) {
  margin: 0 0 14px;
  color: var(--ink);
  font: 400 clamp(2rem, 4vw, 3.9rem)/1.05 var(--font-display);
  letter-spacing: -.055em;
}

.friend-facts > div {
  display: grid;
  grid-template-columns: 5.5em minmax(0, 1fr);
  align-items: baseline;
  gap: 8px;
  border-top: 1px solid var(--friend-line);
  padding-block: 9px;
}

.friend-facts dt {
  color: #5c564d;
  font-size: .82rem;
}

.friend-facts dd {
  color: var(--ink);
  font-size: clamp(.88rem, 1.2vw, 1.04rem);
  font-weight: 600;
  line-height: 1.45;
}

@media (min-width: 760px) {
  .village-guide .collection-heading {
    min-height: 65px;
    margin-bottom: 14px;
    padding-right: min(45%, 470px);
  }

  .village-guide .friend-tabs {
    position: absolute;
    right: 0;
    bottom: 100%;
  }
}

@media (max-width: 759px) {
  .friend-tabs {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .friend-tab {
    gap: 4px;
    padding-inline: 3px;
  }

  .friend-list > .friend {
    grid-template-columns: 1fr 1fr;
    min-height: 210px;
  }

  .friend-content {
    padding: 18px;
  }

  .friend-facts > div {
    grid-template-columns: 4.5em minmax(0, 1fr);
  }
}

@media (max-width: 520px) {
  .village-guide .collection-heading { margin-bottom: 10px; }
  .friend-tab { min-height: 46px; font-size: .83rem; }
  .friend-tab-face { width: 25px; height: 27px; }

  .friend-list > .friend {
    grid-template-columns: minmax(0, 1fr);
    min-height: 0;
  }

  .friend-art { height: clamp(138px, 42vw, 200px); }
  .friend-content {
    padding: 14px 16px 9px;
  }

  .friend-content :is(h3,h4) { margin-bottom: 8px; }

  .friend-facts > div {
    grid-template-columns: 5em minmax(0, 1fr);
    padding-block: 5px;
  }

  .friend-facts dt { font-size: .77rem; }
  .friend-facts dd { font-size: .87rem; }
}
