/**
 * Maison Havitat — adaptation mobile complète
 * Objectif : même contenu que desktop (tous produits, menus, sections)
 */

/* ——— Base ——— */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  overflow-x: hidden;
  max-width: 100vw;
}

img,
video,
picture {
  max-width: 100%;
  height: auto;
}

/* Ne pas écraser les images en ratio fixe (catalogue, insta, produit) */
.mh-catalog-card-img-wrap img,
.mh-insta-card img,
.product-gallery.mh-gallery-main .mh-slide,
.mh-product-row .mh-card img {
  height: 100%;
  object-fit: cover;
}

.mh-catalog-page,
.mh-product-page-body,
.mh-designers-page,
body[data-page="cart"] {
  overflow-x: hidden;
  width: 100%;
  max-width: 100%;
}

.mh-home-page {
  overflow-x: clip;
  overflow-y: visible;
  width: 100%;
  max-width: 100%;
}

/* Neutralise grilles Habitat qui coupent la largeur */
.mh-home-page .content-grid,
.mh-home-page .mh-content-grid,
.mh-catalog-page .content-grid,
.mh-designers-page .content-grid {
  display: block !important;
  width: 100% !important;
  max-width: 100% !important;
  margin-left: auto !important;
  margin-right: auto !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
  grid-template-columns: none !important;
  overflow: visible !important;
}

@media (max-width: 991px) {
  /* Bouton ☰ dans la barre noire */
  .mh-mobile-menu-btn {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
  }

  body.FR .mh-mobile-menu-btn,
  body.FR .mh-header-black .mh-mobile-menu-btn,
  html.mh-is-mobile .mh-mobile-menu-btn {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
  }

  body.FR .mh-nav-white,
  html.mh-is-mobile .mh-nav-white {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    max-height: none !important;
    overflow: visible !important;
  }

  /* ——— Navigation : liens visibles (scroll horizontal) comme le menu desktop ——— */
  .mh-nav-divider {
    display: block !important;
    width: 1px;
    height: auto;
    align-self: stretch;
  }

  .mh-nav-white-inner {
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: stretch;
    overflow: hidden;
  }

  .mh-nav-all-wrap {
    flex-shrink: 0;
    border-right: 1px solid #ddd;
    border-bottom: none;
  }

  .mh-nav-links {
    display: flex !important;
    flex: 1 1 auto;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
    min-width: 0;
    gap: 0;
  }

  .mh-nav-links::-webkit-scrollbar {
    display: none;
  }

  .mh-nav-links li {
    flex: 0 0 auto;
    scroll-snap-align: start;
  }

  .mh-nav-links a {
    padding: 14px 14px;
    font-size: 0.75rem;
    min-height: 44px;
    white-space: nowrap;
  }

  /* ——— Accueil : rangées produits — toutes les cartes accessibles ——— */
  .mh-home-heading {
    font-size: 1rem;
    padding: 0 12px;
    text-align: left;
  }

  .mh-home-inner {
    padding-left: 12px;
    padding-right: 12px;
  }

  .mh-product-row {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 10px;
    padding: 0 0 12px 2px;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    scrollbar-width: thin;
  }

  .mh-product-row .mh-card {
    flex: 0 0 min(44vw, 200px);
    scroll-snap-align: start;
    min-width: 0;
  }

  .mh-product-row .mh-card-name {
    font-size: 0.75rem;
  }

  .mh-product-row .mh-card-price {
    font-size: 0.8125rem;
  }

  /* Catégories : 2 colonnes (pas 1) — plus proche du desktop */
  .mh-categories-item {
    flex: 0 0 calc(50% - 4px) !important;
    max-width: calc(50% - 4px) !important;
  }

  /* Promo duo : empilé mais images pleine largeur */
  .mh-home-promo-duo {
    width: 100%;
  }

  .mh-promo-composite-img,
  .mh-promo-tile--image-only img {
    min-height: min(65vw, 400px);
  }

  .mh-assises-single-img {
    min-height: auto;
  }

  /* Instagram : scroll conservé */
  .mh-insta-grid > [role='listitem'] {
    width: min(65vw, 260px);
  }

  /* ——— Catalogue : tous les produits, cartes lisibles ——— */
  .mh-catalog-page-header {
    padding: 16px 12px 12px;
  }

  .mh-catalog-page-title {
    font-size: clamp(1.5rem, 6vw, 2rem);
  }

  .mh-catalog-wrap {
    padding: 0 10px 40px;
  }

  .mh-catalog-grid.products-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px 10px;
  }

  .mh-catalog-grid.mh-catalog-grid--dense {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px 8px;
  }

  .mh-catalog-card-title {
    font-size: 0.8125rem;
  }

  .mh-catalog-card-price {
    font-size: 0.875rem;
  }

  .mh-catalog-view {
    display: flex;
  }

  .mh-catalog-view-btn {
    width: 40px;
    height: 40px;
  }

  .catalog-load-more-wrap {
    padding: 24px 12px 8px;
    text-align: center;
  }

  .mh-load-more-btn {
    width: 100%;
    max-width: 400px;
    min-height: 48px;
    padding: 14px 20px;
    font-size: 0.875rem;
  }

  /* ——— Fiche produit ——— */
  .mh-gallery-arrows {
    opacity: 1 !important;
    width: 40px;
    height: 40px;
    font-size: 1.25rem;
  }

  .thumb-product-gallery .product-image-container {
    width: 64px;
    height: 64px;
  }

  .mh-product-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    gap: 0;
    border-bottom: 1px solid #e8e8e8;
  }

  .mh-product-tabs button {
    flex-shrink: 0;
    white-space: nowrap;
    min-height: 44px;
    padding: 12px 16px;
  }

  .mh-add-block {
    display: flex !important;
    flex-direction: column;
    gap: 10px;
  }

  .mh-buy-section {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
  }

  .mh-add-block .mh-btn-cart,
  #mh-add-cart.mh-btn-cart-primary {
    display: flex !important;
    width: 100% !important;
    min-height: 52px !important;
    visibility: visible !important;
    opacity: 1 !important;
    color: #fff !important;
    background: #111 !important;
  }

  .mh-sticky-cart-mobile {
    z-index: 500;
  }

  .mh-btn-wishlist {
    width: 100%;
  }

  .mh-product-page {
    padding-bottom: calc(100px + env(safe-area-inset-bottom, 0px)) !important;
  }

  .mh-related-section .products-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px 10px;
  }

  /* ——— Panier ——— */
  .cart-page {
    padding: 20px 12px calc(24px + env(safe-area-inset-bottom, 0px));
  }

  .mh-cart-checkout input[type='email'] {
    font-size: 16px;
  }

  /* ——— Designers ——— */
  .mh-spotlight-content {
    grid-template-columns: 1fr;
  }

  .mh-spotlight-right {
    display: block;
    min-height: 280px;
  }

  .mh-spotlight-secondary-img {
    position: relative;
    inset: auto;
    min-height: 280px;
  }

  .mh-inspirations-track {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 12px;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 8px;
  }

  .mh-inspiration-card {
    flex: 0 0 min(78vw, 300px);
  }

  /* ——— Footer ——— */
  .mh-footer-columns {
    grid-template-columns: 1fr 1fr;
    gap: 20px 12px;
  }

  .mh-reinsurance-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px 10px;
  }
}

@media (max-width: 480px) {
  .mh-footer-columns {
    grid-template-columns: 1fr;
  }

  .mh-categories-item {
    flex: 0 0 calc(50% - 4px) !important;
    max-width: calc(50% - 4px) !important;
  }

  /* Petits écrans : grille catalogue toujours 2 colonnes (tous les produits visibles) */
  .mh-catalog-grid.products-grid,
  .mh-catalog-grid.mh-catalog-grid--dense {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Très petits écrans : option 1 colonne désactivée — l'utilisateur veut voir le maximum */
@media (max-width: 360px) {
  .mh-catalog-grid.products-grid {
    gap: 14px 8px;
  }

  .mh-product-row .mh-card {
    flex: 0 0 min(52vw, 180px);
  }
}

/* ——— Admin ——— */
@media (max-width: 991px) {
  .admin-layout {
    grid-template-columns: 1fr;
  }

  .admin-sidebar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
    padding: 16px;
  }

  .admin-sidebar a {
    font-size: 0.8125rem;
    padding: 8px 0;
  }

  .admin-main {
    padding: 20px 12px;
  }

  .admin-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .admin-form {
    max-width: 100%;
  }
}

/* Safe areas iPhone */
@supports (padding: env(safe-area-inset-top)) {
  .mh-header-wrap {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }

  .mh-sticky-cart-mobile.visible-scroll {
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }
}

/* ========== Contenu visible sur mobile (anti-clipping Habitat) ========== */
@media (max-width: 991px) {
  html,
  body.FR.escda {
    height: auto !important;
    min-height: 100%;
    overflow-x: hidden !important;
    overflow-y: auto !important;
  }

  body.FR .content-grid,
  body.FR .mh-content-grid,
  body.FR .content-grid.mh-content-grid {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    min-height: 0 !important;
    max-height: none !important;
    height: auto !important;
    overflow: visible !important;
    grid-template-columns: none !important;
    grid-template-rows: none !important;
    flex: none !important;
  }

  body.FR .mh-home-main,
  body.FR main,
  body.FR #product-root,
  body.FR #mh-designers-root,
  body.FR .mh-designers-main {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
  }

  /* Accueil — toutes les sections */
  body.FR .mh-home-section,
  body.FR .mh-home-section.full-width,
  body.FR .mh-home-section--welcome,
  body.FR .mh-home-section--instagram,
  body.FR .mh-home-section--banner,
  body.FR .mh-home-section--assises,
  body.FR .mh-home-section--promo-duo,
  body.FR .mh-home-promo-duo,
  body.FR #tg-duo-1,
  body.FR #tg-duo-2,
  body.FR #mh-assises-banner,
  body.FR #tg-full-2,
  body.FR #mh-recent-products,
  body.FR #mh-instagram-root,
  body.FR .mh-insta,
  body.FR .mh-home-inner {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    max-height: none !important;
    overflow: visible !important;
  }

  body.FR .mh-home-promo-duo {
    display: flex !important;
    flex-direction: column;
  }

  /* Catégories : grille 2 colonnes (flex, pas display:block) */
  body.FR #home-categories,
  body.FR .mh-categories-links,
  html.mh-is-mobile #home-categories,
  html.mh-is-mobile .mh-categories-links {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    width: 100% !important;
    visibility: visible !important;
    opacity: 1 !important;
    max-height: none !important;
    overflow: visible !important;
  }

  body.FR .mh-categories-item,
  html.mh-is-mobile .mh-categories-item {
    display: flex !important;
    flex: 0 0 calc(50% - 4px) !important;
    max-width: calc(50% - 4px) !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  body.FR .mh-home-inner--narrow {
    display: block !important;
    padding: 28px 16px 40px;
  }

  body.FR .mh-home-welcome-title,
  body.FR .mh-home-welcome-text {
    display: block !important;
    visibility: visible !important;
  }

  /* Fiche produit — styles dans product-habitat.css (sans CSS Habitat.fr) */

  /* ——— Renforts mobile (site maison havitat :5500) ——— */
  html.mh-is-mobile {
    -webkit-tap-highlight-color: transparent;
  }

  html.mh-is-mobile button,
  html.mh-is-mobile a,
  html.mh-is-mobile .mh-filter-btn,
  html.mh-is-mobile .mh-nav-all,
  html.mh-is-mobile .mh-catalog-icon-btn {
    touch-action: manipulation;
  }

  html.mh-is-mobile .mh-header-actions .mh-icon-btn[title='Aide'],
  html.mh-is-mobile .mh-header-actions .mh-header-phone,
  html.mh-is-mobile .mh-header-actions .mh-icon-btn[title="Liste d'envies"] {
    display: none !important;
  }

  html.mh-is-mobile .mh-header-actions .mh-account-btn,
  html.mh-is-mobile .mh-header-actions .mh-cart-btn {
    display: inline-flex !important;
    visibility: visible !important;
  }

  html.mh-is-mobile .mh-catalog-view-btn[data-cols='6'] {
    display: none !important;
  }

  html.mh-is-mobile .mh-catalog-card-img-wrap {
    display: block;
    position: relative;
    aspect-ratio: 1;
    min-height: 140px;
    margin-bottom: 10px;
    overflow: hidden;
    background: #f5f5f5;
  }

  html.mh-is-mobile .mh-catalog-card-img-wrap img {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 140px;
    object-fit: cover !important;
    visibility: visible !important;
    opacity: 1 !important;
  }

  /* Instagram — après « Afficher plus » : grille 2 colonnes avec photos visibles */
  html.mh-is-mobile .mh-insta-grid--expanded {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
    overflow: visible !important;
    flex-wrap: wrap !important;
  }

  html.mh-is-mobile .mh-insta-grid--expanded > [role='listitem'] {
    width: 100% !important;
    flex: none !important;
    min-width: 0;
  }

  html.mh-is-mobile .mh-insta-card {
    width: 100%;
    min-height: 140px;
  }

  html.mh-is-mobile .mh-insta-card img {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    visibility: visible !important;
    opacity: 1 !important;
  }

  html.mh-is-mobile .mh-catalog-icon-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
  }

  html.mh-is-mobile .mh-catalog-card-desc {
    font-size: 0.75rem;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  html.mh-is-mobile .mh-catalog-card-brand {
    font-size: 0.875rem;
  }

  html.mh-is-mobile .mh-filter-drawer {
    width: 100%;
    max-width: 100%;
    border-radius: 16px 16px 0 0;
    top: auto;
    bottom: 0;
    height: min(88vh, 640px);
    transform: translateY(100%);
    padding-top: 12px;
  }

  html.mh-is-mobile .mh-filter-drawer.is-open {
    transform: translateY(0);
  }

  html.mh-is-mobile .mh-filter-drawer-head {
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 2;
    padding-bottom: 12px;
    margin-bottom: 16px;
    border-bottom: 1px solid #eee;
  }

  html.mh-is-mobile .mh-filter-overlay.is-visible {
    backdrop-filter: blur(2px);
  }

  html.mh-is-mobile .mh-categories-row {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    padding: 0 10px 24px !important;
  }

  html.mh-is-mobile .mh-home-hero {
    margin: 0;
    line-height: 0;
  }

  html.mh-is-mobile .mh-home-hero-cta {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    bottom: 16px;
  }

  html.mh-is-mobile .product-gallery-container {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    overflow: visible !important;
  }

  html.mh-is-mobile .product-gallery.mh-gallery-main {
    width: 100% !important;
    max-width: 100% !important;
  }

  html.mh-is-mobile .product-info-side,
  html.mh-is-mobile .product-info-side h1,
  html.mh-is-mobile .mh-tab-panel {
    max-width: 100% !important;
    overflow-wrap: break-word;
    word-break: break-word;
  }

  html.mh-is-mobile .thumb-product-gallery {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    gap: 8px !important;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
  }

  html.mh-is-mobile .thumb-product-gallery .product-image-container {
    flex: 0 0 64px;
    width: 64px !important;
    height: 64px !important;
  }

  html.mh-is-mobile .mh-related-section .mh-product-row {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    gap: 12px !important;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 8px;
  }

  html.mh-is-mobile .mh-related-section .product-card,
  html.mh-is-mobile .mh-related-section .mh-catalog-card {
    flex: 0 0 min(44vw, 180px);
    min-width: 0;
  }

  html.mh-is-mobile .cart-item img {
    width: 88px;
    height: 88px;
  }

  html.mh-is-mobile .mh-cart-checkout .btn-primary,
  html.mh-is-mobile #mh-revolut-pay {
    width: 100%;
    min-height: 52px;
    font-size: 1rem;
  }

  html.mh-is-mobile #toast {
    left: 12px;
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    max-width: none;
    text-align: center;
  }

  html.mh-is-mobile.mh-menu-open {
    overflow: hidden;
    touch-action: none;
  }

  html.mh-is-mobile.mh-menu-open .mh-header-wrap {
    z-index: 600;
  }

  html.mh-is-mobile.mh-menu-open .mh-mobile-menu-btn {
    background: rgba(255, 255, 255, 0.15);
  }

  body.FR .mh-mobile-menu-btn,
  body.FR .mh-header-black .mh-mobile-menu-btn {
    display: flex !important;
    pointer-events: auto !important;
    touch-action: manipulation;
  }

  .mh-menu-backdrop.is-open {
    z-index: 850 !important;
    pointer-events: auto !important;
    opacity: 1 !important;
  }

  .mh-menu-dropdown.is-open {
    z-index: 900 !important;
    display: block !important;
    pointer-events: auto !important;
  }

  .mh-menu-flyout-btn,
  .mh-menu-flyout-link,
  .mh-nav-all,
  .mh-mobile-menu-btn {
    pointer-events: auto !important;
    cursor: pointer !important;
  }

  body.mh-product-page-body .mh-payment-options,
  body.FR .mh-payment-options {
    display: flex !important;
    flex-wrap: wrap;
  }

  body.mh-product-page-body .product-information-flex-container,
  body.mh-product-page-body .product-info-side,
  body.mh-product-page-body .mh-buy-section,
  body.mh-product-page-body .mh-atouts,
  body.mh-product-page-body .mh-product-details-wrap {
    display: block;
    visibility: visible;
    max-height: none !important;
    overflow: visible !important;
  }

  body.mh-product-page-body .product-information-flex-container {
    display: flex !important;
    flex-direction: column !important;
  }

  body.mh-product-page-body #mh-add-cart,
  body.mh-product-page-body .mh-buy-section .mh-btn-cart,
  body.FR #mh-add-cart,
  body.FR .mh-buy-section .mh-btn-cart {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    visibility: visible !important;
    opacity: 1 !important;
    width: 100% !important;
    min-height: 52px !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    color: #fff !important;
    background: #111 !important;
    border: none !important;
    font-size: 0.8rem !important;
    font-weight: 600 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.08em !important;
  }

  /* Catalogue — cartes et filtres */
  body.FR .mh-catalog-wrap,
  body.FR .mh-catalog-toolbar,
  body.FR .mh-catalog-grid,
  body.FR .mh-catalog-card,
  body.FR .mh-catalog-card-body {
    overflow: visible !important;
    max-height: none !important;
  }

  body.FR .mh-catalog-card-img-wrap,
  body.FR .mh-catalog-card-img-wrap img,
  body.FR .mh-insta-card img {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    max-height: none !important;
  }

  body.FR .mh-catalog-card-actions,
  body.FR .mh-catalog-icon-btn {
    display: flex !important;
    opacity: 1 !important;
    visibility: visible !important;
  }

  /* Designers */
  body.FR .mh-landing-page,
  body.FR .mh-content-spotlight,
  body.FR .mh-designers-list,
  body.FR .mh-inspirations,
  body.FR .mh-spotlight-right {
    display: block !important;
    visibility: visible !important;
  }

  body.FR .mh-spotlight-content {
    display: grid !important;
  }

  /* Footer */
  body.FR #mh-site-footer,
  body.FR #site-footer,
  body.FR .mh-footer {
    display: block !important;
    visibility: visible !important;
    overflow: visible !important;
  }

  body.FR .mh-footer a,
  body.FR #mh-site-footer a {
    pointer-events: auto !important;
    cursor: pointer !important;
  }

  /* Placeholders Habitat (squelettes) masqués */
  body.FR .placeholder-skeleton,
  body.FR .placeholder-skeleton svg {
    display: none !important;
    height: 0 !important;
    overflow: hidden !important;
  }
}
