/* Контейнер секции книг */
.books-section {
    max-width: 1200px;
    margin: 24px auto 64px auto;
    padding: 0 16px;
}

/* Тулбар (счётчик и подсказки) */
.books-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.books-toolbar .hint {
    font-size: 0.9rem;
    opacity: 0.8;
}

/* --- Грид карточек --- */
/* Мобильно по умолчанию: 3 колонки */
.books-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

/* ≥560px — оставляем 3 колонки (чтобы не прыгало на 2) */
@media (min-width: 560px) {
    .books-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* ≥840px — 4 колонки */
@media (min-width: 840px) {
    .books-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

/* ≥1120px — можно оставить 4 (как было) */
@media (min-width: 1120px) {
    .books-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

/* --- Карточка книги --- */
.book-card {
    position: relative;
    display: flex;
    flex-direction: column;
    background: var(--card-bg, #fff);
    border: 1px solid rgba(0,0,0,0.06);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 8px 22px rgba(0,0,0,0.06);
    transition: transform .2s ease, box-shadow .2s ease;
}
.book-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 26px rgba(0,0,0,0.12);
}

/* Обложка */
.book-cover-wrap {
    position: relative;
    aspect-ratio: 3/4;
    background: #f4f4f4;
    overflow: hidden;
}
.book-cover {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Кнопка лайка */
.like-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    border: none;
    outline: none;
    background: rgba(255,255,255,0.9);
    border-radius: 999px;
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0,0,0,0.12);
    transition: transform .18s ease, background .18s ease;
}
.like-btn:hover { transform: scale(1.06); }
.like-btn[aria-pressed="true"] { background: #ffe6ea; }

.like-icon {
    width: 22px;
    height: 22px;
    display: block;
}
.like-icon path {
    fill: none;
    stroke: #e73b67;
    stroke-width: 2;
}
.like-btn[aria-pressed="true"] .like-icon path {
    fill: #e73b67;
}

/* Контент карточки */
.book-body {
    padding: 12px 12px 14px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.book-title {
    font-weight: 700;
    font-size: 0.95rem;
    line-height: 1.5;
}
.book-title a {
    color: inherit;
    text-decoration: none;
}
.book-title a:hover {
    text-decoration: underline;
}
.book-authors {
    font-size: 0.95rem;
    opacity: 0.85;
}

/* Рейтинг */
.rating-row {
    margin-top: 6px;
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 10px;
}
.rating-range {
    width: 100%;
}
.rating-value {
    min-width: 36px;
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

/* Скелетоны */
.skeleton {
    background: linear-gradient(90deg, rgba(0,0,0,0.06), rgba(0,0,0,0.12), rgba(0,0,0,0.06));
    background-size: 200% 100%;
    animation: shimmer 1.2s infinite;
}
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}
.book-card.skeleton .book-cover-wrap { background: #eaeaea; }
.book-card.skeleton .book-body > div { height: 14px; border-radius: 6px; }
.book-card.skeleton .book-body > div:nth-child(1) { width: 70%; }
.book-card.skeleton .book-body > div:nth-child(2) { width: 50%; }
.book-card.skeleton .book-body > div:nth-child(3) { width: 90%; }

/* Сообщение об ошибке / пустом результате */
.inline-note {
    padding: 14px 16px;
    border-radius: 12px;
    background: rgba(255,160,1,0.12);
    border: 1px solid rgba(255,160,1,0.35);
}

/* Поддержка тем */
:root[data-theme="dark"] .book-card {
    --card-bg: #16181d;
    border-color: rgba(255,255,255,0.06);
    box-shadow: 0 8px 22px rgba(0,0,0,0.4);
}
:root[data-theme="dark"] .book-card:hover {
    box-shadow: 0 12px 28px rgba(0,0,0,0.6);
}
:root[data-theme="dark"] .book-cover-wrap { background: #20232a; }
:root[data-theme="dark"] .inline-note {
    background: rgba(255,160,1,0.16);
    border-color: rgba(255,160,1,0.45);
}

/* -------- Мобильная «компактная» настройка для пропорционального уменьшения -------- */
@media (max-width: 559px) {
    .books-section { padding: 0 8px; }
    .books-grid { gap: 8px; }

    /* вкладки занимают всю ширину и сами переноятся строками */
    .books-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        justify-content: flex-start;
    }
    .tabs {
        width: 100%;
        /* важные параметры для переноса целых вкладок */
        display: flex;
        flex-wrap: wrap;
        gap: .5rem;
    }
    .tab-btn {
        white-space: nowrap;   /* не ломать текст внутри кнопки */
        flex: 0 0 auto;        /* кнопка не сжимается и переносится целиком */
    }

    .book-card {
        border-radius: 10px;
        box-shadow: 0 4px 14px rgba(0,0,0,0.06);
    }

    .like-btn {
        top: 6px;
        right: 6px;
        width: 26px;
        height: 26px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    }
    .like-icon { width: 16px; height: 16px; }

    .book-body { padding: 8px 8px 10px 8px; gap: 6px; }
    .book-title { font-size: 0.78rem; line-height: 1.35; }
    .book-authors { font-size: 0.74rem; }

    .rating-row { margin-top: 4px; gap: 6px; }
    .rating-value { min-width: 28px; font-size: 0.78rem; }
    .books-toolbar .hint { font-size: 0.8rem; }
}

/* === Стили вкладок === */
.tabs {
  /* раньше было inline-flex без переноса, из-за чего кнопки не помещались */
  display: flex;
  flex-wrap: wrap;           /* ключ к переносу по строкам */
  gap: .5rem;
  background: var(--ifm-background-surface-color, transparent);
  border-radius: 12px;
  padding: .25rem;
  /* чтобы контейнер мог сжиматься внутри тулбара и правильно переносить элементы */
  min-width: 0;
}
.tab-btn {
  border: none;
  padding: .5rem .9rem;
  border-radius: 10px;
  cursor: pointer;
  background: transparent;
  font: inherit;
  line-height: 1.2;
  /* не делим кнопку на части и не переносим слова внутри */
  white-space: nowrap;
  flex: 0 0 auto;
}
.tab-btn[aria-selected="true"] {
  background: #FFA001;
  color: #1a1a1a;
  font-weight: 600;
}

/* (дубликат базового — оставлен для совместимости, но без изменений проблемной логики) */
.books-toolbar {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:1rem;
  flex-wrap:wrap;
}

/* === Плавающая кнопка багов === */
.bug-fab {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background: #FFA001;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  font-size: 26px;
  z-index: 999;
  transition: transform 0.2s;
}
.bug-fab:hover { transform: scale(1.1); }

/* === Панель багов === */
.bug-panel {
  position: fixed;
  bottom: 90px;
  right: 20px;
  max-width: 420px;
  max-height: 480px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.3);
  padding: 16px;
  font-size: 12px;
  display: none;
  flex-direction: column;
  gap: 10px;
  z-index: 1000;
  overflow-y: auto;
}

/* На мобильных — максимум 320 */
@media (max-width: 600px) {
  .bug-panel {
    width: min(320px, calc(100vw - 40px));
    max-width: 320px;
  }
}
.bug-panel h4 {
  margin: 0 0 8px;
  font-size: 16px;
  color: #e53935;
}

.bug-item {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "text actions"
    "status actions";
  gap: 6px 10px;
  padding: 10px;
  border-radius: 8px;
  border-left: 3px solid #FFA001;
  background: #fafafa;
  transition: background 0.2s, opacity 0.2s;
}
.bug-text { grid-area: text; }
.bug-actions { grid-area: actions; display: flex; gap: 6px; align-items: start; }
.bug-status { grid-area: status; font-size: 12px; opacity: .8; }

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.08);
  background: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
  transition: transform .15s, background .15s, box-shadow .15s, border-color .15s;
  font-size: 18px;
}
.icon-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,.12); }
.icon-btn:focus { outline: none; border-color: #FFA001; }

/* Состояния бага */
.bug-item.status-open  { background: #ffe1d2; } /* тёплый оттенок */
.bug-item.status-fixed { background: #daf4e9; opacity: 0.92; } /* зелёный намёк */

/* Подсветка активной кнопки */
.icon-btn[aria-pressed="true"] { background: #ffe7c2; }
.btn-fixed[aria-pressed="true"] { background: #c9f2e4; }

/* Тёмная тема */
html[data-theme="dark"] .bug-panel { background: #1A1A1A; color: #F1F1F1; }
html[data-theme="dark"] .bug-item { background: #242424; border-left-color: #FFA001; }
html[data-theme="dark"] .bug-item.status-open  { background: #2a2320; }
html[data-theme="dark"] .bug-item.status-fixed { background: #1f2a26; }
html[data-theme="dark"] .icon-btn { background: #16181d; color: #F1F1F1; border-color: rgba(255,255,255,0.08); }
html[data-theme="dark"] .icon-btn[aria-pressed="true"] { background: #3a2d22; }
html[data-theme="dark"] .btn-fixed[aria-pressed="true"] { background: #25433a; }
