/* ── Каталог книг · карточки из cards-experiment ──── */

:root {
  --bg:         #f0ece4;
  --surface:    #ffffff;
  --gold:       #c9a227;
  --green:      #1a3d1a;
  --text:       #111111;
  --text-2:     #555555;
  --muted:      #888888;
  --badge-bg:   rgba(201,162,39,0.12);
  --badge-text: #9a7a1a;
  --border:     #e8e3da;
  --cover-bg:   #e2ddd4;
}

body.v3-inner {
  background: var(--bg);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Основной контейнер ─────────────────────────────── */

.catalog-main {
  flex: 1;
  padding: 28px 5% 80px;
  max-width: 1920px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}

/* ── Шапка страницы ──────────────────────────────────── */

.catalog-page-header {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 20px;
}

.catalog-page-title {
  font-size: 1.625rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.catalog-count {
  font-size: 0.8125rem;
  color: var(--muted);
}

/* ── Панель фильтров ────────────────────────────────── */

.catalog-filters {
  background: var(--surface);
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  margin-bottom: 20px;
  border: 1px solid var(--border);
}

.search-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  flex-wrap: wrap;
}

.search-wrap {
  flex: 1;
  min-width: 240px;
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 12px;
  width: 18px; height: 18px;
  color: var(--muted);
  pointer-events: none;
}

.filter-search {
  width: 100%;
  padding: 9px 36px 9px 40px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.875rem;
  font-family: inherit;
  background: var(--bg);
  outline: none;
  transition: border-color 0.2s;
}
.filter-search:focus { border-color: var(--gold); }

.search-clear {
  position: absolute;
  right: 10px;
  background: none; border: none;
  font-size: 1rem; color: var(--muted);
  cursor: pointer; padding: 2px 4px; line-height: 1;
  transition: color 0.15s;
}
.search-clear:hover { color: var(--text); }

.btn-advanced {
  padding: 9px 14px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8125rem; font-weight: 600;
  white-space: nowrap;
  display: flex; align-items: center; gap: 6px;
  transition: all 0.18s;
}
.btn-advanced:hover,
.btn-advanced.open { background: var(--text); color: white; border-color: var(--text); }
.adv-arrow { font-size: 0.6875rem; transition: transform 0.2s; }
.btn-advanced.open .adv-arrow { transform: rotate(180deg); }

.adv-count {
  background: var(--gold); color: var(--text);
  border-radius: 10px; font-size: 0.6875rem; font-weight: 800;
  padding: 1px 6px; min-width: 18px; text-align: center;
}

.catalog-sort {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.8125rem; font-family: inherit;
  background: var(--bg); color: var(--text);
  cursor: pointer; outline: none;
  transition: border-color 0.2s;
}
.catalog-sort:focus { border-color: var(--gold); }

/* ── Расширенный поиск ──────────────────────────────── */

.advanced-panel {
  max-height: 0; overflow: hidden;
  transition: max-height 0.32s ease, padding 0.32s ease;
  padding: 0 18px;
  border-top: 0 solid var(--border);
}
.advanced-panel.open {
  max-height: 600px;
  padding: 16px 18px 14px;
  border-top: 1px solid var(--border);
}

.adv-row {
  display: flex; gap: 12px; flex-wrap: wrap;
  align-items: flex-end; margin-bottom: 10px;
}
.adv-field { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 140px; }
.adv-field-narrow { flex: 0 0 120px; min-width: 100px; }

.adv-label {
  font-size: 0.6875rem; font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--muted);
}

.adv-input, .adv-select {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.8125rem; font-family: inherit;
  background: var(--bg);
  outline: none; transition: border-color 0.2s;
  width: 100%;
}
.adv-input:focus, .adv-select:focus { border-color: var(--gold); }

.btn-adv-reset {
  padding: 6px 14px;
  background: none; border: 1px solid var(--border);
  border-radius: 6px; font-size: 0.75rem; color: var(--muted);
  cursor: pointer; transition: all 0.18s;
  white-space: nowrap; align-self: flex-start; margin-top: 10px;
}
.btn-adv-reset:hover { border-color: #c0392b; color: #c0392b; }

/* ── Активные теги ──────────────────────────────────── */

.active-tags {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 10px 18px 12px;
  border-top: 1px solid var(--border);
}
.filter-tag {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--text); color: rgba(240,236,228,0.88);
  border-radius: 4px; padding: 4px 10px 4px 12px;
  font-size: 0.75rem;
  animation: tag-in 0.18s ease both;
}
.filter-tag-remove {
  background: none; border: none;
  color: rgba(240,236,228,0.5);
  cursor: pointer; font-size: 0.875rem; line-height: 1;
  padding: 0; transition: color 0.15s;
}
.filter-tag-remove:hover { color: var(--gold); }
@keyframes tag-in {
  from { opacity: 0; transform: scale(0.85); }
  to   { opacity: 1; transform: scale(1); }
}

/* ── Сетка книг ─────────────────────────────────────── */

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}

/* ── Карточка книги (из cards-experiment.html) ───────── */

.book-card {
  background: var(--surface);
  border-radius: 10px;
  display: flex;
  align-items: stretch;
  padding: 18px 20px;
  gap: 16px;
  cursor: pointer;
  box-shadow: inset 3px 0 0 var(--gold), 0 2px 8px rgba(0,0,0,0.06);
  transition: transform 0.22s ease, box-shadow 0.22s ease;
  animation: card-enter 0.22s ease both;
}
.book-card:hover {
  transform: translateY(-3px);
  box-shadow: inset 5px 0 0 var(--gold), 0 8px 24px rgba(0,0,0,0.09);
}

@keyframes card-enter {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Обложка */
.book-cover {
  width: 80px;
  min-width: 80px;
  height: 110px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  background: var(--cover-bg);
}
.book-cover img {
  width: 100%; height: 100%;
  object-fit: cover; display: block;
}
.book-initials {
  font-size: 1.375rem; font-weight: 700;
  color: rgba(0,0,0,0.2);
  user-select: none;
}

/* Текстовый блок */
.book-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.book-badge {
  display: inline-block;
  font-size: 0.6875rem; font-weight: 700;
  letter-spacing: 0.05em;
  background: var(--badge-bg);
  color: var(--badge-text);
  padding: 3px 8px;
  border-radius: 4px;
  align-self: flex-start;
  margin-bottom: 7px;
  white-space: nowrap;
}

.book-title {
  font-size: 0.9375rem; font-weight: 700;
  line-height: 1.35; color: var(--text);
  margin: 0 0 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.book-author {
  font-size: 0.8125rem; font-weight: 500;
  color: var(--text-2);
  margin: 0 0 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.book-meta {
  font-size: 0.6875rem; color: var(--muted);
  margin: 0 0 7px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.book-desc {
  font-size: 0.8125rem; line-height: 1.55;
  color: var(--text-2);
  margin: 0;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Нижняя строка: статус + метки */
.book-footer {
  display: flex; flex-wrap: wrap; gap: 5px;
  margin-top: 10px; padding-top: 8px;
  border-top: 1px solid rgba(232,227,218,0.8);
}

/* Бейджи доступности */
.book-avail {
  font-size: 0.625rem; font-weight: 700;
  letter-spacing: 0.05em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 4px; white-space: nowrap;
}
.avail-online {
  background: rgba(30,93,30,0.1); color: #1e5d1e;
  border: 1px solid rgba(30,93,30,0.2);
}
.avail-hall {
  background: rgba(201,162,39,0.1); color: #8a6200;
  border: 1px solid rgba(201,162,39,0.3);
}
.avail-closed {
  background: rgba(100,60,0,0.08); color: #6b4400;
  border: 1px solid rgba(100,60,0,0.2);
}
.avail-none {
  background: rgba(0,0,0,0.04); color: var(--muted);
  border: 1px solid rgba(0,0,0,0.1);
}

/* Метки-предупреждения */
.warn-pill {
  font-size: 0.5625rem; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase;
  padding: 2px 6px; border-radius: 3px; white-space: nowrap;
}
.w-adult  { background: #6b0d28; color: #ffcccc; }
.w-drug   { background: #7a2800; color: #ffc8a0; }
.w-terror { background: #1a0000; color: #ff9999; border: 1px solid #6b0000; }
.w-agent  { background: #1a1a6b; color: #c8c0ff; }

/* ── Скелетон загрузки ──────────────────────────────── */

.catalog-skeleton-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}

.skeleton-card {
  height: 148px;
  border-radius: 10px;
  display: flex;
  gap: 16px;
  padding: 18px 20px;
  background: var(--surface);
  box-shadow: inset 3px 0 0 rgba(201,162,39,0.25), 0 2px 8px rgba(0,0,0,0.05);
}

.sk-cover {
  width: 80px; min-width: 80px; height: 110px;
  border-radius: 6px;
  background: linear-gradient(90deg, #e0dbd2 25%, #eae5db 50%, #e0dbd2 75%);
  background-size: 200% 100%;
  animation: shimmer 1.6s infinite ease-in-out;
  flex-shrink: 0;
}

.sk-body {
  flex: 1;
  display: flex; flex-direction: column; gap: 8px;
}

.sk-line {
  border-radius: 4px;
  background: linear-gradient(90deg, #e8e3da 25%, #f0ece4 50%, #e8e3da 75%);
  background-size: 200% 100%;
  animation: shimmer 1.6s infinite ease-in-out;
}
.sk-badge  { height: 20px; width: 56px; animation-delay: 0.05s; }
.sk-title  { height: 15px; width: 85%; animation-delay: 0.10s; }
.sk-title2 { height: 15px; width: 60%; animation-delay: 0.14s; }
.sk-author { height: 12px; width: 45%; animation-delay: 0.18s; }
.sk-anno   { height: 11px; width: 90%; animation-delay: 0.22s; }

.skeleton-card:nth-child(even) .sk-cover { animation-delay: 0.1s; }
.skeleton-card:nth-child(3n)   .sk-cover { animation-delay: 0.2s; }

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Пустое состояние ───────────────────────────────── */

.catalog-empty {
  text-align: center; padding: 60px 20px;
  color: var(--muted); animation: fade-in 0.3s ease both;
}
.empty-icon { font-size: 2.5rem; margin-bottom: 12px; }
.catalog-empty > div:nth-child(2) { font-size: 0.875rem; margin-bottom: 6px; color: var(--text); }
.empty-hint { font-size: 0.75rem; }

/* ── Пагинация ──────────────────────────────────────── */

.catalog-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 32px;
}

.page-btn {
  padding: 9px 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8125rem; font-weight: 600;
  transition: all 0.18s;
}
.page-btn:hover:not(:disabled) { background: var(--text); color: white; border-color: var(--text); }
.page-btn:disabled { opacity: 0.4; cursor: default; }

.page-info {
  font-size: 0.8125rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.page-jump {
  width: 52px;
  padding: 5px 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.8125rem;
  font-family: inherit;
  text-align: center;
  background: var(--bg);
}

@media (max-width: 767px) {
  .catalog-pagination { gap: 10px; margin-top: 20px; }
  .page-btn { padding: 8px 12px; font-size: 0.75rem; }
}

/* ═══════════════════════════════════════════════
   МОДАЛЬНОЕ ОКНО — «Сцена с занавесом»
   ═══════════════════════════════════════════════ */

.catalog-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(10,18,10,0.72);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 1010;
  opacity: 0; transition: opacity 0.28s ease;
  pointer-events: none;
}
.catalog-modal-overlay.visible { opacity: 1; pointer-events: all; }

.catalog-modal {
  position: fixed;
  z-index: 1011;
  width: 560px;
  max-width: calc(100vw - 32px);
  max-height: 88vh;
  background: var(--bg);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 32px 96px rgba(10,18,10,0.52);
  opacity: 0;
  /* Позиция задаётся через JS */
}

/* Кнопка закрытия — поверх баннера */
.catalog-modal-close {
  position: absolute;
  top: 12px; right: 14px;
  width: 32px; height: 32px;
  background: rgba(0,0,0,0.38);
  border: none; border-radius: 50%;
  font-size: 0.9375rem; line-height: 1;
  cursor: pointer; color: rgba(255,255,255,0.8);
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s;
  z-index: 10;
}
.catalog-modal-close:hover { background: rgba(0,0,0,0.65); color: #fff; }

/* Баннер — двухколоночный: портретная обложка слева, заголовок справа */
.modal-banner {
  display: flex;
  align-items: stretch;
  background: linear-gradient(135deg, #1a3118 0%, #0d1a0d 100%);
  min-height: 200px;
  flex-shrink: 0;
  overflow: hidden;
}

/* Колонка с обложкой */
.modal-banner-cover-col {
  flex-shrink: 0;
  width: 140px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 24px 0 20px 24px;
}

.catalog-modal-cover {
  width: 108px;
  height: auto;
  max-height: 180px;
  object-fit: contain;
  border-radius: 5px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.55), 0 2px 6px rgba(0,0,0,0.3);
  display: block;
}

.catalog-modal-cover-placeholder {
  width: 108px;
  height: 154px;
  border-radius: 5px;
  background: rgba(201,162,39,0.1);
  border: 1px solid rgba(201,162,39,0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: Georgia, serif;
  font-size: 2.625rem; font-weight: normal;
  color: rgba(201,162,39,0.45);
}

/* Текстовая часть справа */
.modal-banner-caption {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 24px 24px 20px 20px;
  min-width: 0;
}

.modal-warnings {
  display: flex; flex-wrap: wrap; gap: 5px;
  margin-bottom: 8px;
}
.modal-warn-pill {
  font-size: 0.625rem; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 3px;
}
.mw-adult  { background: #6b0d28; color: #ffcccc; }
.mw-drug   { background: #7a2800; color: #ffc8a0; }
.mw-terror { background: #5c0e0e; color: #ff9999; border: 1px solid #6b0000; }
.mw-agent  { background: #3b3b00; color: #fff3a0; }

.catalog-modal-title {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1.25rem; font-weight: normal;
  line-height: 1.3; color: #ffffff;
  margin: 0 0 6px;
  text-shadow: 0 1px 4px rgba(0,0,0,0.6);
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.catalog-modal-author {
  font-size: 0.6875rem; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--gold); margin: 0;
}

/* Полоса метаданных */
.modal-meta-strip {
  display: flex; flex-wrap: wrap;
  background: #111111;
  padding: 10px 24px;
  flex-shrink: 0;
  gap: 0;
}

.modal-meta-item {
  display: flex; flex-direction: column; gap: 2px;
  padding-right: 20px;
  border-right: 1px solid rgba(255,255,255,0.1);
  margin-right: 20px;
}
.modal-meta-item:last-child { border-right: none; margin-right: 0; padding-right: 0; }

.meta-label {
  font-size: 0.5625rem; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: rgba(255,255,255,0.38);
}
.meta-value {
  font-size: 0.75rem; color: rgba(255,255,255,0.85);
  letter-spacing: 0.02em;
}

/* Прокручиваемое тело */
.catalog-modal-body {
  padding: 20px 24px 24px;
  overflow-y: auto; flex: 1;
  display: flex; flex-direction: column; gap: 16px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.catalog-modal-annotation {
  font-size: 0.875rem; line-height: 1.7;
  color: #333333; margin: 0;
}

.catalog-modal-actions {
  display: flex; flex-direction: column; gap: 8px;
  margin-top: auto; padding-top: 4px;
}

.btn-read {
  background: var(--green); color: #f5f0e8;
  border: none; padding: 12px 20px; border-radius: 6px;
  font-family: inherit; font-size: 0.8125rem; font-weight: 700;
  letter-spacing: 0.05em; text-transform: uppercase;
  cursor: pointer; text-align: center; text-decoration: none;
  display: block; transition: background 0.2s;
}
.btn-read:hover { background: #0b1d0b; }

.btn-hall {
  background: rgba(201,162,39,0.1); color: #7a5c00;
  border: 1px solid rgba(201,162,39,0.4);
  padding: 11px 20px; border-radius: 6px;
  font-family: inherit; font-size: 0.8125rem; font-weight: 700;
  letter-spacing: 0.05em; text-transform: uppercase;
  cursor: pointer; text-align: center;
  transition: background 0.2s, border-color 0.2s;
}
.btn-hall:hover { background: rgba(201,162,39,0.2); border-color: var(--gold); }

.btn-bookmark {
  background: transparent; color: var(--muted);
  border: 1px solid var(--border);
  padding: 10px 20px; border-radius: 6px;
  font-family: inherit; font-size: 0.8125rem; font-weight: 700;
  letter-spacing: 0.04em; text-transform: uppercase;
  cursor: pointer; text-align: center;
  transition: all 0.2s;
}
.btn-bookmark:hover { border-color: var(--gold); color: #7a5c00; }
.btn-bookmark.active {
  background: rgba(201,162,39,0.1);
  border-color: var(--gold); color: #7a5c00;
}

.hall-info {
  background: rgba(92,14,14,0.07);
  border: 1px solid rgba(139,26,26,0.25);
  border-radius: 6px; padding: 12px 14px;
  font-size: 0.8125rem; color: #4a1010; line-height: 1.75;
  display: none;
}
.hall-info.visible { display: block; }

/* ── Библиографическая запись ───────────────────── */

.modal-biblio {
  background: rgba(201,162,39,0.05);
  border: 1px solid rgba(201,162,39,0.18);
  border-left: 3px solid var(--gold);
  border-radius: 0 6px 6px 0;
  padding: 12px 14px;
}

.modal-biblio-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.modal-biblio-label {
  font-size: 0.5625rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.modal-biblio-copy {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px 10px;
  font-size: 0.6875rem;
  font-family: inherit;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.modal-biblio-copy:hover { border-color: var(--gold); color: #7a5c00; }

.modal-biblio-text {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 0.8125rem;
  line-height: 1.65;
  color: #333333;
  margin: 0;
  user-select: text;
}

/* ── Адаптив ────────────────────────────────────────── */

@media (max-width: 1279px) {
  .catalog-grid,
  .catalog-skeleton-grid {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  }
}

@media (max-width: 767px) {
  .catalog-main { padding: 14px 4% 60px; }

  .catalog-grid,
  .catalog-skeleton-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .book-cover { width: 64px; min-width: 64px; height: 90px; }
  .book-title { font-size: 0.875rem; }
  .book-desc  { -webkit-line-clamp: 2; }
  .book-card  { padding: 14px 16px; gap: 12px; }

  .search-row { padding: 10px 12px; gap: 8px; }
  .search-wrap { min-width: 0; }
  .catalog-sort, .btn-advanced { width: 100%; justify-content: center; }
  .adv-field { min-width: 100%; }
  .advanced-panel.open { max-height: 1400px; }

  /* Модалка — bottom sheet */
  .catalog-modal {
    top: auto !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    max-height: 92vh;
    border-radius: 16px 16px 0 0;
  }
  .modal-banner-cover-col { width: 110px; padding: 18px 0 16px 16px; }
  .catalog-modal-cover { width: 88px; max-height: 140px; }
  .catalog-modal-cover-placeholder { width: 88px; height: 126px; font-size: 2.125rem; }
  .modal-banner-caption { padding: 18px 16px 16px 16px; }
  .catalog-modal-title { font-size: 1.0625rem; }
  .modal-meta-strip { padding: 10px 16px; }
  .modal-meta-item:nth-child(n+4) { display: none; }
  .catalog-modal-body { padding: 16px 16px 24px; }
}
