/* "Das sind wir - Fakten" for the zivag/facts content element.
   The section used to be a single exported picture per language, so its text
   could not be selected, searched, translated or reflowed on a phone, and
   every wording change meant going back to the drawing file. It is markup now.

   Three grid rows - icon with keyword, dot, explanation - are what keep the
   artwork's alignment: every dot sits on the one rule and every explanation
   starts on the same line, however many lines the individual texts run to.
   The item wrapper is display: contents so its three children land in those
   rows directly, each pinned to its own column through --facts-col.

   Icon and keyword share the first row as one bottom-aligned block, so a
   keyword that wraps to two lines lifts its icon instead of crowding it -
   which is how the Unia column sits in the artwork. The icon files carry
   transparent padding up to one common canvas height, so a single max-height
   reproduces the size relations of the drawing: the wordmark stays the
   tallest mark and the pictograms stay smaller. */

.section-facts {
    padding-top: 4vw;
    padding-bottom: 4vw;
}

.section-facts h2 {
    margin-bottom: 1rem;
}

.facts-subtitle {
    margin-bottom: 3.5rem;
    font-weight: 300;
}

.facts-grid {
    display: grid;
    grid-template-columns: repeat(var(--facts-columns, 4), 1fr);
    grid-template-rows: auto auto auto;
    column-gap: 2rem;
    align-items: end;
}

/* One rule behind every column, on the dot row. The dots follow it in the
   markup, so they paint on top of it without needing a stacking context. */
.facts-rule {
    grid-row: 2;
    grid-column: 1 / -1;
    align-self: center;
    height: 1px;
    background: #d5d6d8;
}

.facts-item {
    display: contents;
}

.facts-head {
    grid-column: var(--facts-col);
    grid-row: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    padding-bottom: 2.4rem;
}

.facts-icon {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    margin-bottom: 1.4rem;
}

.facts-icon img {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 64px;
}

.facts-label {
    color: var(--black, #000);
    font-weight: 700;
    font-size: 1rem;
    line-height: 1.4;
    text-align: center;
}

.facts-dot {
    grid-column: var(--facts-col);
    grid-row: 2;
    justify-self: center;
    flex: 0 0 auto;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--main-color, #e73531);
}

.facts-text {
    grid-column: var(--facts-col);
    grid-row: 3;
    /* The explanations hang from the rule, as in the artwork: they all start
       on the same line and a longer one grows downwards. */
    align-self: start;
    padding-top: 2.4rem;
    color: var(--black, #000);
    font-weight: 300;
    font-size: .95rem;
    line-height: 1.55;
    text-align: center;
}

/* Below 1200px a quarter of the content column is too narrow for a keyword
   like "Tochtergesellschaft der Gewerkschaft Unia", so the row stands up: the
   rule becomes a vertical axis down the middle, each fact is a centred stack
   of dot, icon, keyword and explanation, and a short connector joins one dot
   to the next. Keeping the line is the point - it is what makes the section a
   timeline rather than four loose blocks.

   The axis is drawn as two stubs growing out of each dot rather than as one
   line behind everything, so it leaves the dot with no gap, never crosses the
   text and needs no stacking context. The first dot only reaches down, the
   last one only up, the ones between reach both ways. */
@media screen and (max-width: 1199.98px) {
    .facts-grid {
        display: block;
        grid-template-columns: none;
        grid-template-rows: none;
        /* Without a cap the entries would stretch the full width of the
           content column and "centred" would stop meaning anything. */
        max-width: 30rem;
        margin-left: auto;
        margin-right: auto;
    }

    /* The horizontal rule has no job in a vertical layout. */
    .facts-rule {
        display: none;
    }

    .facts-item {
        position: relative;
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding-bottom: 3.5rem;
    }

    .facts-item:last-child {
        padding-bottom: 0;
    }

    /* Source order is head, dot, explanation; here the dot marks the top of
       the entry instead of sitting between keyword and explanation. */
    .facts-dot {
        position: relative;
        order: -1;
        grid-column: auto;
        grid-row: auto;
        align-self: center;
        margin-bottom: 2rem;
    }

    /* ::before reaches up towards the entry above, ::after down towards this
       entry's icon. Both start at the edge of the dot, so the line always
       leaves the point itself. */
    .facts-dot::before,
    .facts-dot::after {
        content: "";
        position: absolute;
        left: 50%;
        width: 1px;
        height: 1.25rem;
        margin-left: -.5px;
        background: #d5d6d8;
    }

    .facts-dot::before {
        bottom: 100%;
    }

    .facts-dot::after {
        top: 100%;
    }

    /* Nothing sits above the first dot or below the last one. */
    .facts-rule + .facts-item .facts-dot::before,
    .facts-item:last-child .facts-dot::after {
        display: none;
    }

    .facts-head {
        grid-column: auto;
        grid-row: auto;
        flex-direction: column;
        align-items: center;
        justify-content: flex-start;
        padding-bottom: 0;
    }

    .facts-icon {
        margin-bottom: .9rem;
    }

    .facts-icon img {
        max-height: 56px;
    }

    .facts-text {
        grid-column: auto;
        grid-row: auto;
        /* The align-self that pins the explanation to the rule on desktop
           would pull it out of the centred stack here. */
        align-self: auto;
        padding-top: .5rem;
    }
}

@media screen and (max-width: 575.9px) {
    .section-facts {
        padding-top: 15vw;
        padding-bottom: 15vw;
    }

    .section-facts.normal,
    .section-facts.bck-grey-set {
        padding-left: 15px;
        padding-right: 15px;
    }

    .facts-item {
        padding-bottom: 3rem;
    }

    .facts-icon img {
        max-height: 48px;
    }
}
