/* ============================================================
   Globale Mobile-Optimierung – bis 980 px
   ============================================================ */

@media (max-width: 980px) {
  :root {
    --mobile-header-h: 68px;
    --mobile-section-py: 60px;
  }

  html {
    scroll-padding-top: calc(var(--mobile-header-h) + 12px);
  }

  body {
    overflow-x: hidden;
  }

  .wrap {
    width: 100%;
    padding-inline: 22px;
  }

  .sec,
  .intro,
  .team,
  .werte,
  .stamm,
  .materials,
  .process,
  .pillars,
  .specs-sec,
  .verfahren,
  .normen,
  .products {
    padding: var(--mobile-section-py) 0;
  }

  .sec-head {
    margin-bottom: 34px;
  }

  .sh {
    font-size: clamp(1.72rem, 7vw, 2.2rem);
    line-height: 1.13;
    margin-block: 11px 12px;
  }

  .sl,
  .intro-text p,
  .leistung-content p,
  .branche-content p {
    font-size: 0.97rem;
    line-height: 1.68;
  }

  /* Header */
  header,
  header.scrolled,
  header.solid,
  .nav {
    height: var(--mobile-header-h);
  }

  .nav {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    padding-inline: 18px;
  }

  .brand {
    min-width: 0;
  }

  .brand-picture {
    display: block;
    min-width: 0;
  }

  .brand img,
  header.scrolled .brand img,
  header.solid .brand img {
    width: auto;
    max-width: min(43vw, 190px);
    height: 38px;
    object-fit: contain;
    object-position: left center;
  }

  .nav-right {
    gap: 7px;
  }

  .nav-cta {
    padding: 8px 12px;
    font-size: 0.78rem;
  }

  .theme-toggle-header {
    display: none;
  }

  .theme-toggle-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .burger {
    display: flex;
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    position: relative;
    z-index: 103;
  }

  .burger span {
    width: 17px;
    transform-origin: center;
  }

  body.nav-open .burger span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
  }

  body.nav-open .burger span:nth-child(2) {
    opacity: 0;
  }

  body.nav-open .burger span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
  }

  /* Mobile Navigation: rechter Off-Canvas-Drawer */
  header.menu-open {
    z-index: 110;
  }

  .nav-menu {
    position: fixed;
    inset:
      var(--mobile-header-h)
      0
      0
      auto;
    z-index: 102;

    display: flex;
    width: min(88vw, 370px);
    max-height: none;
    min-height: calc(100dvh - var(--mobile-header-h));
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;

    flex-direction: column;
    align-items: stretch;
    gap: 0;

    padding:
      12px
      16px
      max(24px, env(safe-area-inset-bottom));

    border: 0;
    border-left: 1px solid var(--line);
    background: var(--bg);
    box-shadow: -18px 0 48px rgba(4, 14, 26, 0.28);

    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translate3d(100%, 0, 0);
    will-change: transform;

    transition:
      transform 0.28s cubic-bezier(0.22, 1, 0.36, 1),
      opacity 0.2s ease,
      visibility 0s linear 0.28s;
  }

  .nav-menu.open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translate3d(0, 0, 0);
    transition-delay: 0s;
  }

  .nav-link {
    min-height: 50px;
    display: flex;
    align-items: center;
    padding: 12px 14px;
    border: 0;
    border-bottom: 1px solid var(--line);
    border-radius: 0;
    color: var(--nav-fg);
    font-size: 0.95rem;
  }

  .nav-link::after {
    display: none;
  }

  .nav-link:hover {
    background: var(--off);
    color: var(--nav-accent);
  }

  .nav-link.active {
    padding-left: 18px;
    border-radius: 9px;
    border-bottom-color: transparent;
    background: var(--blue-soft);
    color: var(--nav-accent);
  }

  .nav-link-mobile-contact {
    margin-top: 14px;
    justify-content: center;
    border: 0;
    border-radius: var(--r);
    background: var(--blue);
    color: #fff;
    font-weight: 700;
  }

  .nav-link-mobile-contact:hover {
    background: var(--blue-d);
    color: #fff;
  }

  .nav-mobile-tools {
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid var(--line);
  }

  .nav-mobile-tools-label {
    display: block;
    margin-bottom: 9px;
    color: var(--mute);
    font-family: var(--fm);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
  }

  .theme-toggle-mobile {
    display: flex;
    width: 100%;
    height: auto;
    min-height: 50px;
    padding: 10px 14px;
    justify-content: flex-start;
    gap: 12px;
    border-color: var(--line2);
    border-radius: var(--r);
    background: var(--off);
    color: var(--ink);
  }

  .theme-toggle-mobile:hover {
    background: var(--blue-soft);
  }

  .theme-toggle-mobile .theme-toggle-icon {
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    border-radius: 8px;
    background: var(--blue-soft);
    color: var(--blue);
  }

  .theme-toggle-mobile .theme-toggle-icon svg {
    width: 17px;
    height: 17px;
  }

  .theme-toggle-text {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
  }

  /* Overlay liegt unter dem Header-Stacking-Context und über dem Inhalt. */
  body::before {
    content: "";
    position: fixed;
    inset: var(--mobile-header-h) 0 0;
    z-index: 99;
    background: rgba(4, 14, 26, 0.58);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition:
      opacity 0.22s ease,
      visibility 0s linear 0.22s;
  }

  body.nav-open::before {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition-delay: 0s;
  }

  /* Unterseiten-Hero */
  .page-hero {
    min-height: 330px;
  }

  .page-hero-bg {
    background-position: center 38%;
    opacity: 0.34;
  }

  .page-hero-inner {
    padding: 42px 22px 46px;
  }

  .breadcrumb {
    margin-bottom: 12px;
    gap: 6px;
    font-size: 0.76rem;
  }

  .page-hero h1 {
    margin: 9px 0 12px;
    font-size: clamp(2rem, 9vw, 2.75rem);
    line-height: 1.04;
  }

  .page-hero p {
    max-width: 34rem;
    font-size: 0.96rem;
    line-height: 1.58;
  }

  /* Allgemeine Raster */
  .intro-grid,
  .werte-grid {
    grid-template-columns: 1fr;
    gap: 32px;
  }

  /* Footer */
  .footer-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 34px 28px;
    margin-bottom: 34px;
  }

  .footer-services {
    grid-column: 1;
  }

  .footer-company {
    grid-column: 2;
  }

  .footer-contact {
    grid-column: 1 / -1;

    padding-top: 28px;
    border-top: 1px solid rgba(69, 154, 240, 0.14);
  }

  .footer-contact-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px 32px;
  }

  .footer-contact-address {
    margin-bottom: 0;
  }

  .footer-bottom {
    grid-template-columns: 1fr;
    align-items: flex-start;
    gap: 14px;
  }

  .footer-bottom-nav {
    justify-content: flex-start;
  }

  .footer-legal {
    gap: 10px 18px;
  }

  /* Dialoge */
  .cookie-actions {
    grid-template-columns: 1fr;
  }

  .cookie-box {
    padding: 26px 24px 22px;
  }

  /* Floating controls */
  .cookie-reopen {
    left: 16px;
    bottom: 16px;
    width: 42px;
    height: 42px;
  }

  .back-to-top {
    right: 16px;
    bottom: 16px;
    width: 46px;
    height: 46px;
  }

  body.nav-open .cookie-reopen,
  body.nav-open .back-to-top,
  html.is-scroll-locked .cookie-reopen,
  body.is-scroll-locked .cookie-reopen,
  html.is-scroll-locked .back-to-top,
  body.is-scroll-locked .back-to-top {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
  }
}

@media (max-width: 980px) {
  /*
   * padding-bottom haelt den fixierten Cookie-Button unten links
   * frei, damit er das Copyright nicht ueberdeckt.
   */
  footer {
    padding: 46px 0 78px;
  }

  /*
   * Oben: Leistungen und Unternehmen nebeneinander.
   * Darunter: Kontakt über volle Breite.
   */
  .footer-grid {
    display: grid;
    grid-template-columns:
      minmax(0, 1.18fr)
      minmax(0, 0.82fr);

    gap: 32px 22px;
    margin-bottom: 30px;
  }

  .footer-grid > .footer-col:nth-child(1) {
    grid-column: 1;
  }

  .footer-grid > .footer-col:nth-child(2) {
    grid-column: 2;
  }

  .footer-contact {
    grid-column: 1 / -1;

    padding-top: 24px;
    border-top: 1px solid rgba(2, 117, 237, 0.16);
  }

  /*
   * Kontakt mobil kompakter:
   * Adresse links, Telefon/Mail rechts.
   */
  .footer-contact-address {
    margin-bottom: 14px;
  }

  .footer-contact-list {
    gap: 4px;
  }

  /*
   * Redundanten Kontakt-Link unter "Unternehmen" mobil ausblenden,
   * weil darunter bereits der Kontaktblock kommt.
   */
  .footer-grid > .footer-col:nth-child(2) a[href="/#kontakt"] {
    display: none;
  }

  .footer-col h4 {
    margin-bottom: 12px;

    font-size: 9.5px;
    letter-spacing: 0.11em;
  }

  .footer-col a,
  .footer-col p,
  .footer-contact-address,
  .footer-contact-list {
    font-size: 0.84rem;
    line-height: 1.52;
  }

  .footer-col a {
    margin-bottom: 8px;
  }

  /*
   * Untere Ebene:
   * Legal-Links oben,
   * 3D-Vorschau fest über Cookie-Einstellungen,
   * Copyright zuletzt.
   */
  /*
   * Weniger Vorlauf oben, dafuer groesserer Abstand zwischen
   * Legal-Zeile und Copyright: Die Links ruecken hoch, das
   * Copyright bleibt an seiner Position.
   */
  .footer-bottom {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 28px;

    padding-top: 8px;
  }

  /*
   * Kein max-width mehr: Das Copyright soll in einer Zeile stehen.
   * Bewusst ohne white-space: nowrap, damit es auf sehr schmalen
   * Geraeten lieber umbricht als horizontal ueberzulaufen.
   */
  .footer-bottom > span:first-child {
    order: 2;

    color: rgba(255, 255, 255, 0.42);
    font-size: 0.72rem;
    line-height: 1.5;
  }

  /*
   * Zwei Zeilen untereinander:
   * 1. Impressum / Datenschutz / AGB / Cookie-Einstellungen
   * 2. 3D-Vorschau
   */
  .footer-legal {
    order: 1;

    display: grid;
    grid-template-columns: 1fr;
    align-items: start;
    justify-content: start;
    gap: 10px;

    width: 100%;
  }

  /*
   * Rechts-Links und Cookie-Button in einer umbruchfaehigen Zeile.
   * Der Button liegt im Markup in .footer-legal-main, deshalb greift
   * hier .footer-legal-main und nicht .footer-legal > a.
   */
  .footer-legal-main {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 10px 18px;
  }

  .footer-legal-main a {
    margin: 0;

    font-size: 0.8rem;
    line-height: 1.45;
  }

  /* Direkt darunter, ohne Trennlinie. */
  .footer-legal-tools {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;

    margin-top: 0;
    padding-top: 0;

    border-top: 0;
  }

  .footer-bottom .footer-configurator-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;

    margin: 0;

    color: rgba(255, 255, 255, 0.56);

    font-size: 0.68rem;
    font-weight: 500;
    line-height: 1.3;
  }

  .footer-bottom .footer-configurator-label {
    padding: 0;
    border: 0;

    color: var(--blue);

    font-family: var(--fm);
    font-size: 0.52rem;
    font-weight: 500;
    letter-spacing: 0.03em;
    line-height: 1.3;
    text-transform: none;
  }

  .footer-bottom .footer-configurator-text {
    white-space: nowrap;
  }

  /* Gleiche Groesse wie die Rechts-Links, da jetzt in derselben Zeile. */
  .footer-cookie-button {
    font-size: 0.8rem;
    line-height: 1.45;
  }
}

/* ============================================================
   Bis 620 px
   ============================================================ */

@media (max-width: 620px) {
  :root {
    --mobile-section-py: 48px;
  }

  .wrap {
    padding-inline: 18px;
  }

  .nav {
    padding-inline: 12px;
  }

  .brand img,
  header.scrolled .brand img,
  header.solid .brand img {
    max-width: 42vw;
    height: 34px;
  }

  .nav-cta {
    display: none;
  }

  .page-hero {
    min-height: 300px;
  }

  .page-hero-inner {
    padding: 36px 18px 40px;
  }

  /* Footer */
  footer {
    padding: 50px 0 78px;
  }

  .footer-grid {
    grid-template-columns: 1fr;
    gap: 28px;
    margin-bottom: 24px;
  }

  .footer-contact {
    grid-column: auto;
  }

  .footer-col h4 {
    margin-bottom: 12px;
  }

  /*
   * Firmenname und Anschrift bilden eine kompakte Gruppe.
   * Danach folgt ein klarer Abstand zu Telefon, Fax und E-Mail.
   */
  .footer-contact-address {
    margin: 0 0 18px;
    line-height: 1.42;
  }

  .footer-contact-address strong,
  .footer-contact-address span {
    display: block;
    margin: 0;
  }

/* Kontaktangaben wirklich kompakt untereinander */
.footer-contact-row,
.footer-contact-row a,
.footer-contact-row span {
  margin-top: 0;
  margin-bottom: 0;
}

.footer-contact-list {
  gap: 3px;
}

.footer-contact-row-wide {
  margin-top: 8px;
}

  .footer-bottom > span:first-child {
    display: block;
    min-height: 0;
    margin: 18px 0 0;
    padding-left: 74px;

    font-size: 0.68rem;
    line-height: 1.5;
  }

  /*
   * Fliesstext im Footer eine Stufe kleiner als bei 980 px
   * (dort 0.84rem). Untergrenze bewusst bei 0.8rem, damit
   * Adresse und Telefonnummer gut lesbar bleiben.
   */
  .footer-col a,
  .footer-col p,
  .footer-contact-address,
  .footer-contact-list {
    font-size: 0.8rem;
  }

  /*
   * Dritte Gruppe:
   * AGB, Impressum und Datenschutz stehen in genau dieser
   * Reihenfolge in einer Zeile. Cookie-Einstellungen folgt darunter.
   */
  .footer-bottom {
    gap: 20px;
    padding-top: 12px;
  }
  
    .footer-bottom > span:first-child {
    display: block;
    min-height: 0;
    margin: 18px 0 0;
    padding-left: 0;

    font-size: 0.68rem;
    line-height: 1.5;
  }

  .footer-legal {
    align-items: flex-start;
    justify-content: flex-start;
  }

  .footer-legal-main {
    display: grid;
    grid-template-columns: repeat(3, max-content);
    align-items: baseline;
    justify-content: start;
    gap: 12px 22px;
    width: 100%;
  }

  .footer-legal-main [data-legal="agb"] {
    order: 1;
  }

  .footer-legal-main [data-legal="impressum"] {
    order: 2;
  }

  .footer-legal-main [data-legal="datenschutz"] {
    order: 3;
  }

  .footer-legal-main a {
    margin: 0;
    font-size: 0.76rem;
    line-height: 1.45;
  }

  .footer-cookie-button {
    order: 4;
    grid-column: 1 / -1;
    justify-self: start;
    width: max-content;
    margin: 0;
    font-size: 0.76rem;
    line-height: 1.45;
  }

  .footer-legal-tools {
    align-items: flex-start;
    margin-top: 0;
  }


  .footer-bottom .footer-configurator-link {
    font-size: 0.66rem;
  }

  .footer-extra {
    justify-content: flex-start;
    margin: -6px 0 26px;
  }

  /* Dialoge und Rechtsseiten */
  .modal {
    padding: 18px 10px;
  }

  .modal-box {
    padding: 32px 20px;
  }

  .legal-page {
    padding: 0;
  }

  .cta-band {
    padding: 52px 0;
  }

  .cta-band-btns {
    flex-direction: column;
    align-items: stretch;
    padding-inline: 18px;
  }

  .cta-band-btns .btn {
    justify-content: center;
    width: 100%;
  }
}

/* ============================================================
   Bis 430 px
   ============================================================ */

@media (max-width: 430px) {
  .wrap {
    padding-inline: 16px;
  }

  .brand img,
  header.scrolled .brand img,
  header.solid .brand img {
    max-width: 40vw;
    height: 31px;
  }

  .burger {
    width: 36px;
    height: 36px;
    flex-basis: 36px;
  }

  .page-hero h1 {
    font-size: clamp(1.85rem, 9.4vw, 2.35rem);
  }

  .cookie-reopen {
    bottom: 12px;
  }

  .back-to-top {
    width: 44px;
    height: 44px;
  }
}