/* TikTok Feed Styles */
/* =========================
   TikTok Scroll-Snap Mode
   1 post = 1 screen (mobile + desktop)
========================= */

html, body {
  height: 100%;
}

/* чтобы страница не “прыгала” из-за скроллбара */
html {
  scroll-behavior: smooth;
}

/* Главный контейнер модуля */
#tiktok-feed-module {
  position: relative;
  width: 100%;
}

/* Контейнер ленты: делаем его скроллящимся на весь экран */
#tiktok-feed-container {
  position: relative;
  height: 100vh;                 /* 1 экран */
  overflow-y: auto;              /* скролл внутри контейнера */
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;

  /* Scroll snap */
  scroll-snap-type: y mandatory;
  scroll-padding-top: 0px;

  /* Скрыть “глобальный” скролл body (мы скроллим внутри контейнера) */
  overscroll-behavior-y: contain;

  /* Плавность и защита */
  scroll-behavior: smooth;

  /* На десктопе “приятнее” */
  scrollbar-width: thin; /* Firefox */
}

/* WebKit scrollbar optional (можешь убрать если не надо) */
#tiktok-feed-container::-webkit-scrollbar {
  width: 10px;
}
#tiktok-feed-container::-webkit-scrollbar-thumb {
  border-radius: 10px;
  background: rgba(255,255,255,.18);
}
#tiktok-feed-container::-webkit-scrollbar-track {
  background: rgba(255,255,255,.06);
}

/* Каждый пост занимает ровно экран */
.tiktok-post {
  position: relative;
  height: 100vh;                 /* 1 пост = 1 экран */
  width: 100%;
  scroll-snap-align: start;       /* фикс к началу */
  scroll-snap-stop: always;       /* чтобы не пролетало сразу 2 */
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Медиа: занимает всю верхнюю область, остальное — инфо/кнопки */
.post-media-container {
  position: relative;
  flex: 1 1 auto;
  min-height: 0; /* важно для flex */
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}

/* Видео и картинка — как TikTok: cover */
.post-media-container video.tiktok-video,
.post-media-container img.tiktok-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Блок с инфой/кнопками — поверх или снизу (как у тебя уже сделано)
   Если у тебя .post-info позиционирован — оставь как есть.
   Ниже универсально: делаем его поверх низа.
*/
.post-info {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;

  padding: 16px;
  z-index: 5;

  /* затемнение снизу, чтобы текст читался */
  background: linear-gradient(to top, rgba(0,0,0,.65), rgba(0,0,0,.12), rgba(0,0,0,0));
  color: #fff;
}

/* Подсказка свайпа/скролла */
#tiktok-swipe-hint {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 9999;
}

/* Лоадер */
#tiktok-loader {
  position: fixed;
  left: 50%;
  top: 14px;
  transform: translateX(-50%);
  z-index: 9999;
}

/* На десктопе отключаем “страничный” скролл body чтобы не конкурировал с контейнером */
body.tiktok-snap-active {
  height: 100%;
  overflow: hidden;
}


#tiktok-feed-module {
    position: relative;
    width: 100%;
    background: #000;
    color: #fff;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    min-height: 100vh;
}

#tiktok-feed-container {
    position: relative;
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    background: #000;
	z-index: 80;
}

.tiktok-post {
    position: relative;
    width: 100%;
    height: 100vh;
    overflow: hidden;
    border-bottom: 1px solid #333;
}

.post-media-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
}

.tiktok-video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
    cursor: pointer;
}

.tiktok-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

.video-controls {
    position: absolute;
    bottom: 100px;
    left: 0;
    right: 0;
    padding: 0 20px;
    display: flex;
    align-items: center;
    background: linear-gradient(transparent, rgba(0,0,0,0.7));
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 10;
}

.post-media-container:hover .video-controls {
    opacity: 1;
}

.video-controls button {
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    padding: 10px;
    opacity: 0.8;
    transition: opacity 0.3s;
}

.video-controls button:hover {
    opacity: 1;
}

.video-progress {
    flex: 1;
    height: 3px;
    background: rgba(255,255,255,0.3);
    margin: 0 15px;
    border-radius: 2px;
    cursor: pointer;
    position: relative;
}

.progress-bar {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: #ff0050;
    border-radius: 2px;
    width: 0%;
    transition: width 0.1s;
}

.post-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 20px;
    background: linear-gradient(transparent, rgba(0,0,0,0.8));
    z-index: 5;
}

.post-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.post-author {
    display: flex;
    flex-direction: column;
}

.author-name {
    font-weight: 600;
    font-size: 16px;
    margin-bottom: 4px;
}

.post-date {
    font-size: 12px;
    opacity: 0.7;
}

.post-category {
    background: rgba(255,255,255,0.1);
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    text-decoration: none;
    color: #fff;
    transition: background 0.3s;
}

.post-category:hover {
    background: rgba(255,255,255,0.2);
}

.post-title {
    font-size: 18px;
    font-weight: 600;
    margin: 10px 0;
    line-height: 1.3;
}

.post-description {
    margin: 10px 0;
    font-size: 14px;
    line-height: 1.4;
    opacity: 0.9;
    max-height: 60px;
    overflow: hidden;
    position: relative;
}

.post-description::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 60px;
    height: 20px;
    background: linear-gradient(to right, transparent, rgba(0,0,0,0.8));
}

.read-more {
    display: inline-block;
    margin-top: 5px;
    font-size: 13px;
    color: #ff0050;
    text-decoration: none;
    font-weight: 500;
    transition: opacity 0.3s;
}

.read-more:hover {
    opacity: 0.8;
    text-decoration: underline;
}

.post-stats {
    display: flex;
    gap: 20px;
    margin: 15px 0;
    font-size: 13px;
    opacity: 0.8;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.stat-item i {
    font-size: 14px;
}

.post-actions {
    display: flex;
    justify-content: space-around;
    padding: 15px 0;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.post-actions button {
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    padding: 10px;
    position: relative;
    transition: transform 0.3s, color 0.3s;
}

.post-actions button:hover {
    transform: scale(1.1);
}

.like-btn {
    color: #fff;
}

.like-btn.liked {
    color: #ff0050;
}

.like-btn .like-count {
    position: absolute;
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 11px;
    opacity: 0.8;
}

.comment-btn:hover {
    color: #08c;
}

.share-btn:hover {
    color: #0f0;
}

.bookmark-btn {
    color: #fff;
}

.bookmark-btn.bookmarked {
    color: #ff0;
}

.bookmark-btn:hover {
    color: #ff0;
}

.tiktok-loader {
    text-align: center;
    padding: 30px;
    display: none;
}

.tiktok-loader .spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto;
    border: 3px solid rgba(255,255,255,0.1);
    border-top: 3px solid #ff0050;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.tiktok-swipe-hint {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.7);
    color: #fff;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 14px;
    z-index: 1000;
    display: none;
}

.hint-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

.hint-content::before {
    content: '↑↓';
    font-size: 16px;
    font-weight: bold;
}

.no-posts {
    text-align: center;
    padding: 50px 20px;
    color: #999;
    font-size: 16px;
}

/* Адаптивность */
@media (max-width: 768px) {
    #tiktok-feed-container {
        max-width: 100%;
    }
    
    .post-actions {
        padding: 10px 0;
    }
    
    .post-actions button {
        font-size: 20px;
        padding: 8px;
    }
    
    .video-controls {
        bottom: 80px;
        padding: 0 15px;
    }
    
    .post-info {
        padding: 15px;
    }
}

@media (min-width: 1024px) {
    #tiktok-feed-container {
        max-width: 600px;
    }
}

/* Темная тема */
@media (prefers-color-scheme: light) {
    #tiktok-feed-module,
    #tiktok-feed-container {
        background: #fff;
        color: #000;
    }
    
    .tiktok-post {
        border-bottom: 1px solid #ddd;
    }
    
    .post-media-container {
        background: #fff;
    }
    
    .tiktok-video,
    .tiktok-image {
        background: #fff;
    }
    
    .video-controls {
        background: linear-gradient(transparent, rgba(255,255,255,0.7));
    }
    
    .video-controls button {
        color: #000;
    }
    
    .video-progress {
        background: rgba(0,0,0,0.3);
    }
    
    .progress-bar {
        background: #ff0050;
    }
    
    .post-info {
        background: linear-gradient(transparent, rgba(255,255,255,0.8));
    }
    
    .post-category {
        background: rgba(0,0,0,0.1);
        color: #000;
    }
    
    .post-category:hover {
        background: rgba(0,0,0,0.2);
    }
    
    .post-description::after {
        background: linear-gradient(to right, transparent, rgba(255,255,255,0.8));
    }
    
    .read-more {
        color: #ff0050;
    }
    
    .post-actions {
        border-top: 1px solid rgba(0,0,0,0.1);
    }
    
    .post-actions button {
        color: #000;
    }
    
    .tiktok-loader .spinner {
        border: 3px solid rgba(0,0,0,0.1);
        border-top: 3px solid #ff0050;
    }
    
    .tiktok-swipe-hint {
        background: rgba(255,255,255,0.9);
        color: #000;
    }
}