/* Gallery — dark section: a giant moving word behind five hover-expand strips (three clips and two stills),
   and a «Пауза» button that stops the clips and the word. Desktop: one screen tall, strips in a row.
   Up to 1023px: two-column grid scrolling over a pinned word. */
[data-qc="gallery"] {
  --gl-bg: var(--qc-night);
  --gl-ink: var(--qc-on-night);
  --gl-tile: var(--qc-night-2);
  --gl-ease: cubic-bezier(0.4, 0, 0.2, 1);
  --gl-tick: 120s;
  position: relative;
  z-index: 25;
  height: 100vh;
  overflow: hidden;
  overflow: clip;
  background: var(--gl-bg);
  color: var(--gl-ink);
}
/* Slide-over, as in the source: only when the section before pins its last screen. */
[data-qc="gallery"][data-gl-overlap] { margin-top: -100vh; }

[data-qc="gallery"] .gl-sr {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---- Ticker ---- */
[data-qc="gallery"] .gl-ticker {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  overflow: hidden;
  z-index: 0;
  pointer-events: none;
}
[data-qc="gallery"] .gl-track {
  display: flex;
  flex-shrink: 0;
}
[data-qc="gallery"] .gl-word {
  font-family: var(--qc-f-display);
  font-weight: 800;
  font-size: clamp(100px, 14vw, 220px);
  line-height: 1.5;
  color: var(--gl-ink);
  white-space: nowrap;
  letter-spacing: -0.04em;
  -webkit-user-select: none;
  user-select: none;
  padding-right: 0.3em;
}
@keyframes gl-ticker {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(-100%, 0, 0); }
}
@media (prefers-reduced-motion: no-preference) {
  .js [data-qc="gallery"][data-qc-ready] .gl-track {
    animation: gl-ticker var(--gl-tick) linear infinite;
    animation-play-state: paused;
  }
  .js [data-qc="gallery"][data-qc-ready][data-gl-live] .gl-track { animation-play-state: running; }
}

/* ---- Strips ---- */
[data-qc="gallery"] .gl-content {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: clamp(24px, 4vw, 60px);
}
[data-qc="gallery"] .gl-frame {
  position: relative;
  height: 70%;
  width: 100%;
  max-width: 1200px;
}
[data-qc="gallery"] .gl-row {
  display: flex;
  gap: 6px;
  height: 100%;
}
[data-qc="gallery"] .gl-item {
  position: relative;
  flex: 1 1 0%;
  min-width: 0;
  height: 100%;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  background: var(--gl-tile);
  transition: flex 0.5s var(--gl-ease);
  -webkit-tap-highlight-color: transparent;
}
[data-qc="gallery"] .gl-item.gl-is-open { flex: 4 1 0%; }
[data-qc="gallery"] .gl-media {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
/* With scripting off, browsers add play controls to every clip; show the posters (in <noscript>) instead. */
.no-js [data-qc="gallery"] video.gl-media { display: none; }
[data-qc="gallery"] .gl-item:focus:not(:focus-visible) { outline: none; }
[data-qc="gallery"] .gl-item:focus-visible { outline: 2px solid var(--gl-ink); outline-offset: 3px; }

/* Without a working script: the source's plain hover, plus keyboard focus. */
[data-qc="gallery"]:not([data-qc-ready]) .gl-row:hover .gl-item,
[data-qc="gallery"]:not([data-qc-ready]) .gl-row:focus-within .gl-item { flex: 1 1 0%; }
[data-qc="gallery"]:not([data-qc-ready]) .gl-row .gl-item:hover,
[data-qc="gallery"]:not([data-qc-ready]) .gl-row .gl-item:focus { flex: 4 1 0%; }

/* Under the strips: the note, and the pause button at the right (only while a script runs and motion is on). */
[data-qc="gallery"] .gl-foot {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 8px;
}
[data-qc="gallery"] .gl-note {
  margin: 0;
  font-family: var(--qc-f-sans);
  font-weight: 500;
  font-size: 13px;
  line-height: 1.5;
  letter-spacing: 0.01em;
  color: var(--qc-on-night-2);
  text-wrap: pretty;
}
[data-qc="gallery"] .gl-motion {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  margin: 0;
  padding: 0 16px 0 12px;
  border: 1px solid var(--qc-on-night-line);
  border-radius: 999px;
  background: transparent;
  color: var(--gl-ink);
  font-family: var(--qc-f-sans);
  font-weight: 600;
  font-size: 13px;
  line-height: 1;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}
[data-qc="gallery"] .gl-motion[hidden] { display: none; }
[data-qc="gallery"] .gl-motion:focus:not(:focus-visible) { outline: none; }
[data-qc="gallery"] .gl-motion:focus-visible { outline: 2px solid var(--gl-ink); outline-offset: 3px; }
@media (hover: hover) and (pointer: fine) {
  [data-qc="gallery"] .gl-motion:hover { background: rgba(245, 240, 234, 0.08); border-color: rgba(245, 240, 234, 0.4); }
}
[data-qc="gallery"] .gl-motion-ico {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
[data-qc="gallery"] .gl-ico-play { display: none; fill: currentColor; }
[data-qc="gallery"][data-gl-paused] .gl-ico-pause { display: none; }
[data-qc="gallery"][data-gl-paused] .gl-ico-play { display: inline; }

/* ---- Tablet and phone ---- */
@media (max-width: 1023px) {
  [data-qc="gallery"] {
    height: auto;
    min-height: 100vh;
    overflow: visible;
    overflow-x: clip;
  }
  [data-qc="gallery"] .gl-ticker {
    position: sticky;
    top: 0;
    right: auto;
    bottom: auto;
    left: auto;
    height: 100vh;
    width: 100%;
    margin-bottom: -100vh;
  }
  [data-qc="gallery"] .gl-content {
    height: auto;
    align-items: flex-start;
    padding: 80px 16px 60px;
  }
  [data-qc="gallery"] .gl-frame {
    height: auto;
    max-width: 700px;
  }
  [data-qc="gallery"] .gl-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    height: auto;
  }
  [data-qc="gallery"] .gl-item {
    flex: none;
    height: auto;
    aspect-ratio: 4 / 5;
    border-radius: 10px;
    transition: transform 0.3s ease;
  }
  [data-qc="gallery"] .gl-item:hover,
  [data-qc="gallery"] .gl-item:focus-visible { transform: scale(1.02); }
  [data-qc="gallery"] .gl-item:last-child:nth-child(odd) {
    grid-column: 1 / -1;
    width: calc(50% - 4px);
    justify-self: center;
  }
  [data-qc="gallery"] .gl-foot {
    position: static;
    flex-wrap: wrap;
    margin-top: 16px;
  }
}

@media (max-width: 479px) {
  [data-qc="gallery"] .gl-content { padding: 60px 12px 48px; }
  [data-qc="gallery"] .gl-row { gap: 6px; }
}

/* Phones (25.11): one picture per row in its own landscape shape, so the renders are not cut to 4:5 slivers,
   and the moving word becomes the section's visible title band above them instead of white slivers peeking
   between the tiles. The pause button gets a 44 px touch target. */
@media (max-width: 767px) {
  [data-qc="gallery"] .gl-ticker {
    position: relative;
    height: auto;
    margin-bottom: 0;
    padding: 64px 0 4px;
  }
  [data-qc="gallery"] .gl-word {
    font-size: 64px;
    line-height: 1.25;
  }
  [data-qc="gallery"] .gl-content { padding: 20px 16px 56px; }
  [data-qc="gallery"] .gl-row {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  [data-qc="gallery"] .gl-item { aspect-ratio: 16 / 10; }
  [data-qc="gallery"] .gl-item:last-child:nth-child(odd) {
    grid-column: auto;
    width: auto;
    justify-self: stretch;
  }
  [data-qc="gallery"] .gl-motion { min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  [data-qc="gallery"] .gl-item { transition: none; }
}
