/* 1. ПЕРЕМЕННЫЕ И ОБЩИЕ СТИЛИ */
:root {
    --bg-color: #141414;
    --card-bg: #202020;
    --border-color: #222222;
    --text-main: #fff;
    --text-muted: #828282;
    --accent: #207cc2;
    --danger: #ed4956;
    --nav-bg: #222222;
    --tile-bg: #161616;
    --tile-br: #222;
}

* { 
    margin: 0; 
    padding: 0; 
    box-sizing: border-box; 
    scrollbar-width:none;scrollbar-color:#353535 #1c1c1c;scrollbar-color:var(--color-accent-800) var(--color-accent-200);
}

input, textarea, select {
    font-size: 16px !important;
}
button, a, .post-actions div {
    touch-action: manipulation;
}
            
    ::-webkit-scrollbar {
        width:10px
    }
    
    ::-webkit-scrollbar-track {
        background:#262626;background:var(--color-accent-600);
    }
            
    ::-webkit-scrollbar-thumb {
        background:#353535;background:var(--color-accent-800);border-radius:0;border:0 #1c1c1c;border:0 var(--color-accent-200);
    }
            
    ::-webkit-scrollbar-thumb:hover {
        background:#4f4f4f;background:var(--color-accent-100);
    }

article.post {
    scroll-margin-top: 70px; /* Высота твоей верхней панели + небольшой запас */
}

html {
    scroll-behavior: smooth;
}

@font-face {
    font-family: 'TOM-Sans';
    src: url('/css/pin-sans-macOS-regular.woff2') format('woff2'); /* проверь путь к файлу */
    font-weight: normal;
    font-style: normal;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: 'TOM-Sans', -apple-system, sans-serif;
    line-height: 1.5;
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 935px;
    margin: 0 auto;
    padding: 0 10px;
}

a { text-decoration: none; color: inherit; }
img { max-width: 100%; height: auto; display: block; }

/* 2. НАВИГАЦИЯ (ДЕКСТОП И МОБАЙЛ) */
.top-nav {
    position: sticky;
    top: 0;
    background: var(--nav-bg);
    backdrop-filter: blur(15px);
    border-bottom: 1px solid var(--border-color);
    padding: 20px 0;
    z-index: 1000;
}

.top-nav .inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -1px;
    text-transform: uppercase;
}

.search-form input {
    background: #262626;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    color: white;
    width: 250px;
    outline: none;
}

.mobile-bottom-nav {
    display: none; /* Скрыто на десктопе */
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #000;
    border-top: 1px solid var(--border-color);
    justify-content: space-around;
    align-items: center;
    padding: 12px 0;
    z-index: 1000;
}

/* 3. ЛЕНТА И ПОСТЫ */
.feed-container {
    max-width: 500px;
    margin: 0 auto;
    padding-top: 20px;
}

.post {
    background: var(--tile-bg);
    margin-bottom: 20px;
    border-radius: 20px;
    overflow: hidden;
    border: 1px solid var(--tile-br);
}

.post-header {
    display: flex;
    align-items: center;
    padding: 12px;
}

.post-actions {
    padding: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

/* 4. ФОРМЫ И КНОПКИ */
.auth-card {
    max-width: 350px;
    margin-top: 30px;
    border-radius: 8px;
    text-align: center;
}

input[type="text"], 
input[type="password"], 
textarea {
    width: 100%;
    background: #222222;
    border: 1px solid var(--border-color);
    color: white;
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 10px;
    outline: none;
    font-size: 14px;
}

textarea {
    resize: none;
    min-height: 40px;
}

button, .btn {
    display: block;
    width: 100%;
    background: var(--accent);
    color: white;
    border: none;
    padding: 16px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: opacity 0.2s;
}

.btn:hover { opacity: 0.8; }

/* 5. ПРОФИЛЬ (СЕТКА) */
.profile-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 28px;
}

.grid-item {
    aspect-ratio: 1/1;
    overflow: hidden;
    position: relative;
    background: #121212;
}

.grid-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: filter 0.3s;
}

.grid-item:hover img {
    filter: brightness(0.7);
}

/* 6. АДАПТИВНОСТЬ (МЕДИА-ЗАПРОСЫ) */
@media (max-width: 768px) {
    body {
        padding-bottom: 60px; /* Место для нижнего меню */
    }

    .top-nav .search-form {
        display: none; /* Прячем поиск сверху на мобайле */
    }

    .mobile-bottom-nav {
        display: flex;
    }

    .feed-container {
        max-width: 100%;
    }

    .post {
        border-radius: 20px;
    }

    .profile-header {
        flex-direction: column;
        text-align: center;
        padding: 20px 0;
    }

    .profile-grid {
        gap: 3px; /* Тонкие разделители как в Instagram */
    }

    .grid-item {
        border-radius: 0;
    }

    .avatar {
        width: 80px !important;
        height: 80px !important;
        margin-bottom: 15px;
    }
}


/* По умолчанию скрываем мобильное меню и показываем десктопное */
.mobile-bottom-nav { display: none; }
.desktop-menu { display: flex; }

@media (max-width: 768px) {
    /* На мобилках прячем десктопные кнопки и поиск */
    .desktop-menu { display: none !important; }
    
    /* Показываем нижнюю панель */
    .mobile-bottom-nav { 
        display: flex; 
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: #000;
        border-top: 0px solid var(--border-color);
        justify-content: space-around;
        padding: 20px 0;
        z-index: 1000;
    }
    
    /* Фикс для всего сайта */
    body {
        padding-bottom: 85px !important;
        /* Убираем пружинистый скролл, который может вызывать дергание панелей */
        overscroll-behavior-y: none; 
    }

    /* Если это режим "Приложения" (на экране Домой) */
    @media (display-mode: standalone) {
        .mobile-bottom-nav {
            height: 90px !important;
            padding-top: 18px !important;
            background: var(--bg-color) !important;
        }
        body {
            padding-bottom: 95px !important;
        }
    }

    
}

.badge {
    position: absolute; top: -5px; right: -8px; background: var(--danger); 
    color: white; border-radius: 50%; width: 16px; height: 16px; font-size: 10px; 
    display: flex; align-items: center; justify-content: center; border: 2px solid #000; font-weight: bold;
}
.dot {
    position: absolute; top: -2px; right: -5px; background: var(--danger); 
    border-radius: 50%; width: 8px; height: 8px; border: 1.5px solid #000;
}

/* 1. Добавляем в самое начало для корректной работы тапов */
.nav-item, .nav-item *, .icon-notifications, .icon-add-post, .icon-explore, .icon-direct, .icon-admin, .nav-profile-link {-webkit-tap-highlight-color: transparent;cursor: pointer;}
/* Контейнер для иконки и бейджа */
.nav-icon-wrapper {position: relative;display: flex;align-items: center;justify-content: center;}
/* Стили для красной точки (бейджа) */
.nav-badge {position: absolute;top: -6px;right: -8px;background: #ff3b30;color: #fff;font-size: 10px;font-weight: 700;min-width: 17px;height: 17px;border-radius: 10px;display: flex;align-items: center;justify-content: center;border: 2px solid #000;padding: 0 3px;box-sizing: border-box;line-height: 1;z-index: 5;}
.icon-notifications:hover .nav-badge {transform: scale(1.1);}
.main-nav {display: flex;justify-content: center;align-items: center;padding: 10px 0;}
.nav-container {display: flex;align-items: center;gap: 22px;}
.nav-item {display: flex;align-items: center;justify-content: center;transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);}
.nav-item svg {display: block;}
@media (max-width: 768px) {
.main-nav {position: fixed;bottom: 0;left: 0;width: 100%;background: var(--bg-color);border-top: 1px solid #262626;z-index: 1000;padding: 12px 0;}
.nav-container {width: 100%;justify-content: space-around;gap: 0;}}
.icon-add-post {cursor: pointer;transition: all 0.3s ease;}
.icon-add-post:hover svg, .icon-add-post:active svg {transform: scale(1.1); stroke-width: 2.5; fill: rgba(255, 255, 255, 0.1);filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.5));
}
.icon-explore {cursor: pointer;transition: all 0.3s ease;}
.icon-explore:hover svg, .icon-explore:active svg {transform: scale(1.1) rotate(15deg);stroke-width: 2.5;fill: rgba(255, 255, 255, 0.1);filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.3));}
/* ДИРЕКТ (Самолет) - Исправлено движение точки вместе с иконкой */
.icon-direct {cursor: pointer;transition: all 0.3s ease;}
.icon-direct:hover svg, .icon-direct:active svg {transform: scale(1.1) translate(2px, -2px); stroke-width: 2.2;fill: rgba(255, 255, 255, 0.1);filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.3));}
/* Чтобы точка уведомлений улетала ВМЕСТЕ с самолетом */
.icon-direct:hover .nav-badge, 
.icon-direct:active .nav-badge,
.icon-direct:hover .nav-badge-dot,
.icon-direct:active .nav-badge-dot {transform: translate(2px, -2px) scale(1.1);}
@keyframes bell-ring {0%, 100% { transform: rotate(0); }25% { transform: rotate(15deg); }50% { transform: rotate(-15deg); }75% { transform: rotate(10deg); }}
.icon-notifications:hover svg, .icon-notifications:active svg {animation: bell-ring 0.6s ease-in-out !important;transform-origin: top center;stroke-width: 2.5;}
.icon-admin {cursor: pointer;transition: all 0.5s ease;}
.icon-admin:hover svg, .icon-admin:active svg {transform: scale(1.1) rotate(90deg);stroke-width: 2.2;fill: rgba(255, 255, 255, 0.15);filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.4));}
/* ПРОФИЛЬ */
.nav-profile-link {display: inline-flex;align-items: center;justify-content: center;}
.nav-avatar-wrapper {width: 28px;height: 28px;border-radius: 50%;display: flex;align-items: center;justify-content: center;border: 2px solid white;box-sizing: border-box;transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);overflow: hidden;}
.nav-avatar-wrapper img {width: 100%;height: 100%;border-radius: 50%;object-fit: cover;display: block;padding: 1px;box-sizing: border-box;}
.nav-profile-link:hover .nav-avatar-wrapper, .nav-profile-link:active .nav-avatar-wrapper {transform: scale(1.15);box-shadow: 0 0 10px rgba(255, 255, 255, 0.4);border-width: 2.2px; }
/* Общее уменьшение при клике для всех иконок на мобилках */
.nav-item:active {transform: scale(0.95);}
/* Корректировка положения бейджа для Директа */
.icon-direct .nav-badge, .icon-direct .nav-badge-dot {transition: all 0.3s ease; /* Плавность для точки */}  
/* --- 1. ОБЩИЕ СТИЛИ (работают везде) --- */
.nav-item {display: flex;align-items: center;justify-content: center;text-decoration: none;transition: all 0.2s ease;}
.nav-icon-wrapper { position: relative; display: flex; }
.nav-badge-dot {position: absolute; top: -2px; right: -2px;width: 10px; height: 10px; background: #ff3b30;border-radius: 50%; border: 2px solid var(--bg-color);}
.nav-avatar-wrapper {width: 26px; height: 26px;border: 2px solid white; border-radius: 50%;display: flex; align-items: center; justify-content: center;overflow: hidden; box-sizing: border-box;}
.nav-avatar-wrapper img {width: 100%; height: 100%; object-fit: cover; border-radius: 50%; padding: 1px;}
.beta-label { font-size: 9px; opacity: 0.6; font-weight: bold; margin-left: 3px; }
.nav-item:active { transform: scale(0.9); }
/* --- 2. КОМПЬЮТЕР (Desktop) --- */
@media (min-width: 769px) {
.mobile-only { display: none !important; }
.top-nav.desktop-only {position: sticky; top: 0; z-index: 1000;height: 65px; background: var(--bg-color);border-bottom: 1px solid var(--border-color);display: flex !important; align-items: center; justify-content: center;}
.top-nav.desktop-only .container {width: 100%; max-width: 935px;display: flex; justify-content: space-between; align-items: center;padding: 0 20px;}
.desktop-menu { display: flex; align-items: center; gap: 22px; }
}
/* --- 3. ТЕЛЕФОН (Mobile) --- */
@media (max-width: 768px) {.desktop-only { display: none !important; }.mobile-only { display: flex !important; }
body {/* Отступы, чтобы контент не прятался под панелями */padding-top: calc(65px + env(safe-area-inset-top)) !important;padding-bottom: calc(60px + env(safe-area-inset-bottom)) !important;}
/* Верхняя панель */
.top-nav.mobile-only {position: fixed; top: 0; left: 0; right: 0; z-index: 1001;background: var(--bg-color); border-bottom: 1px solid var(--border-color);height: calc(65px + env(safe-area-inset-top));display: flex !important; align-items: center;}
.top-nav.mobile-only .inner {display: flex !important; justify-content: space-between !important;width: 100%; padding: 0 15px; align-items: center;}
/* Нижняя панель */
.mobile-bottom-nav.mobile-only {position: fixed; bottom: 0; left: 0; right: 0; z-index: 1001;background: var(--bg-color); border-top: 1px solid var(--border-color);height: calc(90px + env(safe-area-inset-bottom));display: flex !important; justify-content: space-around;align-items: center;}
/* 1. Убираем синий квадрат при нажатии (стандарт браузера) */
* { -webkit-tap-highlight-color: transparent; }
/* 2. Общая анимация нажатия для всех иконок */
.nav-item:active {transform: scale(0.85); /* Иконка слегка сжимается под пальцем */transition: transform 0.1s ease;}
/* 3. Специфические анимации (теперь на :active) */
/* Компас (крутится) */
.icon-explore:active svg {transform: rotate(25deg);}
/* Директ (улетает чуть вверх) */
.icon-direct:active svg {transform: translate(3px, -3px);}
/* Админка (вращается) */
.icon-admin:active svg {transform: rotate(90deg);}
/* Колокольчик (трясется) */
.icon-notifications {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    /* Магия для iOS: заставляем GPU следить за элементом */
    transform: translateZ(0); 
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    user-select: none;
}

/* 2. Анимация (обязательно через !important, чтобы перебить системные задержки) */
@keyframes bell-ring-mobile {
    0%, 100% { transform: rotate(0); }
    20% { transform: rotate(15deg); }
    40% { transform: rotate(-15deg); }
    60% { transform: rotate(10deg); }
    80% { transform: rotate(-10deg); }
}

/* 3. Срабатывание при нажатии */
.icon-notifications:active svg {
    animation: bell-ring-mobile 0.4s ease-in-out !important;
    /* Убираем задержку появления анимации */
    transition: none !important;
}
/* Аватарка */
.nav-profile-link:active .nav-avatar-wrapper {transform: scale(0.9);border-color: rgba(255, 255, 255, 0.7);}}
.nav-home-icon svg {
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.nav-home-icon:hover svg {
    /* Слегка приподнимаем и увеличиваем */
    transform: translateY(-3px) scale(1.1);
    /* Можно добавить легкое свечение */
    filter: drop-shadow(0 0 5px rgba(255,255,255,0.3));
}

/* Эффект нажатия */
.nav-home-icon:active svg {
    transform: translateY(0) scale(0.9);
}
/* Анимация дрожания всей иконки */
@keyframes trash-shake {
    0% { transform: rotate(0deg); }
    25% { transform: rotate(3deg); }
    50% { transform: rotate(0deg); }
    75% { transform: rotate(-3deg); }
    100% { transform: rotate(0deg); }
}

.nav-delete-icon:hover svg {
    animation: trash-shake 0.2s infinite;
    stroke: #ff3b30; /* Цвет становится красным при наведении */
}

/* Анимация крышки (поднимаем её чуть выше) */
.nav-delete-icon .trash-lid {
    transition: transform 0.2s ease;
    transform-origin: center;
}

.nav-delete-icon:hover .trash-lid {
    transform: translateY(-2px) rotate(-5deg);
}

/* Эффект нажатия (сжатие) */
.nav-delete-icon:active svg {
    transform: scale(0.8);
    transition: 0.1s;
}

/* Базовый стиль ссылки */
.showcase-link {
    display: flex;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    -webkit-tap-highlight-color: transparent;
}

/* Класс, который будет добавлять JS при касании */
.is-clicking {
    transform: scale(0.85) rotate(90deg) !important;
}

@media (hover: hover) {
    .showcase-link:hover {
        /* При наведении: чуть увеличиваем и поворачиваем на 90 градусов */
        transform: scale(1.1) rotate(90deg);
    }

    .showcase-link svg rect {
        /* Плавный переход для квадратов внутри */
        transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    }

    /* При наведении: квадраты немного "собираются" к центру */
    .showcase-link:hover svg rect:nth-child(1) { transform: translate(1px, 1px); }
    .showcase-link:hover svg rect:nth-child(2) { transform: translate(-1px, 1px); }
    .showcase-link:hover svg rect:nth-child(3) { transform: translate(-1px, -1px); }
    .showcase-link:hover svg rect:nth-child(4) { transform: translate(1px, -1px); }
}

/* Оставляем твой рабочий эффект нажатия (для клика) */
.showcase-link:active {
    transform: scale(0.9) rotate(90deg) !important;
    transition: transform 0.1s !important;
}



/* 1. ОБЩИЙ КОНТЕЙНЕР (База — полностью твоя) */
.post-carousel-container { 
    position: relative; 
    width: 100%; 
    overflow: hidden; 
    background: #000; 
    touch-action: pan-y; 
    user-select: none;
    -webkit-user-drag: none; 
    border-radius: 20px;
}

/* 2. РЕЖИМЫ (Одиночное фото vs Карусель) */
.post-carousel-container.single-mode { 
    aspect-ratio: auto; 
    height: auto; 
}

/* УБРАЛИ ЖЕСТКИЙ aspect-ratio: 3/4, теперь высота динамическая */
.post-carousel-container.multi-mode { 
    height: auto; 
}

/* 3. ТРЕК И СЛАЙДЫ (Адаптировали под динамическую высоту) */
.post-carousel-track { 
    display: flex; 
    /* Убрали height: 100%, чтобы трек растягивался по высоте контента */
    width: 100%;
    transition: transform 0.3s ease-out; 
    will-change: transform; 
}

/* 3. ТРЕК И СЛАЙДЫ */
.post-carousel-slide { 
    flex: 0 0 100%; 
    width: 100%;
    /* ЖЁСТКОЕ ЦЕНТРИРОВАНИЕ ПО ВЕРТИКАЛИ И ГОРИЗОНТАЛИ */
    display: flex !important;
    align-items: center !important;     /* Центрует по вертикали (чтобы не липло к верху) */
    justify-content: center !important; /* Центрует по горизонтали */
    background: #050505;                /* Цвет полей вокруг картинок */
    overflow: hidden;
}

/* 4. КАРТИНКИ (Чистый Instagram-style без обрезания краев) */
.post-carousel-container.multi-mode .post-carousel-slide img {
    width: 100% !important;
    height: 100% !important;
    
    /* ИСПОЛЬЗУЕМ CONTAIN И ПРИНУДИТЕЛЬНОЕ ВЫРАВНИВАНИЕ */
    object-fit: contain !important; /* Картинка сжимается/растягивается, но сохраняет свои пропорции */
    display: block;
    margin: auto !important;        /* Дополнительная страховка для центрирования в некоторых браузерах */
}

/* В режиме карусели принудительно даем картинкам 100% высоты, 
   но за счет contain они будут аккуратно вставать по центру с полями */
.post-carousel-container.multi-mode .post-carousel-slide img {
    height: 100% !important;
    object-fit: contain !important; /* ЖЕСТКО: Никакого cover, только оригинальный масштаб */
}

/* 5. КНОПКИ И СЧЕТЧИК */
.carousel-btn { 
    position: absolute; 
    top: 50%; 
    transform: translateY(-50%); 
    background: rgba(0,0,0,0.5); 
    color: #fff; 
    border: none; 
    width: 28px; 
    height: 28px; 
    border-radius: 50%; 
    cursor: pointer; 
    z-index: 5; 
    font-size: 12px; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    opacity: 0.7; 
}
.carousel-btn:hover { opacity: 1; }
.carousel-btn.prev { left: 10px; }
.carousel-btn.next { right: 10px; }

.carousel-counter { 
    position: absolute;
    top: 12px;
    right: 12px;
    /* Эффект стекла */
    background: rgba(25, 25, 25, 0.4); 
    backdrop-filter: blur(8px); 
    -webkit-backdrop-filter: blur(8px);
    
    /* Граница для четкости */
    border:0px solid rgba(255, 255, 255, 0.1);
    
    color: #fff;
    padding: 4px 10px;
    border-radius: 20px; /* Делаем его овальным */
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    z-index: 10;
    
    /* Тень для объема */
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    pointer-events: none;
}

/* Скрываем стрелки на мобилках (оставляем свайп) */
@media (pointer: coarse) {
    .carousel-btn { display: none !important; }
}


#toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #262626;
    color: white;
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    z-index: 10000;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s;
    opacity: 0;
    border: 1px solid #333;
}

#toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}
