/* Final mobile layout layer. Loaded after page-specific theme styles. */
@media (max-width: 1024px) {
  html,
  body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }
}

@media (max-width: 520px) {
  .header-container {
    min-width: 0;
    gap: 8px;
  }

  .header-city {
    display: none !important;
  }

  .site-logo {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .header-actions {
    min-width: 0;
    gap: 6px;
  }

  .rentals-header-lang {
    min-width: 0;
    gap: 1px !important;
    padding: 2px !important;
  }

  .rentals-header-lang a {
    min-width: 26px !important;
    min-height: 26px !important;
    padding: 0 5px !important;
    font-size: .68rem !important;
  }
}

@media (max-width: 760px) {
  .locations-sidebar__actions {
    min-width: 0 !important;
  }

  .city-fact__label,
  .city-fact__value {
    white-space: normal !important;
    overflow-wrap: anywhere;
  }

  body.page-template-page-rentals:not(.wp-admin) .rentals-hero__btn {
    min-width: 0 !important;
    max-width: 100%;
    white-space: normal !important;
    overflow-wrap: anywhere;
    line-height: 1.15;
  }
}

/* Keep the rentals page locked to the viewport on touch devices.
   Individual components that need horizontal scrolling keep their own overflow. */
@media (max-width: 760px) {
  html:has(body.page-template-page-rentals),
  body.page-template-page-rentals:not(.wp-admin) {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  body.page-template-page-rentals:not(.wp-admin) .rentals-page,
  body.page-template-page-rentals:not(.wp-admin) .rentals-page > section,
  body.page-template-page-rentals:not(.wp-admin) .rentals-page .container {
    min-width: 0;
    max-width: 100%;
  }
}

/* The area guide is redundant beside the compact mobile catalog controls. */
body.page-template-page-rentals:not(.wp-admin) #rentals-area-guide-open {
  display: none !important;
}

@media (max-width: 560px) {
  body.page-template-page-rentals:not(.wp-admin) .rentals-page > .rentals-hero:not(.rentals-hero--detail) .rentals-hero__btn--primary {
    font-size: 0.95rem !important;
  }

  body.page-template-page-rentals:not(.wp-admin) .rentals-page > .rentals-hero:not(.rentals-hero--detail) .rentals-hero__btn--ghost,
  body.page-template-page-rentals:not(.wp-admin) .rentals-page > .rentals-hero:not(.rentals-hero--detail) .rentals-hero__btn--locations {
    font-size: 0.88rem !important;
  }
}

/* Rental filters: the sheet itself never scrolls.  Only the form area does,
   so the header and the apply action stay reachable on short phone screens. */
@media (max-width: 560px) {
  body.page-template-page-rentals:not(.wp-admin) #filters-surface {
    position: fixed !important;
    top: calc(var(--header-h) + 8px) !important;
    right: 8px !important;
    bottom: auto !important;
    left: 8px !important;
    z-index: 100000 !important;
    display: flex !important;
    flex-direction: column !important;
    width: auto !important;
    max-width: none !important;
    max-height: calc(100svh - var(--header-h) - 16px) !important;
    margin: 0 !important;
    padding: 12px !important;
    overflow: hidden !important;
    border-radius: 20px !important;
    overscroll-behavior: contain;
    transform: translateY(20px) !important;
  }

  body.page-template-page-rentals:not(.wp-admin) #rentals-filters.is-open #filters-surface {
    transform: translateY(0) !important;
  }

  body.page-template-page-rentals:not(.wp-admin) #filters-surface .rentals-filter-panel__head {
    position: static !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 8px !important;
    margin: -12px -12px 10px !important;
    padding: 12px !important;
    overflow: visible !important;
  }

  body.page-template-page-rentals:not(.wp-admin) #filters-surface .rentals-filter-panel__title {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    font-size: 0.9rem !important;
  }

  body.page-template-page-rentals:not(.wp-admin) #filters-surface .rentals-filter-panel__actions {
    display: flex !important;
    margin-left: auto !important;
    width: auto !important;
  }

  body.page-template-page-rentals:not(.wp-admin) #filters-surface .rentals-filter-close {
    min-width: 0 !important;
    min-height: 34px !important;
    padding: 0 10px !important;
    font-size: 0.72rem !important;
    white-space: nowrap;
  }

  body.page-template-page-rentals:not(.wp-admin) #filters-surface .rentals-filter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    align-content: start !important;
    flex: 0 1 auto !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding: 0 2px 4px !important;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  body.page-template-page-rentals:not(.wp-admin) #filters-surface .rentals-filter-field {
    grid-column: span 1 !important;
  }

  body.page-template-page-rentals:not(.wp-admin) #filters-surface .rentals-filter-field--rooms,
  body.page-template-page-rentals:not(.wp-admin) #filters-surface .rentals-filter-field--price {
    grid-column: 1 / -1 !important;
  }

  body.page-template-page-rentals:not(.wp-admin) #filter-rooms-group {
    grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
    gap: 4px !important;
  }

  body.page-template-page-rentals:not(.wp-admin) #filter-rooms-group .rentals-filter-segment,
  body.page-template-page-rentals:not(.wp-admin) #filter-rooms-group .rentals-filter-segment:first-child {
    grid-column: auto !important;
    min-width: 0 !important;
    padding: 0 4px !important;
  }

  body.page-template-page-rentals:not(.wp-admin) #filters-surface .rentals-filter-footer {
    position: static !important;
    flex: 0 0 auto !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    align-items: stretch !important;
    gap: 8px !important;
    margin: 10px -12px -12px !important;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom)) !important;
    background: rgba(250, 253, 253, 0.98) !important;
  }

  body.page-template-page-rentals:not(.wp-admin) #filters-surface .rentals-filter-active {
    display: none !important;
  }

  body.page-template-page-rentals:not(.wp-admin) #filters-surface .rentals-filter-actions {
    position: static !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    width: 100% !important;
    gap: 8px !important;
    padding: 0 !important;
    background: transparent !important;
  }

  body.page-template-page-rentals:not(.wp-admin) #filters-surface .rentals-filter-actions .filters-reset,
  body.page-template-page-rentals:not(.wp-admin) #filters-surface .rentals-filter-actions .filters-apply {
    width: 100% !important;
    min-width: 0 !important;
    min-height: 38px !important;
    margin: 0 !important;
  }

  body.page-template-page-rentals:not(.wp-admin) #filters-surface .filters-apply {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-height: 38px !important;
    padding: 0 14px !important;
    font-weight: 800 !important;
    white-space: nowrap;
  }
}
