/* =====================================================================
   Собственный виджет Telegram-канала
   Заменяет iframe tgwidget.com. Классы с префиксом .te-tg,
   ни один существующий стиль темы не переопределяется.
   ===================================================================== */

.te-tg {
  --te-tg-blue: #0090e1;
  --te-tg-blue-dark: #007ec6;
  --te-tg-accent-soft: rgba(0, 144, 225, 0.05);
  --te-tg-accent-soft-hover: rgba(0, 144, 225, 0.11);
  --te-tg-accent-track: rgba(0, 144, 225, 0.35);
  --te-tg-bg: #ffffff;
  --te-tg-border: rgba(15, 40, 60, 0.08);
  --te-tg-text: #1f2d3a;
  --te-tg-muted: #7c8a97;
  --te-tg-height: var(--te-tg-height-desktop, 450px);

  display: flex;
  flex-direction: column;
  background: var(--te-tg-bg);
  border: 1px solid var(--te-tg-border);
  border-radius: 12px;
  overflow: hidden;
  font-size: 15px;
  line-height: 1.45;
  color: var(--te-tg-text);
  box-shadow: 0 4px 18px rgba(31, 45, 58, 0.06);
}

.te-tg__caption {
  margin: 0;
  padding: 14px 16px 0;
  font-weight: 500;
  text-align: center;
}

/* ---------- шапка канала ---------- */

.te-tg__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--te-tg-border);
  text-decoration: none;
  color: inherit;
  transition: background-color 0.2s ease;
}

.te-tg__head:hover {
  background: var(--te-tg-accent-soft);
  text-decoration: none;
  color: inherit;
}

.te-tg__avatar {
  flex: 0 0 50px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--te-tg-blue);
  display: flex;
  align-items: center;
  justify-content: center;
}

.te-tg__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.te-tg__avatar svg {
  width: 26px;
  height: 26px;
  color: #fff;
}

.te-tg__ident {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.te-tg__title {
  font-weight: 600;
  font-size: 16px;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.te-tg__sub {
  font-size: 13px;
  color: var(--te-tg-muted);
}

.te-tg__dot {
  margin: 0 4px;
}

/* ---------- лента ---------- */

.te-tg__feed {
  flex: 1 1 auto;
  max-height: var(--te-tg-height);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--te-tg-accent-track) transparent;
}

.te-tg__feed::-webkit-scrollbar {
  width: 6px;
}

.te-tg__feed::-webkit-scrollbar-thumb {
  background: var(--te-tg-accent-track);
  border-radius: 3px;
}

.te-tg__feed::-webkit-scrollbar-track {
  background: transparent;
}

.te-tg__empty {
  margin: 0;
  padding: 24px 8px;
  text-align: center;
  color: var(--te-tg-muted);
  font-size: 14px;
}

/* ---------- пост ---------- */

.te-tg-post {
  background: #f6f8fa;
  border: 1px solid var(--te-tg-border);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.te-tg-post__forward {
  font-size: 12px;
  color: var(--te-tg-muted);
}

.te-tg-post__text {
  font-size: 14.5px;
  line-height: 1.5;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.te-tg-post__text.is-clamped {
  display: -webkit-box;
  -webkit-line-clamp: 6;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.te-tg-post__text a {
  color: var(--te-tg-blue);
  text-decoration: none;
}

.te-tg-post__text a:hover {
  text-decoration: underline;
}

.te-tg-post__text b,
.te-tg-post__text strong {
  font-weight: 600;
}

.te-tg-post__text pre,
.te-tg-post__text code {
  background: rgba(15, 40, 60, 0.06);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 13px;
  white-space: pre-wrap;
}

.te-tg-post__text blockquote {
  margin: 6px 0;
  padding-left: 10px;
  border-left: 3px solid var(--te-tg-blue);
  color: #46586a;
}

.te-tg-post__text tg-spoiler {
  background: #b6c1cb;
  border-radius: 3px;
  color: transparent;
  cursor: pointer;
  transition: all 0.2s ease;
}

.te-tg-post__text tg-spoiler:hover {
  background: transparent;
  color: inherit;
}

.te-tg-post__toggle {
  align-self: flex-start;
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  font-size: 13px;
  color: var(--te-tg-blue);
  cursor: pointer;
}

.te-tg-post__toggle:hover {
  text-decoration: underline;
}

/* ---------- медиа ---------- */

.te-tg-media {
  display: grid;
  gap: 3px;
  border-radius: 8px;
  overflow: hidden;
}

.te-tg-media--single {
  grid-template-columns: 1fr;
}

.te-tg-media--duo {
  grid-template-columns: 1fr 1fr;
}

.te-tg-media--grid {
  grid-template-columns: 1fr 1fr;
}

.te-tg-media--grid .te-tg-media__item:first-child {
  grid-column: span 2;
}

.te-tg-media__item {
  position: relative;
  display: block;
  overflow: hidden;
  background: #e6ebf0;
  aspect-ratio: 4 / 3;
}

.te-tg-media--single .te-tg-media__item {
  aspect-ratio: 16 / 10;
}

.te-tg-media__item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.35s ease;
}

.te-tg-media__item:hover img {
  transform: scale(1.04);
}

.te-tg-media__play {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 46px;
  height: 46px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  pointer-events: none;
}

.te-tg-media__play::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 54%;
  transform: translate(-50%, -50%);
  border-style: solid;
  border-width: 8px 0 8px 14px;
  border-color: transparent transparent transparent #fff;
}

.te-tg-media__duration {
  position: absolute;
  right: 6px;
  bottom: 6px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 11px;
  line-height: 1;
  padding: 3px 6px;
  border-radius: 4px;
}

.te-tg-media__more {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 22px;
  font-weight: 600;
}

/* ---------- превью ссылки ---------- */

.te-tg-preview {
  display: flex;
  gap: 10px;
  padding: 8px 10px;
  border-left: 3px solid var(--te-tg-blue);
  background: var(--te-tg-accent-soft);
  border-radius: 0 8px 8px 0;
  text-decoration: none;
  color: inherit;
}

.te-tg-preview:hover {
  text-decoration: none;
  color: inherit;
  background: var(--te-tg-accent-soft-hover);
}

.te-tg-preview__image {
  flex: 0 0 64px;
  width: 64px;
  height: 64px;
  border-radius: 6px;
  overflow: hidden;
}

.te-tg-preview__image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.te-tg-preview__body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.te-tg-preview__site {
  font-size: 12px;
  color: var(--te-tg-blue);
  font-weight: 600;
}

.te-tg-preview__title {
  font-size: 14px;
  font-weight: 600;
}

.te-tg-preview__descr {
  font-size: 13px;
  color: var(--te-tg-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------- остальные вложения ---------- */

.te-tg-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.te-tg-attachments__item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--te-tg-border);
  border-radius: 7px;
  background: var(--te-tg-accent-soft);
  color: var(--te-tg-text);
  font-size: 13px;
  overflow-wrap: anywhere;
  text-decoration: none;
}

.te-tg-attachments__item:hover {
  background: var(--te-tg-accent-soft-hover);
  color: var(--te-tg-text);
  text-decoration: none;
}

/* ---------- метаданные поста ---------- */

.te-tg-post__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: var(--te-tg-muted);
}

.te-tg-post__views {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.te-tg-post__views svg {
  flex: 0 0 auto;
}

.te-tg-post__date {
  color: var(--te-tg-muted);
  text-decoration: none;
}

.te-tg-post__date:hover {
  color: var(--te-tg-blue);
  text-decoration: none;
}

/* ---------- кнопка «подписаться» ---------- */

.te-tg__join {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 54px;
  padding: 14px 18px;
  background: var(--te-tg-blue);
  color: #fff;
  font-weight: 600;
  font-size: 16px;
  text-decoration: none;
  transition: background-color 0.25s ease;
}

.te-tg__join:hover {
  background: var(--te-tg-blue-dark);
  color: #fff;
  text-decoration: none;
}

.te-tg__join svg {
  flex: 0 0 auto;
}

/* ---------- скелетон и подгрузка ---------- */

.te-tg-skeleton {
  border-radius: 10px;
  border: 1px solid var(--te-tg-border);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.te-tg-skeleton__media {
  height: 120px;
  border-radius: 8px;
}

.te-tg-skeleton__line {
  height: 12px;
  border-radius: 6px;
}

.te-tg-skeleton__line--short {
  width: 60%;
}

.te-tg-skeleton__media,
.te-tg-skeleton__line {
  background: linear-gradient(90deg, #eef1f4 25%, #e2e7ec 37%, #eef1f4 63%);
  background-size: 400% 100%;
  animation: te-tg-shimmer 1.4s ease infinite;
}

@keyframes te-tg-shimmer {
  0% {
    background-position: 100% 50%;
  }

  100% {
    background-position: 0 50%;
  }
}

.te-tg__loader {
  padding: 10px;
  text-align: center;
  font-size: 13px;
  color: var(--te-tg-muted);
}

@media (prefers-reduced-motion: reduce) {

  .te-tg-skeleton__media,
  .te-tg-skeleton__line {
    animation: none;
  }

  .te-tg-media__item img {
    transition: none;
  }
}

/* ---------- адаптив ---------- */

@media screen and (max-width: 960px) {
  .te-tg {
    --te-tg-height: 60vh;
  }
}

@media screen and (max-width: 640px) {
  .te-tg__head {
    padding: 12px;
  }

  .te-tg__avatar {
    flex-basis: 42px;
    width: 42px;
    height: 42px;
  }

  .te-tg__title {
    font-size: 15px;
  }

  .te-tg__feed {
    padding: 10px;
    gap: 10px;
  }

  .te-tg__join {
    font-size: 15px;
    min-height: 48px;
  }
}

/* ---------- тема MAX ---------- */

.te-tg--max {
  --te-tg-blue: #7b53f5;
  --te-tg-blue-dark: #6640df;
  --te-tg-accent-soft: rgba(123, 83, 245, 0.06);
  --te-tg-accent-soft-hover: rgba(123, 83, 245, 0.12);
  --te-tg-accent-track: rgba(123, 83, 245, 0.35);
}

.te-tg--max .te-tg__avatar,
.te-tg--max .te-tg__join {
  background: linear-gradient(135deg, #8d63ff 0%, #6640df 100%);
}

.te-tg--max .te-tg__join:hover {
  background: linear-gradient(135deg, #7d51f5 0%, #5733cc 100%);
}

.te-tg--max .te-tg__avatar-letter {
  color: #fff;
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
}
