/* ポスターと作品画像の拡大表示 */
.works-art-preview {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: clamp(20px, 5dvh, 56px) clamp(88px, 8vw, 120px);
  border: 0;
  background: transparent;
}

/* 周りは暗くして、ほかのダイアログ（common.css の dialog::backdrop）と同じくぼかす。 */
.works-art-preview::backdrop {
  background: rgb(50 52 74 / 80%);
}

.works-art-preview[open] {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.works-art-preview > picture {
  display: contents;
}

.works-art-preview img {
  flex: none;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: calc(100% - 56px);
  object-fit: contain;
}

/* トップのポスターの拡大：大きい画像（ローディング画面のあとに読む）が届くまでは、
   読み込み済みの4枚目のポスター（index.html と同じ URL）を同じ大きさで出しておく。 */
#poster-dialog img {
  background: url('../images/about/poster-preview.webp?v=20261129-light') center / contain no-repeat;
}

@media (prefers-reduced-motion: no-preference) {
  .works-art-preview[open] img {
    animation: works-art-preview-enter 260ms ease-out both;
  }
}

@media (max-width: 680px) {
  .works-art-preview {
    padding-inline: max(12px, env(safe-area-inset-left), env(safe-area-inset-right));
    padding-block-end: max(12px, env(safe-area-inset-bottom));
  }

  .works-art-preview[open] {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) 44px;
    grid-template-rows: minmax(0, 1fr) 44px;
    place-items: center;
  }

  .works-art-preview img {
    grid-column: 1 / -1;
    grid-row: 1;
    max-height: 100%;
  }

  .works-art-preview-close {
    grid-column: 2;
    grid-row: 2;
  }
}

@keyframes works-art-preview-enter {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.works-art-preview-close {
  flex: none;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  background: transparent url("../../works/img/batten.webp") center / contain no-repeat;
}
