.project-viewer {
  width: min(1600px, calc(100% - 48px));
  max-width: none;
  max-height: calc(100dvh - 32px);
  padding: 0;
  overflow-x: hidden;
  overflow-y: auto;
  border: 1px solid rgba(250, 249, 245, 0.18);
  border-radius: 20px;
  background: var(--surface-dark);
  color: var(--on-dark);
  color-scheme: dark;
  box-shadow: 0 32px 120px rgba(0, 0, 0, 0.5);
  overscroll-behavior: contain;
}

.project-viewer::backdrop {
  background: rgba(13, 12, 11, 0.78);
  backdrop-filter: blur(12px);
}

.project-viewer[open] {
  animation: project-viewer-enter 260ms ease both;
}

.project-viewer-window {
  width: 100%;
}

.project-viewer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 20px 28px;
  border-bottom: 1px solid rgba(250, 249, 245, 0.08);
}

.project-viewer-category {
  margin: 0 0 8px;
  color: var(--on-dark-soft);
  font-size: 12px;
}

.project-viewer-header h2 {
  margin: 0;
  color: var(--on-dark);
  font-family: var(--font-serif);
  font-size: clamp(24px, 3vw, 38px);
  font-weight: 500;
  line-height: 1.15;
  text-wrap: balance;
}

.project-viewer-close,
.project-viewer-arrow {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid rgba(250, 249, 245, 0.16);
  border-radius: 50%;
  background: rgba(250, 249, 245, 0.04);
  color: var(--on-dark);
  font: 400 20px/1 var(--font-sans);
  cursor: pointer;
  transition: background 180ms ease;
}

.project-viewer-close {
  font-size: 28px;
}

.project-viewer-close:hover,
.project-viewer-arrow:hover:enabled {
  background: rgba(250, 249, 245, 0.14);
}

.project-viewer :focus-visible {
  outline-color: var(--on-dark);
}

.project-viewer-gallery {
  padding: 0 0 24px;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 44%, #292722 0, #141412 65%, #10100f 100%);
}

.project-viewer-stage {
  position: relative;
  height: clamp(300px, 66dvh, 780px);
  overflow: hidden;
  perspective: 1100px;
  touch-action: pan-y;
  user-select: none;
  cursor: grab;
}

.project-viewer-stage:active {
  cursor: grabbing;
}

.project-viewer-slide {
  position: absolute;
  top: 5%;
  left: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(68vw, 960px);
  height: 84%;
  filter: brightness(0.6);
  transform: translateX(-50%) translateX(calc(var(--side) * clamp(160px, 29vw, 420px) + var(--offset) * 90px)) translateZ(calc(var(--distance) * -120px)) rotateY(calc(var(--side) * -58deg));
  transition: transform 520ms cubic-bezier(0.22, 1, 0.36, 1), filter 520ms ease;
  -webkit-box-reflect: below 14px linear-gradient(transparent 65%, rgba(255, 255, 255, 0.16));
  cursor: pointer;
}

.project-viewer-slide.is-active {
  filter: brightness(1);
  cursor: default;
}

.project-viewer-slide img,
.project-viewer-slide video {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 6px;
  object-fit: contain;
  filter: drop-shadow(0 20px 18px rgba(0, 0, 0, 0.32));
  -webkit-user-drag: none;
}

.project-viewer-slide:not(.is-active) > * {
  pointer-events: none;
}

.project-viewer-navigation {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
}

.project-viewer-counter {
  min-width: 5em;
  margin: 0;
  font: 400 13px/1 var(--font-mono);
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.project-viewer-arrow:disabled {
  opacity: 0.25;
  cursor: default;
}

.project-viewer-range {
  display: block;
  width: min(280px, 60%);
  height: 20px;
  margin: 16px auto 0;
  background: transparent;
  accent-color: var(--on-dark);
  cursor: ew-resize;
}

.project-viewer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 32px;
  border-top: 1px solid rgba(250, 249, 245, 0.08);
}

.project-viewer-description {
  max-width: 62ch;
  margin: 0;
  color: var(--on-dark-soft);
  font-size: 13px;
}

.project-viewer-description:empty {
  display: none;
}

.project-viewer-links {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  gap: 16px;
  margin-left: auto;
  font-size: 12px;
}

.project-viewer-links a {
  padding-block: 6px;
  text-decoration: underline;
  text-decoration-color: rgba(250, 249, 245, 0.25);
  text-underline-offset: 4px;
}

.project-viewer-links a:hover {
  text-decoration-color: currentColor;
}

@keyframes project-viewer-enter {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 768px) {
  .project-viewer {
    width: calc(100% - 20px);
    max-height: calc(100dvh - 24px);
    border-radius: 16px;
  }

  .project-viewer-header {
    gap: 12px;
    padding: 20px;
  }

  .project-viewer-slide {
    width: 90vw;
    transform: translateX(-50%) translateX(calc(var(--side) * 33vw + var(--offset) * 48px)) translateZ(calc(var(--distance) * -85px)) rotateY(calc(var(--side) * -62deg));
  }

  .project-viewer-footer {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
    padding: 20px;
  }

  .project-viewer-links {
    margin-left: 0;
  }
}

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

  .project-viewer-slide {
    transition: none;
  }
}
