/* ============================================================
   SHORTS (sw1 · social-week · агент shorts-clips)
   Шортсы: FAB «Записать», студия записи (камера/галерея/превью),
   шэринг в чат, подписка на автора, музыкальная строка, retry.
   Светлая + тёмная темы; 390px первичен, 1280px — центрированная
   карточка (плеер-режим vd уже даёт 9:16-центр — здесь только
   аккуратно дополняем). Все анимации уважают prefers-reduced-motion.
   ============================================================ */

/* ---------- Демо/локальные слайды без карточек: показываем нативную ленту ----------
   eco-max-vd строит сетку карточек только из слайдов с видео; если карточек нет
   (демо-слайды sw1 за флагом vyShortsDemo), vd-has-grid всё равно прячет скроллер.
   Пустая сетка → возвращаем нативную вертикальную ленту. */
#view-clips.vd-has-grid:not(.vd-player-mode) .vd-clips-grid:empty {
  display: none;
}

#view-clips.vd-has-grid:not(.vd-player-mode) .vd-clips-grid:empty ~ #clips-scroller {
  display: block;
}

/* ---------- Пустое состояние: кнопки «Записать шортс» ---------- */

.clips-empty__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 10px;
}

.clips-empty__actions .btn-primary {
  border: 0;
  padding: 10px 18px;
  border-radius: 999px;
}

/* ---------- FAB «Записать» в разделе шортсов ---------- */

.vy-shorts-fab {
  position: absolute;
  right: 14px;
  bottom: calc(16px + var(--safe-bottom, 0px));
  z-index: 12;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  border: 0;
  border-radius: 999px;
  background: var(--accent, #1a56db);
  color: #fff;
  font: 600 14px/1 inherit;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.28);
  transition: transform var(--motion-base, 0.22s ease), box-shadow var(--motion-base, 0.22s ease);
}

.vy-shorts-fab:hover {
  transform: translateY(-1px);
}

.vy-shorts-fab:active {
  transform: scale(0.97);
}

.vy-shorts-fab svg {
  width: 18px;
  height: 18px;
}

.vy-shorts-fab:focus-visible {
  outline: 2px solid var(--accent, #1a56db);
  outline-offset: 2px;
}

/* сетка-режим vd: FAB над сеткой; плеер-режим: над нижним краем карточки */
#view-clips.vd-player-mode .vy-shorts-fab {
  bottom: calc(24px + var(--safe-bottom, 0px));
}

/* Мобильный: FAB по центру — не перекрывает правый рельс лайков */
@media (max-width: 860px) {
  .vy-shorts-fab {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    bottom: calc(14px + var(--safe-bottom, 0px));
  }
  .vy-shorts-fab:active {
    transform: translateX(-50%) scale(0.97);
  }
}

/* ---------- Оверлей студии ---------- */

.vy-shorts-studio {
  position: fixed;
  inset: 0;
  z-index: 120; /* выше шитов комментариев (80/90) и тостов */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(9, 14, 26, 0.62);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  box-sizing: border-box;
}

.vy-shorts-studio.hidden {
  display: none;
}

.vy-shorts-card {
  width: min(440px, 100%);
  max-height: min(92dvh, 760px);
  display: flex;
  flex-direction: column;
  background: var(--surface, #fff);
  color: var(--text, #0f172a);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 18px;
  box-shadow: 0 24px 64px rgba(4, 9, 20, 0.4);
  overflow: hidden;
  animation: vy-shorts-in var(--motion-base, 0.22s ease);
}

@keyframes vy-shorts-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.vy-shorts-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border, #e2e8f0);
}

.vy-shorts-card__head strong {
  font-size: 16px;
}

/* — Выбор источника — */

.vy-shorts-pick {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
}

.vy-shorts-pick__btn {
  display: grid;
  grid-template-columns: 44px 1fr;
  grid-template-rows: auto auto;
  column-gap: 14px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 14px;
  background: var(--surface-2, #eef1f6);
  color: var(--text, #0f172a);
  text-align: left;
  cursor: pointer;
  transition: border-color var(--motion-fast, 0.14s ease), background var(--motion-fast, 0.14s ease);
}

.vy-shorts-pick__btn:hover {
  border-color: var(--accent, #1a56db);
  background: var(--accent-soft, rgba(26, 86, 219, 0.1));
}

.vy-shorts-pick__ico {
  grid-row: 1 / span 2;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--accent-soft-strong, rgba(26, 86, 219, 0.16));
  color: var(--accent, #1a56db);
}

.vy-shorts-pick__ico svg {
  width: 22px;
  height: 22px;
}

.vy-shorts-pick__t {
  font-weight: 600;
  font-size: 15px;
}

.vy-shorts-pick__d {
  font-size: 12.5px;
  color: var(--text-muted, #64748b);
}

.vy-shorts-pick__note {
  margin: 4px 2px 0;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text-muted, #64748b);
}

/* — Камера — */

.vy-shorts-cam {
  position: relative;
  width: min(430px, 100%);
  max-width: 100%;
  aspect-ratio: 9 / 16;
  max-height: 92dvh;
  margin: 0 auto;
  border-radius: 18px;
  overflow: hidden;
  background: #05070d;
  box-shadow: 0 24px 64px rgba(4, 9, 20, 0.4);
  display: flex;
  flex-direction: column;
  animation: vy-shorts-in var(--motion-base, 0.22s ease);
}

.vy-shorts-cam__video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #05070d;
}

.vy-shorts-cam__shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(4, 9, 20, 0.55), transparent 22%, transparent 62%, rgba(4, 9, 20, 0.7));
  pointer-events: none;
}

.vy-shorts-cam__bar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  color: #fff;
}

.vy-shorts-cam__title {
  font-weight: 600;
  font-size: 15px;
}

.vy-shorts-ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  border: 1px solid rgba(237, 243, 255, 0.28);
  border-radius: 999px;
  background: rgba(6, 11, 22, 0.55);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  color: #fff;
  font: 600 13px/1 inherit;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--motion-fast, 0.14s ease);
}

.vy-shorts-ghost:hover {
  background: rgba(107, 150, 255, 0.24);
}

.vy-shorts-cam__hint {
  position: relative;
  z-index: 2;
  margin-top: auto;
  align-self: center;
  max-width: 82%;
  text-align: center;
  color: rgba(255, 255, 255, 0.92);
  font-size: 13px;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.55);
}

.vy-shorts-cam__foot {
  position: relative;
  z-index: 2;
  display: grid;
  place-items: center;
  padding: 18px 0 calc(22px + var(--safe-bottom, 0px));
}

.vy-shorts-rec {
  position: relative;
  width: 78px;
  height: 78px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  display: grid;
  place-items: center;
}

.vy-shorts-rec__ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 5px solid rgba(255, 255, 255, 0.9);
  transition: transform var(--motion-base, 0.22s ease), opacity var(--motion-base, 0.22s ease);
}

.vy-shorts-rec__dot {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: #ef2b4a;
  transition: width var(--motion-base, 0.22s ease), height var(--motion-base, 0.22s ease), border-radius var(--motion-base, 0.22s ease), background var(--motion-base, 0.22s ease);
}

.vy-shorts-rec.is-rec .vy-shorts-rec__dot {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: #ef2b4a;
}

.vy-shorts-rec.is-rec .vy-shorts-rec__ring {
  transform: scale(1.06);
  border-color: rgba(239, 43, 74, 0.85);
}

.vy-shorts-rec:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 4px;
}

.vy-shorts-cam__err {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: calc(120px + var(--safe-bottom, 0px));
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(12, 18, 32, 0.88);
  color: #fff;
  font-size: 13.5px;
  text-align: center;
}

.vy-shorts-cam__err.hidden {
  display: none;
}

/* — Превью — */

.vy-shorts-card--preview {
  width: min(480px, 100%);
}

.vy-shorts-prev {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
  overflow: auto;
}

.vy-shorts-prev__video {
  width: 100%;
  max-height: 46dvh;
  aspect-ratio: 9 / 16;
  object-fit: contain;
  border-radius: 14px;
  background: #05070d;
}

.vy-shorts-prev__label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted, #64748b);
  margin-bottom: 6px;
}

.vy-shorts-prev__caption {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 12px;
  background: var(--surface-2, #eef1f6);
  color: var(--text, #0f172a);
  font: 400 14px/1.45 inherit;
  font-family: inherit;
  resize: vertical;
  min-height: 66px;
}

.vy-shorts-prev__caption:focus {
  outline: 2px solid var(--accent, #1a56db);
  outline-offset: 1px;
}

.vy-shorts-prev__meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12.5px;
  color: var(--text-muted, #64748b);
}

.vy-shorts-prev__warn {
  color: #b45309;
}

html[data-theme="dark"] .vy-shorts-prev__warn {
  color: #fbbf24;
}

.vy-shorts-prev__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.vy-shorts-prev__actions .btn-primary {
  border: 0;
  padding: 10px 18px;
  border-radius: 999px;
}

.vy-shorts-prev__actions .vy-shorts-ghost {
  background: var(--surface-2, #eef1f6);
  border-color: var(--border, #e2e8f0);
  color: var(--text, #0f172a);
}

.vy-shorts-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-muted, #64748b);
}

.vy-shorts-progress.hidden {
  display: none;
}

.vy-shorts-progress__bar {
  position: relative;
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: var(--surface-2, #eef1f6);
  overflow: hidden;
}

.vy-shorts-progress__bar::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--p, 0%);
  border-radius: inherit;
  background: var(--accent, #1a56db);
  transition: width 0.2s ease;
}

/* ---------- Шеринг шортса в чат ---------- */

.vy-share-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 95;
  display: flex;
  flex-direction: column;
  max-height: 72dvh;
  background: var(--surface, #fff);
  color: var(--text, #0f172a);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -12px 40px rgba(4, 9, 20, 0.3);
  transform: translateY(0);
  transition: transform var(--motion-base, 0.22s ease);
}

.vy-share-sheet.hidden {
  display: none;
}

@media (min-width: 861px) {
  .vy-share-sheet {
    left: 50%;
    right: auto;
    bottom: 24px;
    width: min(400px, calc(100vw - 32px));
    max-height: 70dvh;
    border-radius: 18px;
    transform: translateX(-50%);
  }
}

.vy-share-sheet__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border, #e2e8f0);
}

.vy-share-sheet__head strong {
  font-size: 15px;
}

.vy-share-sheet__search {
  padding: 10px 16px 4px;
}

.vy-share-sheet__search input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 10px;
  background: var(--surface-2, #eef1f6);
  color: var(--text, #0f172a);
  font: 400 14px inherit;
  font-family: inherit;
}

.vy-share-list {
  flex: 1;
  overflow: auto;
  padding: 6px 8px 10px;
  min-height: 90px;
}

.vy-share-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}

.vy-share-row:hover {
  background: var(--surface-2, #eef1f6);
}

.vy-share-row__avatar {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
  overflow: hidden;
}

.vy-share-row__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.vy-share-row__name {
  font-weight: 600;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vy-share-row__hint {
  font-size: 12px;
  color: var(--text-muted, #64748b);
}

.vy-share-row--util {
  color: var(--accent, #1a56db);
}

.vy-share-empty {
  padding: 22px 16px;
  text-align: center;
  font-size: 13.5px;
  color: var(--text-muted, #64748b);
}

.vy-share-scrim {
  position: fixed;
  inset: 0;
  z-index: 94;
  background: rgba(15, 23, 42, 0.42);
}

.vy-share-scrim.hidden {
  display: none;
}

/* ---------- Дополнения к слайдам клипа ---------- */

/* Подписка на автора: маленькая пилюля у имени */
.clip-slide__byline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  min-width: 0;
}

.clip-slide__follow {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: #fff;
  font: 600 12.5px/1 inherit;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--motion-fast, 0.14s ease), border-color var(--motion-fast, 0.14s ease);
  flex-shrink: 0;
}

.clip-slide__follow:hover {
  background: rgba(255, 255, 255, 0.28);
}

.clip-slide__follow.is-on {
  background: var(--accent, #1a56db);
  border-color: transparent;
}

.clip-slide__follow[hidden] {
  display: none;
}

.clip-slide__follow.is-busy {
  opacity: 0.6;
  pointer-events: none;
}

/* Автор — кнопка (переход в чат с автором) */
.clip-slide__author {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-family: inherit;
  padding: 0;
  cursor: pointer;
  text-align: left;
  max-width: 100%;
}

.clip-slide__author strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 180px;
}

.clip-slide__author:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
  border-radius: 6px;
}

/* Музыкальная строка */
.clip-slide__music {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  margin-top: 4px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.32);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  color: rgba(255, 255, 255, 0.94);
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
}

.clip-slide__music svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

.clip-slide__music span {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Ошибка видео: кнопка «Повторить» */
.clip-slide__err {
  flex-direction: column;
  gap: 8px;
  text-align: center;
}

.clip-slide__err button {
  padding: 8px 16px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font: 600 13px/1 inherit;
  font-family: inherit;
  cursor: pointer;
}

.clip-slide__err button:hover {
  background: rgba(255, 255, 255, 0.26);
}

/* Демо-слайды (синтетика без видео) */
.clip-slide__demo-bg {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.clip-slide__demo-bg::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 90% at 20% 10%, hsl(var(--demo-hue, 212) 85% 58% / 0.95), hsl(calc(var(--demo-hue, 212) + 40) 80% 30%) 70%, #0a0f1e);
}

.clip-slide__demo-bg span {
  position: relative;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  color: rgba(255, 255, 255, 0.95);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.clip-slide--local .clip-slide__views,
.clip-slide--demo .clip-slide__views {
  display: none;
}

/* Локальные/демо: скрываем кнопки, требующие серверный id */
.clip-slide--local [data-clip-comment],
.clip-slide--local [data-clip-share],
.clip-slide--demo [data-clip-comment],
.clip-slide--demo [data-clip-share] {
  display: none;
}

/* ---------- Анимации: reduced-motion ---------- */

@media (prefers-reduced-motion: reduce) {
  .vy-shorts-card,
  .vy-shorts-cam,
  .vy-share-sheet {
    animation: none;
    transition: none;
  }
  .vy-shorts-fab:hover {
    transform: none;
  }
  @media (max-width: 860px) {
    .vy-shorts-fab:hover {
      transform: translateX(-50%);
    }
  }
  .vy-shorts-progress__bar::before {
    transition: none;
  }
}
