/* Раздел «Загрузки». Владелец — блок E.
   Эталон — docs/redesign/canvas/body_Downloads.html; всё, что там написано
   инлайновым style=, лежит здесь классами. Префикс dlq- (downloads queue):
   короткие имена вида «dl-» + кнопка/карточка/форма/пагинация принадлежат
   старой системе и запрещены приёмкой, поэтому свои сделаны длиннее. */

/* ---- Раскладка раздела ----
   Форма, баннер и чипы прибиты сверху, карточки прокручиваются, пагинация
   остаётся на нижней кромке панели — как в артборде. #downloads-rows меняет
   себя целиком, поэтому колонкой обязана быть вся цепочка до него. */
#dl-summary { flex: none; }
#downloads-pane-slot { display: flex; flex-direction: column; overflow: hidden; }
#downloads-pane-content {
  display: flex; flex-direction: column;
  flex: 1; min-height: 0;
}
#downloads-rows { display: flex; flex-direction: column; flex: 1; min-height: 0; }

/* ---- Форма вставки ссылок (вне поллинга) ---- */
.dlq-form {
  flex: none;
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px;
  background: var(--surf2);
  border-bottom: 1px solid var(--line);
}
.dlq-url {
  min-height: 64px; resize: vertical;
  border-radius: 10px; border-color: var(--line2);
  font-family: inherit;
}
.dlq-url::placeholder { color: var(--ink4); }

.dlq-preview {
  display: flex; align-items: center; gap: 8px;
  flex: none; padding: 7px;
  background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px;
}
.dlq-preview-pic { position: relative; flex: none; width: 80px; height: 46px; }
.dlq-preview-pic > img { width: 80px; height: 46px; border-radius: 7px; }
.dlq-preview-empty {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 7px; background: var(--surf3); color: var(--ink4);
}
.dlq-preview.is-loading .dlq-preview-empty {
  background: linear-gradient(90deg, var(--surf2), var(--surf3), var(--surf2));
  background-size: 200% 100%;
  animation: yts-skel 1.4s ease-in-out infinite;
}
.dlq-preview-count {
  position: absolute; right: -6px; top: -7px;
  background: var(--dark-surface); color: var(--on-dark);
}
.dlq-preview-text { width: 120px; line-height: 1.4; }
.dlq-preview-text > b { display: block; font-weight: 500; color: var(--ink2); }

.dlq-controls { display: flex; flex-direction: column; gap: 6px; flex: none; }
.dlq-quality { width: 150px; font-family: inherit; cursor: pointer; }
.dlq-mode { background: var(--surf3); }

.dlq-go { height: 64px; padding: 0 18px; flex: none; }

/* Прямая запись на диск не создаёт строки на сервере — её прогресс живёт
   рядом с полем вставки. */
#stream-status {
  flex: none;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  font-size: 12px; color: var(--ink2);
  background: var(--infoSoft);
  border-bottom: 1px solid var(--line);
}

/* ---- Баннер про браузер без докачки ---- */
.dlq-banner {
  flex: none;
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  background: var(--warnSoft);
  border-bottom: 1px solid var(--line);
}
.dlq-banner > .ic { color: var(--warn); flex: none; }
.dlq-banner-text { font-size: 12px; line-height: 1.4; color: var(--ink2); }
.dlq-banner-text > b { color: var(--warn); }
.dlq-banner-more { margin-top: 4px; color: var(--ink3); }

/* ---- Чипы-фильтры ---- */
.dlq-chips { flex: none; flex-wrap: wrap; }
.dlq-chip {
  display: inline-flex; align-items: center; gap: 5px;
  height: 24px; padding: 0 9px;
  border: 1px solid var(--line); border-radius: 6px;
  background: var(--surface); color: var(--ink2);
  font: 600 12px/1 var(--font-ui);
  cursor: pointer; white-space: nowrap;
}
.dlq-chip:hover { background: var(--surf2); }
.dlq-chip[data-filter="error"] { color: var(--err); }
.dlq-chip[data-filter="expired"] { color: var(--ink4); }
.dlq-chip.is-on,
.dlq-chip.is-on[data-filter] { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.dlq-chip-n { font-variant-numeric: tabular-nums; opacity: .75; }
.dlq-chip.is-on .dlq-chip-n { opacity: .85; }

/* ---- Сетка карточек ---- */
.dlq-grid {
  display: grid; gap: 12px; padding: 12px;
  grid-template-columns: repeat(1, minmax(0, 1fr));
  align-content: start;
  flex: 1; min-height: 0; overflow: auto;
}
/* Сколько колонок помещается, считает браузер и просит у сервера ровно
   столько строк (см. fitColumns в js/sections/downloads.js). Ширина не может
   приехать инлайном — style= в шаблонах запрещён, поэтому раскладку выбирает
   атрибут. */
#downloads-rows[data-cols="2"] .dlq-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
#downloads-rows[data-cols="3"] .dlq-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
#downloads-rows[data-cols="4"] .dlq-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
#downloads-rows[data-cols="5"] .dlq-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
#downloads-rows[data-cols="6"] .dlq-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }

/* ---- Карточка ----
   Имя класса задано контрактом: tests/test_web.py (строки 617 и 632) считает
   карточки по `class="dl-row"` — точным совпадением атрибута, поэтому второго
   класса на корне быть не может, и вид карточки повторяет .card здесь. */
.dl-row {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  display: flex; flex-direction: column;
}
.dl-row[data-status="error"] { border-color: var(--err); }
.dl-row[data-status="expired"] { opacity: .62; }
.dl-row.is-saving { border-color: var(--accent); }

/* Кадр скругляется сам: overflow:hidden на самой карточке обнулял бы её
   автоминимум как элемента сетки, и строка перестала бы расти под карточку,
   которой прибавили строку прогресса записи на диск. */
.dlq-shot {
  position: relative; display: block; flex: none;
  overflow: hidden; border-radius: 11px 11px 0 0;
}
.dlq-shot > img { width: 100%; height: 150px; object-fit: cover; display: block; }
.dl-row[data-status="expired"] .dlq-shot > img { filter: grayscale(1); }
.dlq-shot-ph {
  width: 100%; height: 150px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surf3); color: var(--ink4);
}
button.dlq-shot { width: 100%; padding: 0; border: 0; background: none; cursor: pointer; }
.dlq-play {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--on-dark); opacity: 0;
  background: rgba(10, 12, 16, .34);
  transition: opacity .12s ease;
}
button.dlq-shot:hover .dlq-play, button.dlq-shot:focus-visible .dlq-play { opacity: 1; }
.dlq-badge { position: absolute; left: 6px; top: 6px; }
.dlq-badge-run { background: var(--accent); color: var(--on-dark); }
.dlq-badge-disk { background: var(--accent); color: var(--on-dark); }
.dlq-badge-wait { background: var(--surface); color: var(--ink2); }
.dlq-dur {
  position: absolute; right: 6px; bottom: 6px;
  background: rgba(10, 12, 16, .82); color: var(--on-dark);
  font-size: 10.5px; font-weight: 600;
  padding: 2px 5px; border-radius: 4px;
}

.dlq-body { padding: 9px 10px 10px; display: flex; flex-direction: column; flex: 1; }
.dlq-title { height: 34px; }
.dlq-meta { margin: 4px 0 8px; }
.dlq-nums { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.dlq-pct { color: var(--accent); }
/* Строка статуса держит высоту сама: без этого поллинг раз в 2 с двигал бы
   кнопки под курсором. */
.dlq-line {
  height: 22px; display: flex; align-items: center; gap: 6px;
  margin-bottom: 9px; overflow: hidden;
}
.dlq-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ink4); flex: none;
}
.dlq-line .ic14 { flex: none; }
.dlq-line-ok .ic14 { color: var(--ok); }

.dlq-prog {
  -webkit-appearance: none; appearance: none;
  display: block; width: 100%; height: 4px;
  border: 0; border-radius: 99px;
  background: var(--surf3); color: var(--accent);
  margin-bottom: 9px;
}
.dlq-prog::-webkit-progress-bar { background: var(--surf3); border-radius: 99px; }
.dlq-prog::-webkit-progress-value { background: var(--accent); border-radius: 99px; }
.dlq-prog::-moz-progress-bar { background: var(--accent); border-radius: 99px; }
.dlq-prog-warn::-webkit-progress-value { background: var(--warn); }
.dlq-prog-warn::-moz-progress-bar { background: var(--warn); }
/* Без value полоса неопределённая — «жду ответа сервера». */
.dlq-prog:not([value]) {
  background: linear-gradient(90deg, var(--surf3), var(--accent), var(--surf3));
  background-size: 200% 100%;
  animation: yts-skel 1.4s ease-in-out infinite;
}

.dlq-err {
  background: var(--errSoft); border-radius: 7px;
  padding: 6px 8px; margin-bottom: 9px;
}
.dlq-err-title { font-size: 11.5px; line-height: 1.35; color: var(--err); font-weight: 600; }
.dlq-err-sub { margin-top: 2px; }
.dlq-err-full {
  margin-top: 6px; padding-top: 6px;
  border-top: 1px solid rgba(193, 31, 51, .22);
  font-family: var(--font-mono); font-size: 10.5px; line-height: 1.45;
  color: var(--ink2); white-space: pre-wrap; word-break: break-word;
  max-height: 140px; overflow: auto;
}

.dlq-acts { display: flex; gap: 5px; margin-top: auto; }
.dlq-acts .btn { min-width: 0; }
.js-save-label { overflow: hidden; text-overflow: ellipsis; }
.dlq-acts > form { display: contents; }

/* ---- Собственный прогресс записи на диск ---- */
.dlq-save { margin-bottom: 9px; }
.dlq-save-pct { display: block; margin-top: 3px; }
.js-save.is-done { color: var(--ok); }
.js-save.is-failed { color: var(--err); }

/* ---- Пусто и пагинация ---- */
.dlq-empty { padding: 28px 16px; flex: 1; min-height: 0; overflow: auto; }
.dlq-pager {
  flex: none;
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px;
  border-top: 1px solid var(--line);
}
.dlq-pager-back .ic14 { transform: rotate(180deg); }
.dlq-page {
  background: none; border: 0; cursor: pointer;
  font: 500 11px/1 var(--font-mono); color: var(--ink4);
  padding: 4px 6px; border-radius: 6px;
}
.dlq-page:hover { background: var(--surf2); }
.dlq-page.is-current { font-size: 13px; font-weight: 600; color: var(--ink); }
