/* =========================================
   Yhteystietokortit — ryhmän henkilöt korttiruudukkona
   ========================================= */

.wdf-yhteystietokortit {
    padding-block: var(--wdf-padding-y);
}

.wdf-yhteystietokortit__otsikko {
    margin: 0 0 48px;
}

/* Kun pohjustusteksti seuraa otsikkoa, kavennetaan otsikon alaväli */
.wdf-yhteystietokortit__otsikko:has(+ .wdf-yhteystietokortit__teksti) {
    margin-bottom: 16px;
}

.wdf-yhteystietokortit__teksti {
    max-width: 70ch;
    margin: 0 0 48px;
}

.wdf-yhteystietokortit__tyhja {
    color: var(--wp--preset--color--neutral-600);
}

.wdf-yhteystietokortit__ruudukko {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 32px;
}

.wdf-yhteystietokortit__kortti {
    position: relative; /* esittelynäkymän peittävä taso */
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: var(--wp--preset--color--base);
    border: var(--wp--custom--border--hairline) solid var(--wp--preset--color--neutral-200);
}

/* Yläosan värikaista; taustakuvan voi vaihtaa sivustokohtaisesti */
.wdf-yhteystietokortit__kortti-banneri {
    height: 80px;
    flex-shrink: 0;
    background-color: var(--wp--preset--color--accent);
    background-size: cover;
    background-position: center;
    opacity: 0.8;
}

/* Sivupadding vain sisällölle, jotta kaista jää täysleveäksi */
.wdf-yhteystietokortit__kortti-sisalto {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    padding: 0 32px 32px;
}

/* Pyöreä kuva nousee puoliksi kaistan päälle */
.wdf-yhteystietokortit__kortti-kuva {
    width: 100%;
    aspect-ratio: 1 / 1;
    margin-top: -40px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--wp--preset--color--surface);
    z-index: 1;
}

.wdf-yhteystietokortit__kortti-kuva img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.wdf-yhteystietokortit__kortti-kuva--placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--wp--preset--color--neutral-200);
}

.wdf-yhteystietokortit__kortti-placeholder-ikoni {
    width: 55%;
    height: 55%;
    color: var(--wp--preset--color--neutral-400);
}

/* Alleviivaus nimen levyisenä: viiva spanissa, ei koko otsikossa */
.wdf-yhteystietokortit__kortti-nimi {
    margin: 24px 0 0;
    font-size: 1.25rem;
    line-height: round(up, 1.15em, 4px);
}

.wdf-yhteystietokortit__kortti-nimi span {
    display: inline-block;
    padding-bottom: 8px;
    border-bottom: var(--wp--custom--border--hairline) solid var(--wp--preset--color--accent);
}

.wdf-yhteystietokortit__kortti-toimenkuva {
    margin: 12px 0 0;
    font-weight: 700;
    font-size: var(--wp--preset--font-size--medium);
}

.wdf-yhteystietokortit__kortti-yhteys {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* !important ohittaa theme.jsonin linkkivärin myös hover-tilassa */
.wdf-yhteystietokortit__kortti-rivi {
    font-size: var(--wp--preset--font-size--medium);
    color: var(--wp--preset--color--contrast) !important;
    text-decoration: none;
}

.wdf-yhteystietokortit__kortti-rivi:hover {
    text-decoration: underline;
}

.wdf-yhteystietokortit__kortti-avaa {
    margin-top: auto; /* tasaa napit korttien alalaitaan */
    padding-top: 24px;
    padding-left: 0;
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: var(--wp--preset--font-size--small);
    font-weight: 700;
    color: var(--wp--preset--color--accent);
}

.wdf-yhteystietokortit__kortti-avaa:hover {
    text-decoration: underline;
}

/* Esittelynäkymä peittää kortin, jotta ruudukon mitat eivät muutu */
.wdf-yhteystietokortit__kortti-esittely {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    padding: 16px;
    background: var(--wp--preset--color--base);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease;
    z-index: 10;
}

.wdf-yhteystietokortit__kortti.is-open .wdf-yhteystietokortit__kortti-esittely {
    opacity: 1;
    visibility: visible;
}

/* Sulkupainike pysyy ylhäällä, teksti vierii alla */
.wdf-yhteystietokortit__kortti-sulje {
    flex-shrink: 0;
    align-self: flex-end;
    padding: 0;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 28px;
    line-height: 1;
    color: var(--wp--preset--color--contrast);
}

.wdf-yhteystietokortit__kortti-esittely-teksti {
    flex: 1 1 auto;
    overflow-y: auto;
    font-size: var(--wp--preset--font-size--small);
    line-height: 1.25rem;
    color: var(--wp--preset--color--contrast);
}

.wdf-yhteystietokortit__kortti-esittely-teksti p {
    margin: 0 0 1em;
}

.wdf-yhteystietokortit__kortti-esittely-teksti :last-child {
    margin-bottom: 0;
}

/* Responsiivisuus: 4 → 3 → 2 → 1 */
@media (max-width: 1366px) {
    .wdf-yhteystietokortit__ruudukko {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 1024px) {
    .wdf-yhteystietokortit__ruudukko {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 767px) {
    .wdf-yhteystietokortit__ruudukko {
        grid-template-columns: 1fr;
    }
}
