/* ============================================================
   COVERPRESS — preview-lib.css (ВРЕМЕННЫЙ ФАЙЛ, подзадача 1)
   Витрина «Библиотеки» по раскладке Apple Books.

   Все числа взяты из боевого CSS books.apple.com
   (web-experience-app-real-f1ca40148188f63f7dd2cd7d4d6d7e05.css),
   ничего не выдумано:

     брейкпоинты            735 / 1069 px
     ширина контента        87.5vw / 692px / 980px      (.l-content-width)
     поля на смартфоне      6.25vw                       (.section__nav)
     сетка                  12 колонок
     гуттер                 2.97vw / 20.6px / 19.4px     (.l-row + .l-column)
     полка (книжная, G)     4 / 5 / 6 карточек           ([data-grid='G'])
     заголовок полки        20px/600, serif New York     (.section__headline--book)
     отступ заголовка       17px                          (.section__headline-link)
     секция                 padding 19px / 32px           (.section)
     разделитель            1px #d6d6d6                   (.section--bordered)
     обложка книги          radius 2.5px, обводка .5px    (.we-artwork--ebook)
     вторичный текст        #636366

   Раздел (экран «все стили категории») — числа владельца: 6 / 5 / 4 / 2.
   Рабочие файлы сайта этот файл не затрагивает.
   ============================================================ */

/* Ничего не прячем за краем: полка на смартфоне выходит под правый край
   за счёт собственных полей, а не за счёт запрета прокрутки на странице.
   Так настоящая ошибка ширины сразу видна, а не маскируется. */

:root {
  --ap-edge: 48px;          /* боковое поле окна (решение владельца: без пустот) */
  --ap-side: 240px;         /* левый сайдбар: поиск + разделы + подборки */
  --ap-side-gap: 32px;
  --ap-gutter: 19.4px;      /* гуттер сетки */
  --ap-cols: 6;             /* карточек в полке = колонок в разделе */
  --ap-serif: "New York", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --ap-muted: #636366;
  --ap-rule: #d6d6d6;
}

/* ── Раскладка Books: слева сайдбар, справа витрина ─────────────────────── */
.lib-layout {
  display: grid;
  grid-template-columns: var(--ap-side) minmax(0, 1fr);
  gap: 0 var(--ap-side-gap);
  padding: 0 var(--ap-edge);
  align-items: start;
}
.lib-content { min-width: 0; }

.lib-side {
  position: sticky;
  top: 0;
  padding: 14px 0 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 100vh;
  overflow-y: auto;
  scrollbar-width: none;
}
.lib-side::-webkit-scrollbar { display: none; }

.lib-title {
  font-family: var(--ap-serif);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.15;
}

/* Поиск по стилям */
.lib-search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 10px;
  background: rgba(0, 0, 0, .05);
  color: var(--ap-muted);
}
.lib-search svg { flex: 0 0 auto; }
.lib-search input {
  flex: 1 1 auto;
  min-width: 0;
  border: none;
  background: none;
  font: inherit;
  font-size: 14px;
  color: #111;
  outline: none;
}
.lib-search input::-webkit-search-cancel-button { display: none; }
.lib-search-clear {
  flex: 0 0 auto; border: none; background: none; cursor: pointer;
  color: var(--ap-muted); padding: 2px; line-height: 0;
}
.lib-search-clear:hover { color: #111; }

/* Разделы: список строк, а не лента пилюль (как в сайдбаре Books) */
.lib-tabs { display: flex; flex-direction: column; gap: 2px; }
.lib-tab {
  width: 100%;
  text-align: left;
  padding: 7px 10px;
  border: none;
  border-radius: 8px;
  background: none;
  color: #111;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.28;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background .2s ease, color .2s ease;
}
.lib-tab:hover { background: rgba(0, 0, 0, .05); }
.lib-tab.active { background: var(--accent); color: #fff; }

/* ── Подборки клиента ───────────────────────────────────────────────────── */
.lib-colls { display: flex; flex-direction: column; align-items: stretch; gap: 2px; }
.lib-colls[hidden] { display: none; }
.lib-colls::-webkit-scrollbar { display: none; }
.lib-colls-title {
  flex: 0 0 auto; font-size: 12px; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: var(--ap-muted); margin-right: 2px;
}
.coll-link {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 7px 10px; border: none; border-radius: 8px;
  background: none; color: #111; font: inherit; font-size: 14px;
  font-weight: 500; cursor: pointer; white-space: nowrap; text-align: left;
}
.coll-link:hover { background: rgba(0,0,0,.05); }
.coll-link.active { background: var(--accent); color: #fff; }
.coll-link.active .coll-count { color: rgba(255,255,255,.7); }
.coll-count { font-size: 13px; color: var(--ap-muted); }
.lib-colls-add {
  flex: 0 0 auto; border: 1px dashed #ccc; background: none; cursor: pointer;
  color: var(--accent); font: inherit; font-size: 13px; font-weight: 600;
  padding: 6px 13px; border-radius: 100px; white-space: nowrap;
}
.lib-colls-add:hover { background: rgba(255,107,71,.08); }
.lib-colls-newrow { flex: 0 0 auto; display: flex; gap: 6px; }
.lib-colls-newrow input {
  min-width: 0; width: 180px; padding: 6px 12px; border: 1px solid #ccc;
  border-radius: 100px; font: inherit; font-size: 14px;
}
.lib-colls-newrow input:focus { outline: none; border-color: var(--accent); }
.lib-colls-newrow button {
  border: none; background: var(--accent); color: #fff; border-radius: 100px;
  padding: 0 14px; font: inherit; font-size: 14px; cursor: pointer;
}

.lib { padding-top: 14px; padding-bottom: 24px; min-width: 0; }

/* ============================================================
   ВИТРИНА: полки с выжимкой
   ============================================================ */
.lib-shelf { padding-top: 14px; padding-bottom: 20px; border-top: 1px solid var(--ap-rule); }
.lib-shelf:first-child { border-top: none; padding-top: 0; }

/* Заголовок полки: serif 20/600 + стрелка, отступ до ряда 17px. */
.lib-shelf-head {
  display: inline-flex;
  align-items: center;
  gap: .5em;
  margin-bottom: 12px;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  color: #111;
  font-family: var(--ap-serif);
  font-size: 20px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: 0;
  transition: gap .2s;
}
.lib-shelf-head svg { color: var(--ap-muted); transition: transform .2s var(--ease), color .2s ease; }
.lib-shelf-head:hover { gap: .8em; }
.lib-shelf-head:hover svg { color: #111; }

/* Ряд полки: ширина карточки = колонка сетки полки, прокрутка вбок. */
.lib-shelf-nav { position: relative; }
.lib-shelf-row {
  display: flex;
  gap: var(--ap-gutter);
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
}
.lib-shelf-row::-webkit-scrollbar { display: none; }
.lib-shelf-row > .lib-card {
  flex: 0 0 calc((100% - (var(--ap-cols) - 1) * var(--ap-gutter)) / var(--ap-cols));
  width: calc((100% - (var(--ap-cols) - 1) * var(--ap-gutter)) / var(--ap-cols));
  scroll-snap-align: start;
}

/* Стрелки листания полки — только на указательных устройствах. */
.lib-arrow {
  position: absolute;
  top: calc((100% - 46px) / 2);
  z-index: 3;
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--ap-rule);
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  color: #111;
  display: none; align-items: center; justify-content: center;
  cursor: pointer; box-shadow: 0 4px 14px rgba(0,0,0,.14);
}
.lib-arrow-prev { left: -14px; }
.lib-arrow-next { right: -14px; }
.lib-arrow:hover { background: #fff; }
.lib-arrow[disabled] { opacity: 0; pointer-events: none; }
@media (hover: hover) and (pointer: fine) and (min-width: 1069px) {
  .lib-shelf-nav:hover .lib-arrow { display: inline-flex; }
}

/* ============================================================
   ЭКРАН РАЗДЕЛА
   ============================================================ */
.lib-sec-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 17px; }
.lib-back {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--ap-rule); background: #fff; color: var(--ap-muted);
  border-radius: 100px; padding: 6px 13px; font: inherit; font-size: 13px;
  font-weight: 500; cursor: pointer;
}
.lib-back:hover { color: #111; border-color: #b8b8b8; }
.lib-sec-title { font-family: var(--ap-serif); font-size: 24px; font-weight: 700; line-height: 1.16; letter-spacing: 0; }
.lib-sec-count { font-size: 14px; color: var(--ap-muted); }
.lib-sec-actions { margin-left: auto; display: flex; gap: 6px; }
.lib-sec-actions button {
  border: none; background: none; cursor: pointer; color: var(--ap-muted);
  font: inherit; font-size: 13px; padding: 6px 8px; border-radius: 8px;
}
.lib-sec-actions button:hover { color: #111; background: #f5f5f7; }
.lib-sec-actions .lib-sec-del:hover { color: #d14a2a; }

/* Колонки раздела — числа владельца: 6 / 5 / 4 / 2. */
.lib-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  column-gap: var(--ap-gutter);
  row-gap: calc(var(--ap-gutter) + 12px);
  min-width: 0;
}
.lib-sentinel { height: 1px; }

/* ============================================================
   КАРТОЧКА СТИЛЯ
   ============================================================ */
.lib-card {
  position: relative;
  display: flex; flex-direction: column;
  cursor: pointer; text-align: left; min-width: 0;
  padding: 0; border: none; background: none; font: inherit; color: inherit;
}
.lib-card .lib-cover {
  position: relative;
  aspect-ratio: 1;
  border-radius: 2.5px;
  overflow: hidden;
  background: #f5f5f7;
  box-shadow: 0 0 0 .5px rgba(0,0,0,.1);
  transition: transform .3s var(--ease);
}
.lib-card:hover .lib-cover { transform: translateY(-2px); }
.lib-card .lib-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Название стиля — пузырёк поверх обложки, прижат в правый нижний угол
   (тот же вид, что .tile-name на главной: белый 96%, blur, pill). */
.lib-name {
  position: absolute;
  right: 10px;
  bottom: 10px;
  max-width: calc(100% - 20px);
  padding: 7px 12px;
  border-radius: 100px;
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
  color: #111;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  z-index: 2;
}
/* Полка стиля у карточек-анонсов — вторым пузырьком слева снизу. */
.lib-shelf-tag {
  position: absolute;
  left: 10px;
  bottom: 10px;
  padding: 6px 10px;
  border-radius: 100px;
  background: rgba(255, 255, 255, .9);
  font-size: 12px;
  line-height: 1.2;
  color: var(--ap-muted);
  z-index: 2;
}

/* Анонс — обложек ещё нет. */
.lib-card.is-soon { cursor: default; }
.lib-card.is-soon .lib-cover {
  background: linear-gradient(135deg, rgba(0,0,0,.03), rgba(0,0,0,.06));
  display: flex; align-items: center; justify-content: center;
}
.lib-card.is-soon:hover .lib-cover { transform: none; }
.lib-card.is-soon .lib-name { color: var(--ap-muted); }
.soon-badge {
  font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  color: var(--ap-muted); border: 1px dashed #c7c7cc; opacity: .6;
  border-radius: 100px; padding: 5px 12px;
}

/* Кнопка «в подборку» */
.lib-add-btn {
  position: absolute; top: 6px; right: 6px; z-index: 2;
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.92); color: #111;
  border: 1px solid var(--ap-rule); cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
  opacity: 0; transform: scale(.85);
  transition: opacity .2s ease, transform .2s ease, background .2s ease;
}
.lib-card:hover .lib-add-btn, .lib-add-btn.is-in { opacity: 1; transform: scale(1); }
.lib-add-btn:hover { background: #fff; color: var(--accent); }
.lib-add-btn.is-in { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Карточка заказа внутри подборки */
.coll-order-card {
  display: flex; flex-direction: column; gap: 6px; justify-content: center;
  padding: 16px; aspect-ratio: 1;
  border: 1px solid var(--ap-rule); border-radius: 2.5px; background: #fff;
}
.coll-order-title { font-size: 14px; font-weight: 600; color: #111; line-height: 1.3; }
.coll-order-meta { font-size: 12px; color: var(--ap-muted); line-height: 1.4; }
.coll-order-link { margin-top: 4px; font-size: 13px; font-weight: 600; color: var(--accent); text-decoration: none; }

.lib-empty { grid-column: 1 / -1; padding: 80px 24px; text-align: center; color: var(--ap-muted); }
.lib-empty h2 { font-family: var(--ap-serif); font-size: 22px; font-weight: 600; margin-bottom: 8px; color: #111; }

/* ============================================================
   ШИРИНЫ ЭКРАНОВ (брейкпоинты Apple: 735 и 1069)
   ============================================================ */

/* Планшет 735–1068: поля 32, гуттер 20.6, полка/раздел 5 */
@media (max-width: 1068px) {
  :root { --ap-edge: 32px; --ap-gutter: 20.6px; --ap-cols: 5; }
  .lib-grid { grid-template-columns: repeat(5, 1fr); }
  .lib-title { font-size: 32px; }
  .lib-sec-title { font-size: 22px; }
}

/* Планшет вертикально (768) — 4 колонки (число владельца) */
@media (max-width: 899px) {
  :root { --ap-cols: 4; }
  .lib-grid { grid-template-columns: repeat(4, 1fr); }
}

/* Сайдбар — только на компьютере (решение владельца). Планшет и уже:
   заголовок, поиск и разделы идут сверху, разделы — лентой пилюль. */
@media (max-width: 1068px) {
  .lib-layout { display: block; }
  .lib-side {
    position: static; max-height: none; overflow: visible;
    flex-direction: column; gap: 10px; padding: 12px 0 4px;
  }
  .lib-title { font-size: 24px; }
  .lib-tabs {
    flex-direction: row; gap: 8px; overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .lib-tabs::-webkit-scrollbar { display: none; }
  .lib-tab {
    width: auto; flex: 0 0 auto; padding: 6px 14px;
    border: 1px solid var(--ap-rule); border-radius: 100px; background: #fff;
    color: var(--ap-muted);
  }
  .lib-tab.active { background: #111; color: #fff; border-color: #111; }
  .lib-colls { flex-direction: row; overflow-x: auto; gap: 8px; }
  .coll-link {
    flex: 0 0 auto; padding: 6px 13px; border: 1px solid var(--ap-rule);
    border-radius: 100px; background: #fff; color: var(--ap-muted);
  }
  .coll-link.active { background: #111; color: #fff; border-color: #111; }
}

/* Смартфон < 735: поля 6.25vw, гуттер 2.97vw, раздел 2 колонки,
   полка — 2 карточки и выглядывающая третья, уходит под правый край. */
@media (max-width: 734px) {
  :root { --ap-edge: 6.25vw; --ap-gutter: 2.97vw; --ap-cols: 2.4; }
  .lib-grid { grid-template-columns: repeat(2, 1fr); row-gap: 24px; }
  .lib-title { font-size: 28px; }
  .lib-sec-title { font-size: 20px; }
  .lib-shelf-head { font-size: 18px; margin-bottom: 10px; }
  .lib-shelf { padding-bottom: 16px; }
  /* Полка выходит под правый край — как в Books на iPhone. Ряд занимает всю
     ширину экрана, поля переносим внутрь него: страница вбок не едет. */
  .lib { padding-left: 0; padding-right: 0; }
  .lib-shelf-head { margin-left: var(--ap-edge); }
  .lib-shelf-row { padding-left: var(--ap-edge); padding-right: var(--ap-edge); }
  .lib-name { right: 8px; bottom: 8px; padding: 6px 10px; font-size: 12px; max-width: calc(100% - 16px); }
  .lib-shelf-tag { left: 8px; bottom: 8px; }
}

/* Смартфон горизонтально (844×390): высоты мало — шапка компактнее,
   поля считают вырез экрана. Колонки раздела остаются планшетные. */
@media (max-height: 500px) and (orientation: landscape) and (max-width: 1068px) {
  .lib-head { padding-top: 10px; }
  .lib-title { font-size: 24px; }
  .lib-sub { display: none; }
  .lib-tabs { margin-top: 10px; }
  .lib-shelf { padding-top: 14px; padding-bottom: 20px; }
  .lib-shelf-head { font-size: 17px; margin-bottom: 12px; }
  .lib { padding-top: 14px; }
}


/* ============================================================
   ПУЗЫРЁК «РАЗДЕЛЫ» (планшет и смартфон, правый верхний угол)
   Как в Books: короткое меню слева, полный список разделов —
   выпадающим списком из пузырька справа.
   ============================================================ */
.lib-sections { display: none; position: relative; margin-left: auto; }

.lib-sections-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--ap-rule); border-radius: 100px;
  background: #fff; color: #111;
  font: inherit; font-size: 14px; font-weight: 500; line-height: 1.28;
  cursor: pointer; white-space: nowrap;
}
.lib-sections-btn svg { transition: transform .2s ease; }
.lib-sections.is-open .lib-sections-btn { background: #111; color: #fff; border-color: #111; }
.lib-sections.is-open .lib-sections-btn svg { transform: rotate(180deg); }

.lib-sections-menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 60;
  min-width: 220px; max-height: 60vh; overflow-y: auto;
  padding: 6px;
  background: #fff; border: 1px solid var(--ap-rule); border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0,0,0,.16);
  display: none; flex-direction: column; gap: 2px;
}
.lib-sections.is-open .lib-sections-menu { display: flex; }
.lib-sections-item {
  border: none; background: none; text-align: left;
  padding: 8px 10px; border-radius: 8px;
  font: inherit; font-size: 14px; color: #111; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lib-sections-item:hover { background: rgba(0,0,0,.05); }
.lib-sections-item.active { background: var(--accent); color: #fff; }

@media (max-width: 1068px) {
  .lib-sections { display: block; }
  /* Строка верхнего меню: короткие пункты слева, пузырёк разделов справа. */
  .lib-topbar { display: flex; align-items: center; gap: 8px; }
  .lib-topbar .lib-tabs { flex: 0 1 auto; }
}

/* Пункт меню не мигает: пульсация была у кнопки «Библиотека», её больше нет. */
.header-link.is-primary { animation: none; }

/* Шапка на планшете: тот же состав, что на компьютере — логотип, три пункта
   меню и вход, всё одной строкой. Размеры чуть меньше десктопных: с полными
   52 px логотипа кнопка входа не влезала в 768 и уезжала за край. */
@media (min-width: 735px) and (max-width: 1068px) and (min-height: 501px) {
  .header { padding: 18px 24px; }
  .header-inner { flex-wrap: nowrap; gap: 12px; }
  .logo { font-size: 34px; }
  .header-nav { display: inline-flex; gap: 8px; flex: 0 1 auto; min-width: 0; }
  .header-link { font-size: 14px; padding: 7px 12px; gap: 6px; white-space: nowrap; }
  .header-link svg { width: 16px; height: 16px; }
  .header-right { gap: 8px; flex: 0 0 auto; }
  .header-account { font-size: 14px; padding: 7px 12px; white-space: nowrap; }
  .header-account-name { display: inline; }
}

/* Основное меню (Главная · Журнал · Как устроено) стоит в шапке и на компьютере,
   и на планшете — в обеих ориентациях, одинаково. На смартфоне его в шапке нет:
   там всё управление в нижней панели. */
/* Без пунктов «На главную» и «Журнал» шапке не нужны две строки:
   логотип слева, вход справа — одной строкой. */
@media (max-width: 480px) {
  .header-inner { flex-wrap: nowrap; }
  .header-right { flex: 0 0 auto; justify-content: flex-end; }
}
