/**
 * Mobile navigation (HTML hamburger, no Theme-Vue).
 * Enthält auch Breakpoint-Overrides – style.less / critical.css bleiben unverändert.
 *
 * Regel: ≤1365px = Mobile-Nav, ≥1366px = Desktop-Nav (keine Dead Zone).
 */

/* Marketplace frontend.css setzt .page-wrapper { margin-top: -11em } global.
   Nur Fahrzeugbörse-Archiv (caroffers) behält den Overlap. */
body:not(.post-type-archive-caroffers) .page-wrapper {
  margin-top: 0 !important;
}

/* -------------------------------------------------------------------------- */
/* Breakpoint-Overrides (schlagen Theme + Customizer wp-custom-css)           */
/* -------------------------------------------------------------------------- */

@media (max-width: 1365px) {
  header nav {
    display: none !important;
  }

  /* Solider Header über dem Hero (kein transparentes Überlagern) */
  .page-header {
    background: #fff !important;
    position: relative !important;
    z-index: 100;
  }

  /*
   * Scroll-Richtung: main.js setzt .fixed (runter) / .scroll (hoch).
   * Ohne fixed hier bleibt der Header im Fluss und scrollt nur mit weg.
   */
  .page-header.fixed,
  .page-header.scroll {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 999 !important;
    background: #fff !important;
    animation: none !important;
    transition: transform 0.35s ease !important;
  }

  /* Runterscrollen: komplett rausschieben */
  .page-header.fixed {
    transform: translateY(-100%) !important;
  }

  /* Hochscrollen: wieder einblenden */
  .page-header.scroll {
    transform: translateY(0) !important;
  }

  .page-header.fixed .mobile .logos,
  .page-header.scroll .mobile .logos {
    height: auto !important;
    overflow: visible !important;
    transform: none !important;
    animation: none !important;
  }

  .page-header .top-header .top-content .nav-wrapper-right,
  .top-header .top-content .nav-wrapper-right {
    display: flex !important;
    width: 100%;
    background: #fff;
  }

  .page-header .top-header .top-content .nav-wrapper-right .brands-landscape {
    display: none !important;
  }

  /*
   * Mobile-Header-Grid:
   *  Zeile 1: Logo | Hamburger (volle Breite, weiß)
   *  Zeile 2: Marken-Logos (volle Breite, weiß)
   */
  .page-header .top-header .top-content .nav-wrapper-right .mobile,
  .top-header .top-content .nav-wrapper-right .mobile,
  .mobile {
    display: grid !important;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "logo burger"
      "brands brands";
    align-items: center;
    width: 100%;
    background: #fff;
    position: relative;
  }

  .page-header .top-header .top-content .nav-wrapper-right .mobile.init-in-progress,
  .top-header .top-content .nav-wrapper-right .mobile.init-in-progress,
  .mobile.init-in-progress {
    display: grid !important;
  }

  .mobile .logo-mobile {
    grid-area: logo;
    background: #fff !important;
    padding: 0.75rem 1rem !important;
    text-align: left !important;
    width: 100%;
    max-width: none;
  }

  .mobile .logo-mobile img {
    height: 28px !important;
    width: auto !important;
    max-width: 70%;
  }

  .mobile .logos {
    grid-area: brands;
    background: #fff !important;
    margin: 0 !important;
    padding: 0.4rem 0.75rem 0.75rem !important;
    width: 100%;
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: center;
    justify-content: space-between;
    gap: 0.35rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .mobile .logos a {
    flex: 0 0 auto;
  }

  .mobile .logos img {
    max-height: 22px !important;
    max-width: 36px !important;
    width: auto !important;
    height: auto !important;
    object-fit: contain;
  }

  .mobile-main-navigation-component {
    grid-area: burger;
    display: flex !important;
    align-items: center;
    justify-content: center;
    position: relative !important;
    right: auto;
    top: auto;
    z-index: 30;
    padding: 0.75rem 1rem !important;
  }

  /* style.css setzt trigger auf fixed – das zerstört die Headerzeile */
  .mobile-main-navigation-component .trigger {
    position: relative !important;
    right: auto !important;
    top: auto !important;
  }

  .mobile-main-navigation-component .trigger:not(.active) .bar1,
  .mobile-main-navigation-component .trigger:not(.active) .bar2,
  .mobile-main-navigation-component .trigger:not(.active) .bar3 {
    background-color: var(--baseFontColor, #4f5151) !important;
  }

  /* Hero-Paginierung: nur Punkte, keine Zahlen */
  .hero-slider .slick-dots {
    bottom: 12px !important;
    left: 0;
    right: 0;
    width: 100%;
    padding: 0;
    margin: 0;
    list-style: none;
    display: flex !important;
    justify-content: center;
    align-items: center;
    gap: 0.35rem;
    z-index: 5;
  }

  .hero-slider .slick-dots li {
    margin: 0 !important;
    width: auto !important;
    height: auto !important;
  }

  .hero-slider .slick-dots li button {
    font-size: 0 !important;
    line-height: 0 !important;
    color: transparent !important;
    text-indent: -9999px !important;
    width: 0.55rem !important;
    height: 0.55rem !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 50% !important;
    background: rgba(255, 255, 255, 0.55) !important;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
    opacity: 1 !important;
  }

  .hero-slider .slick-dots li button::before {
    display: none !important;
    content: none !important;
  }

  .hero-slider .slick-dots li.slick-active button {
    background: #fff !important;
    width: 0.7rem !important;
    height: 0.7rem !important;
  }
}

@media (min-width: 1366px) {
  /* Kontert Customizer: @media (min-width: 1365px) and (max-width: 1367px) */
  header nav {
    display: flex !important;
  }

  .page-header .top-header .top-content .nav-wrapper-right,
  .top-header .top-content .nav-wrapper-right {
    display: none !important;
  }

  .page-header .top-header .top-content .nav-wrapper-right .mobile,
  .top-header .top-content .nav-wrapper-right .mobile,
  .mobile,
  .mobile.init-in-progress {
    display: none !important;
  }

  .mobile-main-navigation-component {
    display: none !important;
  }
}

@media (min-width: 1366px) and (max-width: 1600px) {
  header nav {
    flex-flow: wrap;
    justify-content: space-between;
    align-items: center;
  }

  header nav .show-lg {
    display: none !important;
  }

  header nav .show-md {
    display: block !important;
  }
}

@media (min-width: 1601px) {
  header nav .show-md {
    display: none !important;
  }

  header nav .show-lg {
    display: block !important;
  }
}

/* -------------------------------------------------------------------------- */
/* Hamburger + Off-Canvas                                                     */
/* -------------------------------------------------------------------------- */

.mobile-main-navigation-component .trigger {
  display: inline-block;
  cursor: pointer;
  position: relative;
  z-index: 40;
  padding-right: 7px;
  transition: transform 0.3s ease, right 0.3s ease, top 0.3s ease;
}

.mobile-main-navigation-component .trigger .mobile-menu-trigger {
  display: block;
}

.mobile-main-navigation-component .trigger .bar1,
.mobile-main-navigation-component .trigger .bar2,
.mobile-main-navigation-component .trigger .bar3 {
  width: 25px;
  height: 3px;
  background-color: var(--baseFontColor, #333);
  margin: 4px 0;
  transition: 0.4s;
  border-radius: 5px;
}

/* Offen: X fixed oben rechts (über Overlay) */
.mobile-main-navigation-component .trigger.active {
  position: fixed !important;
  right: 12px !important;
  top: 12px !important;
  padding: 0;
  z-index: 40;
}

.mobile-main-navigation-component .trigger.active .bar1,
.mobile-main-navigation-component .trigger.active .bar2,
.mobile-main-navigation-component .trigger.active .bar3 {
  background-color: #fff;
}

.mobile-main-navigation-component .trigger.active .bar1 {
  transform: rotate(-45deg) translate(-2px, 2px);
}

.mobile-main-navigation-component .trigger.active .bar2 {
  opacity: 0;
}

.mobile-main-navigation-component .trigger.active .bar3 {
  transform: rotate(45deg) translate(-8px, -8px);
}

/*
 * Off-canvas: versteckt bis .active.
 * Spezifität > critical.css; !important gegen width/transform-Konflikte.
 * Wichtig: kein transform am .page-header bei offenem Menü (sonst bricht position:fixed).
 */
.page-header .top-header .top-content .nav-wrapper-right .mobile-main-navigation-component .overlay,
.mobile-main-navigation-component .overlay {
  position: fixed !important;
  top: 0 !important;
  right: 0 !important;
  left: auto !important;
  bottom: 0 !important;
  z-index: 35;
  width: min(100vw, 420px) !important;
  max-width: 100vw !important;
  min-width: 250px;
  height: 100vh !important;
  height: 100dvh !important;
  margin: 0;
  padding: 3em 0 2em;
  overflow-x: hidden;
  overflow-y: auto;
  list-style: none;
  background-color: var(--baseFontColor, #292929);
  border-right: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch;
  transform: translateX(100%) !important;
  transition: transform 0.45s ease;
  pointer-events: none;
  visibility: hidden;
}

.page-header .top-header .top-content .nav-wrapper-right .mobile-main-navigation-component .overlay.active,
.mobile-main-navigation-component .overlay.active {
  transform: translateX(0) !important;
  pointer-events: auto;
  visibility: visible;
}

/* Header-transform/Animation aus → sonst ist fixed-Overlay am Header gebunden */
@media (max-width: 1365px) {
  .page-header.overlay-active,
  .page-header.overlay-active.fixed,
  .page-header.overlay-active.scroll {
    transform: none !important;
    animation: none !important;
  }
}

.mobile-main-navigation-component .overlay .logo-mobile {
  padding: 0 2em 1.5em;
}

.mobile-main-navigation-component .overlay .logo-mobile img,
.mobile-main-navigation-component .overlay .logo-mobile picture {
  max-width: 180px;
  height: auto;
}

.mobile-main-navigation-component .overlay .nav {
  border-top: 1px solid rgba(255, 255, 255, 0.35);
  border-bottom: 1px solid rgba(255, 255, 255, 0.35);
  padding: 1em 0;
  width: 100%;
}

.mobile-main-navigation-component .overlay .nav .menu,
.mobile-main-navigation-component .overlay .nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.mobile-main-navigation-component .overlay .nav .menu-item {
  margin: 0;
}

.mobile-main-navigation-component .overlay .nav a {
  display: block;
  padding: 0.55em 2em;
  color: #fff;
  text-decoration: none;
}

.mobile-main-navigation-component .overlay .nav .text,
.mobile-main-navigation-component .overlay .nav .indicator {
  color: #fff;
}

.mobile-main-navigation-component .overlay .nav .sub-menu {
  list-style: none;
  margin: 0;
  padding: 0 0 0 1em;
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.45s ease;
}

.mobile-main-navigation-component .overlay .nav .menu-item-has-children.open > .sub-menu,
.mobile-main-navigation-component .overlay .nav .sub-menu.active {
  max-height: 100vh;
}

.mobile-main-navigation-component .overlay .nav .sub-menu a {
  background-color: #fff;
  color: var(--baseFontColor, #292929);
}

.mobile-main-navigation-component .overlay .nav .sub-menu a .text {
  color: var(--baseFontColor, #292929);
}

.mobile-main-navigation-component .overlay .nav .dropdown-indicator {
  display: none;
}

.mobile-main-navigation-component .overlay .mobile-hero-navbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5em;
  padding: 1.5em 1em 0;
}

.mobile-main-navigation-component .overlay .mobile-hero-navbar .nav-item {
  color: #fff;
}

.admin-bar .mobile-main-navigation-component .overlay {
  padding-top: 5em;
}

.admin-bar .mobile-main-navigation-component .trigger.active {
  top: calc(12px + 32px);
}

@media (max-width: 782px) {
  .admin-bar .mobile-main-navigation-component .trigger.active {
    top: calc(12px + 46px);
  }
}

/* -------------------------------------------------------------------------- */
/* Footer Rechtsmenü: umbrechen, keine horizontale Scrollbar                  */
/* -------------------------------------------------------------------------- */

.footer-section .main-footer .copy .menu-rechtliches-container ul {
  flex-wrap: wrap !important;
  justify-content: center;
  row-gap: 0.5em;
  max-width: 100%;
}

.footer-section .main-footer .copy .menu-rechtliches-container ul li:first-child:before {
  content: none;
  margin: 0;
}

@media (max-width: 700px) {
  .footer-section .main-footer .copy {
    height: auto !important;
    min-height: 3em;
    padding: 1.25em 1em !important;
    box-sizing: border-box;
  }

  .footer-section .main-footer .copy .menu-rechtliches-container {
    max-width: 100%;
  }
}
