/* Inicio móvil — alineado a plantilla profesional (tab bar + feed) */

@media (min-width: 769px) {
  .mobile-tabbar {
    display: none !important;
  }

  .home-nuevas-main {
    display: none !important;
  }
}

@media (max-width: 768px) {
  /* Una sola fila de header: sin barra global de ubicación/búsqueda (está en el buscador de cada sección). */
  body.is-mobile-layout.ui-advanced {
    --topbar-offset: 3.65rem;
  }

  body.is-mobile-layout.ui-advanced .topbar-row--tools {
    display: none !important;
  }

  body.is-mobile-layout.ui-advanced .topbar-row--main {
    flex-wrap: nowrap !important;
    align-items: center;
    gap: 0.35rem;
  }

  body.is-mobile-layout.ui-advanced .topbar-brand {
    flex: 1 1 auto !important;
    min-width: 0;
    max-width: none !important;
  }

  body.is-mobile-layout.ui-advanced .topbar-actions {
    flex: 0 1 auto !important;
    width: auto !important;
    order: 2 !important;
    margin-left: auto !important;
    flex-wrap: nowrap;
    gap: 0.25rem;
  }

  body.is-mobile-layout.ui-advanced .btn-publicar-top {
    display: none;
  }

  body.is-mobile-layout.ui-advanced .topbar-theme-btn {
    order: 3;
    flex-shrink: 0;
    margin-left: 0 !important;
  }

  body.is-mobile-layout.ui-advanced.view-inicio {
    --topbar-offset: 3.65rem;
  }

  body.ui-advanced {
    padding-bottom: calc(4.75rem + env(safe-area-inset-bottom, 0px));
  }

  body.ui-advanced .topbar-row--main > .topbar-theme-btn {
    margin-left: auto;
    min-width: 44px;
    min-height: 44px;
  }

  /* Inicio: hamburguesa + marca + tema; acciones en fila 2; Publicar en tab bar */
  body.ui-advanced.view-inicio .menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    order: 0;
    flex-shrink: 0;
    min-width: 44px;
    min-height: 44px;
  }

  /* Invitado en inicio: segunda fila solo para login/registro */
  body.is-mobile-layout.ui-advanced.view-inicio:has(#topbarGuestAuth:not(.hidden)) {
    --topbar-offset: 5.35rem;
  }

  body.is-mobile-layout.ui-advanced.view-inicio:has(#topbarGuestAuth:not(.hidden)) .topbar-row--main {
    flex-wrap: wrap !important;
    row-gap: 0.3rem;
  }

  body.is-mobile-layout.ui-advanced.view-inicio:has(#topbarGuestAuth:not(.hidden)) .topbar-actions {
    flex: 1 1 100% !important;
    width: 100% !important;
    justify-content: flex-end;
  }

  body.ui-advanced.view-inicio .topbar-brand {
    order: 1;
  }

  body.ui-advanced.view-inicio .topbar-brand-name {
    display: block;
    text-transform: uppercase;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    color: var(--brand-gold, #fbbf24);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.ui-advanced.view-inicio .topbar-guest-auth .btn {
    padding: 0.38rem 0.55rem;
    font-size: 0.68rem;
  }

  .ofertas-grid--home-carousel .promo-card--home-feed {
    flex: 0 0 min(280px, 86vw);
  }

  .ofertas-grid--home-carousel .promo-card--home-feed .promo-card-img-wrap {
    min-height: 150px;
  }

  body.ui-advanced.view-admin .mobile-tabbar {
    display: none;
  }

  body.ui-advanced.view-inicio .content-grid {
    padding-top: 0.35rem;
  }

  body.ui-advanced.view-inicio .hero-site-brand {
    display: none;
  }

  body.ui-advanced.view-inicio .hero--home {
    border-radius: 0 0 20px 20px;
    margin-left: -1rem;
    margin-right: -1rem;
    width: calc(100% + 2rem);
    max-width: none;
  }

  body.ui-advanced.view-inicio .hero-home-shell {
    padding: 1.5rem 1.1rem 1.65rem;
  }

  body.ui-advanced.view-inicio .hero-home-title {
    max-width: none;
    font-size: 1.55rem;
  }

  body.ui-advanced.view-inicio .hero-purpose-tabs {
    display: none;
  }

  body.ui-advanced.view-inicio .hero-local-script {
    display: none;
  }

  .home-section--first {
    margin-top: 0.25rem;
  }

  .home-section-title {
    font-size: 1.05rem;
  }

  /* Tarjetas «¿Qué necesitas?» — apiladas como mockup */
  .need-cards--stack {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .need-cards--stack .need-card {
    min-height: 92px;
    padding: 1rem 1.1rem;
    border-radius: 18px;
  }

  .need-cards--stack .need-card-icon {
    width: 52px;
    height: 52px;
    border-radius: 16px;
  }

  .need-cards--stack .need-card-body h4 {
    font-size: 1rem;
    letter-spacing: 0.04em;
  }

  .need-cards--stack .need-card-go {
    width: 38px;
    height: 38px;
    background: rgba(255, 255, 255, 0.12);
  }

  [data-theme="light"] .need-cards--stack .need-card-go {
    background: rgba(15, 23, 42, 0.08);
    color: #0f172a;
  }

  /* Categorías — rejilla compacta */
  .home-cat-explore-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    justify-items: center;
    gap: 0.85rem 0.5rem;
  }

  .home-cat-circle {
    width: auto;
  }

  .home-cat-circle-inner {
    width: 58px;
    height: 58px;
    font-size: 1.35rem;
  }

  .home-cat-circle-label {
    font-size: 0.62rem;
    max-width: 4.5rem;
  }

  /* Nuevas publicaciones — carrusel horizontal */
  #homeNuevasSidebar {
    display: none !important;
  }

  .home-nuevas-scroll {
    overflow-x: auto;
    margin: 0 -0.25rem;
    padding: 0 0.25rem 0.35rem;
    scroll-snap-type: x mandatory;
    scrollbar-width: thin;
  }

  .home-nuevas-list--feed {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 0.75rem;
    min-width: min-content;
  }

  .home-nuevas-list--feed .home-nueva-row {
    flex: 0 0 min(280px, 78vw);
    scroll-snap-align: start;
    flex-direction: column;
    align-items: flex-start;
    padding: 0.85rem;
  }

  .home-nuevas-list--feed .home-nueva-thumb {
    width: 100%;
    height: 120px;
    border-radius: 14px;
  }

  .home-nuevas-list--feed .home-nueva-arrow {
    display: none;
  }

  .ofertas-grid--home-carousel .promo-card {
    flex: 0 0 min(260px, 82vw);
  }

  /* Tab bar inferior */
  .mobile-tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 120;
    display: flex;
    align-items: flex-end;
    justify-content: space-around;
    gap: 0.15rem;
    padding: 0.35rem 0.5rem calc(0.45rem + env(safe-area-inset-bottom, 0px));
    background: linear-gradient(180deg, color-mix(in srgb, var(--bg-elevated) 94%, transparent) 0%, var(--bg) 100%);
    border-top: 1px solid var(--border);
    box-shadow: var(--shadow);
    backdrop-filter: blur(12px);
  }

  .mobile-tabbar-item {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    padding: 0.35rem 0.15rem;
    border: none;
    background: none;
    color: var(--text-muted);
    text-decoration: none;
    font-family: var(--font);
    font-size: 0.58rem;
    font-weight: 600;
    border-radius: 10px;
    transition: color var(--transition), background var(--transition);
  }

  .mobile-tabbar-item svg {
    width: 22px;
    height: 22px;
  }

  .mobile-tabbar-item.active {
    color: var(--brand-gold, #2563eb);
    background: color-mix(in srgb, var(--brand-gold, #2563eb) 12%, transparent);
  }

  .mobile-tabbar-fab {
    flex: 0 0 auto;
    width: 52px;
    height: 52px;
    margin: 0 0.15rem 0.35rem;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand-gold, #3b82f6), var(--brand-gold-dim, #2563eb));
    color: #ffffff;
    box-shadow: 0 6px 20px color-mix(in srgb, var(--brand-gold, #2563eb) 45%, transparent);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transform: translateY(-6px);
  }

  .mobile-tabbar-fab svg {
    width: 26px;
    height: 26px;
  }

  body.ui-advanced .footer {
    padding-bottom: 1rem;
  }

  /* Buscador compacto (móvil): una sola barra de ubicación + campos más densos */
  body.is-mobile-layout.view-has-section-finder .topbar-row--tools .location-wrap {
    display: none !important;
  }

  body.is-mobile-layout .hero-finder {
    padding: 0.65rem 0.75rem 0.55rem;
    border-radius: 16px;
  }

  body.is-mobile-layout .hero-finder-location {
    padding-bottom: 0.45rem;
    margin-bottom: 0.45rem;
    align-items: center;
  }

  body.is-mobile-layout .hero-finder-location-icon {
    margin-top: 0;
    font-size: 1rem;
  }

  body.is-mobile-layout .hero-finder-location-fields {
    gap: 0.4rem 0.5rem;
  }

  body.is-mobile-layout .hero-finder-location-item {
    flex: 1 1 calc(50% - 0.25rem);
  }

  body.is-mobile-layout .hero-finder-select--loc {
    padding: 0.32rem 1.5rem 0.32rem 0.45rem;
    font-size: 0.78rem;
  }

  body.is-mobile-layout .hero-finder-purpose {
    margin-bottom: 0.5rem;
    padding-bottom: 0.4rem;
  }

  body.is-mobile-layout .hero-finder-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    border-width: 1px;
    border-radius: 10px;
    gap: 0;
  }

  body.is-mobile-layout .hero-finder-field {
    padding: 0.32rem 0.45rem;
    align-items: center;
    gap: 0.25rem;
    border-right: none;
    border-bottom: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
  }

  body.is-mobile-layout .hero-finder-field--tag,
  body.is-mobile-layout .hero-finder-submit {
    grid-column: 1 / -1;
  }

  body.is-mobile-layout .hero-finder-field--sub {
    border-right: none;
  }

  body.is-mobile-layout .hero-finder--section .hero-finder-location {
    display: none;
  }

  body.is-mobile-layout .ofertas-hero {
    display: none;
  }

  body.is-mobile-layout .ofertas-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.35rem;
    margin-bottom: 0.5rem;
    padding: 0.5rem 0 0;
  }

  body.is-mobile-layout .ofertas-toolbar h3 {
    font-size: 0.95rem;
    margin: 0;
  }

  body.is-mobile-layout .ofertas-toolbar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    justify-content: flex-start;
  }

  body.is-mobile-layout .ofertas-toolbar-actions .btn-primary {
    display: none;
  }

  body.is-mobile-layout .section-header--stacked {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
    margin-bottom: 0.35rem;
  }

  body.is-mobile-layout .section-header--stacked h3 {
    font-size: 0.95rem;
    margin: 0;
  }

  body.is-mobile-layout .dynamic-section {
    padding-top: 0.25rem;
  }

  body.is-mobile-layout .content-grid {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  body.is-mobile-layout .hero-finder-field-label {
    margin-bottom: 0;
    font-size: 0.58rem;
  }

  body.is-mobile-layout .hero-finder-field-icon {
    margin-top: 0;
    font-size: 0.9rem;
  }

  body.is-mobile-layout .hero-finder-select:not(.hero-finder-select--loc) {
    font-size: 0.78rem;
  }

  body.is-mobile-layout .hero-finder-input {
    font-size: 0.78rem;
  }

  body.is-mobile-layout .hero-finder-submit {
    padding: 0.5rem 0.85rem;
    min-height: 42px;
    width: 100%;
  }

  body.is-mobile-layout .hero-cta-cards {
    grid-template-columns: 1fr;
    gap: 0.4rem;
    margin-top: 0.5rem;
  }

  body.is-mobile-layout .hero-cta-cards .hero-cta-card {
    flex-direction: row;
    align-items: center;
    min-height: 0;
    padding: 0.48rem 0.65rem;
    border-radius: 12px;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
  }

  body.is-mobile-layout .hero-cta-card-icon {
    width: 2rem;
    text-align: center;
    font-size: 1.1rem;
  }

  body.is-mobile-layout .hero-cta-card-copy {
    flex: 1;
    min-width: 0;
  }

  body.is-mobile-layout .hero-cta-card-title {
    font-size: 0.82rem;
    line-height: 1.15;
  }

  body.is-mobile-layout .hero-cta-card-desc {
    font-size: 0.62rem;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  body.is-mobile-layout .hero-home-shell {
    padding: 1.1rem 0.85rem 1.2rem;
  }
}
