/*
 * БЕРТЧ 2026 | ПРЕМИУМ ЛЕНТА (AURORA ENGINE + VERTICAL DOCK 2.0)
 * Версия 8.3: SMART FRAME HEIGHT (Фикс пропадания видео на ПК)
 * Файл: assets/css/feed-reels.css
 */

:root {
    --safe-top: env(safe-area-inset-top, 20px);
    --safe-bottom: env(safe-area-bottom, 20px);
    
    --bg-deep: #030305;
    --like-accent: #ff2b54;
    
    /* Умная переменная: по умолчанию занимает весь экран (для мобильных) */
    --frame-height: 100dvh;
}

@media (min-width: 768px) {
    :root {
        /* На ПК жестко вычисляем высоту фрейма, чтобы скрипты не ломались */
        --frame-height: min(850px, calc(100dvh - 40px));
    }
}

/* БАЗОВЫЕ НАСТРОЙКИ (Изолированная зона) */
.yazme-premium-feed {
    /* Форсируем прозрачные стеклянные переменные НЕЗАВИСИМО от темы сайта */
    --btn-secondary-bg: rgba(255, 255, 255, 0.15) !important;
    --btn-secondary-hover: rgba(255, 255, 255, 0.25) !important;
    --glass-border: rgba(255, 255, 255, 0.2) !important;
    --text-primary: #ffffff !important;
    --text-secondary: rgba(255, 255, 255, 0.7) !important;
    --bg-panel: rgba(20, 20, 25, 0.4) !important;
    
    width: 100%;
    height: 100dvh; /* Тело сайта всегда на весь экран */
    background: var(--bg-deep);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    overflow: hidden;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* =========================================
   AURORA BACKGROUND ENGINE (ЖИВОЙ ФОН)
   ========================================= */
.aurora-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
    background: var(--bg-deep);
    overflow: hidden;
    pointer-events: none;
}

.aurora-bg::before,
.aurora-bg::after {
    content: '';
    position: absolute;
    width: 60vw;
    height: 60vw;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.5;
    animation: aurora 15s ease-in-out infinite alternate;
}

.aurora-bg::before {
    background: radial-gradient(circle, rgba(107, 72, 255, 0.4) 0%, transparent 70%);
    top: -20%;
    left: -10%;
}

.aurora-bg::after {
    background: radial-gradient(circle, rgba(75, 98, 138, 0.4) 0%, transparent 70%);
    bottom: -20%;
    right: -10%;
    animation-delay: -5s;
}

@keyframes aurora {
    0% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(10%, 15%) scale(1.2); }
    100% { transform: translate(-10%, -10%) scale(0.9); }
}

/* =========================================
   НОВЫЙ ЕДИНЫЙ ФРЕЙМ ДЛЯ ПК И МОБАЙЛА
   ========================================= */
.feed-app-container {
    position: relative;
    width: 100%;
    /* Используем умную переменную вместо жестких процентов */
    height: var(--frame-height);
    margin: 0 auto;
    overflow: hidden;
    z-index: 1;
    background: var(--bg-deep); 
}

@media (min-width: 768px) {
    .feed-app-container {
        max-width: 420px;
        /* Идеальное центрирование фрейма на мониторе ПК */
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        border-radius: 40px;
        box-shadow: 0 30px 90px rgba(0,0,0,0.8), 0 0 0 1px var(--glass-border);
    }
}

/* =========================================
   СЦЕНА (КОНТЕЙНЕР ЛЕНТЫ) - ULTRA-FAST ENGINE
   ========================================= */
.feed-stage {
    height: 100%;
    width: 100%;
    overflow: hidden; 
    touch-action: none; 
    position: relative;
}

.feed-wrapper {
    width: 100%;
    display: flex;
    flex-direction: column;
    transition: transform 0.15s cubic-bezier(0.1, 0.9, 0.2, 1); 
    will-change: transform;
}

/* =========================================
   КАРТОЧКА ПОСТА (СЛАЙД)
   ========================================= */
.feed-post {
    /* Жестко привязываем высоту поста к переменной, чтобы не было нулевой высоты на ПК */
    height: var(--frame-height);
    width: 100%;
    flex: 0 0 var(--frame-height); 
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* =========================================
   МЕДИА СЛОИ (ИММЕРСИВНОСТЬ)
   ========================================= */
.media-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.media-bg-blur {
    position: absolute;
    top: -15%;
    left: -15%;
    width: 130%;
    height: 130%;
    object-fit: cover;
    filter: blur(60px) brightness(0.4);
    z-index: 0;
    pointer-events: none;
    transform: scale(1.1);
}

.media-fg {
    width: 100%;
    height: 100%;
    object-fit: contain;
    position: relative;
    z-index: 2;
    filter: drop-shadow(0 20px 40px rgba(0,0,0,0.6));
}

/* =========================================
   АУДИОПЛЕЕР
   ========================================= */
.audio-card-glass {
    position: relative;
    z-index: 2;
    background: var(--bg-panel);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border-radius: 32px;
    padding: 30px;
    width: 85%;
    max-width: 400px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.audio-disk {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--p-accent), #2b2b36);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5), inset 0 0 0 4px rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: spinDisk 10s linear infinite;
    animation-play-state: paused;
}

.audio-disk.playing { animation-play-state: running; }

.audio-disk::after {
    content: '';
    width: 30px;
    height: 30px;
    background: var(--bg-deep);
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.1);
}

@keyframes spinDisk {
    100% { transform: rotate(360deg); }
}

.audio-controls {
    display: flex;
    align-items: center;
    gap: 20px;
    width: 100%;
}

.play-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--text-primary);
    color: var(--bg-deep);
    border: none;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.play-btn:active { transform: scale(0.9); }

.audio-waveform {
    flex: 1;
    height: 40px;
    background: var(--btn-secondary-bg);
    border-radius: 20px;
    position: relative;
    overflow: hidden;
}

.audio-progress {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    background: var(--p-accent);
    width: 0%;
    opacity: 0.8;
    transition: width 0.1s linear;
}

/* =========================================
   ТЕКСТОВЫЕ КАРТОЧКИ
   ========================================= */
.text-card-glass {
    position: relative;
    z-index: 2;
    background: var(--bg-panel);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border-radius: 36px;
    padding: 40px 30px;
    width: 85%;
    max-width: 400px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.text-card-content {
    font-size: clamp(20px, 5vw, 28px);
    font-weight: 700;
    line-height: 1.4;
    text-align: center;
    color: var(--text-primary);
    word-wrap: break-word;
    width: 100%;
}

/* =========================================
   UI СЛОЙ (ТЕКСТ + КНОПКИ)
   ========================================= */
.ui-layer {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%; 
    background: linear-gradient(180deg, transparent 75%, rgba(0,0,0,0.8) 100%);
    z-index: 10;
    pointer-events: none;
}

/* Левая часть: Описание видео */
.content-left {
    position: absolute;
    left: 16px;
    bottom: calc(100px + var(--safe-bottom)); 
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: calc(100% - 80px);
    pointer-events: none;
}

.post-caption {
    font-size: 15px;
    line-height: 1.5;
    color: var(--text-primary);
    font-weight: 400;
    text-shadow: 0 2px 8px rgba(0,0,0,0.8);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    cursor: pointer;
    pointer-events: all;
    transition: all 0.3s ease;
}

.post-caption.expanded {
    -webkit-line-clamp: unset;
    background: var(--bg-panel);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    padding: 12px;
    border-radius: 16px;
}

/* Правая часть: Vertical Floating Dock */
.action-dock-vertical {
    position: absolute;
    right: 12px; 
    bottom: calc(120px + var(--safe-bottom)); 
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px; 
    pointer-events: all;
}

.action-btn-clean {
    background: transparent;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    outline: none;
}

.action-btn-clean i {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px; 
    
    background: var(--btn-secondary-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    
    /* Возвращаем эффект стекла */
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.action-btn-clean .action-count {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    text-shadow: 0 2px 6px rgba(0,0,0,0.8);
    transition: all 0.3s;
}

.action-btn-clean:active i {
    transform: scale(0.85);
    background: var(--btn-secondary-hover);
}

.action-btn-clean.liked i {
    color: #fff !important;
    background: var(--like-accent) !important;
    border-color: var(--like-accent) !important;
    box-shadow: 0 8px 25px rgba(255, 43, 84, 0.4) !important;
    animation: springPop 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

/* =========================================
   АНИМАЦИИ
   ========================================= */
@keyframes springPop {
    0% { transform: scale(1); }
    40% { transform: scale(1.2); }
    70% { transform: scale(0.9); }
    100% { transform: scale(1); }
}

.double-tap-heart {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    font-size: 140px;
    color: var(--like-accent);
    z-index: 100;
    pointer-events: none;
    filter: drop-shadow(0 10px 40px rgba(255, 43, 84, 0.6));
    opacity: 0;
}

.double-tap-heart.animate {
    animation: cinematicTap 0.9s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes cinematicTap {
    0% { transform: translate(-50%, -50%) scale(0) rotate(-20deg); opacity: 0; }
    30% { transform: translate(-50%, -50%) scale(1.2) rotate(10deg); opacity: 1; }
    50% { transform: translate(-50%, -50%) scale(0.95) rotate(-5deg); opacity: 1; }
    80% { transform: translate(-50%, -50%) scale(1) rotate(0deg); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(2); opacity: 0; filter: blur(10px); }
}

.aurora-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    border: 3px solid transparent;
    border-top-color: var(--p-accent);
    border-right-color: rgba(255,255,255,0.5);
    border-radius: 50%;
    animation: ring-spin 1s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite;
    filter: drop-shadow(0 0 10px var(--p-accent));
}

@keyframes ring-spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}