/* ============================================================
   СТИЛИ ДЛЯ СТРАНИЦЫ /math/ (СЕЧЕНИЯ МНОГОГРАННИКОВ)
   ============================================================ */

/* ---- ОБЩИЕ БЛОКИ ---- */
.page-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 24px 40px;
}

/* ---- БЛОК 1: ВСТУПЛЕНИЕ ---- */
.intro-block {
    padding: 20px 0 20px;
}

.intro-block h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 16px;
    line-height: 1.3;
}

.intro-block p {
    font-size: 1rem;
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 12px;
}

.intro-block strong {
    color: var(--text-primary);
}

.info-box {
    background: var(--bg-canvas);
    padding: 20px 24px;
    border-radius: 12px;
    margin: 16px 0;
    border-left: 4px solid var(--accent-chart);
}

.info-box h4 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-top: 0;
    margin-bottom: 12px;
}

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

.info-box ul li {
    padding: 4px 0;
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.info-box ul li strong {
    color: var(--text-primary);
}

/* ---- БЛОК 2: ЗАГОЛОВКИ СЕКЦИЙ ---- */
.section-header {
    text-align: center;
    padding: 40px 0 12px;
}

.section-header h2 {
    font-size: 1.6rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.section-header p {
    font-size: 1rem;
    color: var(--text-secondary);
    margin: 0;
}

/* ---- БЛОК 3: СЕТКА ФИГУР (АВТОМАТИЧЕСКОЕ ПОСТРОЕНИЕ) ---- */
.figures-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    padding: 8px 0 16px;
}

.figure-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 12px 25px;
    background: var(--bg-base);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    text-decoration: none;
    transition: all 0.25s ease;
}

.figure-card:hover {
    border-color: var(--border-focus);
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.06);
}

.figure-card img {
    width: 80px;
    height: auto;
    display: block;
    margin-bottom: 10px;
}

.figure-card span {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    text-align: center;
}

/* ---- БЛОК 4: ТРЕНАЖЕРЫ (САМОСТОЯТЕЛЬНОЕ ПОСТРОЕНИЕ) ---- */
.trainers-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    padding: 8px 0 16px;
    max-width: 780px;
    margin: 0 auto;
}

.trainer-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 12px 14px;
    background: var(--bg-base);
    border: 2px solid var(--border-light);
    border-radius: 12px;
    text-decoration: none;
    transition: all 0.25s ease;
}

.trainer-card:hover {
    border-color: var(--border-focus);
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.08);
}

.trainer-card img {
    width: 100%;
    max-width: 200px;
    height: 170px;
    object-fit: cover;
    display: block;
    margin-bottom: 10px;
    border-radius: 6px;
}

.trainer-card span {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-primary);
}

.trainer-card .trainer-card-go {
    display: inline-block;
    margin-top: 12px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1;
    color: var(--btn-primary-text);
    background: var(--btn-primary-bg);
    transition: background 0.25s ease;
}

.trainer-card:hover .trainer-card-go {
    background: var(--btn-primary-hover);
}

/* ============================================================
   АЛГОРИТМ ПОСТРОЕНИЯ СЕЧЕНИЙ (МЕТОД СЛЕДОВ)
   ============================================================ */

.algorithm-block {
    padding: 40px 0 30px;
    background: var(--bg-canvas);
}

.algorithm-block .container {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 20px;
}

.algorithm-block h2 {
    text-align: center;
    font-size: 1.6rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.alg-desc {
    text-align: center;
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

/* ---- ВКЛАДКИ ---- */
.alg-tabs {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.alg-tab {
    padding: 10px 24px;
    background: var(--bg-base);
    border: 1px solid var(--border-light);
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.25s ease;
    font-family: inherit;
}

.alg-tab:hover {
    background: var(--bg-surface);
    border-color: var(--border-focus);
}

.alg-tab.active {
    background: var(--btn-primary-bg);
    color: var(--btn-primary-text);
    border-color: var(--btn-primary-bg);
}

/* ---- ПАНЕЛИ ---- */
.alg-panel {
    display: none;
    background: var(--bg-base);
    border-radius: 14px;
    padding: 28px 32px;
    border: 1px solid var(--border-light);
    animation: fadeIn 0.3s ease;
}

.alg-panel.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ---- ВКЛАДКА 1: КЛАССИЧЕСКИЙ АЛГОРИТМ ---- */
.alg-step {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-light);
}

.alg-step:last-of-type {
    border-bottom: none;
    margin-bottom: 16px;
}

.step-num {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--btn-primary-bg);
    color: var(--btn-primary-text);
    border-radius: 50%;
    font-weight: 700;
    font-size: 0.9rem;
}

.step-text strong {
    display: block;
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.step-text p {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0;
}

.step-text .alg-hint {
    margin-top: 6px;
    padding: 8px 14px;
    background: var(--bg-canvas);
    border-radius: 8px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    border-left: 3px solid var(--accent-chart);
}

.alg-result {
    padding: 14px 18px;
    background: var(--bg-canvas);
    border-radius: 10px;
    text-align: center;
    font-size: 0.95rem;
    color: var(--text-secondary);
    border: 1px solid var(--border-light);
}

.alg-result strong {
    color: var(--text-primary);
}

/* ============================================================
   БЛОК-СХЕМА (SVG)
   ============================================================ */

.flowchart-svg-wrapper {
    max-width: 750px;
    margin: 0 auto;
    padding: 10px 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.flowchart-svg {
    width: 100%;
    height: auto;
    display: block;
    background: var(--bg-base);
    border-radius: 12px;
}

/* Адаптив для очень маленьких экранов */
@media (max-width: 480px) {
    .flowchart-svg-wrapper {
        padding: 4px 0;
    }
}



/* ---- ВКЛАДКА 3: СТИХОТВОРЕНИЕ ---- */
.poem-block {
    max-width: 600px;
    margin: 0 auto;
    padding: 10px 0;
}

.poem-text {
    font-size: 1rem;
    line-height: 1.8;
    color: var(--text-secondary);
    padding: 20px 24px;
    border-radius: 12px;
}

.poem-text p {
    margin: 0;
}

.poem-text strong {
    color: var(--text-primary);
}

.poem-author {
    text-align: right;
    margin-top: 16px;
    padding-right: 8px;
}

.poem-author p {
    margin: 2px 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.poem-author strong {
    color: var(--text-primary);
}

.poem-link {
    font-size: 0.8rem;
    color: var(--text-tertiary);
}



/* ---- БЛОК 6: ПРИМЕРЫ ПОСТРОЕНИЯ ---- */
.examples-block {
    padding: 20px 0 30px;
}

.examples-block h3 {
    text-align: center;
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 20px;
}

.examples-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    max-width: 780px;
    margin: 0 auto;
}

.example-item {
    display: block;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--border-light);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    background: var(--bg-base);
}

.example-item:hover {
    transform: scale(1.02);
    box-shadow: 0 6px 20px rgba(0,0,0,0.08);
}

.example-item img {
    width: 100%;
    height: auto;
    display: block;
}

/* ============================================================
   АДАПТИВ
   ============================================================ */

@media (max-width: 992px) {
    .figures-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .trainers-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .algorithm-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .page-wrapper {
        padding: 16px 16px 30px;
    }

    .intro-block h1 {
        font-size: 1.5rem;
    }

    .intro-block p {
        font-size: 0.95rem;
    }

    .info-box {
        padding: 16px 18px;
    }

    .info-box ul li {
        font-size: 0.9rem;
    }

    .section-header h2 {
        font-size: 1.3rem;
    }

    .section-header p {
        font-size: 0.9rem;
    }

    .figures-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .figure-card {
        padding: 12px 10px 10px;
    }

    .figure-card img {
        width: 60px;
    }

    .figure-card span {
        font-size: 0.8rem;
    }

    .trainers-grid {
        grid-template-columns: 1fr 1fr;
        gap: 14px;
        max-width: 500px;
    }

    .trainer-card img {
        max-width: 150px;
    }

    .trainer-card span {
        font-size: 0.85rem;
    }

    .algorithm-grid {
        grid-template-columns: 1fr 1fr;
        gap: 14px;
    }

    .algorithm-block h3 {
        font-size: 1.1rem;
    }

    .examples-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .examples-block h3 {
        font-size: 1.1rem;
    }
}

@media (max-width: 480px) {
    .page-wrapper {
        padding: 12px 12px 24px;
    }

    .intro-block {
        padding: 16px 0 12px;
    }

    .intro-block h1 {
        font-size: 1.25rem;
    }

    .intro-block p {
        font-size: 0.9rem;
    }

    .info-box {
        padding: 12px 14px;
        border-radius: 10px;
    }

    .info-box h4 {
        font-size: 0.9rem;
    }

    .info-box ul li {
        font-size: 0.85rem;
    }

    .section-header {
        padding: 28px 0 8px;
    }

    .section-header h2 {
        font-size: 1.1rem;
    }

    .section-header p {
        font-size: 0.85rem;
    }

    .figures-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .figure-card {
        padding: 10px 8px 8px;
        border-radius: 10px;
    }

    .figure-card img {
        width: 50px;
    }

    .figure-card span {
        font-size: 0.75rem;
    }

    .trainers-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
        max-width: 100%;
    }

    .trainer-card {
        padding: 12px 8px 10px;
    }

    .trainer-card img {
        max-width: 100%;
    }

    .trainer-card span {
        font-size: 0.8rem;
    }

    .algorithm-grid {
        grid-template-columns: 1fr;
        max-width: 320px;
        margin: 0 auto;
    }

    .algorithm-block h3 {
        font-size: 1rem;
    }

    .examples-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .examples-block h3 {
        font-size: 1rem;
    }
}
/* ============================================================
   АДАПТИВ
   ============================================================ */

@media (max-width: 768px) {
    .algorithm-block {
        padding: 28px 0 20px;
    }

    .algorithm-block h2 {
        font-size: 1.3rem;
    }

    .alg-desc {
        font-size: 0.85rem;
    }

    .alg-tabs {
        gap: 6px;
    }

    .alg-tab {
        padding: 8px 16px;
        font-size: 0.85rem;
    }

    .alg-panel {
        padding: 18px 16px;
    }

    .alg-step {
        gap: 12px;
        margin-bottom: 14px;
        padding-bottom: 14px;
        flex-direction: column;
    }

    .step-num {
        width: 32px;
        height: 32px;
        font-size: 0.8rem;
    }

    .step-text p {
        font-size: 0.9rem;
    }

    .step-text .alg-hint {
        font-size: 0.85rem;
    }

    .alg-result {
        font-size: 0.9rem;
        padding: 12px 14px;
    }

    .flow-branch {
        flex-direction: column;
        gap: 16px;
        align-items: center;
    }

    .flow-yes,
    .flow-no {
        width: 100%;
        max-width: 280px;
    }

    .flow-diamond {
        width: 100px;
        height: 100px;
        font-size: 0.75rem;
    }

    .flow-box {
        font-size: 0.85rem;
        padding: 10px 16px;
        min-width: 100px;
    }

    .flow-box.small {
        font-size: 0.8rem;
        padding: 8px 12px;
        min-width: 80px;
    }

    .poem-text {
        font-size: 0.9rem;
        padding: 16px 18px;
    }

    .poem-author {
        text-align: center;
    }
}

@media (max-width: 480px) {
    .algorithm-block h2 {
        font-size: 1.1rem;
    }

    .alg-tab {
        padding: 6px 12px;
        font-size: 0.8rem;
        border-radius: 8px;
    }

    .alg-panel {
        padding: 14px 12px;
        border-radius: 10px;
    }

    .step-text p {
        font-size: 0.85rem;
    }

    .step-text .alg-hint {
        font-size: 0.8rem;
        padding: 6px 10px;
    }

    .poem-text {
        font-size: 0.85rem;
        padding: 14px 14px;
    }
}
