/* Kontakte – compact cards with an offset blue backdrop. Override the variables to match the site. */

.kontakte-wrap {
    container-type: inline-size; /* columns react to the widget's width, not the viewport */
}

.kontakte {
    --kontakte-columns: 3;
    --kontakte-gap: 1.5rem;
    --kontakte-radius: 10px;
    --kontakte-padding: 0.875rem 1.125rem;
    --kontakte-bg: #fff;
    --kontakte-border: rgba(0, 0, 0, 0.12);
    --kontakte-accent: #279fd3;      /* the blue backdrop */
    --kontakte-offset: 6px;          /* how far it sticks out top-right */
    --kontakte-offset-hover: 10px;
    --kontakte-focus: currentColor;
    --kontakte-icon-width: 9rem;      /* width of the icon side */
    --kontakte-icon-padding: 0.5rem;  /* space around the icon inside its side */
    --kontakte-icon-min-height: 7rem; /* minimum card height when it has an icon */
    --kontakte-bild-ratio: 4 / 3;     /* format="bild": image aspect ratio */
    --kontakte-bild-fit: cover;       /* format="bild": cover = crop, contain = whole image (logos) */
    --kontakte-bild-position: center; /* which part stays visible when cropped */
    --kontakte-placeholder: rgba(0, 0, 0, 0.05); /* team card without a photo */

    display: grid;
    grid-template-columns: repeat(var(--kontakte-columns), minmax(0, 1fr));
    gap: var(--kontakte-gap);
    align-content: start; /* never stretch rows if the list ends up taller than its cards */
    list-style: none;
    margin: 0;
    /* room for the backdrop so it isn't clipped at the edges */
    padding: var(--kontakte-offset-hover) var(--kontakte-offset-hover) 0 0;
}

/* Fewer columns when the container gets narrow */
@container (max-width: 860px) {
    .kontakte {
        grid-template-columns: repeat(var(--kontakte-columns-md, 2), minmax(0, 1fr));
    }
}

@container (max-width: 520px) {
    .kontakte {
        grid-template-columns: 1fr;
    }
}

/* Width mode: [kontakte breite="260px"] – as many cards as fit, stretched to fill the row.
   Higher specificity than the rules above, so the column breakpoints don't apply. */
.kontakte.kontakte--breite {
    grid-template-columns: repeat(auto-fill, minmax(min(var(--kontakte-card-width), 100%), 1fr));
}

.kontakte__item {
    position: relative; /* anchor for backdrop + stretched link */
    isolation: isolate; /* keeps the backdrop's z-index local to the card */
    margin: 0;
}

/* Blue backdrop, offset up and to the right */
.kontakte__item::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: var(--kontakte-accent);
    border-radius: var(--kontakte-radius);
    transform: translate(var(--kontakte-offset), calc(var(--kontakte-offset) * -1));
    transition: transform 0.2s ease;
}

.kontakte__card {
    display: flex;
    height: 100%;
    box-sizing: border-box;
    background: var(--kontakte-bg);
    border: 1px solid var(--kontakte-border);
    border-radius: var(--kontakte-radius);
    overflow: hidden;
}

.kontakte__inhalt {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0; /* long URLs/words wrap instead of widening the card */
    padding: var(--kontakte-padding);
}

/* Icon fills the whole left side of the card, full height.
   The img is absolutely positioned inside its frame, so its width/height
   attributes can't add height to the card or the grid. */
.kontakte__icon-rahmen {
    position: relative;
    flex: none;
    width: var(--kontakte-icon-width);
    min-height: var(--kontakte-icon-min-height);
    border-right: 1px solid var(--kontakte-border);
}

/* .kontakte prefix beats theme/Elementor rules like ".elementor img { height: auto }" */
.kontakte .kontakte__icon {
    position: absolute;
    inset: 0;
    box-sizing: border-box;
    width: 100%;
    height: 100%;
    max-width: none;
    padding: var(--kontakte-icon-padding);
    object-fit: contain;
}

.kontakte__name {
    margin: 0;
    font-size: 1.05em;
    line-height: 1.3;
}

.kontakte__beschreibung {
    margin: 0;
    line-height: 1.45;
}

.kontakte__link {
    margin: auto 0 0; /* push to the bottom so links align across cards */
    padding-top: 0.25rem;
}

/* Whole card clickable, but only one link in the accessibility tree */
.kontakte__card a::after {
    content: "";
    position: absolute;
    inset: 0;
}

/* Hover: backdrop slides out further */
.kontakte__item:has(a):hover::before {
    transform: translate(var(--kontakte-offset-hover), calc(var(--kontakte-offset-hover) * -1));
}

/* No outline on mouse click / tap … */
.kontakte__card a:focus {
    outline: none;
}

/* … but keep a visible ring for keyboard users (WCAG 2.4.7) */
.kontakte__item:has(a:focus-visible) .kontakte__card {
    outline: 3px solid var(--kontakte-focus);
    outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
    .kontakte__item::before {
        transition: none;
    }
}

/* Image format: [kontakte format="bild"] – image on top, name below */
.kontakte__card--bild {
    flex-direction: column;
}

/* The frame sets the size; the img just fills it. Otherwise the img's height
   attribute (e.g. 768 for "large") leaks into the flex column on mobile and
   leaves a big gap below the image. */
.kontakte__bild-rahmen {
    position: relative;
    flex: none;
    aspect-ratio: var(--kontakte-bild-ratio);
    overflow: hidden;
    border-bottom: 1px solid var(--kontakte-border);
}

/* .kontakte prefix beats theme/Elementor rules like ".elementor img { height: auto }" */
.kontakte .kontakte__bild {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    max-width: none;
    object-fit: var(--kontakte-bild-fit);
    object-position: var(--kontakte-bild-position);
}

.kontakte__card--bild .kontakte__inhalt {
    justify-content: center;
    text-align: center;
}

.kontakte__card--bild .kontakte__name a {
    color: inherit;
    text-decoration: none;
}

.kontakte__item:hover .kontakte__card--bild .kontakte__name a {
    text-decoration: underline;
}

/* Team: [team] – square photo across the card, name and positions below */
.kontakte--team {
    --kontakte-bild-ratio: 1;
    --kontakte-bild-fit: cover;
    --kontakte-bild-position: center 25%; /* per member via "Bildausschnitt" */
    --kontakte-muted: #767676;            /* SLK line; lightest grey with 4.5:1 on white (WCAG AA) */
}



.kontakte__bild-rahmen--leer {
    background: var(--kontakte-placeholder);
}

/* Text left-aligned from the top: name, then SLK (grey), then SPD */
.kontakte--team .kontakte__inhalt {
    justify-content: flex-start;
    gap: 0;
    text-align: left;
}

.kontakte--team .kontakte__name {
    margin-bottom: 0.6rem;
}

/* .kontakte prefix beats theme/Elementor paragraph margins */
.kontakte .kontakte__funktion {
    margin: 0;
    line-height: 1.4;
}

.kontakte .kontakte__funktion--slk {
    color: var(--kontakte-muted);
}

/* Grouped output: [kontakte gruppiert="1"] */
.kontakte-gruppe + .kontakte-gruppe {
    margin-top: 2.5rem;
}

.kontakte-gruppe__titel {
    margin: 0 0 1rem;
}

/* Visually hidden, still read by screen readers (in case the theme doesn't define it) */
.kontakte .screen-reader-text {
    position: absolute !important;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

/* Mobile / narrow: 2 team cards per row instead of one full-width face.
   columns-md = min(spalten, 2), so spalten="1" stays one column. */
@container (max-width: 520px) {
    .kontakte.kontakte--team {
        --kontakte-gap: 0.75rem;
        grid-template-columns: repeat(var(--kontakte-columns-md, 2), minmax(0, 1fr));
    }

    .kontakte--team .kontakte__inhalt {
        padding: 0.625rem 0.75rem;
        font-size: 0.875rem;
    }

    .kontakte--team .kontakte__name {
        margin-bottom: 0.35rem;
        font-size: 1rem;
    }
}
