/* File detail galleries. The original image remains uncropped at every size. */
html[data-theme] .modern-site .article-page [data-gallery].article-gallery {
  container-type: inline-size;
  min-width: 0;
  max-width: 100%;
  padding: clamp(10px, 1.5vw, 17px);
  border: 1px solid var(--ui-line);
  border-radius: 15px;
  background: var(--ui-surface);
}
html[data-theme] .article-page [data-gallery] .article-section-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 14px;
  margin: 0 0 10px;
}
html[data-theme] .article-page [data-gallery] .article-section-heading h2 {
  margin: 0;
  font-size: clamp(18px, 3.8cqi, 25px);
  line-height: 1.16;
}
.article-page [data-gallery] .file-gallery-tools {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 4px;
}
html[data-theme] .article-page [data-gallery] .file-gallery-tools button {
  position: static;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  min-width: 36px;
  height: 36px;
  padding: 0 8px;
  margin: 0;
  border: 1px solid color-mix(in srgb, var(--ui-muted) 60%, var(--ui-surface));
  border-radius: 8px;
  color: var(--ui-ink);
  background: var(--ui-soft);
  box-shadow: none;
  transform: none;
  cursor: pointer;
  font: inherit;
  font-size: 18px;
  line-height: 1;
}
.file-gallery-tools .modern-icon { width: 17px; height: 17px; }
html[data-theme] .article-page [data-gallery] .file-gallery-tools .file-gallery-zoom {
  margin-inline-start: 3px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 600;
}
html[data-theme] .article-page [data-gallery] .file-gallery-tools button:is(:hover,:focus-visible) {
  color: var(--ui-accent);
  border-color: var(--ui-accent);
  background: var(--ui-tint);
}
html[data-theme] .article-page [data-gallery] .article-gallery-counter {
  min-width: 0;
  padding: 0 3px;
  border: 0;
  background: transparent;
  color: var(--ui-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
html[data-theme] .article-page.modern-material [data-gallery] .article-gallery-stage {
  position: relative;
  overflow: hidden;
  border: 0;
  border-radius: 10px;
  background: #142026;
}
html[data-theme] .article-page.modern-material [data-gallery] .article-gallery-stage > [data-gallery-open] {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  place-items: center;
  width: 100%;
  height: clamp(132px, 51vw, 348px);
  height: clamp(116px, min(55cqi, 49svh), 352px);
  min-height: 0;
  max-height: none;
  aspect-ratio: auto;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: #142026 !important;
  cursor: zoom-in;
}
.article-page [data-gallery-open]::before {
  content: "";
  position: absolute;
  inset: -20px;
  z-index: -1;
  pointer-events: none;
  background: #142026 var(--file-gallery-backdrop, none) center / cover no-repeat;
  filter: blur(18px);
  opacity: .32;
}
html[data-theme] .article-page.modern-material [data-gallery] .article-gallery-stage #full-photo[data-gallery-main] {
  display: block;
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
  min-height: 0;
  min-width: 0;
  margin: 0 !important;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  object-fit: scale-down !important;
  object-position: center;
}
.article-page [data-gallery-ready="true"] .article-gallery-zoom { display: none; }
.article-page [data-gallery-open]:focus-visible { outline-offset: -4px; }
html[data-theme] .article-page [data-gallery] .article-gallery-thumbs {
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-start;
  align-items: center;
  gap: 6px;
  margin: 6px 0 0;
  padding: 3px 2px 6px;
  overflow-x: auto;
  scrollbar-width: thin;
  scroll-snap-type: x proximity;
}
html[data-theme] .article-page.modern-material [data-gallery] .article-gallery-thumbs > [data-gallery-thumb] {
  display: grid;
  place-items: center;
  position: relative;
  box-sizing: border-box;
  flex: 0 0 68px;
  width: 68px;
  height: 46px;
  margin: 0;
  padding: 0;
  border: 1px solid var(--ui-line);
  border-radius: 6px;
  opacity: 1;
  background: #172128;
  scroll-snap-align: center;
}
html[data-theme] .article-page.modern-material [data-gallery] .article-gallery-thumbs img {
  display: block;
  width: 100% !important;
  height: 100% !important;
  max-width: 100%;
  object-fit: contain !important;
  background: transparent;
}
html[data-theme] .article-page.modern-material [data-gallery] .article-gallery-thumbs > [data-gallery-thumb]:is(.is-active,:focus-visible) {
  border-color: var(--ui-accent);
  outline: 2px solid var(--ui-accent);
  outline-offset: 0;
  box-shadow: none;
}
html[data-theme] .article-page [data-gallery] .article-gallery-hint {
  margin: 4px 0 0;
  color: var(--ui-muted);
}
.file-gallery-unavailable, .file-gallery-no-preview img { visibility: hidden; }
.file-gallery-no-preview::after {
  content: attr(data-frame-number);
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #e5edf0;
  font-variant-numeric: tabular-nums;
}
.article-page .file-gallery-error [data-gallery-open]::after, .file-gallery-lightbox.file-gallery-error::after {
  content: "Изображение недоступно";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 10px;
  color: #e5edf0;
  font-size: 14px;
  pointer-events: none;
}
.article-page [data-gallery-ready]:not(.file-gallery-error) [data-gallery-status],
.file-gallery-lightbox:not(.file-gallery-error) .article-lightbox__status {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
}
.article-lightbox.file-gallery-lightbox .article-lightbox__thumb {
  position: relative;
  background: #172128;
}
.article-lightbox.file-gallery-lightbox .article-lightbox__thumb img { object-fit: contain; }
.article-lightbox.file-gallery-lightbox .article-lightbox__image { object-fit: scale-down; }
@media (pointer: coarse) {
  html[data-theme] .article-page [data-gallery] .file-gallery-tools button {
    min-width: 44px;
    height: 44px;
  }
}
