/* ==========================================================================
   baufranke.de – Feinschliff 2026-09 (wird auf allen Seiten zuletzt geladen)
   Ziel: ruhigeres Raster, konsistente Abstände/Typo, saubere Mobil-Reihenfolge.
   Struktur der Seiten bleibt; alles hier ist rein CSS und rückbaubar.
   ========================================================================== */

:root {
    --section-y: clamp(3.25rem, 7vw, 6.5rem);
    --header-gap: clamp(1.5rem, 3.5vw, 2.75rem);
    --radius-card: 16px;
    --grid-gap: clamp(1rem, 2.2vw, 1.75rem);
    --brand-gradient: linear-gradient(135deg, #0f6b2f 0%, #1f9a45 100%);
}

/* --------------------------------------------------------------------------
   Typografie & Rhythmus
   -------------------------------------------------------------------------- */
h1, h2, h3, h4 { text-wrap: balance; }
h2 { font-size: clamp(1.75rem, 1.2rem + 2.2vw, 2.6rem); letter-spacing: -0.012em; line-height: 1.18; }
h3 { font-size: clamp(1.15rem, 1rem + 0.9vw, 1.5rem); }
.section-padding { padding: var(--section-y) 0; }
.section-header { margin-bottom: var(--header-gap); }
.section-header h2 { margin-bottom: 0.5rem; }
.section-subtitle,
.section-header p { max-width: 62ch; margin-left: auto; margin-right: auto; line-height: 1.55; }
.section-header.text-center + * { margin-top: 0; }
.lead { font-size: clamp(1.05rem, 0.95rem + 0.5vw, 1.25rem); line-height: 1.55; }
p { line-height: 1.65; }
.container { padding-left: clamp(1rem, 4vw, 1.5rem); padding-right: clamp(1rem, 4vw, 1.5rem); }

/* Seitenkopf: kompakter, Untertitel lesbar */
.page-header { padding: calc(var(--spacing-2xl) + 64px) 0 var(--spacing-2xl); }
.page-header h1 { margin-bottom: 0.5rem; }
.page-header p { color: rgba(255, 255, 255, 0.88); max-width: 60ch; margin: 0 auto; }

/* Buttons: gleiche Höhe, kein Springen */
.btn { min-height: 46px; display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; }
.btn-large { min-height: 52px; }
.cta-actions, .hero-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; justify-content: center; }

/* --------------------------------------------------------------------------
   Startseite
   -------------------------------------------------------------------------- */
.intro-grid { gap: clamp(2rem, 5vw, 4.5rem); align-items: center; }
.intro-image img { width: 100%; height: auto; } /* Freisteller mit Alpha – bewusst ohne Rahmen/Schatten */
.key-benefits { display: grid; gap: 0.75rem; margin-top: var(--spacing-lg); }
.benefit-item { padding: 0.85rem 1rem; border-radius: 12px; background: rgba(15, 107, 47, 0.06); align-items: center; }
.benefit-item h3, .benefit-content h3, .benefit-content h4 { margin: 0 0 0.15rem; font-size: 1.05rem; }
.benefit-content p { margin: 0; font-size: 0.95rem; }
body.dark-mode .benefit-item { background: rgba(255, 255, 255, 0.05); }

.services-grid { max-width: none; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--grid-gap); margin-top: var(--spacing-xl); }
a.service-card, .service-card {
    text-align: left; padding: 1.5rem; border-radius: var(--radius-card); gap: 0.75rem;
    box-shadow: var(--shadow-sm); transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}
a.service-card:hover, a.service-card:focus-visible { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: var(--primary-green-text); outline: none; }
.service-card-icon {
    width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center;
    background: var(--brand-gradient); color: #fff; margin-bottom: 0.25rem; flex: none;
}
.service-card-icon svg { width: 26px; height: 26px; }
.service-card h3 { margin: 0; font-size: 1.2rem; }
.service-card p { margin: 0; font-size: 0.95rem; line-height: 1.55; }
.service-card p { flex: 1 1 auto; }
.service-card-link { margin-top: auto; padding-top: 0.5rem; }
.services-grid + .text-center { margin-top: var(--spacing-xl); }

/* Karte + Legende: Legende gleichmäßig, Karte mit Rand */
.legend-grid { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: var(--grid-gap); }
.legend-item { border-radius: 14px; height: 100%; }
.map-container, #projectMap, .project-map { border-radius: var(--radius-card); overflow: hidden; box-shadow: var(--shadow-md); }

/* Kontaktblock Startseite: lesbare Karten */
.contact-section .contact-info-card, .contact-section .contact-card { backdrop-filter: none; }

/* --------------------------------------------------------------------------
   Leistungen: Sektionen kompakter, Glass-Card lesbar, Mobil volle Breite
   -------------------------------------------------------------------------- */
.service-section { min-height: 88vh; padding: clamp(64px, 9vw, 110px) 0; }
.text-box { max-width: 520px; background: rgba(255, 255, 255, 0.94); box-shadow: var(--shadow-lg); }
body.dark-mode .text-box { background: rgba(6, 26, 22, 0.88); }
.service-tags { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 1rem 0 1.25rem; }
.service-tags .tag { margin: 0; }
/* Flip-Karten: Vorder- und Rückseite teilen sich eine Grid-Zelle → Höhe folgt dem Inhalt,
   nichts wird mehr abgeschnitten (vorher absolute Positionierung mit fester min-height). */
.flip-card { display: grid; min-height: 0; }
.flip-card-front, .flip-card-back { position: relative; grid-area: 1 / 1; min-height: 0; height: auto; }
.flip-card-container { min-height: 0; }
@media (max-width: 768px) {
    .service-section { min-height: 0; padding: 48px 0 64px; }
    .text-box { max-width: none; margin: 0 1rem; }
    .parallax-bg { top: 0; height: 100%; }
}

/* Projektablauf: Original-Timeline (vertikal) bleibt unverändert */

/* --------------------------------------------------------------------------
   Referenzen
   -------------------------------------------------------------------------- */
.features-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--grid-gap); }
.feature-item { border-radius: var(--radius-card); overflow: hidden; }
/* Video-Masonry (7/5-Raster bleibt): gleiche Zeilenhöhe, damit die Reihen bündig sind */
.video-masonry { gap: var(--grid-gap); }
.video-masonry-item { border-radius: var(--radius-card); overflow: hidden; height: clamp(220px, 26vw, 380px); }
.video-masonry-item .masonry-video { width: 100%; height: 100%; object-fit: cover; }
@media (max-width: 640px) {
    .features-grid { grid-template-columns: 1fr; }
    .video-masonry { grid-template-columns: 1fr; }
    .video-masonry-item, .video-masonry-item:nth-child(n) { grid-column: 1 / -1; height: auto; aspect-ratio: 16 / 9; }
}
.filter-navigation { display: flex !important; flex-wrap: wrap; justify-content: center; gap: 0.6rem; max-width: none; }
.filter-btn { width: auto; border-radius: 999px; padding: 0.55rem 1.15rem; font-size: 0.95rem; }
.project-cards-grid { gap: var(--grid-gap); }
.project-card { border-radius: var(--radius-card); }
.project-card-header { padding: 0.9rem 1rem; }
.project-card-body { padding: 1rem 1.25rem 1.25rem; }
.project-card-footer { padding: 0 1.25rem 1.25rem; }
.project-card-title { font-size: 1.1rem; line-height: 1.35; }

/* --------------------------------------------------------------------------
   Karriere
   -------------------------------------------------------------------------- */
.job-listings { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--grid-gap); }
.job-listings .jobs-loading, .job-listings .jobs-error, .job-listings .no-jobs { grid-column: 1 / -1; }
@media (max-width: 900px) { .job-listings { grid-template-columns: 1fr; } }
.job-card { border-radius: var(--radius-card); display: flex; flex-direction: column; }
.apprenticeship-grid { gap: clamp(1.5rem, 4vw, 3rem); }
@media (max-width: 900px) { .apprenticeship-grid { grid-template-columns: 1fr; } }

/* --------------------------------------------------------------------------
   Kontakt
   -------------------------------------------------------------------------- */
.contact-main { min-height: 0; }
.contact-grid-main { gap: clamp(2rem, 5vw, 4.5rem); }
.contact-form-wrapper, .contact-form-container { border-radius: var(--radius-card); }
.form-group input, .form-group select, .form-group textarea { min-height: 46px; border-radius: 10px; }
.form-group textarea { min-height: 140px; }
.leaflet-popup-content-wrapper { border-radius: 12px; }
body.dark-mode .leaflet-popup-content-wrapper, body.dark-mode .leaflet-popup-tip { background: #0f2320; color: #e6f0ea; }
body.dark-mode .leaflet-popup-content a { color: #5ed087; }

/* --------------------------------------------------------------------------
   Footer & Kleinigkeiten
   -------------------------------------------------------------------------- */
.footer-grid { gap: clamp(1.5rem, 4vw, 3rem); }
@media (max-width: 900px) { .footer-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .footer-grid { grid-template-columns: 1fr; } }
.footer-section h4 { margin-bottom: 0.75rem; }
.footer-section ul li { margin-bottom: 0.4rem; }

/* Fokus-Sichtbarkeit (Tastatur) */
a:focus-visible, button:focus-visible, summary:focus-visible { outline: 3px solid var(--primary-green-text); outline-offset: 2px; }

/* Bewegung reduzieren */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

/* Mobil-Feinschliff */
@media (max-width: 768px) {
    .section-padding { padding: 3rem 0; }
    .services-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.85rem; }
    a.service-card, .service-card { padding: 1.1rem; }
    .service-card-icon { width: 42px; height: 42px; border-radius: 11px; }
    .service-card h3 { font-size: 1.05rem; }
    .service-card p { font-size: 0.9rem; }
    .intro-grid { grid-template-columns: 1fr; gap: 1.5rem; }
    .intro-image { order: -1; }
    .page-header { padding: calc(var(--spacing-xl) + 64px) 0 var(--spacing-xl); }
    .cta-actions .btn, .hero-actions .btn { width: 100%; }
    .filter-navigation { gap: 0.45rem; }
    .filter-btn { padding: 0.5rem 0.9rem; font-size: 0.9rem; }
}
@media (max-width: 420px) {
    .services-grid { grid-template-columns: 1fr; }
}

/* ==========================================================================
   Modale: ein gemeinsames Schema (2026-09)
   Vorher hatte jedes Modal eigene Overlay-Farben, Radien, Close-Buttons und
   z-index-Werte. Hier werden alle auf dieselben Tokens gezogen; Struktur und
   JS bleiben unverändert.
   ========================================================================== */
:root {
    --modal-overlay: rgba(9, 24, 16, 0.78);
    --modal-blur: blur(6px);
    --modal-radius: 18px;
    --modal-shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
    --modal-header: linear-gradient(135deg, #0f6b2f 0%, #1f9a45 100%);
    --z-modal: 10000;
    --z-lightbox: 10100;
}

/* --- Overlays: gleiche Farbe, gleicher Blur, gleiche Ebene ---------------- */
.modal-overlay,
.project-modal .project-modal-backdrop,
.project-modal .project-modal-overlay,
.pdf-modal,
.angebot-pdf-modal .angebot-pdf-overlay,
.privacy-modal .privacy-modal-overlay,
.video-lightbox .video-lightbox-overlay {
    background: var(--modal-overlay) !important;
    -webkit-backdrop-filter: var(--modal-blur);
    backdrop-filter: var(--modal-blur);
}
.modal-overlay, .project-modal, .pdf-modal, .privacy-modal { z-index: var(--z-modal); }
.angebot-pdf-modal, .video-lightbox { z-index: calc(var(--z-modal) + 1); }

/* --- Container: gleicher Radius, gleicher Schatten ------------------------ */
.modal-overlay .modal,
.project-modal-container,
.pdf-modal-content,
.angebot-pdf-container,
.privacy-modal-content,
.video-lightbox-container {
    border-radius: var(--modal-radius);
    box-shadow: var(--modal-shadow);
    overflow: hidden;
}

/* --- Kopfzeile: überall der grüne Markenverlauf --------------------------- */
.modal-overlay .modal-header,
.project-modal-header,
.pdf-modal-header,
.angebot-pdf-header,
.privacy-modal-header {
    background: var(--modal-header);
    border-bottom: none;
    padding: 1.15rem clamp(1.25rem, 3vw, 2rem);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}
.modal-overlay .modal-title,
.project-modal-title,
.pdf-modal-title,
.angebot-pdf-header h3,
.privacy-modal-header h2 {
    color: #fff;
    margin: 0;
    font-size: clamp(1.05rem, 0.95rem + 0.6vw, 1.45rem);
    line-height: 1.25;
    font-weight: 700;
}

/* --- Schließen-Button: überall derselbe runde Knopf ----------------------- */
.modal-overlay .modal-close,
.project-modal-close,
.pdf-modal-close,
.angebot-pdf-close,
.privacy-modal-close {
    width: 42px; height: 42px; min-width: 42px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.28);
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer; flex: none; padding: 0;
    transition: background 0.2s ease, transform 0.2s ease;
}
.modal-overlay .modal-close:hover,
.project-modal-close:hover,
.pdf-modal-close:hover,
.angebot-pdf-close:hover,
.privacy-modal-close:hover { background: rgba(255, 255, 255, 0.3); transform: scale(1.06); }
.modal-overlay .modal-close::before { color: #fff; font-size: 1.5rem; line-height: 1; }
.pdf-modal-close { font-size: 1.6rem; line-height: 1; }
.privacy-modal-close svg, .project-modal-close svg, .angebot-pdf-close svg { width: 22px; height: 22px; }

/* --- Body: gleiche Innenabstände ----------------------------------------- */
.modal-overlay .modal-body,
.project-modal-body,
.project-modal-content,
.pdf-modal-body,
.privacy-modal-body { padding: clamp(1.25rem, 3vw, 2rem); }

/* --------------------------------------------------------------------------
   Bilder im Projektmodal: ruhiges Raster, erstes Bild groß
   -------------------------------------------------------------------------- */
.modal-images-container {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    overflow: visible;
}
.modal-image-item { aspect-ratio: 1; border-radius: 12px; margin: 0; }
.modal-image-item:first-child { grid-column: span 2; grid-row: span 2; aspect-ratio: 1; }
.modal-images-container img { width: 100%; height: 100%; object-fit: cover; display: block; }
.modal-image-item:hover { transform: none; }
.modal-image-item:hover img { transform: scale(1.04); }
.modal-images-container img { transition: transform 0.35s ease; }
.modal-image-caption { font-size: 0.8rem; padding: 0.6rem 0.7rem; }
.modal-image-item:first-child .modal-image-caption { font-size: 0.9rem; }
@media (max-width: 900px) { .modal-images-container { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 560px) {
    .modal-images-container { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .modal-image-item:first-child { grid-column: span 2; grid-row: auto; aspect-ratio: 4 / 3; }
}

/* --------------------------------------------------------------------------
   Gemeinsame Lightbox (assets/js/lightbox.js)
   -------------------------------------------------------------------------- */
.fx-lightbox {
    position: fixed; inset: 0; z-index: var(--z-lightbox);
    display: none; align-items: center; justify-content: center;
    padding: clamp(3.5rem, 8vh, 5rem) clamp(0.75rem, 5vw, 5rem) clamp(5.5rem, 12vh, 7rem);
}
.fx-lightbox.is-open { display: flex; }
.fx-lightbox-backdrop { position: absolute; inset: 0; background: rgba(6, 16, 11, 0.94); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.fx-lightbox-bar {
    position: absolute; top: 0; left: 0; right: 0; z-index: 2;
    display: flex; align-items: center; justify-content: space-between;
    gap: 1rem; padding: clamp(0.75rem, 2vw, 1.25rem);
}
.fx-lightbox-counter { color: rgba(255, 255, 255, 0.9); font-size: 0.95rem; font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.fx-lightbox-btn {
    width: 46px; height: 46px; border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.25); background: rgba(255, 255, 255, 0.12);
    color: #fff; display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer; padding: 0; -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
    transition: background 0.2s ease, transform 0.2s ease;
}
.fx-lightbox-btn:hover { background: rgba(255, 255, 255, 0.24); transform: scale(1.06); }
.fx-lightbox-btn[hidden] { display: none; }
.fx-lightbox-prev, .fx-lightbox-next { position: absolute; top: 50%; transform: translateY(-50%); z-index: 2; width: 52px; height: 52px; }
.fx-lightbox-prev { left: clamp(0.5rem, 2vw, 1.5rem); }
.fx-lightbox-next { right: clamp(0.5rem, 2vw, 1.5rem); }
.fx-lightbox-prev:hover, .fx-lightbox-next:hover { transform: translateY(-50%) scale(1.06); }
.fx-lightbox-stage { position: relative; z-index: 1; margin: 0; display: flex; flex-direction: column; align-items: center; gap: 0.75rem; max-width: 100%; max-height: 100%; }
.fx-lightbox-image {
    max-width: min(1400px, 100%); max-height: calc(100vh - 12rem);
    width: auto; height: auto; object-fit: contain; border-radius: 10px;
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.55);
    opacity: 0; transition: opacity 0.25s ease;
}
.fx-lightbox-image.is-loaded { opacity: 1; }
.fx-lightbox-caption { color: rgba(255, 255, 255, 0.88); font-size: 0.92rem; text-align: center; max-width: 70ch; line-height: 1.45; }
.fx-lightbox-strip {
    position: absolute; left: 0; right: 0; bottom: 0; z-index: 2;
    display: flex; gap: 8px; justify-content: flex-start; align-items: center;
    padding: clamp(0.6rem, 2vw, 1rem); overflow-x: auto; scrollbar-width: none;
}
.fx-lightbox-strip::-webkit-scrollbar { display: none; }
.fx-lightbox-strip button {
    flex: none; width: 74px; height: 52px; padding: 0; cursor: pointer;
    border: 2px solid transparent; border-radius: 8px; overflow: hidden;
    background: none; opacity: 0.55; transition: opacity 0.2s ease, border-color 0.2s ease;
}
.fx-lightbox-strip button img { width: 100%; height: 100%; object-fit: cover; display: block; }
.fx-lightbox-strip button:hover { opacity: 0.85; }
.fx-lightbox-strip button.is-active { opacity: 1; border-color: #3fbf6a; }
.fx-lightbox-btn:focus-visible, .fx-lightbox-strip button:focus-visible { outline: 3px solid #3fbf6a; outline-offset: 2px; }
@media (max-width: 640px) {
    .fx-lightbox-prev, .fx-lightbox-next { width: 44px; height: 44px; }
    .fx-lightbox-strip button { width: 58px; height: 42px; }
}
@media (prefers-reduced-motion: reduce) { .fx-lightbox-image { transition: none; opacity: 1; } }
