/* Preserve each desktop's original width; its phone follows the same height. */
@media (min-width: 851px) {
  .portfolio-category { container-type: inline-size; }
  .portfolio-category .portfolio-showcase {
    --legacy-wrap: min(1320px, calc(100cqw - 112px));
    width: calc(100% - 64px);
    max-width: 1660px;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: none;
    gap: 40px;
  }
  .showcase-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) max-content;
    gap: clamp(22px, 2vw, 36px);
    align-items: center;
    min-width: 0;
  }
  .showcase-row-left { grid-template-columns: max-content minmax(0, 1fr); }
  .showcase-row-left > .portfolio-device-pair { grid-column: 1; grid-row: 1; }
  .showcase-row-left > .showcase-copy { grid-column: 2; grid-row: 1; }
  .portfolio-device-pair {
    --desktop-span: 8;
    --desktop-size: calc((var(--legacy-wrap) + 24px) * var(--desktop-span) / 12 - 24px);
    --preview-height: calc((var(--desktop-size) - var(--preview-inset)) / var(--preview-ratio) + var(--preview-inset));
    --mobile-size: calc((var(--preview-height) - 16px) * .55 + 16px);
    display: grid;
    grid-template-columns: var(--desktop-size) var(--mobile-size);
    gap: 18px;
    align-items: center;
    min-width: 0;
  }
  .device-pair-second { --desktop-span: 6; }
  .showcase-row-left .portfolio-device-pair { grid-template-columns: var(--mobile-size) var(--desktop-size); }
  .portfolio-device-pair > .portfolio-shot { grid-area: auto; min-width: 0; }
  .showcase-row-left .portfolio-desktop-shot { grid-column: 2; grid-row: 1; }
  .showcase-row-left .portfolio-mobile-shot { grid-column: 1; grid-row: 1; }
  .portfolio-category .showcase-row > .showcase-heading,
  .portfolio-category .showcase-row > .showcase-copy { min-width: 0; max-width: none; padding: 0; margin: 0; }
  .portfolio-category .showcase-row > .showcase-copy { width: 100%; max-width: 38ch; justify-self: center; }
  .showcase-row-right > .showcase-heading,
  .showcase-row-right > .showcase-copy { grid-area: auto; }
  .showcase-row > .showcase-heading { container-type: inline-size; }
  .portfolio-category .showcase-heading .showcase-title { font-size: clamp(30px, 18cqw, 72px); line-height: 1.06; max-width: 100%; text-align: center; }
  .portfolio-category .showcase-heading .showcase-title > em { font-size: .79em; letter-spacing: .025em; line-height: 1.18; }
  .portfolio-category .showcase-copy p { font-size: 16px; line-height: 1.65; margin-bottom: 14px; }
  .portfolio-category .showcase-copy p:last-child { margin-bottom: 0; }
  .portfolio-mobile-shot { height: var(--preview-height); }
  .portfolio-mobile-shot .portfolio-image { height: 100%; }
}
.portfolio-category .portfolio-mobile-shot { padding: 6px; border-radius: 10px; }
.portfolio-category .portfolio-mobile-shot .portfolio-image { border-radius: 4px; aspect-ratio: 11 / 20; }
.portfolio-category .portfolio-mobile-shot img { width: 100%; height: 100%; aspect-ratio: 11 / 20; object-fit: contain; object-position: center; }
.portfolio-category .portfolio-mobile-shot::before,
.portfolio-category .portfolio-mobile-shot::after { width: 28px; height: 28px; }
@media (min-width: 851px) and (max-width: 1100px) {
  .portfolio-category .portfolio-showcase { --legacy-wrap: calc(100cqw - 64px); }
}
@media (min-width: 851px) and (max-width: 970px) {
  .device-pair-first, .device-pair-third, .device-pair-fourth { --desktop-span: 7; }
}
/* At narrower desktop sizes, the copy moves above the unchanged image pairing. */
@media (min-width: 851px) and (max-width: 1180px) {
  .showcase-row { display: flex; flex-direction: column; align-items: stretch; gap: 24px; }
  .showcase-row .portfolio-device-pair { align-self: flex-end; }
  .showcase-row-left .portfolio-device-pair { align-self: flex-start; }
  .portfolio-category .showcase-row > .showcase-copy { max-width: 42ch; align-self: center; }
  .portfolio-category .showcase-heading .showcase-title { font-size: clamp(40px, 5vw, 50px); }
  .showcase-heading .showcase-title > span, .showcase-heading .showcase-title em > span { display: inline; }
}
/* Two full-width desktops, followed by their two phone screenshots together. */
@media (max-width: 850px) {
  .portfolio-category .portfolio-showcase {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas: 'heading heading' 'copy copy' 'first first' 'second second' 'mobile-first mobile-second';
    gap: 24px 16px;
  }
  .portfolio-category .portfolio-showcase-extended {
    grid-template-areas: 'heading heading' 'copy copy' 'first first' 'second second' 'mobile-first mobile-second'
      'more more' 'third third' 'fourth fourth' 'mobile-third mobile-fourth' 'last last';
  }
  .showcase-row, .portfolio-device-pair { display: contents; }
  .portfolio-mobile-shot { width: min(100%, 260px); height: auto; align-self: start; }
  .showcase-mobile-first { grid-area: mobile-first; justify-self: end; }
  .showcase-mobile-second { grid-area: mobile-second; justify-self: start; }
  .showcase-mobile-third { grid-area: mobile-third; justify-self: end; }
  .showcase-mobile-fourth { grid-area: mobile-fourth; justify-self: start; }
  .portfolio-category .showcase-copy p { font-size: 15px; line-height: 1.65; }
  .portfolio-category .portfolio-mobile-shot::before,
  .portfolio-category .portfolio-mobile-shot::after { width: 22px; height: 22px; }
}
