/**
 * Ennätys: the record section of a growing guide, the records table and the
 * newest records list (includes/ennatys/ennatys.php).
 *
 * Structure:
 *   section.ennatys-osio.color-section.wrapper-alternate-color#ennatys   (a guide)
 *   section.ennatys-osio.ennatys-osio--vuosi.wrapper-extra-color#vuoden-ennatykset   (a results year)
 *     .ennatys-osio__rivi > .ennatys-osio__teksti (sub-heading, h2, p, p.ennatys-osio__napit)
 *                         + .ennatys-osio__kuvat (.mittakaava.mittakaava--sovita, .vaaka)
 *   .ennatykset > h3.ennatykset-ryhma + table.ennatykset-taulukko   [applari_ennatykset]
 *   ul.ennatykset-tuoreimmat                                        [applari_ennatykset nayta="tuoreimmat"]
 *
 * Text and drawings stack on phones and stand side by side from 990px. The
 * table turns into two-line rows on phones.
 */

/* ---- Record section ---- */
.ennatys-osio__rivi {
    display: flex;
    flex-direction: column;
    gap: 40px;
    max-width: calc(var(--container-width) + 2 * var(--mobile-side-padding));
    margin: 0 auto;
    padding: 0 var(--mobile-side-padding);
}

.ennatys-osio__teksti > * {
    margin: 0 0 16px;
}

/* Long plant names hyphenate on phones only; wider screens break between words. */
.ennatys-osio__teksti h2 {
    overflow-wrap: break-word;
    text-wrap: balance;
}

@media only screen and (max-width: 767px) {
    .ennatys-osio__teksti h2 {
        hyphens: auto;
    }
}

.ennatys-osio__napit {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 28px;
    margin-top: 28px !important;
}

.ennatys-osio__kuvat {
    display: flex;
    flex-direction: column;
    gap: 40px;
    min-width: 0;
}

@media only screen and (min-width: 990px) {
    .ennatys-osio__rivi {
        flex-direction: row;
        align-items: center;
        gap: 64px;
    }

    .ennatys-osio__rivi > * {
        flex: 1 1 0;
    }
}

/* Year variant (a results year, ennatys-osio--vuosi): up to a dozen
   drawings. The text and the scale drawing share the first row, the scales
   fill the row under them (four abreast); without a scale drawing the text
   takes the first row. */
@media only screen and (min-width: 990px) {
    .ennatys-osio--vuosi .ennatys-osio__rivi {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        align-items: center;
        gap: 56px 64px;
    }

    .ennatys-osio--vuosi .ennatys-osio__kuvat {
        display: contents;
    }

    .ennatys-osio--vuosi .ennatys-osio__rivi:not(:has(.mittakaava)) > .ennatys-osio__teksti,
    .ennatys-osio--vuosi .vaaka {
        grid-column: 1 / -1;
    }

    .ennatys-osio--vuosi .ennatys-osio__rivi:not(:has(.mittakaava)) > .ennatys-osio__teksti {
        max-width: 760px;
    }

    .ennatys-osio--vuosi .vaaka {
        --vaaka-w: 15rem;
    }
}

/* ---- Records table ---- */
.ennatykset-ryhma {
    margin: 2em 0 0.5em;
}

.ennatykset-taulukko {
    width: 100%;
    table-layout: fixed; /* the same columns in every group's table */
    border: 0;
    border-collapse: collapse;
    font-size: 0.95em;
}

.ennatykset-taulukko th,
.ennatykset-taulukko td {
    padding: 8px 12px 8px 0;
    border: 0;
    border-bottom: 1px solid var(--border-clr);
    text-align: left;
    vertical-align: top;
}

.ennatykset-taulukko th:nth-child(1) { width: 30%; }
.ennatykset-taulukko th:nth-child(2) { width: 22%; }
.ennatykset-taulukko th:nth-child(4) { width: 12%; }

.ennatykset-taulukko th {
    font-size: 0.8em;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--placeholder-clr);
}

.ennatykset-sarja,
.ennatykset-merkki {
    display: block;
    font-size: 0.85em;
    opacity: 0.85;
}

.ennatykset-arvo {
    font-family: var(--title-font);
    color: var(--heading-clr);
    white-space: nowrap;
}

/* "omatoimimittaus", "maailmanennätys" under the record value */
.ennatykset-arvo .ennatykset-merkki {
    font-family: var(--main-font);
    color: var(--font-clr);
}

@media only screen and (max-width: 767px) {
    .ennatykset-taulukko thead {
        display: none;
    }

    .ennatykset-taulukko tr {
        display: grid;
        grid-template-columns: 1fr auto;
        gap: 2px 12px;
        padding: 10px 0;
        border-bottom: 1px solid var(--border-clr);
    }

    .ennatykset-taulukko td {
        padding: 0;
        border: 0;
    }

    /* Plant and record on the first line, grower and year on the second. */
    .ennatykset-taulukko td:nth-child(3),
    .ennatykset-taulukko td:nth-child(4) {
        font-size: 0.9em;
    }

    .ennatykset-taulukko td:nth-child(2),
    .ennatykset-taulukko td:nth-child(4) {
        text-align: right;
    }
}

/* ---- Newest records ---- */
.ennatykset-tuoreimmat {
    list-style: none;
    margin: 0;
    padding: 0;
}

.ennatykset-tuoreimmat li {
    padding: 8px 0;
    border-bottom: 1px solid var(--border-clr);
}

.ennatykset-tuoreimmat strong {
    font-family: var(--title-font);
    font-weight: 400;
    color: var(--heading-clr);
}
