/* ============================================================
   Медиатека
   ============================================================ */

/* два экрана раздела — список и страница человека — живут в одной вкладке,
   поэтому колоночную раскладку .view повторяем внутри каждого */
#media-list, #media-person { display: flex; flex-direction: column; gap: 14px; }

/* лента разделов: четыре пилюли в строку на узком экране не помещаются */
.pills-scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.pills-scroll::-webkit-scrollbar { display: none; }
.pills-scroll .pill { flex: 0 0 auto; }

.media-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.media-bar .pills { min-width: 0; }
#media-sort-btn { flex-shrink: 0; white-space: nowrap; }

/* сетка постеров: три в ряд — обложка узнаётся, но на экран влезает десяток */
.media-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 11px 10px; }
.media-card {
  border: none; background: none; padding: 0;
  display: flex; flex-direction: column; gap: 6px;
  text-align: left;
  transition: transform 0.12s ease;
}
.media-card:active { transform: scale(0.96); }
.media-poster {
  position: relative; display: block;
  aspect-ratio: 2 / 3;
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--pink-tint);
  box-shadow: var(--shadow-sm);
}
.media-poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-poster-empty {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; opacity: 0.7;
}
/* оценка кружком в углу постера — её видно, не открывая карточку */
.media-rate {
  position: absolute; right: 5px; bottom: 5px;
  min-width: 22px; height: 22px; padding: 0 5px;
  border-radius: 999px;
  background: var(--pink-grad); color: #fff;
  font-size: 12px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 6px rgba(var(--shadow-rgb), 0.35);
}
.media-prog {
  position: absolute; left: 5px; top: 5px;
  padding: 2px 6px; border-radius: 999px;
  background: rgba(0, 0, 0, 0.55); color: #fff;
  font-size: 10.5px; font-weight: 700;
}
/* высота под две строки фиксирована: иначе у соседей по ряду разъезжаются
   подписи под постером */
.media-name {
  font-size: 12.5px; font-weight: 700; line-height: 1.25; color: var(--text);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.5em;
}
.media-card { align-self: start; }
.media-sub {
  font-size: 11px; font-weight: 600; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.row-chevron { color: var(--muted-2); font-size: 20px; line-height: 1; flex-shrink: 0; }

/* ---------- страница режиссёра или автора ---------- */

.person-hero {
  display: flex; align-items: center; gap: 14px;
  background: var(--panel);
  border-radius: var(--r-md);
  box-shadow: var(--shadow);
  padding: 16px;
}
.person-face {
  width: 56px; height: 56px; min-width: 56px;
  border-radius: 50%;
  background: var(--pink-grad); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 800;
}
.person-stats { min-width: 0; }
/* длинное ФИО в шапке обрезаем: целиком оно всё равно видно в карточке ниже */
#person-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-name { font-size: 17px; font-weight: 800; letter-spacing: -0.01em; word-break: break-word; }
.person-sub { font-size: 13px; color: var(--muted); font-weight: 600; margin-top: 3px; }

/* ---------- шторка записи ---------- */

.media-form-top { display: flex; gap: 12px; }
.media-form-fields { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.media-form-fields .pill {
  flex: 0 0 auto; text-align: left;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.poster-pick {
  width: 96px; height: 144px; min-width: 96px;
  position: relative; overflow: hidden;
  border: 1.5px dashed var(--pink-soft);
  border-radius: var(--r-sm);
  background: var(--pink-tint);
  color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.poster-pick img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.poster-plus { font-size: 24px; font-weight: 400; line-height: 1; }
.poster-hint { font-size: 11px; font-weight: 700; }
.poster-clear {
  position: absolute; right: 5px; top: 5px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; line-height: 1;
}

/* оценка: десять клавиш в одну строку, повторный тап снимает */
.rate-picker { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; }
.rate-dot {
  border: none;
  background: var(--panel-soft);
  color: var(--text-2);
  border-radius: 9px;
  padding: 9px 0;
  font-size: 12.5px; font-weight: 700;
  box-shadow: var(--shadow-sm);
}
.rate-dot.active { background: var(--pink-grad); color: #fff; }

#media-done-fields, #media-series-fields { display: flex; flex-direction: column; gap: 10px; }
.season-row { display: flex; gap: 8px; }

/* Cover search sheet */
.cover-search { display: flex; gap: 8px; }
.cover-search .field { flex: 1; min-width: 0; margin: 0; }
.cover-search .btn { flex-shrink: 0; padding: 0 18px; }
.cover-status { margin: 10px 2px 0; white-space: normal; }
.cover-status:empty { display: none; }
.cover-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
  margin: 12px 0 14px;
  max-height: calc(var(--app-h, 100vh) * 0.5); overflow-y: auto;
}
.cover-tile {
  display: flex; flex-direction: column; gap: 3px;
  border: none; background: none; padding: 0; text-align: left;
  font-family: inherit; color: var(--text); min-width: 0;
}
.cover-tile img {
  width: 100%; aspect-ratio: 2 / 3; object-fit: cover;
  border-radius: 12px; background: var(--panel-soft);
}
.cover-name { font-size: 12.5px; font-weight: 700; line-height: 1.2;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cover-sub { font-size: 11px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cover-grid.busy .cover-tile:not(.loading) { opacity: 0.45; }
.cover-tile.loading img { animation: cover-pulse 0.9s ease-in-out infinite alternate; }
@keyframes cover-pulse { to { opacity: 0.4; } }
