/* Wohnen-Fix Static-Suche + Exposé – Mobile: kein Horizontal-Scroll, kompakte Topbar */

html:has(body.wf-suche-page),
html:has(body.expose-page) {
  overflow-x: clip;
  max-width: 100%;
}

body.wf-suche-page,
body.expose-page {
  overflow-x: clip;
  max-width: 100%;
  width: 100%;
}

body.wf-suche-page .wf-app,
body.expose-page .wf-app,
body.wf-suche-page .wf-main,
body.expose-page .wf-main {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: clip;
}

/* Exposé: leere Such-Spalte nicht im Grid reservieren */
body.expose-page .wf-topbar .wf-topbar__search {
  display: none !important;
}

@media (max-width: 899px) {
  body.wf-suche-page .wf-topbar--marketing,
  body.expose-page .wf-topbar--marketing {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    padding: 8px max(12px, env(safe-area-inset-right, 0px)) 8px
      max(12px, env(safe-area-inset-left, 0px));
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: clip;
  }

  body.wf-suche-page .wf-topbar--marketing .wf-suche-marketing-nav,
  body.expose-page .wf-topbar--marketing .wf-suche-marketing-nav {
    display: none !important;
  }

  /* Hero-/Filter-Suche reicht auf Mobile */
  body.wf-suche-page .wf-topbar--marketing .wf-topbar__search {
    display: none !important;
  }
}

@media (max-width: 767px) {
  body.wf-suche-page .wf-topbar,
  body.expose-page .wf-topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    padding: 8px max(12px, env(safe-area-inset-right, 0px)) 8px
      max(12px, env(safe-area-inset-left, 0px));
    overflow-x: clip;
  }

  body.wf-suche-page .wf-suche-brand,
  body.expose-page .wf-suche-brand {
    min-width: max-content;
    max-width: 100%;
    font-size: 1rem;
    gap: 8px;
    overflow: visible;
  }

  body.wf-suche-page .wf-suche-brand .fx-wordmark,
  body.expose-page .wf-suche-brand .fx-wordmark {
    min-width: max-content;
    overflow: visible;
    text-overflow: clip;
    white-space: nowrap;
  }

  body.wf-suche-page .wf-suche-brand .fx-brand__icon,
  body.expose-page .wf-suche-brand .fx-brand__icon {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
  }

  body.expose-page .wf-topbar__auth {
    flex-shrink: 1;
    min-width: 0;
    max-width: min(52vw, 168px);
    justify-content: flex-end;
    gap: 6px;
  }

  /* Suche: Buttons über die volle Kopfzeile, nicht in einen 168px-Kasten quetschen. */
  body.wf-suche-page .wf-topbar--marketing .wf-topbar__auth {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: stretch;
    justify-content: stretch;
    flex-shrink: 0;
    width: 100%;
    max-width: none;
    min-width: 0;
    gap: 8px;
    padding-top: 0;
  }

  body.wf-suche-page .wf-topbar__auth .portal-product-nav__inserat,
  body.wf-suche-page .wf-topbar__auth .portal-product-nav__anmelden,
  body.wf-suche-page .wf-topbar__auth .portal-product-nav__registrieren,
  body.wf-suche-page .wf-topbar__auth .portal-btn--switch {
    width: 100%;
    min-width: 0;
    min-height: 40px;
    padding: 8px 12px;
    font-size: 0.84rem;
    white-space: nowrap;
    box-sizing: border-box;
  }

  body.wf-suche-page .wf-topbar__auth .portal-product-nav__inserat,
  body.wf-suche-page .wf-topbar__auth .portal-btn--switch {
    grid-column: 1 / -1;
  }

  body.wf-suche-page .wf-topbar__auth .portal-profile {
    grid-column: 1 / -1;
    width: 100%;
    max-width: none;
  }

  body.expose-page .wf-topbar__auth .portal-btn {
    min-height: 34px;
    padding: 6px 10px;
    font-size: 0.72rem;
    white-space: nowrap;
  }

  /* Zweiter CTA sprengt schmale Viewports – Suche/Exposé-Inhalt hat eigene CTAs */
  body.wf-suche-page .wf-topbar__auth .wf-topbar__guest-link,
  body.expose-page .wf-topbar__auth .wf-topbar__guest-link {
    display: none;
  }

  body.wf-suche-page .wf-suche-main,
  body.expose-page .expose-main {
    padding-left: max(12px, env(safe-area-inset-left, 0px));
    padding-right: max(12px, env(safe-area-inset-right, 0px));
    box-sizing: border-box;
  }

  body.wf-suche-page .wf-market-hero,
  body.wf-suche-page .wf-suche-main {
    max-width: 100%;
    overflow-x: clip;
  }

  /* Fix-Familie / Footer: volle Breite ohne Overflow */
  body.wf-suche-page .wf-marketing-chrome-root,
  body.expose-page .wf-marketing-chrome-root {
    max-width: 100%;
    overflow-x: clip;
  }

  body.wf-suche-page .nkf-close-cta,
  body.expose-page .nkf-close-cta {
    width: min(92%, calc(100% - 24px)) !important;
    max-width: min(92%, calc(100% - 24px)) !important;
    margin-left: auto !important;
    margin-right: auto !important;
    box-sizing: border-box;
  }
}

@media (max-width: 480px) {
  body.wf-suche-page .wf-suche-brand .fx-wordmark__prefix,
  body.expose-page .wf-suche-brand .fx-wordmark__prefix {
    display: inline;
  }
}

/* Handy: Logo links, Menü mit drei Strichen rechts. Desktop bleibt ohne den Button. */
@media (min-width: 900px) {
  body.wf-suche-page .wf-suche-menu {
    display: none !important;
  }
}

@media (max-width: 899px) {
  body.wf-suche-page .wf-topbar--marketing.wf-topbar--suche {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "brand menu"
      "auth auth";
    align-items: center;
  }

  body.wf-suche-page .wf-topbar--marketing.wf-topbar--suche.is-menu-open {
    grid-template-areas:
      "brand menu"
      "nav nav"
      "auth auth";
  }

  body.wf-suche-page .wf-suche-menu {
    display: inline-flex;
    grid-area: menu;
    justify-self: end;
    align-self: center;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 42px;
    height: 42px;
    margin: 0;
    padding: 0;
    border: 1px solid rgba(31, 138, 99, 0.35);
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
    flex-shrink: 0;
  }

  body.wf-suche-page .wf-suche-menu span {
    display: block;
    width: 18px;
    height: 2px;
    border-radius: 2px;
    background: #1b3f34;
    transition: transform 0.2s ease, opacity 0.2s ease;
  }

  body.wf-suche-page .wf-topbar.is-menu-open .wf-suche-menu span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
  }

  body.wf-suche-page .wf-topbar.is-menu-open .wf-suche-menu span:nth-child(2) {
    opacity: 0;
  }

  body.wf-suche-page .wf-topbar.is-menu-open .wf-suche-menu span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
  }

  body.wf-suche-page .wf-topbar--marketing.is-menu-open .wf-suche-marketing-nav {
    display: flex !important;
    grid-area: nav;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 6px;
    width: 100%;
    margin: 0;
    padding: 4px 0 2px;
  }

  body.wf-suche-page .wf-topbar--marketing.is-menu-open .wf-suche-marketing-nav__link {
    display: block;
    padding: 12px 14px;
    border-radius: 10px;
    background: #f4faf7;
    color: #1b3f34;
    font-size: 0.95rem;
    font-weight: 700;
    text-decoration: none;
  }
}
