.project-photo-link {
  position: relative;
  display: block;
  color: white;
  cursor: zoom-in;
}

.project-photo-hint {
  position: absolute;
  right: 14px;
  bottom: 14px;
  padding: 9px 13px;
  border: 1px solid rgb(255 255 255 / 35%);
  border-radius: 6px;
  background: rgb(17 27 26 / 90%);
  color: white;
  font-size: 14px;
  font-weight: 650;
  line-height: 1.4;
}

.project-photo-link:focus-visible {
  outline: 3px solid var(--accent, #a84c2e);
  outline-offset: 5px;
}

.project-viewer:not([open]),
.project-viewer [hidden] {
  display: none;
}

.project-viewer {
  width: min(1180px, calc(100% - 40px));
  height: min(920px, calc(100dvh - 40px));
  max-width: none;
  max-height: none;
  margin: auto;
  padding: 20px;
  overflow: hidden;
  border: 1px solid rgb(255 255 255 / 20%);
  border-radius: 12px;
  background: #111b1a;
  color: #fff;
}

.project-viewer[open] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  gap: 16px;
}

.project-viewer::backdrop {
  background: rgb(5 13 12 / 85%);
}

.project-viewer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.project-viewer-header h2 {
  margin: 0;
  color: inherit;
  font-size: 19px;
  font-weight: 600;
  line-height: 1.4;
}

.project-viewer button {
  min-width: 44px;
  min-height: 44px;
  padding: 10px 16px;
  border: 1px solid #71827f;
  border-radius: 6px;
  background: #22312f;
  color: #fff;
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
  cursor: pointer;
  touch-action: manipulation;
}

.project-viewer .project-viewer-close {
  flex-shrink: 0;
  background: #f8f5ed;
  color: #111b1a;
}

.project-viewer button:focus-visible,
.project-viewer-viewport:focus-visible {
  outline: 3px solid #efc594;
  outline-offset: 3px;
}

.project-viewer button:active:not(:disabled) {
  transform: scale(0.97);
}

.project-viewer button:disabled {
  opacity: 0.5;
  cursor: default;
}

.project-viewer-viewport {
  display: grid;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  place-items: center;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  background: #0a1110;
}

.project-viewer-image {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: contain;
}

.project-viewer-viewport.is-zoomed {
  display: block;
}

.project-viewer-details {
  min-width: 0;
  max-height: 24dvh;
  overflow: auto;
  overscroll-behavior: contain;
}

.project-viewer-details p {
  margin: 0;
  color: inherit;
}

.project-viewer-count {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  opacity: 0.75;
}

.project-viewer-caption,
.project-viewer-message {
  margin-top: 5px !important;
  font-size: 16px;
  line-height: 1.5;
}

.project-viewer-retry {
  margin-top: 8px;
}

.project-viewer-controls {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

@media (hover: hover) and (pointer: fine) {
  .project-photo-link:hover .project-photo-hint {
    background: #111b1a;
  }

  .project-viewer button:hover:not(:disabled) {
    border-color: #fff;
  }
}

@media (max-width: 620px) {
  .project-viewer {
    width: 100%;
    height: 100dvh;
    padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right))
      max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    border: 0;
    border-radius: 0;
  }

  .project-viewer[open] {
    gap: 12px;
  }

  .project-viewer-controls {
    gap: 8px;
  }

  .project-viewer-controls button {
    padding-inline: 8px;
  }
}
