/* ==========================================================================
   Riool Cinema — публичный каталог (media.html)
   Использует токены темы из tools.css (:root).
   ========================================================================== */

.lib { padding: calc(var(--header-h) + 40px) 0 80px; }

/* --- Шапка каталога --- */
.lib__head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px 32px;
  margin-bottom: 22px;
}

.lib__title { font-size: clamp(28px, 4vw, 42px); }

.lib__stats {
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 15px;
}

.lib__search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 320px;
  max-width: 460px;
  padding: 0 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.lib__search:focus-within {
  border-color: var(--border-strong);
  background: var(--surface-strong);
}
.lib__search-icon { width: 20px; height: 20px; color: var(--text-dim); flex: none; }
.lib__search input {
  flex: 1;
  min-width: 0;
  padding: 13px 0;
  background: none;
  border: 0;
  outline: none;
  font-size: 16px;
}
.lib__search input::placeholder { color: var(--text-dim); }
.lib__search-clear {
  display: grid;
  place-items: center;
  width: 26px; height: 26px;
  padding: 0;
  background: none;
  border: 0;
  border-radius: 50%;
  color: var(--text-dim);
  flex: none;
}
.lib__search-clear[hidden] { display: none; }
.lib__search-clear svg { width: 16px; height: 16px; }
.lib__search-clear:hover { color: var(--text); background: var(--surface-strong); }

/* --- Подсказки поиска (выпадающий список) --- */
.lib__suggest {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 60;
  max-height: 60vh;
  overflow-y: auto;
  padding: 6px;
  background: var(--surface-strong);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
.lib__suggest[hidden] { display: none; }
.lib__suggest-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  text-align: left;
  background: none;
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--text);
  transition: background var(--dur) var(--ease);
}
.lib__suggest-item:hover,
.lib__suggest-item:focus-visible { background: var(--accent-soft); }
.lib__suggest-play {
  display: grid;
  place-items: center;
  width: 26px; height: 26px;
  flex: none;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
}
.lib__suggest-play svg { width: 14px; height: 14px; }
.lib__suggest-name {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lib__suggest-empty { padding: 12px; color: var(--text-dim); font-size: 14px; text-align: center; }
.lib__suggest-all {
  width: 100%;
  margin-top: 4px;
  padding: 10px;
  background: none;
  border: 0;
  border-top: 1px solid var(--border);
  color: var(--accent-light);
  font-size: 13.5px;
  font-weight: 600;
  text-align: center;
}
.lib__suggest-all:hover { color: var(--text); }

/* --- Дисклеймер для новых посетителей --- */
.lib__note {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 20px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
}
.lib__note[hidden] { display: none; }
.lib__note-icon { width: 22px; height: 22px; flex: none; margin-top: 1px; color: var(--accent-light); }
.lib__note-body { flex: 1; min-width: 0; }
.lib__note-title { margin: 0 0 8px; color: var(--text); font-weight: 600; font-size: 15px; }
.lib__note-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 5px;
  font-size: 14px;
  line-height: 1.45;
}
.lib__note-list b { color: var(--text); font-weight: 600; }
.lib__note-close {
  display: grid;
  place-items: center;
  width: 26px; height: 26px;
  flex: none;
  padding: 0;
  background: none;
  border: 0;
  border-radius: 50%;
  color: var(--text-dim);
}
.lib__note-close:hover { color: var(--text); background: var(--surface-strong); }
.lib__note-close svg { width: 16px; height: 16px; }


/* --- Хлебные крошки --- */
.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  margin-bottom: 20px;
  padding: 6px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.breadcrumb__item {
  padding: 7px 12px;
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  font-size: 15px;
  border: 0;
  background: none;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.breadcrumb__item:hover { background: var(--surface-strong); color: var(--text); }
.breadcrumb__item.is-current { color: var(--text); font-weight: 600; cursor: default; }
.breadcrumb__sep {
  width: 16px;
  height: 16px;
  flex: none;
  color: var(--text-dim);
  user-select: none;
}

/* --- Тело каталога --- */
.lib__status {
  padding: 40px 0;
  color: var(--text-muted);
  text-align: center;
}
.lib__status[hidden] { display: none; }

.lib__grid { display: block; }

.lib__section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 26px 0 14px;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.lib__section-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* --- Папки --- */
.lib-folders {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.lib-folder {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  transition: transform var(--dur) var(--ease), border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.lib-folder:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  background: var(--surface-strong);
}
.lib-folder__icon {
  display: grid;
  place-items: center;
  width: 42px; height: 42px;
  flex: none;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent-light);
}
.lib-folder__icon svg { width: 22px; height: 22px; }
.lib-folder__meta { min-width: 0; }
.lib-folder__name {
  font-weight: 600;
  font-size: 15px;
  line-height: 1.3;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.lib-folder__count { margin-top: 3px; color: var(--text-dim); font-size: 13px; }

/* --- Файлы --- */
.lib-files {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 8px;
}
.lib-file {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  text-align: left;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text);
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.lib-file:hover { background: var(--surface-strong); border-color: var(--border); }
.lib-file__play {
  display: grid;
  place-items: center;
  width: 30px; height: 30px;
  flex: none;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
}
.lib-file__play svg { width: 15px; height: 15px; }
.lib-file__name {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 14.5px;
  line-height: 1.35;
}
.lib-file__path {
  color: var(--text-dim);
  font-size: 11.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lib-file__ext {
  flex: none;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--surface-strong);
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.lib-empty { padding: 40px 0; color: var(--text-muted); text-align: center; }

/* --- Плеер --- */
.player {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.player[hidden] { display: none; }
.player__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 15, 12, 0.86);
  backdrop-filter: blur(6px);
}
.player__dialog {
  position: relative;
  width: min(1100px, 100%);
  background: #05130f;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.player__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.player__info { min-width: 0; }
.player__title { display: block; font-weight: 600; font-size: 15px; }
.player__path {
  display: block;
  margin-top: 2px;
  color: var(--text-dim);
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.player__close {
  display: grid;
  place-items: center;
  width: 38px; height: 38px;
  flex: none;
  border: 0;
  border-radius: 50%;
  background: var(--surface-strong);
  color: var(--text);
  transition: background var(--dur) var(--ease);
}
.player__close:hover { background: var(--accent-soft); color: var(--accent-light); }
.player__close svg { width: 20px; height: 20px; }

.player__stage {
  position: relative;
  background: #000;
  aspect-ratio: 16 / 9;
}
.player__stage video { width: 100%; height: 100%; background: #000; }
.player__overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  background: rgba(3, 15, 12, 0.7);
  pointer-events: none;
}
.player__overlay[hidden] { display: none; }
.player__spinner {
  width: 38px; height: 38px;
  border: 3px solid var(--accent-soft);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: player-spin 0.9s linear infinite;
}
@keyframes player-spin { to { transform: rotate(360deg); } }
.player__overlay-text { color: var(--text-muted); font-size: 14px; }
.player.is-error .player__spinner { display: none; }

@media (max-width: 640px) {
  .lib { padding-top: calc(var(--header-h) + 24px); }
  .lib-folders { grid-template-columns: 1fr 1fr; gap: 10px; }
  .lib-folder { flex-direction: column; align-items: flex-start; gap: 10px; padding: 14px; }
  .lib-files { grid-template-columns: 1fr; }
  .player { padding: 0; }
  .player__dialog { width: 100%; height: 100%; border-radius: 0; border: 0; display: flex; flex-direction: column; }
  .player__stage { aspect-ratio: auto; flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .player__spinner { animation: none; }
}
