/* ═══════════════════════════════════════════════════════════════════════
   Modulares Grid – Startseite Kachel-Zeilen
   ═══════════════════════════════════════════════════════════════════════ */

.modulares-grid {
    max-width: 70rem;
    margin: 2rem auto;
    padding: 0 0.9375rem;
    /* Brand-navy background shows as hairline between tiles → modern grid look */
    background: transparent;
}

/* Each row: two equal tiles side by side */
.mgrid-row {
    display: flex;
    gap: 4px;          /* brand-color gap = modern grid line */
    margin-bottom: 4px;
}
.mgrid-row:last-child {
    margin-bottom: 0;
}

.mgrid-tile {
    flex: 1 1 0;          /* flex-grow fills gap-corrected width automatically */
    min-width: 0;
    aspect-ratio: 1;
    position: relative;
    border-radius: 6px;
    overflow: hidden;
    background-repeat: no-repeat;
    box-shadow: 0 2px 12px rgba(41, 50, 98, 0.10);
    transition: box-shadow 0.3s ease;
}
.mgrid-tile:hover {
    box-shadow: 0 6px 28px rgba(41, 50, 98, 0.22);
}

/* Image tile */
.mgrid-tile--image {
    background-color: #ddd;
}

.mgrid-tile-link {
    display: block;
    width: 100%;
    height: 100%;
    position: relative;
    color: inherit;
    text-decoration: none;
}

.mgrid-tile-link::after {
    content: "";
    position: absolute;
    inset: 0;
    /* Cinematic gradient overlay — matches hero overlay direction */
    background: linear-gradient(
        to top,
        rgba(41, 50, 98, 0.45) 0%,
        rgba(41, 50, 98, 0.12) 45%,
        transparent 75%
    );
    opacity: 1;
    pointer-events: none;
    transition: opacity 0.45s ease;
}

.mgrid-tile__image {
    display: block;
    width: 100%;
    height: 100%;
    background-repeat: no-repeat;
    transition: transform 0.45s ease;
    transform-origin: center center;
}

.mgrid-tile__image:hover {
    cursor: pointer;
}

.mgrid-tile--image:hover .mgrid-tile__image,
.mgrid-tile--image:focus-within .mgrid-tile__image {
    transform: scale(1.05);
}

.mgrid-tile--image:hover .mgrid-tile-link::after,
.mgrid-tile--image:focus-within .mgrid-tile-link::after {
    opacity: 0;
}

/* Text tile */
.mgrid-tile--text {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(1.5rem, 4vw, 3rem);
}

.mgrid-tile__content {
    width: 100%;
    font-size: clamp(0.8rem, 1.6vw, 1.1rem);
    line-height: 1.5;
}

.mgrid-tile__content a {
    color: var(--mgrid-link-color, #0073aa);
}

/* ── Heading base: underline via text-decoration (per line, text-width only) ── */
.mgrid-tile__content h1,
.mgrid-tile__content h2,
.mgrid-tile__content h3,
.mgrid-tile__content h4,
.mgrid-tile__content h5 {
    color: inherit;
    display: block;          /* block so text-align: center from TinyMCE works */
    margin-bottom: 0.6em;
    letter-spacing: -0.015em;   /* tight tracking — matches hero headline style */
    /* Underline intrudes into the text from below, decorates each line individually */
    text-decoration: underline;
    text-decoration-color: var(--mgrid-heading-underline-color, color-mix(in srgb, currentColor 25%, transparent));
    text-decoration-thickness: 0.3em;
    text-underline-offset: -0.05em;  /* negative: moves underline up into cap-height */
    text-decoration-skip-ink: none;  /* no gaps at descenders */
}

/* ::after no longer needed — underline handled by text-decoration above */

.mgrid-tile__content h1 {
    font-size: clamp(1.2rem, 2.5vw, 2rem);
    font-weight: 700;   /* matches hero headline weight */
}

.mgrid-tile__content h2 {
    font-size: clamp(1rem, 2vw, 1.6rem);
    font-weight: 700;
}

.mgrid-tile__content h3 {
    font-size: clamp(0.9rem, 1.8vw, 1.3rem);
    font-weight: 600;
}

.mgrid-tile__content h4 {
    font-size: clamp(0.85rem, 1.5vw, 1.15rem);
    font-weight: 500;
}

.mgrid-tile__content h5 {
    font-size: clamp(0.8rem, 1.3vw, 1rem);
    font-weight: 500;
}

.mgrid-tile__content p {
    color: inherit;
    margin-bottom: 0.4em;
}

/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 640px) {
    .mgrid-row {
        flex-direction: column;
    }

    .mgrid-tile {
        flex: 0 0 100%;
        width: 100%;
        aspect-ratio: auto;
        min-height: 0;
    }

    .mgrid-tile--image {
        aspect-ratio: 4 / 3;
    }

    .mgrid-tile--text {
        padding: clamp(1.5rem, 5vw, 2.5rem);
    }

    .mgrid-tile__content {
        font-size: clamp(0.75rem, 3.5vw, 1rem);
    }

    .mgrid-tile__content h1 {
        font-size: clamp(1rem, 5vw, 1.5rem);
    }

    .mgrid-tile__content h2 {
        font-size: clamp(0.9rem, 4.5vw, 1.3rem);
    }

    .mgrid-tile__content h3 {
        font-size: clamp(0.85rem, 4vw, 1.15rem);
    }

    .mgrid-tile__content h4 {
        font-size: clamp(0.8rem, 3.5vw, 1rem);
    }

    .mgrid-tile:first-child {
        order: var(--mgrid-mobile-order-left, 0);
    }

    .mgrid-tile:last-child {
        order: var(--mgrid-mobile-order-right, 1);
    }
}
