.equipment-card .equipment-photo {
  --photo-limit: 170px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  place-items: center;
  width: 100%;
  height: 170px;
  margin: 0 0 20px;
  padding: 0;
  cursor: zoom-in;
}

.equipment-card .equipment-photo img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  margin: auto;
  object-fit: contain;
  object-position: center;
}

.equipment-photo-frame {
  display: block;
  position: relative;
  overflow: hidden;
  width: min(100%, calc(var(--photo-limit, 170px) * var(--photo-ratio, 1)));
  aspect-ratio: var(--photo-ratio, 1);
  margin: auto;
}

.equipment-card .equipment-photo-frame img,
.equipment-viewer-photo .equipment-photo-frame img {
  position: absolute;
  top: var(--crop-top, 0%);
  left: var(--crop-left, 0%);
  width: var(--crop-width, 100%);
  height: var(--crop-height, 100%);
  max-width: none;
  max-height: none;
  margin: 0;
  object-fit: fill;
  transform: none;
}

.equipment-card .equipment-photo:focus-visible,
.equipment-viewer-close:focus-visible {
  outline: 2px solid #315cff;
  outline-offset: 4px;
}

html.equipment-viewer-open,
body.equipment-viewer-open {
  overflow: hidden;
  overscroll-behavior: none;
}

dialog.equipment-viewer {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 24px;
  border: 0;
  background: transparent;
  color: #f7f7f5;
  font: inherit;
  overflow: auto;
  overscroll-behavior: contain;
}

dialog.equipment-viewer[open] {
  display: grid;
  place-items: center;
}

dialog.equipment-viewer::backdrop {
  background: rgb(10 12 16 / 86%);
}

.equipment-viewer-panel {
  width: min(1120px, 100%);
  overflow: hidden;
  background: #181a1f;
  border: 1px solid rgb(255 255 255 / 14%);
  border-radius: 12px;
  box-shadow: 0 24px 80px rgb(0 0 0 / 45%);
}

.equipment-viewer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 12px 16px 12px 22px;
}

.equipment-viewer-header h2 {
  margin: 0;
  font: inherit;
  font-size: clamp(15px, 1.4vw, 20px);
  font-weight: 500;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.equipment-viewer-close {
  display: grid;
  place-items: center;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid rgb(255 255 255 / 18%);
  border-radius: 50%;
  background: #22252c;
  color: #fff;
  font: inherit;
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
  transition: background .18s, border-color .18s;
}

.equipment-viewer-close:hover {
  background: #315cff;
  border-color: #315cff;
}

.equipment-viewer-photo {
  --photo-padding: clamp(12px, 2vw, 24px);
  --photo-height: min(70svh, 700px, calc(100svh - 140px));
  --photo-limit: calc(var(--photo-height) - var(--photo-padding) * 2);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  place-items: center;
  width: 100%;
  height: var(--photo-height);
  padding: var(--photo-padding);
  background: #f1f2f2;
}

.equipment-viewer-photo .equipment-photo-frame .equipment-viewer-image {
  display: block;
  min-width: 0;
  min-height: 0;
}

@media (max-width: 760px) {
  .equipment-card .equipment-photo {
    --photo-limit: 114px;
    height: 114px;
    margin-bottom: 14px;
  }

  dialog.equipment-viewer { padding: 14px; }
  .equipment-viewer-header { gap: 12px; padding: 10px 10px 10px 16px; }
  .equipment-viewer-photo { --photo-height: min(52svh, 340px, calc(100svh - 140px)); }
}

@media (prefers-reduced-motion: reduce) {
  .equipment-viewer-close { transition: none; }
}
