/* School Leadership plugin (people_plugins/school_leadership_plugin.html). The cards come from
   staff_plugins/staff-list-plugin.css; this sheet lays the role groups out.

   Each role group is a row of its own: its heading over its cards, both centred, with a rule between them as
   wide as the cards. A card keeps the width it would have four to a line, so a lone Dean is the same size as
   each of four administrators rather than stretching across the page, and a group of more than four wraps with
   its last line centred. Two to a line below 1200px, one below 768px. */

.school-leadership {
    --school-leadership-per-line: 4;
    --school-leadership-column-gap: var(--staff-column-gap, 36px);
    --school-leadership-row-gap: var(--staff-row-gap, 34px);
}

/* A group is as wide as its widest line of cards -- one card for the Dean, three for the Vice Deans -- and
   centred by its row, so the rule under its heading spans exactly its cards. The template sets
   --school-leadership-count to the group's size; past one line's worth, the group takes the full width and wraps.
   A role with a cap of its own (people.leadership.MAX_PER_LINE -- the Advisory Council, three) sets
   --school-leadership-max-per-line, and wraps there instead: its cards keep their four-to-a-line width, three
   across and centred. */
.school-leadership__group {
    --school-leadership-span: min(
        var(--school-leadership-count, 1),
        var(--school-leadership-per-line),
        var(--school-leadership-max-per-line, var(--school-leadership-per-line))
    );
    width: calc(
        var(--school-leadership-span)
        * (100% - (var(--school-leadership-per-line) - 1) * var(--school-leadership-column-gap))
        / var(--school-leadership-per-line)
        + (var(--school-leadership-span) - 1) * var(--school-leadership-column-gap)
    );
    flex: 0 0 auto;
}

/* A line of groups: usually one, though the Vice Deans share the Dean's (people.leadership.
   SHARES_LINE_WITH_PREVIOUS). Each group keeps the width its cards give it, so the Dean's one card and the Vice
   Deans' three fill a line of four, a column gap apart like any two cards. Where they do not fit -- two to a line
   or fewer -- the second wraps below, as far down as the next row would be. Groups line up at the top, so the
   headings sit level. */
.school-leadership__row {
    --school-leadership-group-gap: 72px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start;
    column-gap: var(--school-leadership-column-gap);
    row-gap: var(--school-leadership-group-gap);
}

.school-leadership__row + .school-leadership__row {
    margin-top: var(--school-leadership-group-gap);
}

/* The site's heading voice: Perstare Black, the weight section headers use (ui-font-display-black). Perstare
   ships no 800, so the 800s elsewhere -- the Staff List Grid's heading, the Events Calendar's day titles -- render
   as this face too. In capitals, like the Staff List Grid's own heading, with the qualifier words in NYU violet
   (people.leadership.HEADING_ACCENT) the way section headers colour theirs. The rule under it is the page's
   divider, the same one that marks the scope break. */
.school-leadership__heading {
    margin: 0 0 32px;
    padding-bottom: 16px;
    border-bottom: 1px solid #E5E7EB;
    color: #161616;
    font-size: 30px;
    line-height: 38px;
    font-weight: 900;
    letter-spacing: -0.03em;
    text-align: center;
    text-transform: uppercase;
}

/* Groups sharing a row -- the Dean and the Vice Deans -- set their headings left, each starting where its first
   card does, so the two read as one line of headings rather than two islands. */
.school-leadership__row--shared .school-leadership__heading {
    text-align: left;
}

.school-leadership__heading-accent {
    color: #57068C;
}

/* Rows are spaced by each cell's own bottom margin rather than row-gap, so the zero-height line break below
   adds no second gap where it forces a new line. The container's negative margin takes back the last one. */
.school-leadership__cards {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    column-gap: var(--school-leadership-column-gap);
    margin-bottom: calc(-1 * var(--school-leadership-row-gap));
}

/* Stretched to its line (flex's default), so a rule on it runs as tall as the tallest card beside it. */
.school-leadership__cell {
    position: relative;
    flex: 0 0 calc(
        (100% - (var(--school-leadership-span) - 1) * var(--school-leadership-column-gap))
        / var(--school-leadership-span)
    );
    min-width: 0;
    margin-bottom: var(--school-leadership-row-gap);
}

/* Where a group turns from school-wide posts to departmental ones, a vertical rule centred in the column gap. */
.school-leadership__cell--scope-break::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: calc(var(--school-leadership-column-gap) / -2);
    width: 1px;
    background: #E5E7EB;
}

.school-leadership__line-break {
    display: none;
}

/* Two to a line: the rule would fall at the end of a line as often as between cards, so the departmental posts
   start a line of their own instead. */
@media (max-width: 1199px) {
    .school-leadership {
        --school-leadership-per-line: 2;
    }

    .school-leadership__cell--scope-break::before {
        display: none;
    }

    .school-leadership__line-break {
        display: block;
        flex: 0 0 100%;
        height: 0;
    }
}

@media (max-width: 767px) {
    .school-leadership {
        --school-leadership-per-line: 1;
        --school-leadership-row-gap: 28px;
    }

    .school-leadership__row {
        --school-leadership-group-gap: 48px;
    }

    .school-leadership__heading {
        margin-bottom: 24px;
        padding-bottom: 12px;
        font-size: 24px;
        line-height: 30px;
    }
}
