/* ============================================
   ART4DEMOCRACY — CLEANED CSS (used selectors only)
   Обновлено: секция SINGLE ARTWORK переработана под галерею
   (главное фото + превью + lightbox). Панель больше не режет превью.
   ============================================ */

/* ---- GOOGLE FONTS IMPORT ---- */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,500;0,700;1,400;1,500&family=Inter:wght@300;400;500;600&display=swap');

/* ---- CSS VARIABLES ---- */
:root {
  --a4d-black: #000000;
  --a4d-off-black: #1a1a1a;
  --a4d-dark-gray: #333333;
  --a4d-mid-gray: #666666;
  --a4d-light-gray: #999999;
  --a4d-border: #e0e0e0;
  --a4d-bg-light: #f8f8f6;
  --a4d-white: #ffffff;
  --a4d-main-color: #F7F4EF;
  --font-serif: 'Playfair Display', Georgia, 'Times New Roman', serif;
  --font-sans: 'Inter', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --transition: all 0.25s ease;
  --max-width: 1400px;
}

/* ---- GLOBAL RESET & BASE ---- */
*, ::before, *::after { box-sizing: border-box; }

body {
  font-family: var(--font-sans);
  background-color: var(--a4d-main-color);
  color: var(--a4d-off-black);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---- GLOBAL TYPOGRAPHY ---- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-serif);
  line-height: 1.2;
}
p, li, span, label, td, th, input, select, textarea, button {
  font-family: var(--font-sans);
}

/* ---- GALLERY PAGE ---- */
.a4d-gallery-wrapper {
  min-height: 80vh;
  background: #F7F4EF;
}

/* Filter bar */
.a4d-filter-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 16px 0 16px;
  position: sticky;
  top: 73px;
  z-index: 100;
}
.a4d-search-input {
  padding: 10px 16px !important;
  border: 1px solid var(--a4d-border) !important;
  border-radius: 0 !important;
  outline: none;
  margin-left: 16px;
  width: 220px !important;
  direction: ltr;
}
.a4d-search-input:focus { border-color: var(--a4d-black); }
.a4d-search-input::placeholder { color: var(--a4d-light-gray); }
.a4d-filter-select {
  width: auto;
  min-width: 140px;
  padding: 13px 32px 13px 12px;
  border: 1px solid var(--a4d-border);
  border-radius: 0;
  font-size: 11px;
  font-family: var(--font-sans);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--a4d-white);
  color: var(--a4d-off-black);
  cursor: pointer;
  margin-right: -1px;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%23333' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
.a4d-filter-select:focus { border-color: var(--a4d-black); z-index: 1; position: relative; }
.a4d-filter-count {
  margin-right: 8px;
  margin-left: auto;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--a4d-mid-gray);
}

/* Gallery grid */
.a4d-gallery-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  padding: 0 16px;
}

/* Artwork card */
.a4d-artwork-card {
  background: var(--a4d-white);
  border: 1px solid var(--a4d-border);
  cursor: pointer;
  transition: var(--transition);
  overflow: hidden;
  display: block;
  text-decoration: none;
  color: inherit;
}
.a4d-artwork-card:hover {
  background: var(--a4d-bg-light);
  text-decoration: none;
  color: inherit;
}
.a4d-artwork-card:hover .a4d-card-image img { transform: scale(1.03); }

/* Card image container */
.a4d-card-image {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: var(--a4d-bg-light);
}
.a4d-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s ease;
}

/* No image placeholder */
.a4d-card-no-image {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--a4d-bg-light);
  color: var(--a4d-border);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* Card body */
.a4d-card-body {
  padding: 14px 16px 18px;
  background: var(--a4d-white);
}
.a4d-card-lot {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--a4d-light-gray);
  margin: 0 0 4px;
}
.a4d-card-artist {
  font-size: 12px;
  font-weight: 400;
  color: var(--a4d-off-black);
  margin: 0 0 2px;
  font-family: var(--font-sans);
}
.a4d-card-title {
  font-size: 13px;
  font-style: italic;
  font-weight: 400;
  color: var(--a4d-off-black);
  margin: 0 0 4px;
  font-family: var(--font-serif);
  line-height: 1.3;
}
.a4d-card-meta {
  font-size: 11px;
  color: var(--a4d-mid-gray);
  margin: 0 0 8px;
  font-family: var(--font-sans);
}
.a4d-card-price {
  font-size: 12px;
  font-weight: 500;
  color: var(--a4d-off-black);
  margin: 0;
  font-family: var(--font-sans);
}

/* ============================================
   SINGLE ARTWORK PAGE  (галерея: фото + превью + lightbox)
   ============================================ */
.a4d-single-wrapper {
  display: flex;
  align-items: flex-start;
  gap: 0;
  min-height: calc(100vh - 74px);
  background: var(--a4d-white);
}

/* Левая панель: залипает на высоту экрана.
   Внутри — колонка: фото (гибко ужимается) + превью снизу.
   overflow убран, чтобы превью никогда не обрезались. */
.a4d-single-image-panel {
  flex: 0 0 60%;
  position: sticky;
  top: 74px;
  height: calc(100vh - 74px);
  overflow: hidden;
  background: var(--a4d-bg-light);
  display: flex;
  flex-direction: column;
  padding: 40px;
}

.a4d-single-image-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  color: var(--a4d-border);
  font-size: 13px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  flex-direction: column;
  gap: 16px;
}

/* Контейнер медиа занимает всю высоту панели */
.a4d-media {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  gap: 16px;
  min-height: 0;
}

/* Зона главного фото — гибкая, ужимается, освобождая место под превью */
.a4d-media-main {
  flex: 1 1 auto;
  min-height: 0;            /* критично для корректного сжатия фото */
  display: flex;
  align-items: center;
  justify-content: center;
}
.a4d-media-main img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  cursor: zoom-in;
  transition: opacity 0.25s ease;
}
.a4d-media-main img.is-swapping { opacity: 0; }

/* Превью (это <button> — жёстко гасим стили кнопок темы/Elementor) */
.a4d-thumbs {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}
.a4d-thumb {
  width: 92px;
  height: 92px;
  flex: 0 0 auto;
  padding: 0 !important;
  margin: 0 !important;
  border: 1px solid var(--a4d-border) !important;
  border-radius: 0 !important;
  background: var(--a4d-white) !important;
  box-shadow: none !important;
  overflow: hidden;
  cursor: pointer;
  line-height: 0 !important;
  color: inherit !important;
  font: inherit !important;
  -webkit-appearance: none;
  appearance: none;
  box-sizing: border-box;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.a4d-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s cubic-bezier(.2,.7,.3,1);
}
.a4d-thumb:hover img { transform: scale(1.08); }
.a4d-thumb:hover,
.a4d-thumb:focus,
.a4d-thumb:focus-visible {
  background: var(--a4d-white) !important;
  border-color: var(--a4d-off-black) !important;
  box-shadow: none !important;
  outline: none !important;
}
.a4d-thumb.is-active {
  border-color: var(--a4d-off-black) !important;
  box-shadow: 0 0 0 1px var(--a4d-off-black) !important;
}

.a4d-single-info {
  flex: 0 0 40%;
  padding: 60px 48px;
  border-left: 1px solid var(--a4d-border);
  overflow-y: auto;
  max-height: calc(100vh - 74px);
  background: var(--a4d-white);
}
.a4d-single-back {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--a4d-mid-gray);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 40px;
  transition: var(--transition);
}
.a4d-single-back:hover { color: var(--a4d-black); }
.a4d-single-back::before { content: '←'; font-size: 14px; }
.a4d-single-lot {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--a4d-light-gray);
  margin-bottom: 6px;
}
.a4d-single-artist {
  font-size: 18px;
  font-weight: 400;
  font-family: var(--font-sans);
  color: var(--a4d-off-black);
  margin-bottom: 4px;
}
.a4d-single-artist a { color: inherit; text-decoration: none; }
.a4d-single-artist a:hover { text-decoration: underline; }
.a4d-single-title {
  font-size: 28px;
  font-style: italic;
  font-weight: 400;
  font-family: var(--font-serif);
  color: var(--a4d-off-black);
  line-height: 1.2;
  margin-bottom: 32px;
}

/* Metadata table */
.a4d-meta-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 32px;
}
.a4d-meta-table tr { border-bottom: 1px solid var(--a4d-border); }
.a4d-meta-table td {
  padding: 12px 0;
  font-size: 13px;
  font-family: var(--font-sans);
  vertical-align: top;
  padding-left: 16px;
}
.a4d-meta-table td:first-child {
  color: var(--a4d-mid-gray);
  font-weight: 400;
  width: 45%;
}
.a4d-meta-table td:last-child {
  color: var(--a4d-off-black);
  font-weight: 500;
}

/* Price on single page */
.a4d-single-price {
  font-size: 22px;
  font-weight: 500;
  font-family: var(--font-sans);
  color: var(--a4d-off-black);
  margin: 24px 0;
  border-top: 1px solid var(--a4d-border);
  padding-top: 24px;
}

.a4d-back-gallery-btn {
  display: block;
  width: 100%;
  padding: 14px 24px;
  background: transparent;
  color: var(--a4d-off-black);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-family: var(--font-sans);
  border: 1px solid var(--a4d-border);
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 32px;
}
.a4d-back-gallery-btn:hover {
  border-color: var(--a4d-black);
  text-decoration: none;
  color: var(--a4d-black);
}

/* Purchase / Sold button */
.a4d-purchase-btn {
  display: block;
  width: 100%;
  padding: 16px 24px;
  background: var(--a4d-off-black);
  color: var(--a4d-white);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-family: var(--font-sans);
  border: 1px solid var(--a4d-off-black);
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: var(--transition);
  margin: 8px 0 16px;
}
.a4d-purchase-btn:not(.sold):hover {
  background: var(--a4d-white);
  color: var(--a4d-off-black);
}
.a4d-purchase-btn.sold {
  background: var(--a4d-light-gray);
  border-color: var(--a4d-light-gray);
  cursor: default;
}

/* Description and bio sections */
.a4d-single-description {
  margin-top: 32px;
  padding-top: 32px;
  border-top: 1px solid var(--a4d-border);
  font-size: 14px;
  line-height: 1.7;
  color: var(--a4d-dark-gray);
  font-family: var(--font-sans);
}
.a4d-single-bio {
  margin-top: 32px;
  padding-top: 32px;
  border-top: 1px solid var(--a4d-border);
}
.a4d-single-bio-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--a4d-mid-gray);
  margin-bottom: 12px;
}
.a4d-single-bio p, .a4d-single-bio-text {
  font-size: 13px;
  line-height: 1.7;
  color: var(--a4d-dark-gray);
  font-family: var(--font-sans);
}
.a4d-single-artist-link { margin: 16px 0 0; font-size: 14px; }
.a4d-single-artist-link a { color: var(--a4d-off-black); text-decoration: underline; }
.a4d-single-artist-link a:hover { opacity: .7; }

/* ============================================
   LIGHTBOX (полноэкранный просмотр фото)
   ============================================ */
.a4d-lightbox {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(18, 16, 13, 0.94);
  opacity: 0;
  transition: opacity 0.25s ease;
}
.a4d-lightbox.is-open { display: flex; opacity: 1; }
body.a4d-lb-locked { overflow: hidden; }

.a4d-lb-stage {
  margin: 0;
  max-width: 86vw;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.a4d-lb-image {
  max-width: 86vw;
  max-height: 80vh;
  width: auto;
  height: auto;
  object-fit: contain;
  box-shadow: 0 24px 70px rgba(0,0,0,.5);
  user-select: none;
  -webkit-user-drag: none;
}
.a4d-lb-caption {
  margin-top: 14px;
  color: #e8e4db;
  font-size: 13px;
  letter-spacing: 0.04em;
  text-align: center;
  max-width: 70vw;
}
.a4d-lb-caption:empty { display: none; }

.a4d-lb-close {
  position: absolute;
  top: 18px; right: 22px;
  width: 44px; height: 44px;
  font-size: 30px; line-height: 1;
  color: #fff !important;
  background: transparent !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  padding: 0 !important;
  cursor: pointer; opacity: .85;
  -webkit-appearance: none; appearance: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.a4d-lb-close:hover,
.a4d-lb-close:focus,
.a4d-lb-close:active {
  background: transparent !important;
  color: #fff !important;
  box-shadow: none !important;
  outline: none !important;
  opacity: 1;
  transform: rotate(90deg);
}

.a4d-lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 56px; height: 56px;
  font-size: 38px; line-height: 1;
  color: #fff !important;
  background: rgba(255,255,255,.06) !important;
  border: 1px solid rgba(255,255,255,.18) !important;
  border-radius: 50% !important;
  box-shadow: none !important;
  padding: 0 !important;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  -webkit-appearance: none; appearance: none;
  transition: background 0.2s ease, border-color 0.2s ease;
}
.a4d-lb-nav:hover,
.a4d-lb-nav:focus,
.a4d-lb-nav:active {
  background: rgba(255,255,255,.20) !important;
  border-color: rgba(255,255,255,.45) !important;
  color: #fff !important;
  box-shadow: none !important;
  outline: none !important;
}
.a4d-lb-prev { left: 24px; }
.a4d-lb-next { right: 24px; }
.a4d-lb-nav[hidden] { display: none; }

.a4d-lb-counter {
  position: absolute;
  bottom: 22px; left: 50%;
  transform: translateX(-50%);
  color: #cfc9bd;
  font-size: 13px; letter-spacing: 0.12em;
}

/* ---- ELEMENTOR STRUCTURE (home) ---- */
.elementor-section { padding-left: 0; padding-right: 0; }
.elementor-container { max-width: var(--max-width); }

/* ---- RESPONSIVE ---- */
@media (max-width: 1200px) {
  .a4d-gallery-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 900px) {
  .a4d-gallery-grid { grid-template-columns: repeat(3, 1fr); }

  .a4d-single-wrapper { flex-direction: column; }

  /* На мобиле НЕ фиксируем высоту и НЕ обрезаем — иначе превью пропадают */
  .a4d-single-image-panel {
    flex: none;
    position: relative;
    top: auto;
    height: auto;
    max-height: none;
    overflow: visible;
    width: 100%;
    padding: 20px 16px;
  }
  .a4d-media { height: auto; }
  .a4d-media-main { flex: none; }
  .a4d-media-main img { width: 100%; max-height: 70vh; }

  /* Превью — горизонтальная лента со скроллом */
  .a4d-thumbs {
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    gap: 10px;
    padding-bottom: 4px;
    scrollbar-width: thin;
  }
  .a4d-thumb { width: 78px; height: 78px; }

  .a4d-single-info {
    flex: none;
    width: 100%;
    max-height: none;
    padding: 40px 24px;
    border-left: none;
    border-top: 1px solid var(--a4d-border);
  }
  .a4d-filter-bar { padding: 12px 16px; top: 60px; }

  .a4d-lb-nav { width: 44px; height: 44px; font-size: 28px; }
  .a4d-lb-prev { left: 10px; }
  .a4d-lb-next { right: 10px; }
  .a4d-lb-image, .a4d-lb-stage { max-width: 94vw; }
}

@media (max-width: 600px) {
  .a4d-gallery-grid { grid-template-columns: repeat(2, 1fr); }
  .a4d-filter-bar { flex-wrap: wrap; gap: 8px; }
  .a4d-search-input { flex: 1 1 100%; width: 100%; margin-left: 0; }
  .a4d-filter-select { flex: 1 1 calc(50% - 4px); }
}

/* ---- SCROLL BEHAVIOR ---- */
html { scroll-behavior: smooth; }

/* ---- PRINT ---- */
@media print {
  .a4d-filter-bar, .a4d-single-back, .a4d-thumbs, .a4d-lightbox { display: none; }
  .a4d-single-wrapper { flex-direction: column; }
  .a4d-single-image-panel { position: static; height: auto; overflow: visible; }
}