/*
  Zambia Air Force Centre of Advanced Learning — Staff page.
  A short page banner and the chain-of-command tree.

  The tree is a stack of tiers. A trunk line runs down the centre; a tier with
  several people spreads into a branch (a bar across the top, a stub down to
  each card) and gathers again underneath (stubs and a bar at the bottom).
*/

/* ---------- Page banner ---------- */

.page-banner {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 360px;
    padding: 120px 20px 60px;
    background-size: cover;
    background-position: center 40%;
    text-align: center;
}

.page-banner::before {
    content: '';
    position: absolute;
    inset: 0;
    background-color: rgba(22, 34, 57, 0.78);
}

.page-banner-text {
    position: relative;
    color: #fff;
}

.page-banner-text h6 {
    margin: 0 0 14px;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.page-banner-text h1 {
    margin: 0;
    font-size: 54px;
    font-weight: 800;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.page-banner-text h1 em {
    font-style: normal;
    color: var(--cal-gold);
}

.page-banner-text p {
    margin: 12px 0 0;
    font-size: 16px;
    font-style: italic;
    letter-spacing: 2px;
    color: var(--cal-gold);
}

@media (max-width: 767px) {
    .page-banner { min-height: 280px; }
    .page-banner-text h1 { font-size: 36px; }
}

/* ---------- Tree ---------- */

.staff-page {
    padding-bottom: 110px;
    background-color: var(--cal-tint, #f4f6fa);
}

.staff-page .section-heading {
    margin-bottom: 50px;
}

.staff-tree {
    --card-w: 330px;
    --gap: 40px;
    --stem: 26px;                 /* length of each connector segment */
    --line: #c3cad6;
    --line-w: 2px;
}

.staff-tier {
    position: relative;
    display: flex;
    justify-content: center;
    gap: var(--gap);
    padding-top: calc(var(--stem) * 2);
}

.staff-tier.is-top {
    padding-top: 0;
}

/* trunk coming down into the tier */
.staff-tier:not(.is-top)::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    width: var(--line-w);
    height: calc(var(--stem) * 2);
    margin-left: calc(var(--line-w) / -2);
    background-color: var(--line);
}

/* a branch: the trunk stops halfway and a bar spreads to each card */
.staff-tier.is-branch::before {
    height: var(--stem);
}

.staff-tier.is-branch {
    padding-bottom: var(--stem);
}

.staff-tier.is-branch.is-last {
    padding-bottom: 0;
}

.staff-bar {
    position: absolute;
    left: 50%;
    width: calc((var(--n) - 1) * (var(--card-w) + var(--gap)) + var(--line-w));
    height: var(--line-w);
    transform: translateX(-50%);
    background-color: var(--line);
}

.staff-bar-top    { top: var(--stem); }
.staff-bar-bottom { bottom: 0; }

/* stubs joining each card of a branch to the bars */
.staff-tier.is-branch .staff-card::before,
.staff-tier.is-branch:not(.is-last) .staff-card::after {
    content: '';
    position: absolute;
    left: 50%;
    width: var(--line-w);
    height: var(--stem);
    margin-left: calc(var(--line-w) / -2);
    background-color: var(--line);
}

.staff-tier.is-branch .staff-card::before { top: calc(var(--stem) * -1 - 3px); height: calc(var(--stem) + 3px); }
.staff-tier.is-branch .staff-card::after  { bottom: calc(var(--stem) * -1); }

/* a large group (four or more on one level) wraps onto rows under the trunk */
.staff-tier.is-group {
    flex-wrap: wrap;
    row-gap: 20px;
    column-gap: 20px;
}

.staff-tier.is-group .staff-card {
    --card-w: 300px;
}

/* three side by side need slightly narrower cards to fit the page */
@media (min-width: 768px) and (max-width: 1199px) {
    .staff-tree { --card-w: 290px; --gap: 24px; }
}

/* ---------- Cards ---------- */

.staff-card {
    position: relative;
    flex: 0 0 var(--card-w);
    width: var(--card-w);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 18px;
    background-color: #fff;
    border: 1px solid var(--cal-line, #e3e7ee);
    border-top: 3px solid var(--cal-gold);
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(23, 34, 56, 0.07);
}

.staff-photo {
    flex: 0 0 76px;
    width: 76px;
    height: 76px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 50%;
    border: 2px solid var(--cal-gold);
    background-color: var(--cal-tint, #f4f6fa);
    font-size: 30px;
    color: #b3bccb;
}

.staff-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center top;
}

.staff-text {
    min-width: 0;
}

.staff-text h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 800;
    line-height: 1.4;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--cal-ink, #172238);
}

.staff-text p {
    margin: 5px 0 0;
    font-size: 14px;
    line-height: 1.45;
    color: #3a4458;
}

.staff-text p span {
    display: block;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--cal-gold-text, #a86400);
}

/* the head of the tree stands taller */
.staff-tier.is-top .staff-card {
    flex-direction: column;
    text-align: center;
    padding: 28px 24px 24px;
    border-top-width: 4px;
    box-shadow: 0 10px 30px rgba(23, 34, 56, 0.12);
}

.staff-tier.is-top .staff-photo {
    flex-basis: 140px;
    width: 140px;
    height: 140px;
    border-width: 3px;
    font-size: 56px;
}

.staff-tier.is-top .staff-text h3 { font-size: 17px; }
.staff-tier.is-top .staff-text p  { font-size: 16px; }

/* ---------- Narrow screens: one column, straight trunk ---------- */

@media (max-width: 767px) {
    .staff-tree { --card-w: min(330px, 100%); }

    .staff-tier,
    .staff-tier.is-branch {
        flex-direction: column;
        align-items: center;
        gap: calc(var(--stem) * 2);
        padding-bottom: 0;
    }

    .staff-tier.is-branch::before { height: calc(var(--stem) * 2); }
    .staff-bar { display: none; }

    .staff-card {
        flex: 0 0 auto;
        width: 100%;
        max-width: 330px;
    }

    /* inside a branch, each later card hangs from the one above */
    .staff-tier.is-branch .staff-card::after { display: none; }
    .staff-tier.is-branch .staff-card::before { display: none; }
    .staff-tier.is-branch .staff-card + .staff-card::before {
        display: block;
        top: calc(var(--stem) * -2 - 3px);
        height: calc(var(--stem) * 2 + 3px);
    }
}
