/* Gallery screen: сетка 2 кол., миниатюры 4:3 + fullscreen viewer; safe-area для iOS */

.screen.gallery {
  display: flex;
  align-items: stretch;
  justify-content: flex-start;
  padding: 0;
  overflow: hidden;
}

.gallery-wrap {
  width: 100%;
  height: 100%;
  padding: 14px;
  padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-family: Helvetica, Arial, sans-serif;
}

.gallery-headline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 10px 0 6px;
  padding-right: 2px;
}

.gallery-title {
  font-family: Akony, sans-serif;
  font-size: 18px;
  letter-spacing: 0.04em;
  margin: 0;
  font-weight: 400;
  line-height: 1.2;
  text-transform: uppercase;
}

.gallery-nav-up {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.92);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}

.gallery-nav-up-icon {
  width: 22px;
  height: 22px;
  display: block;
  opacity: 0.95;
}

.gallery-nav-up:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.24);
}

.gallery-nav-up:active {
  transform: scale(0.96);
}

.gallery-nav-up:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.45);
  outline-offset: 2px;
}

.gallery-grid {
  flex: 1;
  align-content: start;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.gallery-thumb {
  position: relative;
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 12px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.06);
  font: inherit;
  color: inherit;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  /* Горизонтальный прямоугольник: ниже по высоте, чем квадрат при той же ширине ячейки */
  aspect-ratio: 4 / 3;
  transition: box-shadow 0.2s ease, transform 0.12s ease;
  animation: mirai-invite-cta 3.2s ease-in-out infinite;
}

.gallery-thumb:hover,
.gallery-thumb:focus-visible {
  animation-play-state: paused;
}

.gallery-thumb:active {
  animation: none;
  transform: scale(0.985);
}

.gallery-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 45%;
  display: block;
  transform: translateZ(0);
}

.gallery-badge {
  position: absolute;
  left: 6px;
  top: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: rgba(255, 255, 255, 0.92);
  font-size: 10px;
  font-weight: 700;
}

/* Fullscreen viewer */
.gallery-viewer-backdrop {
  position: absolute;
  inset: 0;
  z-index: 60;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.gallery-viewer-backdrop[hidden],
.gallery-viewer[hidden] {
  display: none !important;
}

.gallery-viewer {
  position: absolute;
  inset: 0;
  z-index: 70;
  display: flex;
  flex-direction: column;
  background: rgba(0, 0, 0, 0.92);
}

.gallery-viewer-head {
  padding: 20px 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.gallery-viewer-title {
  font-family: Akony, sans-serif;
  font-size: 16px;
  letter-spacing: 0.04em;
  margin: 2px 0 6px;
}

.gallery-pos-num {
  color: #ff4f9a;
}

.gallery-viewer-sub {
  font-family: Helvetica, Arial, sans-serif;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.70);
  margin-top: 4px;
}

.gallery-viewer-close {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.92);
  font-weight: 700;
  font-family: Helvetica, Arial, sans-serif;
}

.gallery-viewer-stage {
  flex: 1;
  position: relative;
  overflow: hidden;
  touch-action: pan-y;
}

.gallery-viewer-track {
  height: 100%;
  display: flex;
  transition: transform 260ms cubic-bezier(.2,.8,.2,1);
  will-change: transform;
}

.gallery-viewer-slide {
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
}

.gallery-viewer-slide img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.gallery-viewer-nav {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.gallery-viewer-btn {
  pointer-events: auto;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 38px;
  height: 48px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  background: rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: rgba(255, 255, 255, 0.80);
  font-size: 16px;
  font-weight: 700;
  opacity: 0.72;
}

.gallery-viewer-btn.prev { left: 10px; }
.gallery-viewer-btn.next { right: 10px; }

.gallery-viewer-btn:active { transform: translateY(-50%) scale(0.98); }

@media (min-width: 768px) {
  .gallery-thumb {
    border-radius: 14px;
  }

  .gallery-badge {
    left: 8px;
    top: 8px;
    padding: 5px 9px;
    font-size: 11px;
  }
}

@media (max-width: 360px) {
  .gallery-wrap {
    padding: 12px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }

  .gallery-grid {
    gap: 6px;
  }
}

