/* Сервер выводит список фотографий для просмотра без JavaScript. */
.projects .projects__grid--gallery {
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-lg);
}

.wh-gallery {
  --wh-gap: var(--space-xs);
  container: warehouse / inline-size;
  min-width: 0;
}

.wh-gallery__list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr));
  gap: var(--wh-gap);
  padding: 0;
  margin: 0;
  list-style: none;
}

.wh-gallery__item {
  position: relative;
  isolation: isolate;
  min-width: 0;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-ink);
  box-shadow: inset 0 0 0 1px var(--color-rule);
}

.wh-gallery__heading {
  max-width: none;
  margin: 0;
  font-size: var(--text-title);
}

.wh-gallery__fallback,
.wh-gallery__role {
  display: block;
  padding: var(--space-sm) var(--space-md);
}

.wh-gallery__image {
  display: block;
  width: 100%;
  height: auto;
}

.wh-gallery__role {
  margin: 0;
  color: var(--color-muted);
  font-size: var(--text-sm);
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.wh-gallery__toggle,
.wh-gallery__select,
.wh-gallery.is-enhanced .wh-gallery__fallback {
  display: none;
}

.wh-gallery.is-enhanced .wh-gallery__toggle:not([hidden]) {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  min-height: 44px;
  margin: 0 0 var(--space-xs) auto;
  padding: var(--space-xs) var(--space-md);
  border: 1px solid var(--color-rule-strong);
  border-radius: var(--radius-pill);
  background: var(--color-surface);
  color: var(--color-ink);
  font-size: var(--text-sm);
  line-height: 1.25;
  text-align: start;
  cursor: pointer;
}

.wh-gallery.is-enhanced .wh-gallery__toggle:hover {
  border-color: var(--color-focus);
}

.wh-gallery__toggle::before {
  content: "";
  box-sizing: border-box;
  width: 0.7rem;
  height: 0.75rem;
  flex: none;
  border-block: 0.375rem solid transparent;
  border-inline-start: 0.65rem solid var(--color-accent);
}

.wh-gallery__toggle[data-playing="true"]::before {
  border: 0;
  border-inline: 0.22rem solid var(--color-accent);
}

.wh-gallery.is-enhanced .wh-gallery__list {
  grid-template-columns: minmax(0, 1fr);
}

.wh-gallery.is-enhanced .wh-gallery__select {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  width: 100%;
  min-height: 56px;
  padding: var(--space-sm) var(--space-md);
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  line-height: 1.2;
  text-align: start;
  cursor: pointer;
}

/* Вкладку можно выбрать нажатием в любом месте фотографии. */
.wh-gallery__select::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: var(--radius-sm);
}

.wh-gallery__select:focus-visible {
  outline: none;
}

.wh-gallery__select:focus-visible::after {
  outline: 3px solid var(--color-focus);
  outline-offset: -4px;
  box-shadow: inset 0 0 0 5px var(--color-surface);
}

.wh-gallery__symbol {
  position: relative;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 1.75rem;
  height: 1.75rem;
  border: 1px solid var(--color-shine);
  border-radius: 50%;
  background: var(--color-shade-mid);
  color: var(--color-on-photo);
}

.wh-gallery__symbol::before,
.wh-gallery__symbol::after {
  content: "";
  position: absolute;
  width: 0.7rem;
  height: 2px;
  background: currentColor;
}

.wh-gallery__symbol::after {
  transform: rotate(90deg);
}

.wh-gallery__item.is-open .wh-gallery__symbol {
  background: var(--color-lime);
  border-color: var(--color-lime);
  color: var(--color-lime-ink);
}

.wh-gallery__item.is-open .wh-gallery__symbol::before {
  width: 0.65rem;
  height: 0.34rem;
  margin-top: -0.15rem;
  border: solid currentColor;
  border-width: 0 0 2px 2px;
  background: transparent;
  transform: rotate(-45deg);
}

.wh-gallery__item.is-open .wh-gallery__symbol::after,
.wh-gallery.is-enhanced .wh-gallery__item:not(.is-open) .wh-gallery__role {
  display: none;
}

.wh-gallery.is-enhanced .wh-gallery__item:not(.is-open) {
  color: var(--color-on-photo);
}

.wh-gallery.is-enhanced .wh-gallery__item:not(.is-open) .wh-gallery__panel {
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--color-shade);
}

.wh-gallery.is-enhanced .wh-gallery__item:not(.is-open) .wh-gallery__image {
  height: 100%;
  object-fit: cover;
}

.wh-gallery.is-enhanced .wh-gallery__item:not(.is-open) .wh-gallery__panel::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, var(--color-shade), var(--color-shade-mid));
}

@container warehouse (min-width: 791px) {
  .wh-gallery.is-enhanced .wh-gallery__list {
    --wh-rail: clamp(62px, 7.4cqw, 94px);
    --wh-open-width: calc(100cqw - (var(--wh-count, 5) - 1) * (var(--wh-rail) + var(--wh-gap)));
    display: flex;
  }

  .wh-gallery.is-enhanced .wh-gallery__item {
    display: flex;
    flex: 0 0 var(--wh-rail);
    flex-direction: column;
    transition: flex-grow 300ms var(--ease-out);
  }

  .wh-gallery.is-enhanced .wh-gallery__item.is-open {
    flex-grow: 1;
  }

  /* Фото и подписи идут друг за другом, чтобы длинные переводы переносились на следующую строку. */
  .wh-gallery__item.is-open .wh-gallery__panel {
    display: contents;
  }

  .wh-gallery__item.is-open .wh-gallery__image {
    order: -1;
    height: calc(var(--wh-open-width) * var(--wh-photo-ratio, 0.41640625));
    object-fit: contain;
  }

  .wh-gallery__item.is-open .wh-gallery__select {
    padding: var(--space-sm) var(--space-lg) 0;
    font-size: clamp(1.5rem, 2.4cqw, 2rem);
  }

  .wh-gallery__item.is-open .wh-gallery__role {
    padding: 0 var(--space-lg) var(--space-md);
  }

  .wh-gallery.is-enhanced .wh-gallery__item:not(.is-open) .wh-gallery__select {
    position: absolute;
    inset: 0;
    flex-direction: column-reverse;
    padding: var(--space-md) var(--space-xs) var(--space-lg);
  }

  .wh-gallery__item:not(.is-open) .wh-gallery__name {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    font-size: var(--text-lg);
    white-space: nowrap;
  }

  .wh-gallery.is-enhanced .wh-gallery__item:not(.is-open) .wh-gallery__panel::after {
    background: linear-gradient(0deg, var(--color-shade), var(--color-shade-mid) 62%, var(--color-shade-soft));
  }
}

@media (prefers-reduced-motion: reduce) {
  .wh-gallery.is-enhanced .wh-gallery__item {
    transition: none;
  }
}
