/* ==========================================================================
   Олег Песков — галерея живописи
   Editorial-минимализм: единственный источник цвета на странице — сами картины.
   ========================================================================== */

:root {
  --bg: #F7F6F3;
  --text: #111111;
  --text-secondary: #787774;
  --line: rgba(0, 0, 0, 0.06);
  --lightbox-bg: rgba(17, 17, 17, 0.94);
  --shadow-hover: 0 2px 8px rgba(0, 0, 0, 0.04);

  --font-display: 'Cormorant Garamond', serif;
  --font-text: 'Golos Text', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  position: relative; /* якорь для .social в правом верхнем углу */
}

/* Соцзначки в правом верхнем углу. Декоративные (Pinterest, WhatsApp) — без ссылки,
   кликается только Telegram. Цвет наследуется через currentColor. */
.social {
  position: absolute;
  top: 20px;
  right: 24px;
  z-index: 10;
  display: flex;
  gap: 16px;
  align-items: center;
}

.social-icon {
  width: 20px;
  height: 20px;
  display: inline-flex;
  color: var(--text-secondary);
}

.social-icon svg {
  width: 100%;
  height: 100%;
  fill: currentColor; /* fill — наследуемое свойство, доходит до <path> без своего fill */
}

/* Только Telegram — ссылка; при наведении темнеет. */
a.social-icon {
  transition: color 200ms ease;
}

a.social-icon:hover {
  color: var(--text);
}

@media (max-width: 640px) {
  .social {
    top: 14px;
    right: 14px;
    gap: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  a.social-icon {
    transition: none;
  }
}

/* Блокировка прокрутки страницы, пока открыт лайтбокс */
body.no-scroll {
  overflow: hidden;
}

h1 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.1;
  font-size: clamp(2.5rem, 5vw + 1rem, 4rem);
  margin: 0 0 20px;
}

a {
  color: inherit;
}

img {
  max-width: 100%;
}

/* ---------- Шапка и подвал ---------- */

.site-header,
.site-footer {
  max-width: 640px;
  margin: 0 auto;
  padding: 96px 24px 64px;
  text-align: center;
}

.site-footer {
  padding: 48px 24px 96px;
  border-top: 1px solid var(--line);
  margin-top: 32px;
}

.lede {
  color: var(--text-secondary);
  font-size: 1.125rem;
  margin: 0 0 32px;
}

.copyright {
  color: var(--text-secondary);
  margin: 24px 0 0;
  font-size: 0.9rem;
}

/* ---------- Кнопка ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 12px 32px;
  background: #111111;
  color: #ffffff;
  border-radius: 4px;
  text-decoration: none;
  font-family: var(--font-text);
  font-weight: 500;
  font-size: 1rem;
  border: none;
  cursor: pointer;
  transition: background 200ms ease, transform 100ms ease;
}

.btn:hover {
  background: #333333;
}

.btn:active {
  transform: scale(0.98);
}

.btn:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 3px;
}

/* ---------- Баннер ---------- */

.banner {
  position: relative;
  max-width: 1400px;
  margin: 0 auto 48px;
  padding: 0 24px;
}

.banner-viewport {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  /* Рамки нет намеренно: края картины растворяются в фоне, линия по краю
     обрывала бы этот переход. */
}

/* Плавный уход краёв в фон страницы. Маска висит на дорожке, а не на вьюпорте:
   стрелки лежат во вьюпорте рядом с дорожкой и не должны растворяться вместе
   с картиной. */
.banner-track {
  position: absolute;
  inset: 0;
  -webkit-mask-image: linear-gradient(to right, transparent 0%, #000 7%, #000 93%, transparent 100%);
  mask-image: linear-gradient(to right, transparent 0%, #000 7%, #000 93%, transparent 100%);
}

@media (max-width: 640px) {
  .banner-viewport {
    aspect-ratio: 4 / 3;
  }

  /* На узком экране 7% — это ~25px, фейд съедает сюжет. Сужаем полосу. */
  .banner-track {
    -webkit-mask-image: linear-gradient(to right, transparent 0%, #000 4%, #000 96%, transparent 100%);
    mask-image: linear-gradient(to right, transparent 0%, #000 4%, #000 96%, transparent 100%);
  }
}

.banner[hidden] {
  display: none;
}

/* Слайды лежат друг на друге, переключение — кроссфейд по opacity, не по transform.
   pointer-events: none у неактивных — иначе невидимый (opacity:0) слайд, оказавшийся
   выше по DOM-порядку, перехватывал бы клики по всей площади баннера. */
.banner-slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 500ms ease;
}

.banner-slide.is-active {
  opacity: 1;
  pointer-events: auto;
}

.banner-slide img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  cursor: pointer;
}

.banner-slide img:focus-visible {
  outline: 2px solid var(--bg);
  outline-offset: -4px;
}

.banner-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--bg);
  /* Тень для читаемости стрелки поверх светлых участков картины — не новый цвет, тот же чёрный из --line */
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
  font-family: var(--font-text);
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
}

.banner-arrow:focus-visible {
  outline: 2px solid var(--bg);
  outline-offset: 2px;
}

.banner-prev {
  left: 8px;
}

.banner-next {
  right: 8px;
}

.banner-dots {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 16px;
}

.banner-dot {
  width: 8px;
  height: 8px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--text-secondary);
  background: transparent;
  cursor: pointer;
}

.banner-dot.is-active {
  background: var(--text);
  border-color: var(--text);
}

.banner-dot:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

/* ---------- Фильтр коллекций ---------- */

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px 32px;
}

.filter-btn {
  background: none;
  border: none;
  border-bottom: 1px solid transparent;
  padding: 4px 0;
  font-family: var(--font-text);
  font-size: 0.95rem;
  color: var(--text-secondary);
  cursor: pointer;
}

/* Неактивная — при наведении подчёркивание пунктиром */
.filter-btn:hover {
  border-bottom-style: dashed;
  border-bottom-color: var(--text-secondary);
}

/* Активная — сплошное подчёркивание, побеждает и при наведении (объявлена ниже hover) */
.filter-btn[aria-selected="true"] {
  color: var(--text);
  border-bottom-style: solid;
  border-bottom-color: var(--text);
}

.filter-btn:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 3px;
}

/* ---------- Галерея ---------- */

.gallery {
  columns: 3;
  column-gap: 24px;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px 96px;
}

@media (max-width: 1024px) {
  .gallery {
    columns: 2;
  }
}

@media (max-width: 640px) {
  .gallery {
    columns: 1;
    padding: 0 16px 64px;
  }
}

.painting {
  break-inside: avoid;
  margin: 0 0 24px;
  cursor: pointer;
}

/* Фильтр коллекций: не подошедшая под категорию картина убирается из потока полностью */
.painting.filtered-out {
  display: none;
}

.painting img {
  display: block;
  width: 100%;
  height: auto;
  /* Рамка вместо скругления: скруглённый угол у холста выглядит как ошибка (см. спеку, п. 5.1) */
  border: 1px solid var(--line);
  border-radius: 0;
  transition: transform 200ms ease, box-shadow 200ms ease;
  /* Живопись не обесцвечивается и не накрывается вуалью — никаких filter/overlay (см. спеку, п. 5.1) */
}

.painting:hover img,
.painting:focus-visible img {
  transform: scale(1.01);
  box-shadow: var(--shadow-hover);
}

.painting:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 4px;
}

/* Появление при скролле: анимируются только opacity и transform */
.reveal {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 600ms cubic-bezier(0.16, 1, 0.3, 1),
              transform 600ms cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* ---------- Лайтбокс ---------- */

.lightbox {
  position: fixed;
  inset: 0;
  background: var(--lightbox-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.lightbox[hidden] {
  display: none;
}

.lightbox-image {
  max-width: 92vw;
  max-height: 88vh;
  object-fit: contain;
  cursor: default;
}

.lightbox-btn {
  position: absolute;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--bg);
  font-family: var(--font-text);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.lightbox-btn:focus-visible {
  outline: 2px solid var(--bg);
  outline-offset: 2px;
}

.lightbox-close {
  top: 16px;
  right: 16px;
  font-size: 1.25rem;
}

.lightbox-prev {
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
}

.lightbox-next {
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
}

.lightbox-counter {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  color: var(--text-secondary);
  font-size: 0.85rem;
  letter-spacing: 0.02em;
}

/* ---------- Уважение к prefers-reduced-motion ---------- */

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }

  .reveal {
    opacity: 1;
    transform: none;
  }
}
