/* School Administration KB — карточки руководства */

.sa-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(450px, 1fr));
    gap: 20px;
    margin: 20px 0;
}

/* Одинаковый размер: все карточки берут высоту самой высокой, фото показываются одним размером */
.sa-grid.sa-equal {
    grid-auto-rows: 1fr;
}

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

/* Список: layout="list" — одна колонка на всю ширину */
.sa-grid.sa-layout-list { grid-template-columns: minmax(0, 1fr); }

.sa-single {
    margin: 20px 0;
    max-width: 600px;
}

.sa-single.sa-single-featured {
    max-width: 920px;
}

.sa-single.sa-align-center {
    margin-left: auto;
    margin-right: auto;
}

.sa-single.sa-align-right {
    margin-left: auto;
    margin-right: 0;
}

.sa-single.sa-align-left {
    margin-right: auto;
    margin-left: 0;
}

.sa-card {
    --sa-size: 200px; /* диаметр круглого фото в режиме photo_pos="top" */
    --sa-accent: #0073aa;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: row;
    align-items: stretch;
}

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

/* ---------- Положение фото: слева / справа ---------- */
.sa-card.sa-photo-right {
    flex-direction: row-reverse;
}

.sa-card.sa-photo-right .sa-photo-wrap {
    border-right: none;
    border-left: 1px solid #eee;
}

.sa-photo-wrap {
    width: 250px;
    background: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-right: 1px solid #eee;
    flex-shrink: 0;
}

.sa-photo {
    width: 100%;
    height: 100%;
    max-width: none;
    object-fit: cover;
    object-position: center top; /* лицо всегда в кадре */
    display: block;
}

.sa-no-photo {
    font-size: 64px;
    width: 64px;
    height: 64px;
    color: #ccc;
}

/* ---------- Положение фото: сверху — карточка-профиль ----------
   Цветная шапка, круглое фото поверх неё, всё по центру. Подходит и для одной карточки (директор),
   и для 2–3 карточек в ряд. Размер круга: photo_width="260px". */
.sa-card.sa-photo-top {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
}

.sa-card.sa-photo-top .sa-photo-wrap {
    width: 100%;
    height: 120px;
    background: linear-gradient(135deg, var(--sa-accent) 0%, #2b5797 100%);
    border: 0;
    align-items: flex-end;
    overflow: visible;
    position: relative;
}

.sa-card.sa-photo-top .sa-photo {
    width: var(--sa-size);
    height: var(--sa-size);
    flex: 0 0 auto;
    border-radius: 50%;
    border: 5px solid #fff;
    box-shadow: 0 4px 14px rgba(0,0,0,0.25);
    margin-bottom: calc(var(--sa-size) / -2);
    position: relative;
    z-index: 1;
    background: #f5f5f5;
}

.sa-card.sa-photo-top .sa-no-photo {
    width: var(--sa-size);
    height: var(--sa-size);
    flex: 0 0 auto;
    box-sizing: border-box;
    border-radius: 50%;
    border: 5px solid #fff;
    background: #f0f0f0;
    box-shadow: 0 4px 14px rgba(0,0,0,0.25);
    margin-bottom: calc(var(--sa-size) / -2);
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: calc(var(--sa-size) * 0.45);
    line-height: 1;
}

.sa-card.sa-photo-top .sa-info {
    padding-top: calc(var(--sa-size) / 2 + 22px);
    align-items: center;
}

.sa-card.sa-photo-top .sa-schedule {
    text-align: center;
    border-left: 0;
    border-top: 3px solid var(--sa-accent);
    width: 100%;
    box-sizing: border-box;
}

.sa-card.sa-photo-top .sa-contacts {
    width: 100%;
}

.sa-card.sa-photo-top .sa-contact-item {
    justify-content: center;
}

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

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

.sa-card.sa-look-featured .sa-photo-wrap {
    width: 38%;
    min-width: 230px;
    max-width: 380px;
    min-height: 340px;
    border: 0;
}

.sa-card.sa-look-featured .sa-info {
    padding: 34px 38px;
}

.sa-card.sa-look-featured .sa-name {
    margin-bottom: 14px;
    font-size: 1.35em;
}

.sa-card.sa-look-featured .sa-name-surname {
    font-size: 1.45em;
    letter-spacing: 0.02em;
}

.sa-card.sa-look-featured .sa-name-first,
.sa-card.sa-look-featured .sa-name-patronymic {
    font-size: 1.25em;
}

.sa-card.sa-look-featured .sa-position {
    font-size: 1.1em;
    padding-bottom: 14px;
    margin-bottom: 18px;
    border-bottom: 2px solid #d6e8f4;
}

.sa-card.sa-look-featured .sa-schedule {
    background: rgba(255,255,255,0.85);
    font-size: 0.95em;
}

/* В крупной карточке контакты идут сразу за должностью (а не прижаты к низу), весь блок по центру: без графика пустого места нет */
.sa-card.sa-look-featured .sa-info {
    justify-content: center;
}

.sa-card.sa-look-featured .sa-contacts {
    margin-top: 0;
    padding-top: 4px;
    border-top: 0;
}

.sa-card.sa-look-featured .sa-contact-item {
    font-size: 1em;
    margin-bottom: 8px;
}


.sa-info {
    padding: 20px;
    flex-grow: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.sa-name {
    margin: 0 0 10px 0;
    font-size: 1.2em;
    color: #333;
    font-weight: 600;
}

.sa-name span {
    display: block;
    line-height: 1.2;
}

.sa-name-surname {
    font-weight: 700;
    text-transform: uppercase;
    font-size: 1.1em;
    margin-bottom: 2px;
}

.sa-name-first,
.sa-name-patronymic {
    font-weight: 400;
    font-size: 1.1em;
}

.sa-position {
    color: #0073aa;
    font-weight: 500;
    margin-bottom: 15px;
    font-size: 0.95em;
}

.sa-schedule {
    background: #f9f9f9;
    padding: 10px;
    border-radius: 4px;
    font-size: 0.9em;
    margin-bottom: 15px;
    border-left: 3px solid #0073aa;
    color: #555;
}

.sa-schedule strong {
    display: block;
    margin-bottom: 3px;
    color: #333;
}

.sa-contacts {
    margin-top: auto;
    padding-top: 15px;
    border-top: 1px solid #eee;
}

.sa-contact-item {
    display: flex;
    align-items: center;
    margin-bottom: 5px;
    font-size: 0.9em;
    color: #000;
    overflow-wrap: anywhere;
}

.sa-contact-item:last-child {
    margin-bottom: 0;
}

.sa-contact-item .dashicons {
    margin-right: 8px;
    color: #999;
    flex: 0 0 auto;
}

.sa-contact-label {
    color: #555;
    font-weight: 600;
}

.sa-contact-item a {
    color: #0073aa;
    text-decoration: none;
    transition: color 0.2s;
}

.sa-contact-item a:hover,
.sa-contact-item a:focus {
    color: #005177;
    text-decoration: underline;
}


/* Обёртка с именем, должностью и графиком: в обычной карточке «прозрачна» (display: contents), поэтому вид не меняется */
.sa-main {
    display: contents;
}

/* ---------- Широкая карточка: имя и должность слева, контакты справа ----------
   Действует для списка (layout="list"), колонки columns="1" и одиночной карточки шире 720 px
   (например, width="1200px"). Крупная карточка (look="featured"), «профиль» (photo_pos="top")
   и сетка из нескольких колонок не затрагиваются. */
.sa-grid.sa-layout-list,
.sa-grid.sa-cols-1,
.sa-single:not(.sa-single-featured) {
    container-type: inline-size;
}

@container (min-width: 720px) {
    .sa-layout-list .sa-card:not(.sa-photo-top):not(.sa-look-featured) .sa-info:has(.sa-contacts),
    .sa-cols-1 .sa-card:not(.sa-photo-top):not(.sa-look-featured) .sa-info:has(.sa-contacts),
    .sa-single .sa-card:not(.sa-photo-top):not(.sa-look-featured) .sa-info:has(.sa-contacts) {
        display: grid;
        grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
        column-gap: 36px;
        align-items: center;
    }

    .sa-layout-list .sa-card:not(.sa-photo-top):not(.sa-look-featured) .sa-info:has(.sa-contacts) > .sa-main,
    .sa-cols-1 .sa-card:not(.sa-photo-top):not(.sa-look-featured) .sa-info:has(.sa-contacts) > .sa-main,
    .sa-single .sa-card:not(.sa-photo-top):not(.sa-look-featured) .sa-info:has(.sa-contacts) > .sa-main {
        display: block;
        grid-column: 1;
    }

    .sa-layout-list .sa-card:not(.sa-photo-top):not(.sa-look-featured) .sa-info:has(.sa-contacts) > .sa-main > :last-child,
    .sa-cols-1 .sa-card:not(.sa-photo-top):not(.sa-look-featured) .sa-info:has(.sa-contacts) > .sa-main > :last-child,
    .sa-single .sa-card:not(.sa-photo-top):not(.sa-look-featured) .sa-info:has(.sa-contacts) > .sa-main > :last-child {
        margin-bottom: 0;
    }

    .sa-layout-list .sa-card:not(.sa-photo-top):not(.sa-look-featured) .sa-info:has(.sa-contacts) > .sa-contacts,
    .sa-cols-1 .sa-card:not(.sa-photo-top):not(.sa-look-featured) .sa-info:has(.sa-contacts) > .sa-contacts,
    .sa-single .sa-card:not(.sa-photo-top):not(.sa-look-featured) .sa-info:has(.sa-contacts) > .sa-contacts {
        grid-column: 2;
        grid-row: 1;
        align-self: center;
        margin: 0;
        padding: 6px 0 6px 32px;
        border-top: 0;
        border-left: 1px solid #e3e3e3;
    }
}
/* На телефоне карточки идут столбиком и сами подстраиваются под содержимое */
@media (max-width: 768px) {
    .sa-grid.sa-equal {
        grid-auto-rows: auto;
    }
}

/* ---------- 3–4 карточки в ряд на широких экранах: горизонтальная карточка слишком тесная,
   поэтому фото ставим сверху (во всю ширину карточки), всё остальное без изменений ---------- */
@media (min-width: 1025px) {
    .sa-grid.sa-cols-3 .sa-card.sa-photo-left,
    .sa-grid.sa-cols-3 .sa-card.sa-photo-right,
    .sa-grid.sa-cols-4 .sa-card.sa-photo-left,
    .sa-grid.sa-cols-4 .sa-card.sa-photo-right {
        flex-direction: column;
    }

    .sa-grid.sa-cols-3 .sa-card.sa-photo-left .sa-photo-wrap,
    .sa-grid.sa-cols-3 .sa-card.sa-photo-right .sa-photo-wrap,
    .sa-grid.sa-cols-4 .sa-card.sa-photo-left .sa-photo-wrap,
    .sa-grid.sa-cols-4 .sa-card.sa-photo-right .sa-photo-wrap {
        width: 100% !important;
        height: 300px;
        border: 0;
        border-bottom: 1px solid #eee;
    }

    .sa-grid.sa-cols-3 .sa-card.sa-look-featured .sa-photo-wrap,
    .sa-grid.sa-cols-4 .sa-card.sa-look-featured .sa-photo-wrap {
        max-width: none;
        min-height: 0;
    }

    .sa-grid.sa-cols-3 .sa-card.sa-look-featured .sa-info,
    .sa-grid.sa-cols-4 .sa-card.sa-look-featured .sa-info {
        padding: 22px 24px;
    }
}

/* Tablet: keep desktop feel, reduce card density */
@media (max-width: 1024px) {
    .sa-grid {
        grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
        gap: 16px;
    }

    .sa-grid.sa-cols-3,
    .sa-grid.sa-cols-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .sa-grid.sa-layout-list {
        grid-template-columns: minmax(0, 1fr);
    }

    .sa-photo-wrap {
        width: 220px;
    }

    .sa-info {
        padding: 16px;
    }

    .sa-card.sa-look-featured .sa-info {
        padding: 24px 26px;
    }
}

/* Small tablets and large phones */
@media (max-width: 768px) {
    .sa-grid,
    .sa-grid[class*="sa-cols-"] {
        grid-template-columns: 1fr !important;
        gap: 14px;
    }

    .sa-card,
    .sa-card.sa-photo-right {
        flex-direction: column;
    }

    .sa-card.sa-photo-left .sa-photo-wrap,
    .sa-card.sa-photo-right .sa-photo-wrap {
        width: 100% !important;
        height: 320px;
        border-right: none;
        border-left: none;
        border-bottom: 1px solid #eee;
    }

    .sa-card.sa-look-featured .sa-photo-wrap {
        max-width: none;
        min-height: 0;
    }

    .sa-single,
    .sa-single.sa-single-featured {
        max-width: 100% !important;
    }
}

/* Smartphones */
@media (max-width: 480px) {
    .sa-grid,
    .sa-single {
        margin: 14px 0;
    }

    .sa-info,
    .sa-card.sa-look-featured .sa-info {
        padding: 14px;
    }

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

    .sa-card.sa-photo-top .sa-photo,
    .sa-card.sa-photo-top .sa-no-photo {
        /* на узком экране круг не больше 70% ширины */
        width: min(var(--sa-size), 70vw);
        height: min(var(--sa-size), 70vw);
        margin-bottom: calc(min(var(--sa-size), 70vw) / -2);
    }

    .sa-name {
        font-size: 1.08em;
    }

    .sa-name-surname,
    .sa-name-first,
    .sa-name-patronymic {
        font-size: 1em;
    }

    .sa-position,
    .sa-schedule,
    .sa-contact-item {
        font-size: 0.88em;
    }

    .sa-card.sa-photo-left .sa-photo-wrap,
    .sa-card.sa-photo-right .sa-photo-wrap {
        height: 280px;
    }
}
