/* ===== Лента Telegram-канала /lenta/ — разметка include/lenta/content.php и Ohta\Telegram\View,
   поведение js/telegram_script.js. Подключается в header.php только на /lenta/.
   Посты — «пузыри» как в Telegram, цвета и шрифт сайта. Слева карточка канала (липкая), справа лента. ===== */

.tg{
    --tg-green: #006738;
    --tg-accent: #87D454;
    --tg-text: #1C1C1C;
    --tg-muted: #6B6F82;
    --tg-faint: #A7ABBE;
    --tg-bubble: #fff;
    --tg-radius: 10px;   /* пост — одинаково на всех углах (без «хвостика» как в Telegram) */
    --tg-head: 116px;   /* низ фиксированной шапки сайта — уточняет скрипт */
    padding: 150px 0 100px;
    background-color: #EFF0F5;
    font-family: "Montserrat", sans-serif;
    color: var(--tg-text);
}

/* лента слева, карточка канала справа (в разметке карточка первой — на телефоне она над лентой) */
.tg_layout{
    display: grid;
    grid-template-columns: minmax(0, 640px) 340px;
    justify-content: center;
    gap: 28px 40px;
}

/* крошки и H1 — над обеими колонками, по левому краю ленты */
.tg_head{
    grid-column: 1 / -1;
    order: -1;
}

/* как заголовки других страниц (.contacts_title, .afisha_title, .sp_title): 48 / 400 / чёрный; отступ от крошек —
   их margin-bottom 60 px (about_style.css) */
.tg_title{
    margin: 0;
    color: #000;
    font-size: 48px;
    font-weight: 400;
    line-height: 1.2;
}

@media (max-width: 1200px){
    .tg_title{
        font-size: 38px;
    }
}

/* ---------- карточка канала ---------- */

/* верх карточки — вровень с первым постом, а не с плашкой даты над ним: высота плашки (~26) + отступ в группе (12) */
.tg_side{
    position: relative;
    order: 2;
    padding-top: 38px;
}

.tg_channel{
    position: sticky;
    top: calc(var(--tg-head) + 20px);
    padding: 24px;
    background-color: #fff;
    border-radius: 20px;
}

.tg_channel_head{
    display: flex;
    align-items: center;
    gap: 12px;
}

/* знак 52 px — чтобы название канала «Курорт «Охта Парк»» вставало в одну строку (при 72 px переносилось) */
.tg_channel_ava{
    flex: none;
    width: 52px;
    height: 52px;
}

.tg_channel_title{
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    line-height: 1.25;
}

.tg_channel_sub{
    margin: 4px 0 0;
    color: var(--tg-muted);
    font-size: 14px;
}

.tg_channel_text{
    margin: 20px 0 24px;
    color: var(--tg-muted);
    font-size: 14px;
    line-height: 1.5;
}

.tg_subscribe{
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    height: 52px;
    border-radius: 100px;
    background-color: var(--tg-green);
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    transition: background-color .2s;
}

.tg_subscribe:hover{
    background-color: #00512C;
    color: #fff;
}

/* вторая кнопка — тот же канал в MAX, оформлена так же, как Telegram */
.tg_subscribe--max{
    margin-top: 10px;
}

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

.tg_feed{
    position: relative;
    min-width: 0;
}

.tg_list,
.tg_group{
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.tg_list{
    gap: 24px;
}

/* плашка липкая только в пределах своего дня (.tg_group) — следующий день её выталкивает, а не ложится сверху */
.tg_day{
    position: sticky;
    top: calc(var(--tg-head) + 10px);
    z-index: 2;
    display: flex;
    justify-content: center;
    pointer-events: none;
}

.tg_day span{
    padding: 5px 14px;
    border-radius: 100px;
    background-color: rgba(107, 111, 130, .55);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    color: #fff;
    font-size: 13px;
    font-weight: 500;
}

/* пузырь: хвостик снизу слева, как у сообщений канала */
.tg_post{
    position: relative;
    max-width: 100%;
    padding: 6px 6px 12px;
    background-color: var(--tg-bubble);
    border-radius: var(--tg-radius);
    box-shadow: 0 1px 2px rgba(28, 28, 28, .06);
    scroll-margin-top: calc(var(--tg-head) + 50px);
}

.tg_post--flash{
    animation: tg-flash 1.6s ease-out;
}

@keyframes tg-flash{
    0%, 30%{ box-shadow: 0 0 0 4px rgba(135, 212, 84, .7); }
    100%{ box-shadow: 0 1px 2px rgba(28, 28, 28, .06); }
}

.tg_post--new{
    animation: tg-in .5s ease-out;
}

@keyframes tg-in{
    from{ opacity: 0; transform: translateY(-10px); }
}

.tg_fwd,
.tg_reply,
.tg_text,
.tg_poll,
.tg_other{
    margin: 6px 10px;
}

.tg_fwd{
    color: var(--tg-green);
    font-size: 13px;
}

.tg_fwd a,
.tg_fwd b{
    color: inherit;
    font-weight: 600;
}

.tg_reply{
    display: block;
    padding: 6px 10px;
    border-left: 3px solid var(--tg-accent);
    border-radius: 6px;
    background-color: rgba(135, 212, 84, .12);
    color: inherit;
    font-size: 13px;
    line-height: 1.35;
    text-decoration: none;
    transition: background-color .2s;
}

.tg_reply:hover{
    background-color: rgba(135, 212, 84, .22);
}

.tg_reply_name{
    display: block;
    color: var(--tg-green);
    font-weight: 600;
}

.tg_reply_text{
    display: block;
    overflow: hidden;
    color: var(--tg-muted);
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* ---------- текст ---------- */

/* как в Telegram: основной текст обычный (400), жирный — полужирный (600); 500/700 сайта в длинных постах, где
   жирным набраны целые абзацы, выглядели тяжело */
.tg_text{
    font-size: 15px;
    font-weight: 400;
    line-height: 1.55;
    overflow-wrap: anywhere;
}

.tg_text i{
    font-style: italic;
}

/* длинный текст свёрнут до ~12 строк, «Читать полностью» — разворачивает (класс ставит скрипт) */
.tg_text.is-clamped{
    max-height: calc(1.5em * 12);
    overflow: hidden;
    -webkit-mask-image: linear-gradient(#000 70%, transparent);
    mask-image: linear-gradient(#000 70%, transparent);
}

.tg_expand{
    margin: -2px 10px 6px;
    padding: 0;
    border: 0;
    background: none;
    color: var(--tg-green);
    font: 600 14px "Montserrat", sans-serif;
    cursor: pointer;
}

.tg_text a{
    color: var(--tg-green);
    text-decoration: underline;
    text-decoration-color: rgba(0, 103, 56, .35);
    text-underline-offset: 2px;
}

.tg_text a:hover{
    text-decoration-color: currentColor;
}

.tg_text b{
    font-weight: 600;
}

.tg_text code{
    padding: 1px 4px;
    border-radius: 4px;
    background-color: #EFF0F5;
    font-family: Consolas, Menlo, monospace;
    font-size: .9em;
}

.tg_text pre{
    margin: 6px 0;
    padding: 10px 12px;
    overflow-x: auto;
    border-radius: 8px;
    background-color: #EFF0F5;
    white-space: pre;
}

.tg_text pre code{
    padding: 0;
    background: none;
}

.tg_tag{
    color: var(--tg-green);
}

.tg_quote{
    position: relative;
    margin: 6px 0;
    padding: 4px 10px 4px 12px;
    border-left: 3px solid var(--tg-accent);
    border-radius: 6px;
    background-color: rgba(135, 212, 84, .12);
}

/* сворачиваемая цитата: 3 строки, по клику целиком */
.tg_quote--expand{
    max-height: calc(1.5em * 3 + 8px);
    overflow: hidden;
    cursor: pointer;
}

.tg_quote--expand::after{
    content: "";
    position: absolute;
    right: 8px;
    bottom: 6px;
    width: 8px;
    height: 8px;
    border-right: 2px solid var(--tg-green);
    border-bottom: 2px solid var(--tg-green);
    transform: rotate(45deg);
}

.tg_quote--expand.is-open{
    max-height: none;
    cursor: auto;
}

.tg_quote--expand.is-open::after{
    display: none;
}

/* спойлер: текст скрыт «шумом», по клику открывается */
.tg_spoiler{
    border-radius: 4px;
    background-color: #C9CCD8;
    color: transparent;
    cursor: pointer;
    transition: color .3s, background-color .3s;
}

.tg_spoiler a,
.tg_spoiler .tg_tag{
    color: transparent;
    pointer-events: none;
}

.tg_spoiler.is-open{
    background-color: transparent;
    color: inherit;
    cursor: auto;
}

.tg_spoiler.is-open a,
.tg_spoiler.is-open .tg_tag{
    color: var(--tg-green);
    pointer-events: auto;
}

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

.tg_media{
    display: grid;
    gap: 3px;
    overflow: hidden;
    border-radius: 6px;   /* внутри поста с отступом 6 px — одинаково на всех углах, как у самого поста */
}

.tg_mi{
    position: relative;
    display: block;
    overflow: hidden;
    background-color: #E4E6EE;
    aspect-ratio: 1;
}

/* фото и видео альбома — кнопки (data-src для Fancybox), не ссылки на файлы: снять оформление кнопки браузера */
button.tg_mi{
    width: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    font: inherit;
    color: inherit;
    text-align: inherit;
    cursor: zoom-in;
}

button.tg_mi--play{
    cursor: pointer;
}

button.tg_mi:focus-visible{
    outline: 2px solid var(--tg-green);
    outline-offset: -2px;
}

.tg_mi img,
.tg_mi video{
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* одно фото или видео — на всю ширину пузыря в своих пропорциях, высокое — не выше 560 px: кадр по центру,
   по бокам его размытая затемнённая копия (.tg_mi_bg), как у фото на детальной афиши. width: 100% обязателен —
   без него элемент сетки с aspect-ratio и max-height ужимался в узкую колонку у левого края */
.tg_media--1 .tg_mi{
    width: 100%;
    aspect-ratio: var(--r, 1.5);
    max-height: 560px;
    background-color: #1E2A23;
    isolation: isolate;
}

.tg_mi_bg{
    position: absolute;
    inset: -30px;
    z-index: -1;
    background: center / cover no-repeat;
    filter: blur(26px) brightness(.7) saturate(1.2);
}

.tg_media--1 .tg_mi img,
.tg_media--1 .tg_mi video{
    position: relative;
    object-fit: contain;
}

.tg_media--2{
    grid-template-columns: 1fr 1fr;
}

.tg_media--3{
    grid-template-columns: 1fr 1fr;
}

.tg_media--3 .tg_mi:first-child{
    grid-column: 1 / -1;
    aspect-ratio: 16 / 10;
}

.tg_media--4{
    grid-template-columns: 1fr 1fr;
}

/* 5 и больше: два крупных сверху, дальше по три; неполный последний ряд растягивается на всю ширину */
.tg_media--5{
    display: flex;
    flex-wrap: wrap;
}

.tg_media--5 .tg_mi{
    flex: 1 1 calc(33.333% - 3px);
    aspect-ratio: auto;
    height: 150px;
}

.tg_media--5 .tg_mi:nth-child(1),
.tg_media--5 .tg_mi:nth-child(2){
    flex-basis: calc(50% - 3px);
    height: 230px;
}

.tg_mi--play::after{
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .12);
    transition: background-color .2s;
}

.tg_mi--play:hover::after{
    background: rgba(0, 0, 0, .25);
}

.tg_media--5 .tg_play,
.tg_media--4 .tg_play,
.tg_media--3 .tg_mi:not(:first-child) .tg_play{
    transform: scale(.75);
}

.tg_mi--video video{
    background-color: transparent;
}

/* кнопка запуска одиночного видео: до нажатия — кадр, ▶ и длительность, без панели плеера */
.tg_vplay{
    position: absolute;
    inset: 0;
    z-index: 2;
    padding: 0;
    border: 0;
    background: linear-gradient(transparent 60%, rgba(0, 0, 0, .25));
    cursor: pointer;
}

.tg_vplay .tg_play{
    width: 68px;
    height: 68px;
    margin: -34px 0 0 -34px;
    background-color: rgba(0, 0, 0, .45);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    transition: background-color .2s;
}

.tg_vplay .tg_play::after{
    top: 22px;
    left: 27px;
    border-width: 12px 0 12px 19px;
}

.tg_vplay:hover .tg_play,
.tg_vplay:focus-visible .tg_play{
    background-color: rgba(0, 103, 56, .85);
}

.tg_mi--video.is-playing .tg_vplay,
.tg_mi--video.is-playing .tg_dur{
    display: none;
}

.tg_mi--external::after{
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .15);
    transition: background-color .2s;
}

.tg_mi--external:hover::after{
    background: rgba(0, 0, 0, .3);
}

.tg_play{
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 1;
    width: 56px;
    height: 56px;
    margin: -28px 0 0 -28px;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, .55);
}

.tg_play::after{
    content: "";
    position: absolute;
    top: 18px;
    left: 22px;
    border-style: solid;
    border-width: 10px 0 10px 16px;
    border-color: transparent transparent transparent #fff;
}

.tg_dur{
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 1;
    padding: 2px 7px;
    border-radius: 100px;
    background-color: rgba(0, 0, 0, .5);
    color: #fff;
    font-size: 12px;
    pointer-events: none;
}

.tg_mi--spoiler img,
.tg_mi--spoiler video{
    filter: blur(24px);
    transform: scale(1.1);
}

.tg_mi--spoiler::before{
    content: "Показать";
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 2;
    padding: 6px 14px;
    border-radius: 100px;
    background-color: rgba(0, 0, 0, .5);
    color: #fff;
    font-size: 13px;
    transform: translate(-50%, -50%);
}

/* ---------- опрос и прочее ---------- */

.tg_poll_q{
    font-size: 15px;
    font-weight: 600;
}

.tg_poll_kind{
    margin: 2px 0 8px;
    color: var(--tg-muted);
    font-size: 13px;
}

.tg_poll ul{
    margin: 0;
    padding: 0;
    list-style: none;
}

.tg_poll li{
    margin-bottom: 6px;
    padding: 8px 12px;
    border-radius: 8px;
    background-color: #EFF0F5;
    font-size: 14px;
}

.tg_poll_go,
.tg_other{
    display: inline-block;
    color: var(--tg-green);
    font-size: 14px;
    font-weight: 600;
}

/* ---------- низ поста ---------- */

/* отделён от текста линией и отступом — иначе «Открыть в Telegram» читалась как последняя строка поста */
.tg_foot{
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 12px 10px 0;
    padding-top: 10px;
    border-top: 1px solid #EFF0F5;
    font-size: 12px;
}

.tg_post > .tg_media + .tg_foot{
    border-top: 0;
    padding-top: 0;
}

.tg_open{
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--tg-muted);
    text-decoration: none;
    transition: color .2s;
}

.tg_open:hover{
    color: var(--tg-green);
}

.tg_time{
    color: var(--tg-faint);
    text-decoration: none;
}

/* ---------- подгрузка ---------- */

.tg_more{
    display: block;
    width: max-content;
    margin: 24px auto 0;
    padding: 12px 28px;
    border-radius: 100px;
    background-color: #fff;
    color: var(--tg-green);
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
}

.tg_more.is-loading{
    color: var(--tg-faint);
    pointer-events: none;
}

/* конец ленты: дальше — только в канале */
.tg_end{
    margin: 24px 0 0;
    padding: 28px 24px;
    border-radius: 20px;
    background-color: #fff;
    text-align: center;
}

.tg_end_title{
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.tg_end_text{
    margin: 8px 0 20px;
    color: var(--tg-muted);
    font-size: 14px;
    line-height: 1.5;
}

.tg_end_btn{
    display: inline-flex;
    padding: 0 32px;
}

/* «Новые посты»: появляется, когда пришли новые, а посетитель уже внизу ленты */
.tg_fresh{
    position: fixed;
    top: calc(var(--tg-head) + 12px);
    left: 50%;
    z-index: 20;
    padding: 10px 20px 10px 38px;
    border: 0;
    border-radius: 100px;
    background-color: var(--tg-green);
    box-shadow: 0 6px 18px rgba(0, 103, 56, .3);
    color: #fff;
    font: 600 14px "Montserrat", sans-serif;
    cursor: pointer;
    transform: translateX(-50%);
}

.tg_fresh::before{
    content: "";
    position: absolute;
    top: 17px;
    left: 18px;
    width: 8px;
    height: 8px;
    border-top: 2px solid #fff;
    border-left: 2px solid #fff;
    transform: rotate(45deg);
}

.tg_fresh[hidden]{
    display: none;
}

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

@media (max-width: 1100px){
    .tg_layout{
        grid-template-columns: minmax(0, 640px);
        gap: 20px;
    }

    .tg_side{
        order: 0;
        padding-top: 0;
    }

    .tg_channel{
        position: static;
    }
}

@media (max-width: 768px){
    .tg{
        padding: 90px 0 70px;
    }

    .tg_title{
        font-size: 28px;
    }

    .tg_channel{
        padding: 20px;
        border-radius: 20px;
    }

    .tg_channel_ava{
        width: 48px;
        height: 48px;
    }

    .tg_channel_title{
        font-size: 17px;
    }

    .tg_channel_text{
        margin: 14px 0 18px;
        font-size: 13px;
    }

    .tg_text{
        font-size: 14px;
    }

    .tg_media--5 .tg_mi{
        height: 100px;
    }

    .tg_media--5 .tg_mi:nth-child(1),
    .tg_media--5 .tg_mi:nth-child(2){
        height: 160px;
    }

}
