html:has(.lightbox[open]) {
  overflow: hidden;
}

.lightbox {
  width: 100vw;
  height: 100vh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 4.5rem 1.5rem 1.5rem;
  border: 0;
  background: transparent;
}

.lightbox[open] {
  display: flex;
  align-items: center;
  justify-content: center;
  animation: lightbox-in 0.3s ease;
}

.lightbox::backdrop {
  background: rgba(5, 5, 5, 0.94);
}

.lightbox-stage {
  position: relative;
  max-width: 100%;
  border-radius: 8px;
  transition: outline-color 0.5s ease;
  outline: 1px solid transparent;
}

.lightbox-stage.is-building {
  outline-color: var(--line-strong);
  background: var(--ink);
  cursor: pointer;
}

.lightbox-phase {
  position: absolute;
  left: 0;
  top: -1.9rem;
  margin: 0;
  font-family: var(--mono);
  font-size: 0.65rem;
  line-height: 1;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: pre;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.lightbox-stage.is-building .lightbox-phase {
  opacity: 1;
}

.build-canvas,
.build-cursors {
  position: absolute;
  inset: 0;
}

.build-canvas {
  z-index: 0;
}

.build-cursors {
  z-index: 1;
}

.build-box.is-page {
  border-color: transparent;
  border-radius: 8px;
}

.build-box.is-child {
  border-color: rgba(245, 245, 243, 0.3);
  border-radius: 3px;
  background: rgba(245, 245, 243, 0.03);
}

.build-paint {
  position: absolute;
  overflow: hidden;
}

.build-paint-fill {
  position: absolute;
  inset: 0;
  border-radius: 4px;
  background-repeat: no-repeat;
  box-shadow: inset 0 0 0 1px rgba(245, 245, 243, 0.25);
}

.build-cursor span:empty {
  display: none;
}

.build-cursor {
  transition: opacity 0.3s ease;
}

.build-cursor.is-hidden {
  opacity: 0;
}

.lightbox-image {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 6rem);
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  transition: opacity 0.6s ease;
}

.lightbox-stage.is-building .lightbox-image {
  opacity: 0;
}

.lightbox-build {
  position: absolute;
  inset: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
}

.lightbox-build.is-done {
  opacity: 0;
}

.build-box {
  position: absolute;
  border: 1px solid rgba(245, 245, 243, 0.55);
  border-radius: 6px;
  background: rgba(245, 245, 243, 0.04);
  transform-origin: top left;
}

.build-cursor {
  position: absolute;
  left: 0;
  top: 0;
  display: flex;
  align-items: flex-start;
  gap: 0.2rem;
  will-change: transform;
}

.build-cursor svg {
  width: 18px;
  height: 18px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.6));
}

.build-cursor span {
  margin-top: 14px;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--white);
  color: var(--black);
  font: 500 0.65rem/1.4 var(--mono);
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.lightbox-close {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  padding: 0.6rem 1.1rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(8, 8, 8, 0.7);
  color: var(--white);
  font: 500 0.85rem var(--sans);
  cursor: pointer;
  transition: border-color 0.25s;
}

.lightbox-close:hover,
.lightbox-close:focus-visible {
  border-color: var(--white);
}

@keyframes lightbox-in {
  from {
    opacity: 0;
    transform: scale(0.98);
  }
}

@media (prefers-reduced-motion: reduce) {
  .lightbox[open] {
    animation: none;
  }
}
