/* School People KB — карточки учителей и учеников */

.st-teachers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 30px;
    margin: 40px 0;
}

/* --- Размеры карточек --- */
.st-teachers-grid.st-size-small {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
}

.st-teachers-grid.st-size-large {
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 40px;
}

.st-teachers-grid.st-size-small .st-teacher-info {
    padding: 15px;
}

.st-teachers-grid.st-size-small h3 { /* Уменьшаем заголовок для маленьких */
    font-size: 1.1em;
}

.st-teachers-grid.st-size-large .st-teacher-info {
    padding: 25px;
}

/* --- Явное число колонок: columns="1..6" --- */
.st-teachers-grid.st-cols-1 { grid-template-columns: minmax(0, 1fr); }
.st-teachers-grid.st-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.st-teachers-grid.st-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.st-teachers-grid.st-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.st-teachers-grid.st-cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.st-teachers-grid.st-cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }

/* --- Выравнивание (обтекание текстом) --- */
.st-teachers-grid.st-align-right {
    float: right;
    width: 300px; /* Фиксированная ширина для боковой колонки */
    margin-left: 30px;
    margin-bottom: 30px;
    margin-top: 10px;
    grid-template-columns: 1fr; /* Одна колонка */
}

.st-teachers-grid.st-align-left {
    float: left;
    width: 300px;
    margin-right: 30px;
    margin-bottom: 30px;
    margin-top: 10px;
    grid-template-columns: 1fr;
}

.st-teachers-grid.st-align-center {
    float: none;
    width: 300px;
    margin: 30px auto; /* По центру */
    grid-template-columns: 1fr;
}

/* --- Карточка --- */
.st-teacher-card {
    background: #fff;
    border: 1px solid #e1e1e1;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    font-family: 'Times New Roman', Times, serif; /* Официальный шрифт с засечками */
}

.st-teacher-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 15px rgba(0,0,0,0.1);
}

.st-teacher-photo {
    aspect-ratio: 3 / 4; /* Портретные пропорции */
    overflow: hidden;
    background: #f4f4f4;
    position: relative;
}

.st-teacher-photo img {
    display: block;
    width: 100%;
    height: 100%;
    max-width: none;
    object-fit: cover;
    object-position: top center; /* Фокус на лице */
    transition: transform 0.5s ease;
}

.st-teacher-card:hover .st-teacher-photo img {
    transform: scale(1.05);
}

.st-no-photo {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #aaa;
    font-size: 14px;
    background: #eee;
}

.st-teacher-info {
    padding: 20px;
    text-align: center;
    flex-grow: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow-wrap: anywhere;
}

.st-teacher-info h3 {
    margin: 0 0 10px;
    font-size: 1.4em;
    color: #333;
    font-weight: bold;
    font-family: 'Georgia', serif; /* Красивый заголовочный шрифт */
}

.st-position {
    color: #0073aa;
    font-weight: 700;
    margin-bottom: 5px;
    font-size: 0.95em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-family: 'Arial', sans-serif; /* Для должности оставим строгий гротеск */
}

.st-subject {
    color: #333;
    font-style: normal;
    margin-bottom: 15px;
    font-size: 1.1em;
    border-bottom: 1px solid #eee;
    padding-bottom: 15px;
    font-weight: 500;
}

.st-bio {
    font-size: 0.9em;
    color: #555;
    line-height: 1.5;
}

.st-bio p {
    margin-bottom: 10px;
}

.st-bio p:last-child {
    margin-bottom: 0;
}

/* =========================================================================
   Положение фото и оформление: photo_pos, look
   ========================================================================= */

/* --- Фото слева / справа: горизонтальная карточка (на широких экранах) --- */
@media (min-width: 769px) {
    .st-teachers-grid.st-horizontal:not([class*="st-cols-"]):not(.st-single) {
        grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
    }
    .st-teachers-grid.st-horizontal.st-size-small:not([class*="st-cols-"]):not(.st-single) {
        grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    }
    .st-teachers-grid.st-horizontal.st-size-large:not([class*="st-cols-"]):not(.st-single) {
        grid-template-columns: repeat(auto-fill, minmax(520px, 1fr));
    }
}

.st-teacher-card.st-photo-left { flex-direction: row; }
.st-teacher-card.st-photo-right { flex-direction: row-reverse; }

.st-teacher-card.st-photo-left .st-teacher-photo,
.st-teacher-card.st-photo-right .st-teacher-photo {
    flex: 0 0 var(--st-photo-w, 40%);
    aspect-ratio: auto;
    min-height: 230px;
}

.st-teacher-card.st-photo-left .st-teacher-photo img,
.st-teacher-card.st-photo-right .st-teacher-photo img {
    position: absolute;
    top: 0;
    left: 0;
}

.st-teacher-card.st-photo-left .st-teacher-info,
.st-teacher-card.st-photo-right .st-teacher-info {
    text-align: left;
    justify-content: center;
}

/* --- Фото сверху в круге: карточка-профиль (photo_pos="profile") --- */
.st-teacher-card.st-photo-profile { --st-size: 150px; }
.st-size-small .st-teacher-card.st-photo-profile { --st-size: 120px; }
.st-size-large .st-teacher-card.st-photo-profile { --st-size: 190px; }

.st-teacher-card.st-photo-profile .st-teacher-photo {
    aspect-ratio: auto;
    height: 100px;
    background: linear-gradient(135deg, #0073aa 0%, #2b5797 100%);
    overflow: visible;
    display: flex;
    justify-content: center;
    align-items: flex-end;
}

.st-teacher-card.st-photo-profile .st-teacher-photo img,
.st-teacher-card.st-photo-profile .st-no-photo {
    box-sizing: border-box;
    flex: 0 0 auto;
    width: var(--st-size);
    height: var(--st-size);
    border-radius: 50%;
    border: 4px solid #fff;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    margin-bottom: calc(var(--st-size) / -2);
    position: relative;
    z-index: 1;
    background: #f4f4f4;
}

.st-teacher-card.st-photo-profile .st-teacher-info {
    padding-top: calc(var(--st-size) / 2 + 18px);
}

/* --- Оформление look="featured": крупная выделенная карточка --- */
.st-teacher-card.st-look-featured {
    background: linear-gradient(135deg, #f1f8fd 0%, #ffffff 55%);
    border-color: #cfe3f1;
    border-top: 5px solid #0073aa;
    box-shadow: 0 8px 26px rgba(0, 115, 170, 0.14);
}

.st-teacher-card.st-look-featured:hover {
    transform: none;
    box-shadow: 0 10px 30px rgba(0, 115, 170, 0.2);
}

.st-teacher-card.st-look-featured .st-teacher-info {
    padding: 26px 28px;
}

.st-teacher-card.st-look-featured .st-teacher-info h3 {
    font-size: 1.6em;
}

.st-teacher-card.st-look-featured.st-photo-left .st-teacher-photo,
.st-teacher-card.st-look-featured.st-photo-right .st-teacher-photo {
    min-height: 380px;
}

/* --- Одна крупная карточка не растягивается на всю ширину --- */
.st-teachers-grid.st-single { grid-template-columns: minmax(0, 1fr); max-width: 640px; }
.st-teachers-grid.st-single.st-featured:not(.st-horizontal) { max-width: 420px; }
.st-teachers-grid.st-single.st-featured.st-horizontal { max-width: 920px; }

/* --- Обтекание для горизонтальных карточек шире --- */
.st-teachers-grid.st-horizontal.st-align-right,
.st-teachers-grid.st-horizontal.st-align-left,
.st-teachers-grid.st-horizontal.st-align-center {
    width: 480px;
}

.st-teachers-grid.st-horizontal.st-featured.st-align-right,
.st-teachers-grid.st-horizontal.st-featured.st-align-left,
.st-teachers-grid.st-horizontal.st-featured.st-align-center {
    width: 560px;
}

/* --- Адаптивность --- */

/* Планшет: много колонок превращаем в три */
@media (max-width: 1024px) {
    .st-teachers-grid.st-cols-4,
    .st-teachers-grid.st-cols-5,
    .st-teachers-grid.st-cols-6 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* Небольшие планшеты: убираем обтекание, три и более колонки превращаем в две */
@media (max-width: 768px) {
    .st-teachers-grid.st-align-right,
    .st-teachers-grid.st-align-left,
    .st-teachers-grid.st-align-center {
        float: none;
        width: 100%;
        margin: 30px 0;
    }

    .st-teachers-grid.st-cols-3,
    .st-teachers-grid.st-cols-4,
    .st-teachers-grid.st-cols-5,
    .st-teachers-grid.st-cols-6 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 16px;
    }
}

/* Телефоны: маленькие карточки — по две в ряд, остальные — по одной */
@media (max-width: 600px) {
    .st-teachers-grid.st-size-small,
    .st-teachers-grid.st-size-small[class*="st-cols-"] {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
    }

    .st-teachers-grid.st-size-small .st-teacher-info {
        padding: 10px;
    }

    .st-teachers-grid.st-size-small h3 {
        font-size: 1em;
    }

    .st-teachers-grid.st-size-small .st-position {
        font-size: 0.8em;
    }

    .st-teachers-grid.st-size-medium[class*="st-cols-"],
    .st-teachers-grid.st-size-large[class*="st-cols-"],
    .st-teachers-grid.st-size-large {
        grid-template-columns: minmax(0, 1fr);
    }

    .st-teachers-grid.st-size-large .st-teacher-info {
        padding: 18px;
    }
}

/* Горизонтальные карточки: в 3 и более колонок на ПК и на небольших экранах фото уходит наверх */
@media (min-width: 1025px) {
    .st-teachers-grid:is(.st-cols-3, .st-cols-4, .st-cols-5, .st-cols-6) .st-teacher-card:is(.st-photo-left, .st-photo-right) {
        flex-direction: column;
    }

    .st-teachers-grid:is(.st-cols-3, .st-cols-4, .st-cols-5, .st-cols-6) .st-teacher-card:is(.st-photo-left, .st-photo-right) .st-teacher-photo {
        flex: none;
        width: 100%;
        aspect-ratio: 3 / 4;
        min-height: 0;
    }

    .st-teachers-grid:is(.st-cols-3, .st-cols-4, .st-cols-5, .st-cols-6) .st-teacher-card:is(.st-photo-left, .st-photo-right) .st-teacher-photo img {
        position: static;
    }

    .st-teachers-grid:is(.st-cols-3, .st-cols-4, .st-cols-5, .st-cols-6) .st-teacher-card:is(.st-photo-left, .st-photo-right) .st-teacher-info {
        text-align: center;
    }
}

@media (max-width: 768px) {
    .st-teacher-card:is(.st-photo-left, .st-photo-right) {
        flex-direction: column;
    }

    .st-teacher-card:is(.st-photo-left, .st-photo-right) .st-teacher-photo {
        flex: none;
        width: 100%;
        aspect-ratio: 3 / 4;
        min-height: 0;
    }

    .st-teacher-card:is(.st-photo-left, .st-photo-right) .st-teacher-photo img {
        position: static;
    }

    .st-teacher-card:is(.st-photo-left, .st-photo-right) .st-teacher-info {
        text-align: center;
    }

    .st-teachers-grid.st-single,
    .st-teachers-grid.st-horizontal.st-align-right,
    .st-teachers-grid.st-horizontal.st-align-left,
    .st-teachers-grid.st-horizontal.st-align-center {
        max-width: 100%;
    }
}

/* Телефоны: одна карточка (в том числе с обтеканием) — на всю ширину, а не в половину из двух колонок */
@media (max-width: 600px) {
    .st-teachers-grid.st-size-small.st-single,
    .st-teachers-grid.st-size-small.st-single[class*="st-cols-"],
    .st-teachers-grid.st-size-small[class*="st-align-"] {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (prefers-reduced-motion: reduce) {
    .st-teacher-card,
    .st-teacher-photo img { transition: none; }
    .st-teacher-card:hover { transform: none; }
    .st-teacher-card:hover .st-teacher-photo img { transform: none; }
}
