/* Article images.
   Shared by the article page (#article_content inside .art-single-wrap) and the
   game page (a game's description is a category-0 article), so every rule here
   is written to stand on its own rather than lean on either wrapper.

   Vocabulary the AI is taught, and that the deterministic placer emits:
     figure.art-img + one of  --full | --wide | --inset-right | --inset-left | --half | --thumb
     div.art-gallery  + one of  --2 | --3 | --4 | --mosaic   containing figure.art-gallery-item

   Any anchor carrying data-lb is picked up by js/article-lightbox.js. Without JS
   the anchor still opens the full-size WebP, so this degrades cleanly. */

/* ---------------------------------------------------------------- figure */

.art-img {
  margin: 22px 0;
  padding: 0;
  clear: none;
}

.art-img a {
  display: block;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line, #e5e7eb);
  border-radius: 2px;
  background: var(--paper, #fff);
  /* the article body underlines every <a>; an image link is not prose */
  border-bottom-width: 1px !important;
  text-decoration: none;
  cursor: zoom-in;
  line-height: 0;
}

.art-img a img,
.art-gallery-item a img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 0;
  transition: transform .45s cubic-bezier(.22, .61, .36, 1);
}

.art-img a:hover img,
.art-gallery-item a:hover img {
  transform: scale(1.025);
}

/* Corner ticks, the same detail the article header and aside cards use. */
.art-img a::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  width: 14px;
  height: 14px;
  border-right: 2px solid var(--bmm-accent);
  border-bottom: 2px solid var(--bmm-accent);
  opacity: 0;
  transition: opacity .2s ease;
  pointer-events: none;
}

.art-img a:hover::after { opacity: 1; }

.art-img-cap {
  margin-top: 7px;
  font-family: 'Fraunces', Georgia, serif;
  font-size: 13px;
  font-style: italic;
  line-height: 1.45;
  color: var(--muted, #6b7280);
}

/* ------------------------------------------------------- placement sizes */

.art-img--full { width: 100%; }

/* Breaks out past the text column. The clamp keeps it inside the viewport on
   narrow screens, where it settles back to full width. */
.art-img--wide {
  width: auto;
  margin-left: calc(-1 * clamp(0px, 4vw, 56px));
  margin-right: calc(-1 * clamp(0px, 4vw, 56px));
}

.art-img--half {
  width: 56%;
  margin-left: auto;
  margin-right: auto;
}

.art-img--thumb {
  width: 180px;
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
}

.art-img--inset-right,
.art-img--inset-left {
  width: 38%;
  max-width: 340px;
  margin-top: 6px;
}

.art-img--inset-right {
  float: right;
  margin-left: 24px;
  margin-right: 0;
}

.art-img--inset-left {
  float: left;
  margin-right: 24px;
  margin-left: 0;
}

/* ---------------------------------------------------------------- gallery */

.art-gallery {
  display: grid;
  gap: 10px;
  margin: 26px 0;
  clear: both;
}

.art-gallery--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.art-gallery--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.art-gallery--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.art-gallery--mosaic {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-rows: 1fr;
}

.art-gallery--mosaic > .art-gallery-item:first-child {
  grid-column: span 2;
  grid-row: span 2;
}

.art-gallery-item {
  margin: 0;
  padding: 0;
  min-width: 0;
}

.art-gallery-item a {
  display: block;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line, #e5e7eb);
  border-bottom-width: 1px !important;
  border-radius: 2px;
  background: var(--paper, #fff);
  text-decoration: none;
  cursor: zoom-in;
  line-height: 0;
}

/* A uniform crop is what makes a grid read as a gallery instead of a ragged
   pile. The lightbox always shows the uncropped image. */
.art-gallery-item a img {
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.art-gallery--mosaic > .art-gallery-item:first-child a img {
  aspect-ratio: 16 / 11;
}

.art-gallery-item .art-img-cap {
  margin-top: 5px;
  font-size: 12px;
}

/* ------------------------------------------------------------- responsive */

@media (max-width: 860px) {
  .art-gallery--4,
  .art-gallery--mosaic { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .art-gallery--mosaic > .art-gallery-item:first-child { grid-column: span 2; grid-row: span 2; }
}

@media (max-width: 640px) {
  .art-img--inset-right,
  .art-img--inset-left {
    float: none;
    width: 100%;
    max-width: none;
    margin-left: 0;
    margin-right: 0;
  }
  .art-img--half { width: 100%; }
  .art-img--wide { margin-left: 0; margin-right: 0; }
  .art-gallery--3,
  .art-gallery--4,
  .art-gallery--mosaic { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .art-gallery--mosaic > .art-gallery-item:first-child { grid-column: span 2; grid-row: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .art-img a img,
  .art-gallery-item a img { transition: none; }
  .art-img a:hover img,
  .art-gallery-item a:hover img { transform: none; }
}

/* -------------------------------------------------------------- lightbox */

.art-lb {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 56px 78px;
  background: rgba(12, 10, 20, .92);
  opacity: 0;
  transition: opacity .18s ease;
}

.art-lb.is-open { opacity: 1; }

.art-lb-stage {
  position: relative;
  max-width: 100%;
  max-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.art-lb-img {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 126px);
  width: auto;
  height: auto;
  border-radius: 2px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .55);
}

.art-lb-cap {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 26px;
  text-align: center;
  font-family: 'Fraunces', Georgia, serif;
  font-size: 14px;
  line-height: 1.5;
  color: #e9e6f5;
  padding: 0 24px;
  pointer-events: none;
}

.art-lb-count {
  position: absolute;
  left: 0;
  right: 0;
  top: 18px;
  text-align: center;
  font-size: 12px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: rgba(233, 230, 245, .6);
  pointer-events: none;
}

.art-lb button {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, .07);
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 2px;
  color: #fff;
  cursor: pointer;
  padding: 0;
  transition: background .16s ease, border-color .16s ease;
}

.art-lb button:hover {
  background: var(--bmm-accent, #7e3af2);
  border-color: var(--bmm-accent, #7e3af2);
}

.art-lb button:focus-visible {
  outline: 2px solid var(--bmm-accent, #7e3af2);
  outline-offset: 2px;
}

.art-lb-close {
  top: 14px;
  right: 14px;
  width: 38px;
  height: 38px;
}

.art-lb-prev,
.art-lb-next {
  top: 50%;
  transform: translateY(-50%);
  width: 42px;
  height: 64px;
}

.art-lb-prev { left: 10px; }
.art-lb-next { right: 10px; }

.art-lb svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

@media (max-width: 640px) {
  .art-lb { padding: 44px 12px 72px; }
  .art-lb-prev, .art-lb-next { width: 34px; height: 52px; }
  .art-lb-img { max-height: calc(100vh - 118px); }
}

body.art-lb-open { overflow: hidden; }
