/* ─────────────────────────────────────────────────────────────
   Телепрограмма: мобильная лента каналов, sticky-дни, свайп.
   Подключается после home.css только на странице /site/tv-program.
   ───────────────────────────────────────────────────────────── */

.tv-guide-page {
    --tv-header-h: 71px;
    --tv-daybar-h: 48px;
    --tv-container-pad: 24px;
    --tv-fade-l: 0px;
    --tv-fade-r: 0px;
}

/* Лента каналов не должна растягивать страницу по горизонтали:
   у grid/flex-детей снимаем min-width: auto. */
.tv-guide-sidebar,
.tv-guide-channels,
.tv-guide-channels {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

.tv-guide-channels .tv-guide-channel-list {
    flex: 1 1 auto;
    min-height: 0;
}

.tv-guide-head-info {
    min-width: 0;
}

/* Элементы, которые нужны только мобильной версии. */
.tv-guide-daybar,
.tv-guide-swipehint,
.tv-guide-step {
    display: none;
}

/* Область программы: жест по горизонтали не мешает вертикальному скроллу. */
.tv-guide-swipe {
    position: relative;
    touch-action: pan-y;
    transition: transform .22s ease;
}

.tv-guide-swipe.is-dragging {
    transition: none;
}

.tv-guide-step {
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: #fff;
    color: var(--ink-2);
    cursor: pointer;
    transition: border-color .16s, color .16s, background .16s;
}

.tv-guide-step .icon {
    width: 17px;
    height: 17px;
}

.tv-guide-step:hover {
    border-color: #b9d2ea;
    color: var(--blue);
}

.tv-guide-step:active {
    background: var(--blue-soft);
}

.tv-guide-step:disabled {
    opacity: .38;
    cursor: default;
}

.tv-guide-channel:focus-visible,
.tv-guide-day:focus-visible,
.tv-guide-step:focus-visible,
.tv-guide-swipe:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: 2px;
}

@media (max-width: 991.98px) {
    /* ───── Каркас: одна колонка без горизонтального переполнения ───── */
    .tv-guide-page .tv-guide-layout {
        grid-template-columns: minmax(0, 1fr);
        gap: 14px;
    }

    .tv-guide-page .tv-guide-content {
        padding-top: .5rem;
    }

    /* Дни из hero переезжают в sticky-полосу под шапкой. */
    .tv-guide-days--hero {
        display: none;
    }

    /* ───── Sticky-полоса дней ───── */
    .tv-guide-daybar {
        display: block;
        position: sticky;
        top: var(--tv-header-h);
        z-index: 40;
        padding: 8px 0;
        border-bottom: 1px solid var(--line);
        background: rgba(245, 248, 252, .94);
        -webkit-backdrop-filter: blur(10px);
        backdrop-filter: blur(10px);
    }

    .tv-guide-daybar-inner {
        display: flex;
        align-items: center;
        gap: 10px;
    }

    .tv-guide-daybar-days {
        display: flex;
        flex: 1 1 auto;
        gap: 8px;
        min-width: 0;
        overflow-x: auto;
        padding-bottom: 2px;
        scroll-snap-type: x proximity;
        scrollbar-width: none;
    }

    .tv-guide-daybar-days::-webkit-scrollbar {
        display: none;
    }

    .tv-guide-daybar .tv-guide-day {
        flex: 0 0 auto;
        padding: 7px 13px;
        background: #fff;
        font-size: 12.5px;
        scroll-snap-align: start;
    }

    .tv-guide-daybar .tv-guide-day.is-active {
        border-color: var(--blue);
        background: var(--blue);
        color: #fff;
    }

    .tv-guide-daybar-nav {
        display: none;
        flex: 0 0 auto;
        gap: 6px;
    }

    /* Стрелки каналов включаются только когда скрипт готов. */
    .tv-guide-daybar-nav[data-tv-ready] {
        display: flex;
    }

    .tv-guide-daybar-nav[data-tv-ready] .tv-guide-step {
        display: inline-flex;
    }

    /* ───── Sticky-лента каналов ───── */
    .tv-guide-page .tv-guide-sidebar {
        position: sticky;
        top: calc(var(--tv-header-h) + var(--tv-daybar-h));
        z-index: 30;
        max-height: none;
        margin: 0 calc(var(--tv-container-pad) * -1);
        padding: 4px 0 0;
        border: 0;
        border-radius: 0;
        background: var(--bg);
        box-shadow: 0 10px 14px -14px rgba(9, 28, 55, .45);
    }

    .tv-guide-sidebar-head {
        display: none;
    }

    .tv-guide-page .tv-guide-channels {
        padding: 0;
    }

    .tv-guide-page .tv-guide-channel-list {
        display: flex;
        flex-wrap: nowrap;
        gap: 8px;
        padding: 4px var(--tv-container-pad) 8px;
        overflow-x: auto;
        overflow-y: hidden;
        scroll-snap-type: x mandatory;
        scroll-padding-inline: var(--tv-container-pad);
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
        scrollbar-width: none;
        -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 var(--tv-fade-l), #000 calc(100% - var(--tv-fade-r)), transparent 100%);
        mask-image: linear-gradient(90deg, transparent 0, #000 var(--tv-fade-l), #000 calc(100% - var(--tv-fade-r)), transparent 100%);
    }

    .tv-guide-page .tv-guide-channel-list::-webkit-scrollbar {
        display: none;
    }

    .tv-guide-page .tv-guide-channel-list.can-prev {
        --tv-fade-l: 26px;
    }

    .tv-guide-page .tv-guide-channel-list.can-next {
        --tv-fade-r: 26px;
    }

    .tv-guide-page .tv-guide-channel {
        flex: 0 0 auto;
        max-width: 62vw;
        height: 44px;
        gap: 8px;
        padding: 6px 15px 6px 7px;
        border: 1px solid var(--line);
        border-radius: var(--radius-pill);
        background: #fff;
        box-shadow: 0 1px 2px rgba(9, 28, 55, .05);
        scroll-snap-align: center;
        transition: background .16s, border-color .16s, box-shadow .16s, color .16s;
    }

    .tv-guide-page .tv-guide-channel.is-active {
        border-color: var(--blue);
        background: var(--blue);
        color: #fff;
        box-shadow: 0 10px 20px -10px rgba(43, 122, 191, .75);
    }

    .tv-guide-page .tv-guide-channel.is-active .tv-guide-channel-name {
        color: #fff;
    }

    .tv-guide-channel .tv-channel-logo,
    .tv-guide-channel .tv-channel-mark {
        width: 30px;
        height: 30px;
        max-width: 30px;
        max-height: 30px;
        border-radius: 50%;
        font-size: 9.5px;
    }

    .tv-guide-channel-name {
        font-size: 12.5px;
    }

    /* ───── Карточка программы ───── */
    .tv-guide-page .tv-guide-main {
        padding: 16px 14px;
        border-radius: 16px;
        overflow: hidden;
    }

    .tv-guide-page .tv-guide-head {
        align-items: center;
        gap: 12px;
        padding-bottom: 12px;
        margin-bottom: 4px;
    }

    .tv-guide-head h2 {
        font-size: 20px;
        letter-spacing: -.01em;
    }

    .tv-guide-swipehint {
        display: block;
        margin-top: 3px;
        color: var(--muted);
        font-size: 11.5px;
        line-height: 1.3;
    }

    .tv-guide-swipehint.is-hidden {
        display: none;
    }

    .tv-guide-back {
        padding-top: 0;
        font-size: 12px;
    }

    /* «Сейчас в эфире» - компактно и заметно. */
    .tv-guide-page .callout--live {
        gap: 10px;
        padding: 11px 12px;
        border-radius: 12px;
    }

    .tv-guide-page .callout--live .callout-icon {
        width: 26px;
        height: 26px;
        border-radius: 8px;
    }

    .tv-guide-page .callout--live .callout-body p {
        font-size: 12.5px;
    }

    .tv-guide-page .callout--live .callout-meta {
        font-size: 11.5px;
    }

    /* ───── Компактные карточки передач ───── */
    .tv-guide-page .tv-program-list {
        margin-top: 6px;
    }

    .tv-guide-page .tv-program-item {
        grid-template-columns: 50px minmax(0, 1fr);
        gap: 8px 12px;
        padding: 11px 0;
    }

    .tv-guide-page .tv-program-time b {
        font-size: 15px;
    }

    .tv-guide-page .tv-program-time span {
        font-size: 10.5px;
    }

    .tv-guide-page .tv-program-body h3 {
        margin-bottom: 2px;
        font-size: 13.5px;
        line-height: 1.3;
    }

    .tv-guide-page .tv-program-body p {
        display: -webkit-box;
        overflow: hidden;
        font-size: 12px;
        line-height: 1.45;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
    }

    .tv-guide-page .tv-program-now {
        grid-column: 2;
        justify-self: start;
        padding: 2px 7px;
        font-size: 10px;
    }

    /* Передача в эфире: акцентная карточка. */
    .tv-guide-page .tv-program-item.is-now {
        padding: 12px;
        border-left-width: 3px;
        border-radius: 12px;
        background: linear-gradient(90deg, #fff6e8 0%, #fffdfa 100%);
    }

    .tv-guide-page .tv-program-item.is-now .tv-program-time b {
        font-size: 16px;
    }

    .tv-guide-page .tv-guide-source {
        padding-top: 14px;
        font-size: 10.5px;
    }
}

@media (max-width: 767.98px) {
    .tv-guide-page {
        --tv-container-pad: 18px;
    }
}

@media (max-width: 575.98px) {
    .tv-guide-daybar-inner {
        gap: 8px;
    }

    .tv-guide-page .tv-guide-head h2 {
        font-size: 19px;
    }

    .tv-guide-page .tv-guide-main {
        padding: 14px 12px;
    }

    .tv-guide-page .tv-program-item {
        grid-template-columns: 46px minmax(0, 1fr);
        gap: 8px 10px;
    }
}

/* ───── Доступность: уважаем настройку «меньше движения» ───── */
@media (prefers-reduced-motion: reduce) {
    .tv-guide-swipe,
    .tv-guide-swipe.is-dragging {
        transition: none;
    }

    .tv-guide-page .tv-guide-channel,
    .tv-guide-day,
    .tv-guide-step {
        transition: none;
    }
}
