/* Страница галереи: раскладка (слева панель фильтров, справа сетка) и сама панель.
   Логика — js/gallery-filters.js. Панель — спокойное тёмное стекло без декора (фон и
   так выразительный): serif для заголовков секций, Questrial для значений, акцент
   (--color-accent) только на ползунках, выбранных вариантах и нижней кнопке.
   Две темы: цвета панели берутся из переменных ниже */

.gallery-page {
  --card-box: clamp(180px, 17vw, 320px);
  --gf-bg: rgba(255, 255, 255, 0.55);
  --gf-line: rgba(36, 36, 36, 0.14);
  --gf-field: rgba(36, 36, 36, 0.05);
  --gf-track: rgba(36, 36, 36, 0.2);
  --gf-muted: rgba(36, 36, 36, 0.55);
  --gf-on-accent: #1b1308;
  --gf-tint: rgba(250, 245, 233, 0.36);   /* вуаль поверх фото-фона панели: текст остаётся читаемым */
}
[data-theme="dark"] .gallery-page {
  --gf-bg: rgba(9, 13, 15, 0.6);
  --gf-line: rgba(255, 255, 255, 0.13);
  --gf-field: rgba(255, 255, 255, 0.04);
  --gf-track: rgba(255, 255, 255, 0.2);
  --gf-muted: rgba(255, 255, 255, 0.55);
  --gf-tint: rgba(5, 9, 12, 0.26);
}

/* ---------- раскладка ---------- */
.gallery-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  column-gap: 48px;
  align-items: start;
  padding: 48px clamp(24px, 6vw, 120px) 160px;
  transition: grid-template-columns 0.5s cubic-bezier(0.65, 0, 0.35, 1), column-gap 0.5s cubic-bezier(0.65, 0, 0.35, 1);
}
.gallery-layout.is-filters-hidden {
  grid-template-columns: 0 minmax(0, 1fr);
  column-gap: 0;
}

.gallery-layout .gallery-grid {
  padding: 0;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.gallery-layout.is-filters-hidden .gallery-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

/* карточки масштабируются с экраном (на главной коробка фиксированные 320px) */
.gallery-page .gallery-card__photo {
  width: 100%;
  max-width: var(--card-box);
  height: var(--card-box);
}
.gallery-page .gallery-card__stage img {
  max-width: var(--card-box);
  max-height: var(--card-box);
}

.gallery-card[hidden] { display: none; }
.gallery-card.is-entering { animation: galleryCardIn 0.55s cubic-bezier(0.22, 0.61, 0.36, 1) both; }
@keyframes galleryCardIn {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: none; }
}

.gallery-empty {
  grid-column: 1 / -1;
  padding: 80px 0;
  text-align: center;
  color: var(--color-text);
}
.gallery-empty p {
  margin-bottom: 24px;
  font-family: "Cormorant Garamond", "Baskerville Display PT", "Baskerville Old Face", Baskerville, Georgia, serif;
  font-size: 28px;
}

/* ---------- панель: шапка · прокручиваемая середина · закреплённый низ ---------- */
.gallery-filter {
  position: sticky;
  top: 112px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 136px);
  overflow: hidden;
  border: 1px solid var(--gf-line);
  border-radius: 32px;
  /* фон панели — то же фото, что на главной (светлое / тёмное по теме), под вуалью */
  background: linear-gradient(var(--gf-tint), var(--gf-tint)), var(--hero-bg) 62% center / cover no-repeat;
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  color: var(--color-text);
  font-family: "Questrial", sans-serif;
  transition: opacity 0.4s ease, transform 0.5s cubic-bezier(0.65, 0, 0.35, 1), visibility 0s linear 0s;
}
.gallery-layout.is-filters-hidden .gallery-filter {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateX(-28px);
  transition: opacity 0.3s ease, transform 0.5s cubic-bezier(0.65, 0, 0.35, 1), visibility 0s linear 0.5s;
}

.gf__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 26px 28px 18px;
}
.gf__title {
  font-family: "Cormorant Garamond", "Baskerville Display PT", "Baskerville Old Face", Baskerville, Georgia, serif;
  font-weight: 400;
  font-size: 36px;
  line-height: 1.05;
}
.gf__count {
  margin-top: 8px;
  font-size: 14px;
  color: var(--gf-muted);
}

.gf__reset {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 16px;
  border: 1px solid var(--gf-line);
  border-radius: 999px;
  background: none;
  color: inherit;
  font-family: inherit;
  font-size: 14px;
  white-space: nowrap;
  cursor: var(--cursor-pointer, pointer);
  transition: border-color 0.3s ease, color 0.3s ease, opacity 0.3s ease;
}
.gf__reset:hover:not(:disabled) { border-color: var(--color-accent); color: var(--color-accent); }
.gf__reset:disabled { opacity: 0.35; cursor: var(--cursor-not-allowed, not-allowed); }
.gf__reset--solid { height: 44px; padding: 0 22px; }

/* середина прокручивается; пока не докручено до конца, край затемнён —
   видно, что ниже есть ещё параметры */
.gf__scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
  padding: 0 28px;
  border-top: 1px solid var(--gf-line);
}
.gf__scroll::-webkit-scrollbar { display: none; }
.gf__scroll.has-more {
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 44px), transparent);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 44px), transparent);
}

.gf__sec + .gf__sec { border-top: 1px solid var(--gf-line); }
.gf__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 20px 0 14px;
  border: none;
  background: none;
  color: inherit;
  cursor: var(--cursor-pointer, pointer);
}
.gf__sec-title {
  font-family: "Cormorant Garamond", "Baskerville Display PT", "Baskerville Old Face", Baskerville, Georgia, serif;
  font-size: 23px;
  line-height: 1;
}
.gf__chev {
  flex-shrink: 0;
  color: var(--gf-muted);
  transition: transform 0.35s cubic-bezier(0.65, 0, 0.35, 1);
}
.gf__sec:not(.is-open) .gf__chev { transform: rotate(180deg); }

.gf__body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.4s cubic-bezier(0.65, 0, 0.35, 1);
}
.gf__sec.is-open .gf__body { grid-template-rows: 1fr; }
.gf__body-inner {
  overflow: hidden;
  min-height: 0;
}
.gf__sec.is-open .gf__body-inner { padding-bottom: 18px; }

/* ---------- цена и год: поля значений + ползунок со шкалой ---------- */
.gf__fields {
  display: flex;
  align-items: center;
  gap: 10px;
}
.gf__dash { color: var(--gf-muted); }
.gf__field {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--gf-line);
  border-radius: 12px;
  background: var(--gf-field);
  transition: border-color 0.3s ease;
}
.gf__field:focus-within { border-color: var(--color-accent); }
.gf__affix { margin-right: 2px; color: var(--gf-muted); font-size: 16px; }
.gf__field input {
  width: 100%;
  min-width: 0;
  border: none;
  background: none;
  color: inherit;
  font-family: inherit;
  font-size: 16px;
  outline: none;
}

.gf__range-track {
  position: relative;
  height: 26px;
  margin: 14px 8px 0;
}
.gf__range-track::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 2px;
  border-radius: 2px;
  background: var(--gf-track);
  transform: translateY(-50%);
}
.gf__range-fill {
  position: absolute;
  top: 50%;
  height: 3px;
  border-radius: 3px;
  background: var(--color-accent);
  transform: translateY(-50%);
}
.gf__range-track input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  background: none;
  pointer-events: none;
  -webkit-appearance: none;
  appearance: none;
}
.gf__range-track input::-webkit-slider-runnable-track { background: none; }
.gf__range-track input::-moz-range-track { background: none; }
.gf__range-track input::-webkit-slider-thumb {
  -webkit-appearance: none;
  pointer-events: auto;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.92);
  background: var(--color-accent);
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.08), 0 2px 8px rgba(0, 0, 0, 0.35);
  cursor: grab;
}
.gf__range-track input::-moz-range-thumb {
  pointer-events: auto;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.92);
  background: var(--color-accent);
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.08), 0 2px 8px rgba(0, 0, 0, 0.35);
  cursor: grab;
}
.gf__range-track input:active::-webkit-slider-thumb { cursor: grabbing; }

.gf__ticks,
.gf__scale {
  position: relative;
  margin: 0 8px;
}
.gf__ticks { height: 6px; }
.gf__ticks i {
  position: absolute;
  top: 0;
  width: 1px;
  height: 6px;
  background: var(--gf-track);
}
.gf__scale { height: 18px; margin-top: 4px; }
.gf__scale span {
  position: absolute;
  top: 0;
  font-size: 13px;
  line-height: 1;
  color: var(--gf-muted);
  white-space: nowrap;
}

/* ---------- списки с чекбоксами (художник, город) ---------- */
.gf__search {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 44px;
  margin-bottom: 8px;
  padding: 0 16px;
  border: 1px solid var(--gf-line);
  border-radius: 999px;
  background: var(--gf-field);
  color: var(--gf-muted);
  transition: border-color 0.3s ease;
}
.gf__search:focus-within { border-color: var(--color-accent); }
.gf__search svg { flex-shrink: 0; }
.gf__search input {
  width: 100%;
  border: none;
  background: none;
  color: var(--color-text);
  font-family: inherit;
  font-size: 15px;
  outline: none;
}
.gf__search input::placeholder { color: var(--gf-muted); }
.gf__search input::-webkit-search-cancel-button { display: none; }

.gf__check {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 9px 0;
  font-size: 16px;
  cursor: var(--cursor-pointer, pointer);
  transition: opacity 0.3s ease;
}
.gf__check[hidden] { display: none; }
.gf__check input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.gf__box {
  position: relative;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  border: 1px solid var(--gf-muted);
  border-radius: 7px;
  transition: background 0.25s ease, border-color 0.25s ease;
}
.gf__box::after {
  content: "";
  position: absolute;
  left: 7px;
  top: 3px;
  width: 5px;
  height: 10px;
  border: solid var(--color-accent);
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg) scale(0);
  transition: transform 0.25s cubic-bezier(0.65, 0, 0.35, 1);
}
.gf__check:hover .gf__box { border-color: var(--color-text); }
.gf__check input:checked + .gf__box {
  border-color: var(--color-accent);
  background: color-mix(in srgb, var(--color-accent) 16%, transparent);
}
.gf__check input:checked + .gf__box::after { transform: rotate(45deg) scale(1); }
.gf__check input:focus-visible + .gf__box { outline: 2px solid var(--color-accent); outline-offset: 2px; }
.gf__label { flex: 1; min-width: 0; }
.gf__num {
  margin-left: auto;
  font-size: 14px;
  font-style: normal;
  color: var(--gf-muted);
}
.gf__check.is-empty { opacity: 0.38; }

.gf__more {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  padding: 4px 0;
  border: none;
  background: none;
  color: var(--color-accent);
  font-family: inherit;
  font-size: 15px;
  cursor: var(--cursor-pointer, pointer);
}
.gf__more[hidden] { display: none; }
.gf__more svg { transition: transform 0.35s cubic-bezier(0.65, 0, 0.35, 1); }
.gf__more:hover svg { transform: translateX(3px); }
.gf__more.is-open svg { transform: rotate(-90deg); }

/* формат — чипы */
.gf__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.gf__chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border: 1px solid var(--gf-line);
  border-radius: 999px;
  background: var(--gf-field);
  color: inherit;
  font-family: inherit;
  font-size: 15px;
  cursor: var(--cursor-pointer, pointer);
  transition: background 0.3s ease, border-color 0.3s ease, opacity 0.3s ease;
}
.gf__chip:hover { border-color: var(--gf-muted); }
.gf__chip[aria-pressed="true"] {
  border-color: var(--color-accent);
  background: color-mix(in srgb, var(--color-accent) 16%, transparent);
}
.gf__chip .gf__num { margin-left: 0; font-size: 13px; }
.gf__chip.is-empty { opacity: 0.38; }

/* ---------- закреплённый низ: Show N artworks ---------- */
/* на десктопе результаты видны рядом и обновляются сразу — кнопка не нужна; она только
   для узкого экрана, где панель идёт над сеткой (закрывает панель и ведёт к результатам) */
.gf__foot {
  display: none;
  padding: 16px 28px 24px;
  border-top: 1px solid var(--gf-line);
}
.gf__scroll { padding-bottom: 6px; }
.gf__apply {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: 54px;
  border: none;
  border-radius: 16px;
  background: var(--color-accent);
  background: linear-gradient(180deg, color-mix(in srgb, var(--color-accent) 78%, #fff) 0%, var(--color-accent) 100%);
  color: var(--gf-on-accent);
  font-family: inherit;
  font-size: 17px;
  cursor: var(--cursor-pointer, pointer);
  box-shadow: 0 6px 20px color-mix(in srgb, var(--color-accent) 28%, transparent);
  transition: filter 0.3s ease, transform 0.3s ease, opacity 0.3s ease;
}
.gf__apply:hover:not(:disabled) { filter: brightness(1.06); transform: translateY(-1px); }
.gf__apply:disabled { opacity: 0.45; cursor: var(--cursor-not-allowed, not-allowed); box-shadow: none; }
.gf__apply svg { transition: transform 0.35s cubic-bezier(0.65, 0, 0.35, 1); }
.gf__apply:hover:not(:disabled) svg { transform: translateX(3px); }

/* ---------- узкий экран: панель над сеткой, 2 колонки ---------- */
@media (max-width: 900px) {
  .gallery-layout,
  .gallery-layout.is-filters-hidden {
    grid-template-columns: 1fr;
    row-gap: 32px;
    padding: 32px 24px 120px;
  }
  .gallery-filter { position: static; max-height: none; }
  .gf__foot { display: block; }
  .gf__scroll { overflow: visible; }
  .gf__scroll.has-more { -webkit-mask-image: none; mask-image: none; }
  .gallery-layout.is-filters-hidden .gallery-filter { display: none; }
  .gallery-layout .gallery-grid,
  .gallery-layout.is-filters-hidden .gallery-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ---------- порции работ: «Show more», заглушки загрузки ---------- */
.gallery-more[hidden] { display: none; }
.gallery-more { transition: opacity 0.3s ease; }
.gallery-more.is-loading { opacity: 0.45; pointer-events: none; }
.gallery-layout .gallery-more { padding-top: 40px; }

.gallery-grid[aria-busy="true"] .gallery-card:not(.gallery-card--skeleton) { opacity: 0.55; transition: opacity 0.25s ease; }

.gallery-card--skeleton { pointer-events: none; }
.gallery-card__ghost,
.gallery-card--skeleton .gallery-card__title i,
.gallery-card--skeleton .gallery-card__meta i {
  display: block;
  background: color-mix(in srgb, var(--color-text) 9%, transparent);
  animation: galleryGhost 1.5s ease-in-out infinite;
}
.gallery-card__ghost { width: 68%; height: 82%; }
.gallery-card--skeleton .gallery-card__title i { width: 56%; height: 22px; margin: 0 auto; }
.gallery-card--skeleton .gallery-card__meta i { width: 38%; height: 14px; margin: 14px auto 0; }
@keyframes galleryGhost { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .gallery-card__ghost, .gallery-card--skeleton i { animation: none; }
}
