/* SHARED-MEDIA-VIEWER-A1 — domain-neutral fullscreen image viewer.
   Portal to document.body. Independent of chat-lightbox, presentation-lightbox,
   Bootstrap .modal/.carousel, and route-specific gallery selectors. */

.shared-media-viewer {
  position: fixed;
  inset: 0;
  z-index: 1400;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  color-scheme: dark;
}

.shared-media-viewer__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(12, 12, 14, 0.88);
}

.shared-media-viewer__dialog {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  max-width: 100vw;
  max-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: calc(12px + env(safe-area-inset-top, 0px))
    calc(12px + env(safe-area-inset-right, 0px))
    calc(12px + env(safe-area-inset-bottom, 0px))
    calc(12px + env(safe-area-inset-left, 0px));
  box-sizing: border-box;
}

.shared-media-viewer__title {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.shared-media-viewer__toolbar {
  flex: 0 0 auto;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin: 0 0 8px;
}

.shared-media-viewer__control {
  box-sizing: border-box;
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  cursor: pointer;
}

.shared-media-viewer__control:hover {
  background: rgba(255, 255, 255, 0.22);
}

.shared-media-viewer__control:active {
  background: rgba(255, 255, 255, 0.3);
}

.shared-media-viewer__control:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring, 0 0 0 3px rgba(13, 110, 253, 0.45));
}

.shared-media-viewer__canvas {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: pan-y pinch-zoom;
}

.shared-media-viewer__image {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

.shared-media-viewer__loading,
.shared-media-viewer__error {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
  color: rgba(255, 255, 255, 0.9);
  text-align: center;
  pointer-events: none;
}

.shared-media-viewer__error {
  pointer-events: auto;
}

.shared-media-viewer__preload {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.shared-media-viewer__nav {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 2;
  box-sizing: border-box;
  width: max(44px, 12%);
  min-width: 44px;
  min-height: 44px;
  margin: 0;
  padding: 0 12px;
  border: 0;
  background: transparent;
  color: #fff;
  display: flex;
  align-items: center;
  cursor: pointer;
}

.shared-media-viewer__nav--prev {
  left: 0;
  justify-content: flex-start;
}

.shared-media-viewer__nav--next {
  right: 0;
  justify-content: flex-end;
}

.shared-media-viewer__nav i {
  font-size: 1.75rem;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.65));
  pointer-events: none;
}

.shared-media-viewer__nav:hover {
  background: rgba(255, 255, 255, 0.08);
}

.shared-media-viewer__nav:active {
  background: rgba(255, 255, 255, 0.14);
}

.shared-media-viewer__nav:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring, 0 0 0 3px rgba(13, 110, 253, 0.45));
}

.shared-media-viewer__counter {
  position: absolute;
  left: 50%;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  z-index: 2;
  transform: translateX(-50%);
  margin: 0;
  padding: 4px 10px;
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  pointer-events: none;
}

.shared-media-viewer--reduced-motion .shared-media-viewer__image,
.shared-media-viewer--reduced-motion .shared-media-viewer__control,
.shared-media-viewer--reduced-motion .shared-media-viewer__nav {
  transition: none;
}

@media (max-width: 430px) {
  .shared-media-viewer__nav {
    width: 44px;
    padding: 0 8px;
  }
}
