.grv {
  padding-block: 48px;
  scroll-margin-top: 80px;
  color: var(--sb-color-white);
  background: var(--sb-color-blue);
}

.grv-heading {
  margin-bottom: 28px;
}

.grv .sb-chapter-label {
  --sb-chapter-label-bg: var(--sb-color-cream);
  --sb-chapter-label-text: var(--sb-color-blue);
}

.grv-heading h2 {
  margin: 16px 0 12px;
  font-size: var(--sb-type-section-title);
  line-height: 1.5;
}

.grv-heading > p:last-child {
  margin: 0;
  color: var(--sb-color-cream);
  font-size: var(--sb-type-detail);
  line-height: 1.8;
}

.grv-grid {
  display: grid;
  grid-template-columns: repeat(var(--grv-columns), minmax(0, 1fr));
  gap: 24px;
  margin: 0 auto;
  padding: 0;
  list-style: none;
}

.grv-grid--1 {
  max-width: 380px;
}

.grv-grid--2 {
  max-width: 760px;
}

.grv-grid--3 {
  max-width: 1040px;
}

.grv-card {
  position: relative;
  min-width: 0;
  background: var(--sb-surface-canvas);
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 20px), calc(100% - 20px) 100%, 0 100%);
}

.grv-sample {
  display: flex;
  flex-direction: column;
  height: 100%;
  color: var(--sb-color-blue);
  text-decoration: none;
}

.grv-sample:focus-visible {
  outline-offset: -5px;
}

.grv-art {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  height: 342px;
  padding: 48px 28px 20px;
}

.grv-art img {
  width: auto;
  height: 100%;
  max-width: 100%;
  object-fit: contain;
  mask: var(--grv-mask) center / 100% 100% no-repeat;
}

.grv-code {
  position: absolute;
  top: 18px;
  left: 20px;
  color: var(--sb-color-blue);
  font-size: var(--sb-type-detail);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.grv-caption {
  display: flex;
  flex: 1;
  flex-direction: column;
  margin-inline: 20px;
  padding-block: 18px 24px;
  border-top: 1px solid var(--sb-border-warm);
}

.grv-caption h3 {
  margin: 0 0 14px;
  font-size: var(--sb-type-body);
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.grv-more {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: auto;
  font-size: var(--sb-type-detail);
  font-weight: 700;
}

.grv-sample:hover .grv-more {
  text-decoration: underline;
  text-underline-offset: .25em;
}

.grv-favorite {
  position: absolute;
  top: 10px;
  right: 10px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--sb-color-blue);
  color: var(--sb-color-blue);
  background: var(--sb-color-cream);
}

.grv-favorite[aria-pressed="true"],
.grv-favorite:hover {
  background: var(--sb-color-yellow);
}

.grv-star {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linejoin: round;
}

.grv-favorite[aria-pressed="true"] .grv-star {
  fill: currentColor;
}

.grv-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 20px 32px;
  margin-top: 32px;
}

.grv-browse,
.grv-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-height: var(--sb-control-min-height);
  font-size: var(--sb-type-detail);
  font-weight: 700;
  line-height: 1.7;
}

.grv-browse {
  padding: 12px 22px;
  border: 1px solid var(--sb-color-cream);
  color: var(--sb-color-blue);
  background: var(--sb-color-cream);
  text-decoration: none;
}

.grv-browse:hover {
  background: var(--sb-color-yellow);
}

.grv-back {
  color: var(--sb-color-white);
  text-underline-offset: .3em;
}

.grv-empty {
  margin: 0;
  padding: 32px;
  color: var(--sb-color-blue);
  background: var(--sb-surface-canvas);
  text-align: center;
}

@media (max-width: 800px) {
  .grv {
    padding-block: 36px;
  }

  .grv-heading h2 {
    font-size: var(--sb-type-section-title-mobile);
  }

  .grv-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px 14px;
    max-width: none;
  }

  .grv-grid--1 {
    grid-template-columns: minmax(0, 1fr);
    max-width: 340px;
  }

  .grv-art {
    height: 288px;
    padding: 42px 12px 16px;
  }

  .grv-code {
    top: 19px;
    left: 12px;
  }

  .grv-favorite {
    right: 8px;
  }

  .grv-caption {
    margin-inline: 14px;
    padding-block: 14px 22px;
  }

  .grv-caption h3 {
    font-size: var(--sb-type-detail);
  }

  .grv-footer {
    flex-direction: column;
    gap: 12px;
    margin-top: 28px;
  }

  .grv-browse {
    width: 100%;
    padding-inline: 14px;
  }
}
