/* Единые стили для страниц терминов глоссария */

/* Основной контейнер */
.term-page-main {
    padding-top: 6rem;
    max-width: 1400px;
    margin: 0 auto;
    padding-left: 2rem;
    padding-right: 2rem;
}

/* Двухколоночный макет */
.term-content-wrapper {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 10px;
    margin-top: 2rem;
    /* Предотвращаем CLS - резервируем место для контента */
    min-height: 400px;
    contain: layout;
}

/* Боковая панель с содержанием */
.term-sidebar {
    position: sticky;
    top: 6rem;
    height: fit-content;
    max-height: none;
    overflow: visible;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.term-toc {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    position: relative;
    overflow: visible;
}

.term-toc h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--foreground);
}

.term-toc-nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.term-toc-nav a {
    color: var(--muted-foreground);
    text-decoration: none;
    font-size: 0.9rem;
    padding: 0.5rem 0.75rem;
    border-radius: calc(var(--radius) - 2px);
    transition: all 0.2s ease;
    display: block;
}

.term-toc-nav a:hover {
    background: var(--muted);
    color: var(--primary);
}

.term-toc-nav a.active {
    background: var(--primary);
    color: var(--primary-foreground);
    font-weight: 500;
}

/* Блок со статьями, в которых используется термин */
.term-related-articles {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-top: 10px;
    position: relative;
}

.term-related-articles h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--foreground);
}

.term-related-nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.term-related-link {
    color: var(--muted-foreground);
    text-decoration: none;
    font-size: 0.9rem;
    padding: 0.5rem 0.75rem;
    border-radius: calc(var(--radius) - 2px);
    transition: all 0.2s ease;
    display: block;
}

.term-related-link:hover {
    background: var(--muted);
    color: var(--primary);
}

/* Основная колонка с контентом */
.term-content-column {
    min-width: 0; /* Предотвращает переполнение */
    background: var(--card);
    padding: 2.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

/* Breadcrumbs */
.term-breadcrumbs {
    margin-bottom: 2rem;
    font-size: 0.9rem;
}

.term-breadcrumbs a {
    color: var(--primary);
    text-decoration: none;
}

.term-breadcrumbs a:hover {
    text-decoration: underline;
}

.term-breadcrumbs span {
    margin: 0 0.5rem;
    color: var(--muted-foreground);
}

.term-breadcrumbs .current {
    color: var(--muted-foreground);
}

/* Заголовок статьи */
.term-header {
    margin-bottom: 3rem;
}

.term-title {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--foreground);
    line-height: 1.2;
}

.term-meta {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    color: var(--muted-foreground);
    font-size: 0.9rem;
}

/* Контент статьи */
.term-article {
    line-height: 1.9;
    color: var(--foreground);
    font-size: 1.05rem;
    max-width: 100%;
}

/* Секции */
.term-section {
    margin-bottom: 3.5rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border);
}

.term-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.term-section h2 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 1.75rem;
    margin-top: 0;
    color: var(--foreground);
    line-height: 1.3;
    letter-spacing: -0.02em;
}

.term-section h2:first-child {
    margin-top: 0;
}

.term-section p {
    font-size: 1.05rem;
    margin-bottom: 1.5rem;
    color: var(--foreground);
    line-height: 1.9;
    text-align: justify;
    text-justify: inter-word;
}

.term-section p:last-child {
    margin-bottom: 0;
}

.term-section h3 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-top: 2.5rem;
    margin-bottom: 1.25rem;
    color: var(--foreground);
    line-height: 1.4;
}

.term-section h3:first-child {
    margin-top: 0;
}

/* Списки */
.term-list {
    list-style: none;
    padding: 0;
    margin: 1.5rem 0 2rem 0;
}

.term-list li {
    margin-bottom: 1rem;
    padding-left: 1.75rem;
    padding-right: 0.5rem;
    position: relative;
    color: var(--foreground);
    line-height: 1.8;
    font-size: 1.05rem;
}

.term-list li:last-child {
    margin-bottom: 0;
}

.term-list li:before {
    content: "•";
    position: absolute;
    left: 0.5rem;
    color: var(--primary);
    font-weight: 700;
    font-size: 1.2rem;
    line-height: 1.8;
}

/* Highlight box (ключевые особенности) */
.term-highlight-box {
    background: var(--muted);
    padding: 2rem;
    border-radius: var(--radius);
    margin: 2rem 0;
    border-left: 4px solid var(--primary);
    box-shadow: var(--shadow-xs);
}

.term-highlight-box h4 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--foreground);
}

.term-highlight-box ul {
    list-style: none;
    padding: 0;
}

.term-highlight-box li {
    margin-bottom: 1rem;
    padding-left: 1.75rem;
    padding-right: 0.5rem;
    position: relative;
    color: var(--foreground);
    line-height: 1.8;
    font-size: 1.05rem;
}

.term-highlight-box li:last-child {
    margin-bottom: 0;
}

.term-highlight-box li:before {
    content: "✓";
    position: absolute;
    left: 0;
    color: var(--primary);
    font-weight: 600;
}

/* Example box (практический пример) */
.term-example-box {
    background: var(--muted);
    padding: 2rem;
    border-radius: var(--radius);
    margin: 2rem 0;
    box-shadow: var(--shadow-xs);
}

.term-example-box h4 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--foreground);
}

.term-example-box p {
    color: var(--foreground);
    margin-bottom: 0;
    line-height: 1.9;
    font-size: 1.05rem;
}

/* Адаптивность */
@media (max-width: 1024px) {
    .term-content-wrapper {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
    
    .term-sidebar {
        position: relative;
        top: 0;
        max-height: none;
        /* Резервируем место для предотвращения CLS */
        min-height: 200px;
    }
    
    .term-toc {
        position: relative;
        top: 0;
    }
    
    .term-related-articles {
        position: relative;
        top: 0;
        margin-top: 1.5rem;
    }
}

@media (max-width: 768px) {
    .term-page-main {
        padding-top: 5rem;
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    .term-title {
        font-size: 2rem;
    }
    
    .term-section h2 {
        font-size: 1.5rem;
    }
    
    .term-section h3 {
        font-size: 1.25rem;
    }
    
    .term-section p {
        font-size: 1rem;
    }
    
    /* Исправление CLS - одноколоночный макет на мобильных */
    .term-content-wrapper {
        grid-template-columns: 1fr;
        gap: 1.5rem;
        /* Предотвращаем смещение - резервируем минимальное место для контента */
        min-height: 300px;
    }
    
    /* Скрываем sidebar на мобильных, чтобы избежать смещения */
    .term-sidebar {
        display: none;
    }
    
    .term-content-column {
        padding: 1.5rem;
    }
    
    .term-section {
        margin-bottom: 2.5rem;
        padding-bottom: 1.5rem;
    }
    
    .term-section h2 {
        font-size: 1.75rem;
        margin-bottom: 1.5rem;
    }
    
    .term-section p {
        font-size: 1rem;
        text-align: left;
    }
    
    .term-article {
        font-size: 1rem;
        line-height: 1.8;
    }
}

/* Блок рекомендуемых статей - на всю ширину */
.term-recommended-articles {
    width: 1336px;
    max-width: 1336px;
    /* Резервируем место для предотвращения CLS при динамической загрузке */
    min-height: 400px;
    margin: 10px auto 0;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2.5rem;
    box-shadow: var(--shadow-sm);
    box-sizing: border-box;
    overflow: visible;
}

.term-recommended-wrapper {
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    overflow: hidden;
}

.term-recommended-articles h2 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 3rem;
    text-align: center;
    color: var(--foreground);
}

/* Карусель для рекомендуемых статей */
.term-recommended-carousel {
    position: relative;
    width: 100%;
    overflow: hidden;
    /* Обеспечиваем пространство для кнопок */
    padding: 0;
    /* Резервируем место для предотвращения CLS при загрузке контента */
    min-height: 300px;
}

.term-recommended-carousel-container {
    overflow: hidden;
    width: 100%;
    position: relative;
    padding-left: 80px;
    padding-right: 80px;
    display: flex;
    justify-content: center;
    align-items: center;
    /* Обеспечиваем пространство для содержимого карточек */
    min-height: 400px;
    /* Скрываем карточки, которые выходят за пределы контейнера */
    clip-path: inset(0);
}

.term-recommended-carousel-track {
    display: flex;
    gap: 2rem;
    transition: transform 0.3s ease;
    width: auto;
    min-width: 100%;
    justify-content: center;
    align-items: stretch;
    /* Скрываем карточки, которые выходят за пределы видимой области */
    position: relative;
    /* Резервируем место для предотвращения CLS */
    min-height: 300px;
}

.term-recommended-card {
    flex: 0 0 calc(33.333% - 1.34rem + 30px);
    min-width: calc(33.333% - 1.34rem + 30px);
    max-width: calc(33.333% - 1.34rem + 30px);
    background: var(--card);
    border-radius: var(--radius);
    padding: 2rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
    display: flex;
    flex-direction: column;
    /* Все карточки одной высоты - растягиваются на всю высоту трека */
    align-self: stretch;
    /* Обеспечиваем минимальную высоту */
    min-height: 100%;
}

.term-recommended-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.term-recommended-card a {
    text-decoration: none;
    color: inherit;
}

.term-recommended-card h3 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--foreground);
    line-height: 1.3;
}

.term-recommended-card h3 a {
    color: var(--foreground);
    transition: color 0.2s ease;
}

.term-recommended-card h3 a:hover {
    color: var(--primary);
}

.term-recommended-card p {
    color: var(--muted-foreground);
    margin-bottom: 1.5rem;
    line-height: 1.6;
    flex-grow: 1;
    /* Ограничение описания до 4 строк с многоточием */
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.term-recommended-meta {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--muted-foreground);
    margin-bottom: 1.5rem;
}

/* Кнопка "Читать" в карточке статьи */
.term-recommended-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    background: var(--primary);
    color: var(--primary-foreground);
    border: 1px solid var(--primary);
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s ease;
    cursor: pointer;
    margin-top: auto;
}

.term-recommended-btn:hover {
    background: var(--primary);
    color: var(--primary-foreground);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.term-recommended-btn:active {
    transform: translateY(0);
}

/* Кнопки навигации карусели */
.term-carousel-btn {
    position: absolute;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--foreground);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.2s ease, z-index 0.2s ease, opacity 0.2s ease;
    box-shadow: var(--shadow-md);
    pointer-events: auto;
    outline: none;
    margin: 0;
    padding: 0;
    /* Центрирование относительно контейнера с карточками - обе кнопки на одной высоте */
    top: 50%;
    transform: translateY(-50%);
    transform-origin: center center;
    /* Предотвращаем обрезание при увеличении */
    overflow: visible;
    /* Позиционирование относительно центра карточек */
    margin-top: 0;
}

.term-carousel-btn-prev,
.term-carousel-btn-next {
    /* Обе кнопки на одной высоте - центрируются по вертикали */
    top: 50%;
    transform: translateY(-50%);
    margin-top: 0;
}

.term-carousel-btn-prev {
    left: 8px;
}

.term-carousel-btn-next {
    right: 8px;
}

.term-carousel-btn:hover {
    background: var(--primary);
    color: var(--primary-foreground);
    border-color: var(--primary);
    transform: translateY(-50%) scale(1.1);
    z-index: 101;
    /* Кнопка при наведении не должна перекрывать содержимое */
    box-shadow: var(--shadow-lg);
}

.term-carousel-btn:active {
    transform: translateY(-50%) scale(0.95);
}

.term-carousel-btn svg {
    width: 20px;
    height: 20px;
    pointer-events: none; /* Позволяет кликам проходить через SVG к кнопке */
}

/* Адаптивность для блока рекомендуемых статей */
@media (max-width: 1400px) {
    .term-recommended-articles {
        width: calc(100% - 4rem);
        max-width: calc(100% - 4rem);
        margin-left: 2rem;
        margin-right: 2rem;
    }
}

@media (max-width: 768px) {
    .term-recommended-articles {
        width: calc(100% - 2rem);
        max-width: calc(100% - 2rem);
        margin-left: 1rem;
        margin-right: 1rem;
        padding: 1.5rem;
        margin-top: 10px;
        /* Резервируем место для предотвращения CLS на мобильных */
        min-height: 350px;
    }
    
    .term-recommended-articles h2 {
        font-size: 2rem;
        margin-bottom: 2rem;
    }
    
    .term-recommended-carousel {
        /* Резервируем место для карусели на мобильных */
        min-height: 250px;
    }
    
    .term-recommended-carousel-track {
        /* Резервируем место для трека на мобильных */
        min-height: 250px;
    }
    
    .term-recommended-card {
        flex: 0 0 100%;
        min-width: 100%;
        max-width: 100%;
    }
    
    .term-carousel-btn {
        width: 40px;
        height: 40px;
    }
    
    .term-carousel-btn-prev {
        left: -20px;
    }
    
    .term-carousel-btn-next {
        right: -20px;
    }
    
    .term-recommended-card {
        padding: 1.5rem;
    }
    
    .term-recommended-card h3 {
        font-size: 1.25rem;
    }
    
    .term-recommended-btn {
        padding: 0.625rem 1.25rem;
        font-size: 0.9rem;
        width: 100%;
    }
}

