header.header--absolute {
    position: sticky;
}

section #subtitle {
    width: 100%;
    text-align: center;
}

section #subtitle h2 {
    display: inline-block;
    font-family: "M PLUS 1p", sans-serif;
    font-size: 36px;
    line-height: 60px;
    color: #f88d02;
    text-transform: uppercase;
}

#popular-lessons {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    color: white;
    position: relative;
}

#popular-lessons .swiper-wrapper {
    display: flex;
    align-items: stretch;
}

#popular-lessons .swiper-slide {
    display: flex;
    flex-direction: column;
    height: auto;
    padding-top: 30px;
    /* важно! */
}

#popular-lessons .lesson-card {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
}

#popular-lessons .lesson-card {
    display: block;
    color: white;
    transition: transform 0.2s;
    margin: 10px;
}

@media (min-width: 1024px) {
    #popular-lessons .lesson-card:hover {
        transform: translateY(-5px);
    }
}

#popular-lessons .lesson-card-content {
    background: transparent;
    border: 1px solid white;
    border-radius: 10px;
    height: 100%;
    padding: 15px;
    min-height: 175px;
    display: flex;
    flex-direction: column;
}

/* Desktop Version */
#popular-lessons .card-top-row {
    display: flex;
    margin-bottom: 15px;
}

#popular-lessons .lesson-image {
    position: relative;
    width: 110px;
    height: 110px;
    margin-top: -30px;
    flex-shrink: 0;
}

#popular-lessons .lesson-image img {
    width: 100%;
    height: 100%;
    border-radius: 8px;
    object-fit: cover;
}

#popular-lessons .lesson-details {
    flex-grow: 1;
    padding-left: 15px;
    display: -webkit-box;
    /* Включает режим flexbox с ограничением строк */
    -webkit-line-clamp: 3;
    /* Максимум 3 строки текста */
    -webkit-box-orient: vertical;
    /* Вертикальная ориентация */
    overflow: hidden;
    /* Добавить многоточие */
    line-height: 1.2em;
    /* Высота строки (нужно для расчёта) */
}

#popular-lessons .lesson-card h3 {
    color: white;
    font-size: 15px;
    margin-bottom: 8px;
    font-weight: bold;
}

#popular-lessons .lesson-card p {
    color: #888;
    font-size: 14px;
    margin-bottom: 0;
    /* Скрыть лишний текст */
    text-overflow: ellipsis;
}

#popular-lessons .lesson-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
    width: 100%;
}

.price .current,
.price .old {
    font-weight: bold;
    color: #ff8a00;
}

.price .current {
    font-size: 18px;
}

.price .old {
    font-size: 14px;
    text-decoration: line-through;
    text-decoration-thickness: 2px;
    margin-top: -10px;
}

#popular-lessons .duration {
    color: #888;
    font-size: 14px;
    margin-left: auto;
    margin-right: 8px;
    display: flex;
    align-items: center;
}

#popular-lessons .duration span {
    margin-left: 3px;
}

#popular-lessons .add-to-cart-btn {
    background: #2a2a2a;
    border: none;
    color: #ff8a00;
    padding: 8px 15px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
    z-index: 10;
}

#popular-lessons .swiper {
    padding: 30px 50px;
}

#popular-lessons .swiper-button-next {
    right: -40px;
    padding-top: 30px;
}

#popular-lessons .swiper-button-prev {
    left: -40px;
    padding-top: 30px;
}

#popular-lessons .swiper-button-next,
#popular-lessons .swiper-button-prev {
    color: #3d3d47;
}

#popular-lessons .swiper-button-next:after,
#popular-lessons .swiper-button-prev:after {
    font-size: 24px;
}

/* Mobile view */
@media (max-width: 767px) {
    #popular-lessons .lesson-card-content {
        flex-direction: column;
        padding: 15px;
        padding-top: 30px;
        border-radius: 15px;
        background-color: transparent;
    }

    #popular-lessons .card-top-row {
        flex-direction: column;
        margin-bottom: 15px;
    }

    #popular-lessons .lesson-image {
        width: 100%;
        height: auto;
        margin-top: -45px;
        position: relative;
        border-radius: 8px;
        margin-bottom: 15px;
    }

    #popular-lessons .lesson-image img {
        width: 100%;
        height: auto;
        aspect-ratio: 1/1;
        object-fit: cover;
    }

    #popular-lessons .lesson-details {
        padding: 0;
    }

    #popular-lessons .lesson-bottom {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
    }

    #popular-lessons .lesson-bottom-row {
        display: flex;
        width: 100%;
        justify-content: space-between;
        margin-bottom: 10px;
    }

    #popular-lessons .add-to-cart-btn {
        width: 100%;
        margin-left: 0;
        text-align: center;
    }
}

#lessons .lessonsBlock {
    display: grid;
    grid-template-columns: 320px 7fr;
    column-gap: 1rem;
    padding: 30px;
}

#lessons .categories-filter a {
    font-size: 15px;
    text-align: center;
    word-wrap: break-word;
    padding: 0 !important;
    display: block;
}

#lessons .categories-filter a div {
    text-transform: lowercase;
}

#lessons .categories-filter a div::first-letter {
    text-transform: uppercase;
}

#lessons .categories-filter a.active {
    color: #ff963a;
}

#lessons .categories-filter a.active .picture {
    -webkit-box-shadow: 0px 0 0 4px #ff963a;
    box-shadow: 0px 0 0 4px #ff963a;
}

#lessons .categories-filter a.active .picture:after {
    display: none;
}

#lessons .categories-filter .picture {
    height: 0;
    padding-bottom: calc(100% - 28px);
    -webkit-box-shadow: 0px 0 0 2px #6c6d74;
    box-shadow: 0px 0 0 2px #6c6d74;
    border-radius: 13px;
    margin: 4px 14px 11.5px 14px;
    position: relative;
    overflow: hidden;
}

#lessons .categories-filter .picture:after {
    width: 100%;
    height: 100%;
    position: absolute;
    left: 0;
    top: 0;
    content: "";
    background-color: #13152054;
}

#lessons .categories-filter .nav-link {
    display: flex;
}

#lessons .categories-filter .nav-link:focus,
#lessons .categories-filter .nav-link:hover {
    text-decoration: none;
}

/* ========================== SIDEBAR ========================== */
#lessons .sidebar {
    position: sticky;
    top: 75px;
    max-height: 85vh;
    overflow-y: auto;

    width: auto;
    background-color: transparent;
    border: 1px solid white;
    border-radius: 12px;
    padding: 1rem;
    height: min-content;
}

/* Стилизация scroll для webkit браузеров */
#lessons .sidebar::-webkit-scrollbar {
    width: 6px;
    /* тонкий скролл */
    background-color: transparent;
    /* прозрачная полоса */
}

#lessons .sidebar::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.8);
    /* белый ползунок с прозрачностью */
    border-radius: 3px;
    /* скругление углов */
    border: 1px solid rgba(255, 255, 255, 0.5);
    /* тонкая обводка */
}

#lessons .sidebar::-webkit-scrollbar-thumb:hover {
    background-color: rgba(255, 255, 255, 1);
    /* при наведении ярче */
}

/* Стилизация скролла для Firefox */
#lessons .sidebar {
    scrollbar-width: thin;
    /* тонкий скролл */
    scrollbar-color: rgba(255, 255, 255, 0.8) transparent;
    /* цвет ползунка и полосы */
}

#lessons .sidebar hr {
    width: 30%;
    border: 1px solid white;
    margin-left: auto;
    margin-right: auto;
}

#lessons .sidebar .categories-list hr {
    width: 30%;
    display: none;
}

#lessons .search-container {
    position: relative;
}

#lessons .search-container-mobile {
    display: none;
}

#lessons .search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    width: 18px;
    height: 18px;
}

#lessons .filter-icon {
    color: #9ca3af;
    width: 18px;
    height: 18px;
}

#lessons .search-input {
    width: 100%;
    background-color: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-radius: 8px;
    padding: 12px 16px 12px 40px;
    color: #ffffff;
    font-size: 14px;
    transition: border-color 0.2s;
}

#lessons .search-input::placeholder {
    color: #6b7280;
}

#lessons .search-input:focus {
    outline: none;
    border-color: #3a3a3a;
}

#lessons .categories-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

#lessons .category-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 8px;
    text-align: left;
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
    font-weight: 500;
}

#lessons .category-item:hover {
    color: #ffaa3a;
    background-color: #1a1a1a;
}

#lessons .category-item.active {
    background-color: #2a2a2a;
    color: #d67900;
    border: 1px solid #3a3a3a;
}

#categoryList button.category-item.category-all-lessons .category-icon,
#categoryList button.category-item.category-all-lessons.active .category-icon,
#categoryList button.category-item.category-all-sets .category-icon,
#categoryList button.category-item.category-all-sets.active .category-icon {
    -webkit-transition: 0.5s;
    transition: 0.5s;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

#categoryList button.category-item.category-all-lessons .category-icon {
    background: url("/wp-content/uploads/2021/07/All-lessons-Inactive.png");
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

#categoryList button.category-item.category-all-lessons:hover,
#categoryList button.category-item.category-all-lessons.active:hover {
    .category-icon {
        background-image: url("/wp-content/uploads/2021/07/All-lessons-Hover.png");
    }
}

#categoryList button.category-item.category-all-lessons.active .category-icon {
    background-image: url("/wp-content/uploads/2021/07/All-lessons-Active.png");
}


#categoryList button.category-item.category-all-sets .category-icon {
    background: url("/wp-content/uploads/2021/07/Sets-Inactive.png");
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

#categoryList button.category-item.category-all-sets:hover,
#categoryList button.category-item.category-all-sets.active:hover {
    .category-icon {
        background-image: url("/wp-content/uploads/2021/07/Sets-Hover.png");
    }
}

#categoryList button.category-item.category-all-sets.active .category-icon {
    background-image: url("/wp-content/uploads/2021/07/Sets-Active.png");
}

#lessons .category-icon {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    object-fit: cover;
}

@media (max-width: 1024px) {
    #lessons .title {
        margin-bottom: 0;
    }

    #popular-lessons {
        padding: 0;
        margin: 0 -15px;
    }

    #popular-lessons .swiper-button-next,
    #popular-lessons .swiper-button-prev {
        display: none;
    }

    /* Сам сайдбар становится попапом на весь экран */
    #lessons .sidebar {
        position: fixed;
        /* Отступ сверху */
        top: 30%;
        left: 0;
        width: 100vw;
        /* Высота с учётом отступа */
        /* Учитываем safe area снизу для iPhone: */
        height: calc(75vh - env(safe-area-inset-bottom, 24px));
        padding: 0 16px calc(24px + env(safe-area-inset-bottom)) 16px;
        /* плавный скролл на iOS */
        -webkit-overflow-scrolling: touch;
        background-color: rgba(10, 10, 10, 0.95);
        z-index: 10000;
        /* Вертикальный padding снизу и горизонтальный */
        padding: 0 16px 24px;
        display: flex;
        flex-direction: column;
        align-items: center;
        overflow-y: scroll;

        display: none;
    }

    #lessons .overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background-color: rgba(0, 0, 0, 0.5);
        /* полупрозрачный черный */
        z-index: 9000;
        /* ниже, чем у sidebar - у sidebar z-index 1000 */
        /* если нужно, чтобы клики проходили */
    }

    /* Контейнер поиска шириной на всю */
    #lessons .sidebar .search-container {
        width: 100%;
    }

    #lessons .search-container-mobile {
        position: relative;
        display: grid;
        grid-template-columns: 9fr 1fr;
        column-gap: 15px;
        align-items: center;
        justify-content: center;
        justify-items: end;
    }

    #lessons .search-container-mobile .filter-field {
        text-align: center;
        background-color: #1a1a1a;
        border: 1px solid #2a2a2a;
        border-radius: 8px;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
    }

    #lessons .sidebar .search-container>div {
        position: relative;
        width: 100%;
    }

    #lessons div.search-container-mobile div.search-field {
        position: relative;
        width: 100%;
    }

    #lessons .sidebar .search-icon,
    #lessons .sidebar .search-input {
        display: none;
    }

    #lessons .sidebar>hr {
        width: 17%;
        border: 2px solid #ffffff47;
        border-radius: 15px;
    }

    #lessons .sidebar .categories-list hr {
        display: block;
        border-radius: 15px;
        margin: 10px auto;
    }

    /* Список категорий в один ряд с прокруткой */
    #lessons .sidebar .categories-list {
        display: flex;
        flex-direction: column;
        width: 100%;
        overflow-y: auto;
    }

    /* Кнопки категорий с картинкой и текстом в ряд */
    #lessons .sidebar .category-item {
        flex: 0 0 auto;
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-radius: 8px;
        background-color: transparent;
        color: #9ca3af;
        cursor: pointer;
        font-size: 14px;
        font-weight: 500;
        border: none;
        white-space: nowrap;
    }

    #lessons .sidebar .category-item.active,
    #lessons .sidebar .category-item:hover {
        color: #ffffff;
        background-color: #3a3a3a;
    }

    #lessons .sidebar .category-icon {
        width: 24px;
        height: 24px;
        border-radius: 50%;
        object-fit: cover;
    }
}


/* ========================== БЛОК УРОКОВ =========================== */

.products-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    /* отступы между карточками */
    margin-left: 0;
    margin-right: 0;
    height: fit-content;
}

.products-grid .food-card.hide {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.95);
    /* избегаем анимировать свойства layout */
    display: none;
    /* можно скрывать сразу, можно через JS с таймаутом */
}

.products-grid .food-card {
    display: block;
    opacity: 1;
    transition: opacity 0.3s ease, transform 0.3s ease;
    transform-origin: top center;
    background-color: #1a1a1a;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #2a2a2a;
    transition: all 0.3s;
    display: flex;
    flex-direction: column;

    content-visibility: auto;
    contain-intrinsic-size: 300px;
}

.products-grid .food-card:hover {
    border-color: #3a3a3a;
}

.products-grid .food-image-container {
    position: relative;
    aspect-ratio: 4/3;
    overflow: hidden;
}

.products-grid .food-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.products-grid .food-card:hover .food-image {
    transform: scale(1.05);
}

.products-grid .food-tag {
    position: absolute;
    top: 12px;
    left: 12px;
    padding: 4px 12px;
    border-radius: 20px;
    color: #ffffff;
    font-size: 12px;
    font-weight: 500;
}

.products-grid .food-tag.orange {
    background-color: #f97316;
}

.products-grid .food-tag.green {
    background-color: #16a34a;
}

.products-grid .food-tag.blue {
    background-color: #3b82f6;
}

.products-grid .food-info {
    padding: 8px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    justify-content: space-between;
}

.products-grid .food-name {
    font-size: 18px;
    line-height: 1.3;
    /* height: 48px; */
    /* примерно 18*1.3*2 */
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    /* обрезка текста по 2 строки */
    -webkit-box-orient: vertical;
    word-break: break-word;
}

.products-grid .food-description {
    color: #9ca3af;
    font-size: 14px;
    margin-bottom: 16px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.products-grid .food-meta {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
}

#lessons div.lessonsBlock .products-grid div.food-info div.item-price,
#lessons div.lessonsBlock .products-grid div.food-info div.item-price * {
    margin-top: 0;
    font-size: 17px;
}

.products-grid .food-time {
    display: flex;
    align-items: center;
    gap: 4px;
    color: #9ca3af;
    font-size: 13px;
    word-spacing: -2px;
}

.products-grid .clock-icon {
    width: 14px;
    height: 14px;
}

.products-grid .add-to-cart-btn {
    width: 100%;
    background-color: #2a2a2a;
    border: 1px solid #3a3a3a;
    color: #ff8a00;
    padding: 10px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    align-self: stretch;
    z-index: 1;
}

.products-grid .add-to-cart-btn:hover,
#popular-lessons .add-to-cart-btn:hover {
    background-color: #3a3a3a;
    border-color: #4a4a4a;
}

.products-grid .add-to-cart-btn:active,
#popular-lessons .add-to-cart-btn:active {
    background-color: #1a1a1a;
}

.products-grid .add-to-cart-btn.added,
#popular-lessons .add-to-cart-btn.added {
    background-color: #af5b0063;
    color: #f58905;
}

.products-grid .add-to-cart-btn.added:hover,
#popular-lessons .add-to-cart-btn.added:hover {
    background-color: #af5a008c;
    color: #f57105;
}

.products-grid .add-to-cart-btn.added:active,
#popular-lessons .add-to-cart-btn.added:active {
    background-color: #af5a0050;
    color: #a34900;
}

.products-grid .add-to-cart-btn.bought,
#popular-lessons .add-to-cart-btn.bought {
    background-color: #136632;
    color: #00ff5d;
}

/* Адаптивность для мобильного */
@media (max-width: 768px) {
    #lessons .lessonsBlock {
        grid-template-columns: 1fr;
        padding: 30px 0px;
    }

    .products-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }
}