/*
 * ninetyone Flex-Grid – Frontend
 * CSS-Grid mit Bento-Kacheln. Spaltenzahl je Breakpoint; Kacheln spannen
 * mehrere Spalten/Reihen und klappen automatisch um, wenn zu breit.
 */
.n91fg, .n91fg * { box-sizing: border-box; }

.n91fg {
    --n91fg-cols-w: 4;
    --n91fg-cols-d: 3;
    --n91fg-cols-t: 2;
    --n91fg-cols-m: 1;
    --n91fg-gap: 20px;
    --n91fg-radius: 14px;
    --n91fg-row: 220px;
    width: 100%;
}

/* ── Grid ── */
.n91fg__grid {
    display: grid;
    grid-template-columns: repeat(var(--n91fg-cols-d), minmax(0, 1fr));
    grid-auto-rows: var(--n91fg-row);
    gap: var(--n91fg-gap);
}

/* ── Kachel ── */
.n91fg-tile {
    --n91fg-cs: 1;
    --n91fg-rs: 1;
    position: relative;
    overflow: hidden;
    box-sizing: border-box;
    border-radius: var(--n91fg-radius);
    border: var(--n91fg-bw, 0) solid var(--n91fg-bc, transparent);
    grid-column: span min(var(--n91fg-cs), var(--n91fg-cols-d));
    grid-row: span var(--n91fg-rs);
    display: flex;
    background: var(--n91fg-bg, transparent);
    color: var(--n91fg-t, inherit);
    text-decoration: none;
    min-width: 0;
}

/* Hintergrundbild + Abdunklung */
.n91fg-tile__bg {
    position: absolute;
    inset: 0;
    background-image: var(--n91fg-img);
    background-size: cover;
    background-position: center;
    z-index: 0;
    transition: transform .5s ease;
}
.n91fg-tile__video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
    transition: transform .5s ease;
}
/* Zoom ist jetzt ein bewusster Hover-Effekt (.n91fg--hz), nicht mehr fest am Link. */
.n91fg-tile__darken {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, var(--n91fg-darken, 0));
    z-index: 1;
}

/* Inhalt */
.n91fg-tile__content {
    position: relative;
    z-index: 2;
    width: 100%;
    padding: clamp(18px, 2.2vw, 30px);
    display: flex;
    flex-direction: column;
    gap: 10px;
    justify-content: var(--n91fg-justify, flex-end);
    align-items: var(--n91fg-align, flex-start);
    text-align: var(--n91fg-text, left);
}
/* Text-/Farb-Kacheln (kein Bild) zentrieren ihren Inhalt vertikal nicht erzwungen,
   sondern folgen ebenfalls der gewählten Position. */
.n91fg-tile--text .n91fg-tile__content,
.n91fg-tile--color .n91fg-tile__content { min-height: 100%; }

.n91fg-tile__eyebrow {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    opacity: .85;
    color: var(--n91fg-e, var(--n91fg-h, inherit));
}
.n91fg-tile__heading {
    margin: 0;
    font-size: clamp(19px, 2vw, 26px);
    font-weight: 700;
    line-height: 1.18;
    color: var(--n91fg-h, inherit);
}
.n91fg-tile__text {
    margin: 0;
    font-size: 15px;
    line-height: 1.55;
    color: var(--n91fg-t, inherit);
    max-width: 52ch;
}
.n91fg-tile__text p { margin: 0 0 .5em; }
.n91fg-tile__text p:last-child { margin-bottom: 0; }
.n91fg-tile__btns {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 6px;
    /* Button-Block folgt der horizontalen Ausrichtung des Inhalts */
    justify-content: var(--n91fg-align, flex-start);
}
.n91fg-tile__btn { align-self: inherit; }

/* Bild-Kacheln: Lesbarkeit per leichtem Bodengradient, wenn nicht abgedunkelt */
.n91fg-tile--image.has-image .n91fg-tile__content::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: linear-gradient(to top, rgba(0,0,0,.45), rgba(0,0,0,0) 55%);
    pointer-events: none;
}
.n91fg-tile--image.is-darkened .n91fg-tile__content::before { display: none; }

/* Ganze Kachel verlinkt → Hover-Effekt */
.n91fg-tile--link { cursor: pointer; }
.n91fg-tile--link:hover { box-shadow: 0 12px 30px rgba(0,0,0,.16); }
.n91fg-tile--link::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 3;
    border-radius: inherit;
    box-shadow: inset 0 0 0 0 rgba(255,255,255,0);
    transition: box-shadow .2s ease;
}
.n91fg-tile--link:focus-visible { outline: 3px solid var(--n91fg-h, #fff); outline-offset: 2px; }

/* ── Schriften ──
   Grid-eigene Schriften (Look-Override) über --n91fg-font-* je Rolle.
   Bei geerbtem Look mit globaler Marke greift zusätzlich .n91cs-fonts. */
.n91fg .n91fg-tile__heading { font-family: var(--n91fg-font-heading, inherit); }
.n91fg .n91fg-tile__text    { font-family: var(--n91fg-font-text, inherit); }
.n91fg .n91fg-tile__eyebrow { font-family: var(--n91fg-font-eyebrow, inherit); }
.n91fg.n91cs-fonts .n91fg-tile__text,
.n91fg.n91cs-fonts .n91fg-tile__eyebrow { font-family: var(--n91cs-font-body, inherit); }
.n91fg.n91cs-fonts .n91fg-tile__heading { font-family: var(--n91cs-font-heading, inherit) !important; }

/* ── Responsive: Spalten je Breakpoint ── */
@media (min-width: 1440px) {
    .n91fg__grid { grid-template-columns: repeat(var(--n91fg-cols-w), minmax(0, 1fr)); }
    .n91fg-tile { grid-column: span min(var(--n91fg-cs), var(--n91fg-cols-w)); }
}
@media (max-width: 1024px) {
    .n91fg__grid { grid-template-columns: repeat(var(--n91fg-cols-t), minmax(0, 1fr)); }
    .n91fg-tile { grid-column: span min(var(--n91fg-cs), var(--n91fg-cols-t)); }
}
@media (max-width: 640px) {
    .n91fg__grid {
        grid-template-columns: repeat(var(--n91fg-cols-m), minmax(0, 1fr));
        grid-auto-rows: auto;
    }
    /* Mobil: Spannen zurücksetzen, Bilder über Seitenverhältnis hoch halten */
    .n91fg-tile {
        grid-column: span min(var(--n91fg-cs), var(--n91fg-cols-m));
        grid-row: auto;
        min-height: 0;
    }
    .n91fg-tile.has-image { min-height: 260px; }
    .n91fg-tile--text, .n91fg-tile--color { min-height: 0; }
}

/* ───── Hover-Effekte (bewusst schaltbar; Modifier je Kachel, global oder per Kachel gesetzt) ───── */
/* Zoom: Hintergrundbild/Video leicht heranzoomen (Transition liegt bereits am Element). */
.n91fg-tile--hz:hover .n91fg-tile__bg,
.n91fg-tile--hz:hover .n91fg-tile__video { transform: scale(1.06); }

/* Kachel vergrößern: ganze Kachel ~1,5 % (über den Nachbarn). */
.n91fg-tile--hs { transition: transform .3s ease, box-shadow .3s ease; }
.n91fg-tile--hs:hover { transform: scale(1.015); z-index: 2; }

/* Bild abdunkeln beim Hover. */
.n91fg-tile--hd .n91fg-tile__bg,
.n91fg-tile--hd .n91fg-tile__video { transition: transform .5s ease, filter .35s ease; }
.n91fg-tile--hd:hover .n91fg-tile__bg,
.n91fg-tile--hd:hover .n91fg-tile__video { filter: brightness(0.82); }

@media (prefers-reduced-motion: reduce) {
    .n91fg-tile--hz:hover .n91fg-tile__bg,
    .n91fg-tile--hz:hover .n91fg-tile__video,
    .n91fg-tile--hs:hover { transform: none; }
}
