/**
 * 조직도 (federation1.php) — gw-org 전용
 * 세로 스택 + 행 단위 가로 배치. 테마 askseo.css 비수정.
 * 단위는 em (16px 로컬 기준) — site-tokens 루트 확대와 무관하게 글씨·카드 크기 유지.
 */

.static-page-body .gw-org {
    --gw-org-brand: var(--gywf-brand, #198754);
    --gw-org-brand-dark: var(--gywf-brand-dark, #146c43);
    --gw-org-brand-light: var(--gywf-brand-light, #d1e7dd);
    --gw-org-text: var(--gywf-text, #383838);
    --gw-org-muted: var(--gywf-text-muted, #6c757d);
    --gw-org-surface: var(--gywf-surface, #f8f9fa);
    --gw-org-border: var(--gywf-border, #e3e5e8);
    --gw-org-radius: var(--gywf-radius, 0.75em);
    --gw-org-line: #a3cbb8;
    --gw-org-fs: 1em;
    --gw-org-name-card-w: 5.5em;
    --gw-org-name-card-h: 2.75em;
    font-size: 16px;
    max-width: none;
    margin: 0;
}

.static-page-body .gw-org__intro {
    margin: 0 0 2em;
    max-width: 42em;
    font-size: 1em;
    line-height: 1.7;
    color: var(--gw-org-muted);
}

.static-page-body .gw-org__stack {
    display: flex;
    flex-direction: column;
    gap: 1.5em;
}

.static-page-body .gw-org__row-group {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1em;
    align-items: start;
}

.static-page-body .gw-org__divider {
    display: block;
    width: 100%;
    height: 0;
    margin: 0.5em 0;
    border: 0;
    border-top: 2px solid var(--gw-org-border);
}

/* ── 소속 묶음 + 개별 카드 ── */
.static-page-body .gw-org__bundle {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.45em;
    width: 100%;
    min-width: 0;
}

.static-page-body .gw-org__bundle-title {
    margin: 0;
    padding: 0 0.15em;
    font-size: var(--gw-org-fs);
    font-weight: 700;
    color: #111;
    line-height: 1.4;
    text-align: center;
    width: 100%;
}

.static-page-body .gw-org__bundle-cards {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.4em;
    justify-content: center;
    width: 100%;
}

/* 사람이름 카드: 이사회와 동일 고정 크기 + 가운데 정렬 */
.static-page-body .gw-org__bundle--names .gw-org__bundle-cards {
    grid-template-columns: repeat(auto-fill, var(--gw-org-name-card-w));
    justify-content: center;
}

.static-page-body .gw-org__node--name {
    width: var(--gw-org-name-card-w);
    max-width: var(--gw-org-name-card-w);
    flex: 0 0 var(--gw-org-name-card-w);
}

.static-page-body .gw-org__node--name .gw-org__row {
    justify-content: center;
    align-items: center;
    text-align: center;
    width: var(--gw-org-name-card-w);
    min-height: var(--gw-org-name-card-h);
    height: var(--gw-org-name-card-h);
    padding: 0.35em 0.4em;
    box-sizing: border-box;
}

.static-page-body .gw-org__node--name .gw-org__person-name {
    display: block;
    width: 100%;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 직책 + 이름: 무조건 줄바꿈(세로) */
.static-page-body .gw-org__bundle--pairs .gw-org__bundle-cards {
    grid-template-columns: repeat(auto-fill, var(--gw-org-name-card-w));
    justify-content: center;
}

.static-page-body .gw-org__node--pair {
    width: var(--gw-org-name-card-w);
    max-width: var(--gw-org-name-card-w);
    flex: 0 0 var(--gw-org-name-card-w);
}

.static-page-body .gw-org__node--pair .gw-org__row {
    flex-direction: column;
    flex-wrap: nowrap;
    justify-content: center;
    align-items: center;
    text-align: center;
    gap: 0.15em;
    width: var(--gw-org-name-card-w);
    min-height: 3.5em;
    height: auto;
    padding: 0.45em 0.35em;
    box-sizing: border-box;
}

.static-page-body .gw-org__node--pair .gw-org__label,
.static-page-body .gw-org__node--pair .gw-org__person-name {
    display: block;
    width: 100%;
    text-align: center;
    white-space: normal;
    word-break: keep-all;
    line-height: 1.3;
}

/* 단체명: 영역 확대 + 한 줄 3개 */
.static-page-body .gw-org__bundle--groups {
    --gw-org-group-card-min-h: 4.5em;
    width: 100%;
    min-width: 0;
}

.static-page-body .gw-org__bundle--groups .gw-org__bundle-cards {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    justify-content: center;
    gap: 0.45em;
}

.static-page-body .gw-org__bundle--groups .gw-org__node--pair {
    width: 100%;
    max-width: none;
    flex: 1 1 auto;
    min-width: 0;
}

.static-page-body .gw-org__bundle--groups .gw-org__node--pair .gw-org__row {
    width: 100%;
    min-height: var(--gw-org-group-card-min-h);
    height: auto;
    padding: 0.7em 0.55em;
    gap: 0.25em;
    box-sizing: border-box;
}

.static-page-body .gw-org__bundle--groups .gw-org__node--pair .gw-org__label {
    font-size: 0.9em;
    font-weight: 700;
    color: #111;
    white-space: normal;
    word-break: keep-all;
    overflow-wrap: break-word;
    line-height: 1.35;
}

.static-page-body .gw-org__bundle--groups .gw-org__node--pair .gw-org__person-name {
    font-size: 0.95em;
    white-space: nowrap;
}

/* 모바일: 카드 개수별 배치 (1→가운데, 2→2개 가운데, 4→2×2, 그 외 유지) */
@media (max-width: 767.98px) {
    .static-page-body .gw-org__bundle--names .gw-org__bundle-cards:has(> :only-child),
    .static-page-body .gw-org__bundle--pairs:not(.gw-org__bundle--groups) .gw-org__bundle-cards:has(> :only-child) {
        grid-template-columns: var(--gw-org-name-card-w);
        justify-content: center;
    }

    .static-page-body .gw-org__bundle--names .gw-org__bundle-cards:has(> :nth-child(2):last-child),
    .static-page-body .gw-org__bundle--pairs:not(.gw-org__bundle--groups) .gw-org__bundle-cards:has(> :nth-child(2):last-child) {
        grid-template-columns: repeat(2, var(--gw-org-name-card-w));
        justify-content: center;
    }

    .static-page-body .gw-org__bundle--names .gw-org__bundle-cards:has(> :nth-child(4):last-child),
    .static-page-body .gw-org__bundle--pairs:not(.gw-org__bundle--groups) .gw-org__bundle-cards:has(> :nth-child(4):last-child) {
        grid-template-columns: repeat(2, var(--gw-org-name-card-w));
        justify-content: center;
    }

    .static-page-body .gw-org__bundle--groups .gw-org__bundle-cards:has(> :only-child) {
        grid-template-columns: minmax(0, 11em);
        justify-content: center;
    }

    .static-page-body .gw-org__bundle--groups .gw-org__bundle-cards:has(> :nth-child(2):last-child) {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        justify-content: center;
        max-width: 22em;
        margin-inline: auto;
    }

    .static-page-body .gw-org__bundle--groups .gw-org__bundle-cards:has(> :nth-child(4):last-child) {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        justify-content: center;
    }
}

.static-page-body .gw-org__node {
    width: 100%;
    min-width: 0;
}

.static-page-body .gw-org__row {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.35em 0.5em;
    width: 100%;
    margin: 0;
    padding: 0.7em 0.9em;
    border: 1px solid var(--gw-org-border);
    border-radius: var(--gw-org-radius);
    background: #fff;
    box-sizing: border-box;
    font-size: var(--gw-org-fs);
    line-height: 1.45;
}

.static-page-body .gw-org__row--single {
    /* alias kept for markup compatibility */
}

.static-page-body .gw-org__label {
    font-size: var(--gw-org-fs);
    font-weight: 700;
    color: #111;
    line-height: 1.45;
    letter-spacing: -0.01em;
    white-space: nowrap;
}

.static-page-body .gw-org__person-name {
    font-size: var(--gw-org-fs);
    font-weight: 600;
    color: var(--gw-org-text);
    line-height: 1.45;
    white-space: nowrap;
}

/* 위계/유형 강조 */
.static-page-body .gw-org__node--president .gw-org__row {
    background: var(--gw-org-brand);
    border-color: var(--gw-org-brand-dark);
    color: #fff;
}

.static-page-body .gw-org__node--president .gw-org__label,
.static-page-body .gw-org__node--president .gw-org__person-name {
    color: #fff;
}

.static-page-body .gw-org__node--vice .gw-org__row {
    background: #f3faf6;
    border-color: var(--gw-org-brand);
}

.static-page-body .gw-org__node--ops .gw-org__row {
    background: #fff;
    border-color: #d0d5db;
}

.static-page-body .gw-org__node--attached .gw-org__row,
.static-page-body .gw-org__node--independent .gw-org__row {
    background: #fff;
    border-color: var(--gw-org-border);
}

.static-page-body .gw-org__node--advisory .gw-org__row {
    background: #f8f6f2;
    border-color: #d9d2c6;
}

@media (min-width: 768px) {
    .static-page-body .gw-org__bundle {
        align-items: stretch;
    }

    .static-page-body .gw-org__bundle-title {
        text-align: left;
    }

    .static-page-body .gw-org__bundle-cards,
    .static-page-body .gw-org__bundle--names .gw-org__bundle-cards,
    .static-page-body .gw-org__bundle--pairs .gw-org__bundle-cards,
    .static-page-body .gw-org__bundle--groups .gw-org__bundle-cards {
        justify-content: start;
    }

    .static-page-body .gw-org__row-group {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 1em 1.25em;
    }

    .static-page-body .gw-org__row-group:has(> :only-child) {
        grid-template-columns: 1fr;
        max-width: 28em;
    }

    .static-page-body .gw-org__bundle--names .gw-org__bundle-cards,
    .static-page-body .gw-org__bundle--pairs:not(.gw-org__bundle--groups) .gw-org__bundle-cards {
        grid-template-columns: repeat(auto-fill, var(--gw-org-name-card-w));
    }

    .static-page-body .gw-org__bundle--groups .gw-org__bundle-cards {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (min-width: 992px) {
    .static-page-body .gw-org__row-group {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    /* 하단 4열: 앞 3개 축소, 단체명 영역 확대 */
    .static-page-body .gw-org__row-group:has(> .gw-org__bundle--groups) {
        grid-template-columns: minmax(0, 0.85fr) minmax(0, 0.85fr) minmax(0, 0.85fr) minmax(0, 1.7fr);
        gap: 1em 1.1em;
    }

    .static-page-body .gw-org__row-group:has(> :nth-child(4)):not(:has(> .gw-org__bundle--groups)) {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .static-page-body .gw-org__row-group:has(> :only-child) {
        grid-template-columns: minmax(16em, 22em);
        max-width: none;
    }

    .static-page-body .gw-org__bundle--groups .gw-org__bundle-cards {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 0.5em;
    }

    .static-page-body .gw-org__bundle--groups .gw-org__node--pair .gw-org__row {
        padding: 0.75em 0.6em;
    }
}

@media (min-width: 1200px) {
    .static-page-body .gw-org__row-group:has(> .gw-org__bundle--groups) {
        grid-template-columns: minmax(0, 0.8fr) minmax(0, 0.8fr) minmax(0, 0.8fr) minmax(0, 1.85fr);
    }
}

/* 진입 애니메이션 */
.static-page-body .gw-org.is-enhanced .gw-org__bundle {
    opacity: 0.75;
    transform: translateY(4px);
}

.static-page-body .gw-org.is-enhanced.is-revealed .gw-org__bundle,
.static-page-body .gw-org.is-enhanced .gw-org__bundle.is-enter {
    opacity: 1;
    transform: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

@media (prefers-reduced-motion: reduce) {
    .static-page-body .gw-org *,
    .static-page-body .gw-org *::before,
    .static-page-body .gw-org *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }

    .static-page-body .gw-org.is-enhanced .gw-org__bundle {
        opacity: 1;
        transform: none;
    }
}
