/* Model project galleries. The source remains ordinary Markdown image embeds;
   publish.js progressively enhances these into a navigable lightbox. */
.model-project {
  --file-line-width: 920px;
}

.callout[data-callout="model-gallery"] {
  border: 0;
  background: transparent;
  box-shadow: none;
  padding: 0;
}

.callout[data-callout="model-gallery"] > .callout-title {
  display: none;
}

.callout[data-callout="model-gallery"] > .callout-content {
  padding: 0;
  column-count: 2;
  column-width: auto;
  column-gap: clamp(0.75rem, 2vw, 1.25rem);
}

.callout[data-callout="model-gallery"] .callout-content > p {
  margin: 0;
}

.callout[data-callout="model-gallery"] .image-embed {
  display: block;
  width: 100%;
  margin: 0 0 clamp(0.75rem, 2vw, 1.25rem);
  break-inside: avoid;
  cursor: zoom-in;
  overflow: hidden;
  border-radius: 0.75rem;
  background: var(--background-secondary);
  user-select: none;
}

.callout[data-callout="model-gallery"] img,
.callout[data-callout="model-gallery"] .model-gallery__thumbnail {
  display: block;
  width: 100%;
  height: auto;
  max-height: none;
  object-fit: contain;
  border-radius: inherit;
  transition: transform 180ms ease, filter 180ms ease;
}

.callout[data-callout="model-gallery"] .model-gallery__source {
  display: none;
}

.callout[data-callout="model-gallery"] .image-embed:hover :is(img, .model-gallery__thumbnail) {
  transform: scale(1.015);
  filter: brightness(1.04);
}

.model-lightbox-open {
  overflow: hidden;
}

.model-lightbox {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: grid;
  grid-template-columns: minmax(3rem, 8vw) minmax(0, 1fr) minmax(3rem, 8vw);
  grid-template-rows: 4rem minmax(0, 1fr) 3rem;
  background: rgba(8, 10, 14, 0.96);
  color: #fff;
  opacity: 0;
  transition: opacity 160ms ease;
}

.model-lightbox.is-open {
  opacity: 1;
}

.model-lightbox__stage {
  grid-column: 2;
  grid-row: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.model-lightbox__image {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  touch-action: none;
  cursor: grab;
  transform-origin: center;
}

.model-lightbox__image:active {
  cursor: grabbing;
}

.model-lightbox__button {
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  box-shadow: none;
  padding: 0;
  opacity: 0.8;
  transition: opacity 140ms ease, background 140ms ease;
}

.model-lightbox__button:hover,
.model-lightbox__button:focus-visible {
  opacity: 1;
  background: rgba(255, 255, 255, 0.1);
  outline: none;
}

.model-lightbox__close {
  grid-column: 3;
  grid-row: 1;
  justify-self: end;
  width: 4rem;
  font-size: 2rem;
}

.model-lightbox__previous,
.model-lightbox__next {
  grid-row: 2;
  align-self: center;
  justify-self: center;
  position: relative;
  display: block;
  width: clamp(2.75rem, 5vw, 3.5rem);
  height: clamp(2.75rem, 5vw, 3.5rem);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 50%;
  background: rgba(24, 27, 33, 0.68);
  font-size: 0;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.model-lightbox__previous::before,
.model-lightbox__next::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0.65rem;
  height: 0.65rem;
  border-top: 2px solid currentColor;
  border-right: 2px solid currentColor;
}

.model-lightbox__previous {
  grid-column: 1;
}

.model-lightbox__previous::before {
  transform: translate(-42%, -50%) rotate(-135deg);
}

.model-lightbox__next {
  grid-column: 3;
}

.model-lightbox__next::before {
  transform: translate(-58%, -50%) rotate(45deg);
}

.model-lightbox__counter {
  grid-column: 2;
  grid-row: 3;
  align-self: center;
  justify-self: center;
  margin: 0;
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.85rem;
  letter-spacing: 0.08em;
}

@media (max-width: 600px) {
  .callout[data-callout="model-gallery"] > .callout-content {
    column-count: 1;
  }

  .model-lightbox {
    grid-template-columns: 3rem minmax(0, 1fr) 3rem;
  }
}
