/* =========================================================
   NDG Haupt-CMS 1.3.9
   Mobile-First, Lesbarkeit und Layoutstabilität
   ========================================================= */

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    min-width: 320px;
    overflow-x: hidden;
}

body.mobile-menu-open {
    overflow: hidden;
}

img,
video,
iframe,
svg {
    max-width: 100%;
}

img {
    height: auto;
}

button,
input,
select,
textarea {
    font: inherit;
}

button,
a,
input,
select,
textarea {
    -webkit-tap-highlight-color: transparent;
}

:focus-visible {
    outline: 3px solid #38bdf8;
    outline-offset: 3px;
}

.mobile-navigation-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 46px;
    height: 46px;
    padding: 0;
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 13px;
    background: var(--surface);
    cursor: pointer;
}

.mobile-navigation-toggle span,
.mobile-navigation-toggle::before,
.mobile-navigation-toggle::after {
    width: 21px;
    height: 2px;
    border-radius: 999px;
    background: currentColor;
    transition:
        transform 180ms ease,
        opacity 180ms ease;
    content: "";
}

.mobile-navigation-toggle {
    flex-direction: column;
    gap: 5px;
}

.mobile-navigation-toggle[aria-expanded="true"] span {
    opacity: 0;
}

.mobile-navigation-toggle[aria-expanded="true"]::before {
    transform: translateY(7px) rotate(45deg);
}

.mobile-navigation-toggle[aria-expanded="true"]::after {
    transform: translateY(-7px) rotate(-45deg);
}

.mobile-navigation-backdrop {
    position: fixed;
    z-index: 18;
    inset: 0;
    display: none;
    border: 0;
    background: rgba(2, 8, 23, 0.68);
    backdrop-filter: blur(6px);
}

.mobile-navigation-backdrop.is-visible {
    display: block;
}

/* Große Tablets und kompakte Notebooks */
@media (max-width: 1100px) {
    .site-header,
    .hero,
    .section,
    .trust,
    .cta {
        width: min(100% - 40px, 1000px);
    }

    .hero {
        gap: 44px;
    }

    .hero h1 {
        font-size: clamp(3rem, 7vw, 4.9rem);
    }

    .bento,
    .projects {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .project-detail-grid {
        grid-template-columns: minmax(0, 1.35fr) minmax(260px, 0.65fr);
    }
}

/* Tablets und Mobilnavigation */
@media (max-width: 850px) {
    .site-header {
        position: sticky;
        top: 0;
        z-index: 30;
        width: 100%;
        max-width: none;
        min-height: 68px;
        margin: 0;
        padding: 10px 16px;
        border-width: 0 0 1px;
        border-radius: 0;
        gap: 12px;
    }

    .brand {
        min-width: 0;
        margin-right: auto;
    }

    .brand img {
        width: min(158px, 43vw);
        height: auto;
    }

    .theme-toggle {
        flex: 0 0 auto;
        width: 44px;
        height: 44px;
    }

    .mobile-navigation-toggle {
        display: inline-flex;
    }

    .site-header nav {
        position: fixed;
        z-index: 31;
        top: 68px;
        right: 0;
        bottom: 0;
        display: flex;
        flex-direction: column;
        width: min(88vw, 380px);
        margin: 0;
        padding: 24px 18px 40px;
        overflow-y: auto;
        gap: 8px;
        border-left: 1px solid var(--line);
        background: var(--bg);
        box-shadow: -24px 0 60px rgba(0, 0, 0, 0.3);
        transform: translateX(105%);
        visibility: hidden;
        transition:
            transform 220ms ease,
            visibility 220ms ease;
    }

    .site-header nav.is-open {
        transform: translateX(0);
        visibility: visible;
    }

    .site-header nav a {
        display: flex;
        align-items: center;
        min-height: 52px;
        padding: 13px 15px;
        color: var(--text);
        border: 1px solid transparent;
        border-radius: 13px;
        font-size: 1rem;
    }

    .site-header nav a:hover,
    .site-header nav a:focus-visible {
        border-color: var(--line);
        background: var(--surface);
    }

    .hero,
    .section,
    .trust,
    .cta {
        width: 100%;
        padding-right: 22px;
        padding-left: 22px;
    }

    .hero {
        grid-template-columns: 1fr;
        min-height: auto;
        padding-top: 72px;
        padding-bottom: 68px;
        gap: 38px;
    }

    .hero h1 {
        margin: 16px 0 22px;
        font-size: clamp(2.55rem, 11.5vw, 4.4rem);
        line-height: 1.01;
        letter-spacing: -0.045em;
        overflow-wrap: anywhere;
    }

    .hero p,
    .section-head p,
    .page-hero p {
        max-width: 65ch;
        font-size: 1.04rem;
        line-height: 1.72;
    }

    .hero-panel {
        width: 100%;
        padding: 20px;
        border-radius: 24px;
    }

    .trust {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        overflow: visible;
        padding-top: 24px;
        padding-bottom: 24px;
        gap: 14px;
    }

    .trust span {
        display: flex;
        align-items: center;
        min-height: 48px;
        padding: 10px 12px;
        border: 1px solid var(--line);
        border-radius: 12px;
        background: var(--surface);
        font-size: 0.9rem;
    }

    .section {
        padding-top: 78px;
        padding-bottom: 78px;
    }

    .section-head {
        margin-bottom: 30px;
    }

    .section-head h2,
    .security h2,
    .cta h2,
    .page-hero h1 {
        font-size: clamp(2.05rem, 8.8vw, 3.45rem);
        line-height: 1.08;
        letter-spacing: -0.035em;
        overflow-wrap: anywhere;
    }

    .bento,
    .projects,
    .security,
    .project-detail-grid,
    .showcase-card,
    .featured-project-card {
        grid-template-columns: 1fr;
    }

    .card,
    .projects article {
        min-height: 0;
        padding: 26px;
        border-radius: 22px;
    }

    .card-wide {
        grid-column: auto;
    }

    .security {
        width: calc(100% - 44px);
        margin: 0 22px;
        padding: 30px 24px;
        gap: 26px;
    }

    .showcase-visual,
    .featured-project-image,
    .featured-project-image img,
    .featured-project-placeholder {
        min-height: 250px;
        max-height: 330px;
    }

    .showcase-content,
    .featured-project-content {
        padding: 30px 24px;
    }

    .project-detail-image img {
        max-height: 420px;
        border-radius: 20px;
    }

    .project-rich-content,
    .project-richtext {
        overflow-wrap: anywhere;
    }

    .project-rich-content table,
    .project-richtext table {
        display: block;
        max-width: 100%;
        overflow-x: auto;
    }

    .cta {
        padding-top: 72px;
        padding-bottom: 72px;
    }
}

/* Smartphones */
@media (max-width: 640px) {
    body {
        font-size: 16px;
        line-height: 1.7;
    }

    .hero,
    .section,
    .trust,
    .cta {
        padding-right: 18px;
        padding-left: 18px;
    }

    .hero {
        padding-top: 54px;
        padding-bottom: 54px;
    }

    .hero h1 {
        font-size: clamp(2.25rem, 12vw, 3.35rem);
    }

    .actions,
    .section-action,
    .featured-project-actions {
        align-items: stretch;
        flex-direction: column;
        width: 100%;
    }

    .actions .btn,
    .section-action .btn,
    .featured-project-actions .btn {
        width: 100%;
        min-height: 50px;
    }

    .trust {
        grid-template-columns: 1fr;
    }

    .section {
        padding-top: 62px;
        padding-bottom: 62px;
    }

    .card,
    .projects article {
        padding: 23px 20px;
    }

    .projects img,
    .featured-projects img,
    .home-projects img,
    .projects-preview img,
    .project-grid img,
    .project-card img,
    .featured-project-card img,
    .home-project-card img,
    .project-image img,
    .project-preview img {
        height: 190px;
        border-radius: 12px;
    }

    .showcase-visual,
    .featured-project-image,
    .featured-project-image img,
    .featured-project-placeholder {
        min-height: 220px;
        max-height: 260px;
    }

    .security {
        width: calc(100% - 36px);
        margin: 0 18px;
        padding: 25px 20px;
        border-radius: 22px;
    }

    .contact-form,
    .newsletter-row {
        grid-template-columns: 1fr;
    }

    .contact-form input,
    .contact-form textarea,
    .newsletter-form input,
    .newsletter-form button {
        min-height: 48px;
        font-size: 16px;
    }

    .cookie-banner,
    .cookie-dialog,
    .accessibility-panel {
        max-width: calc(100vw - 24px) !important;
    }

    .footer-brand-line {
        font-size: 0.88rem;
        line-height: 1.6;
    }
}

/* Sehr kleine Smartphones */
@media (max-width: 390px) {
    .site-header {
        padding-inline: 12px;
    }

    .brand img {
        width: 140px;
    }

    .hero,
    .section,
    .trust,
    .cta {
        padding-right: 15px;
        padding-left: 15px;
    }

    .hero h1 {
        font-size: 2.2rem;
    }

    .section-head h2,
    .security h2,
    .cta h2,
    .page-hero h1 {
        font-size: 1.95rem;
    }

    .card,
    .projects article {
        padding: 21px 17px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .site-header nav,
    .mobile-navigation-toggle span,
    .mobile-navigation-toggle::before,
    .mobile-navigation-toggle::after {
        transition: none;
    }
}
