.popup {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(255, 254, 248, 0.72);
}

.popup.open {
  display: flex;
}

.popup-card {
  position: relative;
  width: min(720px, 94vw);
  max-height: 92vh;
  overflow-y: auto;
  padding: 22px;
  border: 4px solid #000;
  background:
    linear-gradient(var(--grid-small) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-small) 1px, transparent 1px),
    var(--paper);
  background-size: 18px 18px;
  box-shadow: 12px 12px 0 #000;
  transform: rotate(-1deg);
}

.popup-card::before {
  content: "";
  position: absolute;
  top: -19px;
  left: 50%;
  width: 158px;
  height: 34px;
  transform: translateX(-50%) rotate(2deg);
  background: rgba(255, 233, 145, 0.82);
  box-shadow: 0 8px 13px rgba(0, 0, 0, 0.14);
}

.popup-top {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 16px;
}

.tag {
  color: var(--blue);
  border-bottom: 3px solid currentColor;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 17px;
  font-weight: var(--font-medium);
}

.close {
  width: 38px;
  height: 38px;
  border: 2px solid #000;
  background: #fff;
  box-shadow: 4px 4px 0 #000;
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
  font-weight: var(--font-heavy);
}

.popup-image {
  display: grid;
  place-items: center;
  aspect-ratio: 1.12 / 1;
  min-height: 300px;
  margin: 18px 0;
  border: 2px solid #67c18e;
  background: var(--blue-soft);
  font-size: 42px;
  font-weight: var(--font-heavy);
  overflow: hidden;
}

.popup-selected {
  display: inline-block;
  margin: 10px 0 0;
  color: var(--ink);
  border-bottom: 3px solid var(--blue);
  font-size: clamp(24px, 4vw, 34px);
  line-height: 1.05;
  font-weight: var(--font-heavy);
}

.popup-selected[hidden] {
  display: none;
}

.popup-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 14px 0 2px;
  scrollbar-width: thin;
}

.popup-tab {
  flex: 1 1 150px;
  min-height: 42px;
  border: 2px solid #000;
  background: #fff;
  color: var(--blue);
  box-shadow: 3px 3px 0 #000;
  padding: 8px 12px;
  cursor: pointer;
  font-weight: var(--font-heavy);
  text-align: center;
}

.popup-tab[aria-selected="true"] {
  background: var(--blue);
  color: #fff;
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 #000;
}

.popup-image img {
  width: 100%;
  height: 100%;
  max-height: min(520px, 56vh);
  object-fit: contain;
  display: none;
  background: #fff;
}

.popup-image.has-image {
  display: block;
  background: #fff;
  aspect-ratio: auto;
  min-height: 0;
}

.popup-image.has-image img {
  display: block;
  width: 100%;
  height: auto;
  max-height: none;
  object-fit: contain;
  object-position: center top;
}

.popup-image.has-image span {
  display: none;
}

.popup-image.gallery {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 10px;
  background: #fffef8;
}

.popup-image.gallery img {
  width: 100%;
  height: 240px;
  object-fit: contain;
  border: 2px solid #67c18e;
  background: #fff;
}

.popup-card h2 {
  margin: 0;
  font-size: clamp(42px, 7vw, 68px);
  line-height: 0.95;
  color: var(--blue);
  font-weight: var(--font-heavy);
}

.popup-copy {
  margin-top: 10px;
}

.popup-copy p {
  margin: 10px 0 0;
  font-size: 22px;
  line-height: 1.35;
  font-weight: var(--font-book);
}

.popup-section {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 2px solid rgba(0, 0, 0, 0.12);
}

.popup-section:first-child {
  margin-top: 8px;
  padding-top: 0;
  border-top: 0;
}

.popup-section h3 {
  margin: 0 0 6px;
  color: var(--blue);
  border-bottom: 3px solid currentColor;
  display: inline-block;
  font-size: 22px;
  line-height: 1.1;
  font-weight: var(--font-heavy);
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 2px solid rgba(0, 0, 0, 0.14);
}

.pill {
  border: 2px solid #000;
  background: #fff;
  color: #000;
  padding: 7px 10px;
  box-shadow: 3px 3px 0 #000;
  font-weight: var(--font-medium);
  text-decoration: none;
}

.website-pill {
  background: var(--blue);
  color: #fff;
}

@media (max-width: 640px) {
  .popup {
    align-items: stretch;
    padding: 12px;
  }

  .popup-card {
    width: 100%;
    max-height: calc(100vh - 24px);
    padding: 16px;
    box-shadow: 6px 6px 0 #000;
    transform: none;
  }

  .popup-image {
    min-height: 210px;
    margin: 12px 0;
    font-size: 32px;
  }

  .popup-image.gallery {
    grid-template-columns: 1fr;
  }

  .popup-copy p {
    font-size: 18px;
  }

  .popup-tab {
    flex-basis: calc(33.333% - 7px);
    min-width: 0;
    min-height: 40px;
    padding: 7px 6px;
    font-size: 15px;
  }
}
