/*
 * DML Mobile & Tablet Boost 1.1
 * Renforcement responsive / tactile / stabilité mobile sans modifier le thème desktop.
 */

@media (max-width: 1024px) {
  html,
  body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    overscroll-behavior-x: none;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }

  @supports (overflow: clip) {
    html,
    body {
      overflow-x: clip;
    }
  }

  *,
  *::before,
  *::after {
    box-sizing: border-box;
  }

  /* Les enfants flex/grid trop larges sont une cause fréquente de scroll horizontal. */
  .row > *,
  [class*="col-"] ,
  #main,
  #content,
  #content-wrapper,
  #wrapper,
  .page-content,
  .product-container,
  .product-information,
  .product-actions,
  .product-miniature,
  .thumbnail-container,
  .cart-grid,
  .cart-grid-body,
  .cart-grid-right,
  .checkout-step {
    min-width: 0;
    max-width: 100%;
  }

  img,
  picture,
  video,
  canvas,
  svg,
  iframe {
    max-width: 100%;
  }

  img,
  video {
    height: auto;
  }

  iframe {
    width: 100%;
  }

  .container,
  .container-fluid {
    max-width: 100%;
  }

  /* Titres, références, URLs et libellés longs. */
  h1, h2, h3, h4, h5, h6,
  p, li, a, span,
  .product-title,
  .product-description,
  .product-reference,
  .breadcrumb,
  .block-category,
  .product-features,
  .product-variants,
  .current-price {
    overflow-wrap: anywhere;
    word-break: normal;
  }

  /* En-tête / recherche */
  #header,
  #header .header-top,
  #header .header-nav,
  #header .container,
  #header .row,
  #search_widget,
  #search_widget form,
  .search-widget,
  .search-widget form {
    max-width: 100%;
  }

  #search_widget input[type="text"],
  .search-widget input[type="text"],
  input[type="search"] {
    min-width: 0;
    max-width: 100%;
  }

  /* Menu mobile : lignes tactiles lisibles et panneau contenu dans l'écran. */
  #mobile_top_menu_wrapper,
  .mobile-menu,
  .offcanvas,
  .off-canvas,
  [class*="mobile-menu"] {
    max-width: 92vw;
    max-height: var(--dml-vh, 100vh);
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  #mobile_top_menu_wrapper .top-menu a,
  #mobile_top_menu_wrapper a.dropdown-item {
    white-space: normal;
    line-height: 1.3;
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  /* Fiches et cartes produits. */
  .product-cover,
  .product-images,
  .products,
  .product-miniature,
  .thumbnail-container,
  .product-description,
  .product-price-and-shipping,
  .product-prices {
    max-width: 100%;
  }

  .product-cover img,
  .product-miniature img,
  .thumbnail-container img {
    max-width: 100%;
    height: auto;
    object-fit: contain;
  }

  .product-price-and-shipping,
  .product-prices,
  .product-variants > .product-variants-item,
  .product-add-to-cart,
  .product-quantity {
    flex-wrap: wrap;
  }

  .product-variants select,
  .product-variants input,
  .product-variants .form-control,
  .product-quantity .qty,
  .product-quantity .input-group {
    max-width: 100%;
  }

  /* Onglets produit et breadcrumb : défilement horizontal contrôlé plutôt que page cassée. */
  .tabs .nav-tabs,
  .nav-tabs,
  .breadcrumb,
  nav.breadcrumb {
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }

  .tabs .nav-tabs,
  .nav-tabs {
    flex-wrap: nowrap;
  }

  .tabs .nav-tabs .nav-link,
  .nav-tabs .nav-link {
    white-space: nowrap;
  }

  /* Tables : panier, caractéristiques, commandes. */
  .table-responsive,
  table {
    max-width: 100%;
  }

  table:not(.table-responsive table) {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Cibles tactiles importantes - minimum mobile 48px. */
  button,
  .btn,
  [role="button"],
  input[type="submit"],
  input[type="button"],
  .add-to-cart,
  .remove-from-cart,
  .cart-line-product-actions a,
  .pagination a,
  .dropdown-toggle,
  .carousel-control-prev,
  .carousel-control-next,
  .close,
  [data-dismiss="modal"] {
    min-height: 48px;
    touch-action: manipulation;
  }

  .pagination a,
  .carousel-control-prev,
  .carousel-control-next,
  .close,
  [data-dismiss="modal"] {
    min-width: 48px;
  }

  /* Formulaires : évite le zoom iOS et les champs hors écran. */
  input,
  select,
  textarea,
  .form-control {
    max-width: 100%;
    font-size: 16px;
  }

  textarea {
    resize: vertical;
  }

  /* Panier / tunnel de commande. */
  .cart-item,
  .cart-summary,
  .checkout-step,
  .payment-options,
  .delivery-options,
  .js-address-form,
  .js-customer-form {
    max-width: 100%;
  }

  .cart-line-product-actions,
  .cart-line-product-actions .remove-from-cart,
  .product-line-actions {
    touch-action: manipulation;
  }

  /* Modales, compte, avis, comparateur : contenu toujours dans le viewport. */
  .modal-dialog,
  .modal-content,
  .dropdown-menu,
  .popover,
  .tooltip-inner {
    max-width: calc(100vw - 24px);
  }

  .modal-content {
    max-height: calc(var(--dml-vh, 100vh) - 24px);
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  /* Les widgets fixes ne doivent jamais agrandir la page. */
  [style*="position: fixed"],
  [style*="position:fixed"] {
    max-width: 100vw;
  }

  /* Évite certains effets hover coûteux ou collants sur écran tactile. */
  @media (hover: none) and (pointer: coarse) {
    .product-miniature:hover,
    .thumbnail-container:hover,
    .card:hover {
      transform: none;
    }
  }

  /* Le footer hors écran coûte moins cher à rendre sur les longs catalogues. */
  #footer,
  .footer-container {
    content-visibility: auto;
    contain-intrinsic-size: auto 600px;
  }
}

@media (max-width: 767px) {
  #wrapper > .container,
  #main .container,
  .page-content > .container,
  #header .container,
  #footer .container,
  .footer-container .container {
    padding-left: 12px;
    padding-right: 12px;
  }

  /* Recherche pleine largeur sur smartphone. */
  #search_widget,
  .search-widget,
  #search_widget form,
  .search-widget form,
  #search_widget input[type="text"],
  .search-widget input[type="text"],
  input[type="search"] {
    width: 100%;
  }

  /* Zone d'achat plus confortable au pouce. */
  .product-actions .add-to-cart,
  .product-actions .btn-primary,
  .product-add-to-cart .add-to-cart {
    min-height: 48px;
  }

  .product-miniature .product-title,
  .product-miniature .product-title a {
    line-height: 1.3;
  }

  .modal-dialog {
    margin: 12px;
    width: auto;
  }

  /* Les grilles Bootstrap anciennes ne doivent pas conserver une largeur fixe. */
  .row > [class*="col-"] {
    max-width: 100%;
  }
}

@media (min-width: 768px) and (max-width: 1024px) {
  /* Tablette : davantage d'air sans toucher au layout desktop. */
  #wrapper > .container,
  #main .container,
  .page-content > .container {
    padding-left: 18px;
    padding-right: 18px;
  }
}

/* Accessibilité + baisse du travail graphique lorsque l'utilisateur le demande. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* DML POINT 104 - panier mobile : suppression du bandeau breadcrumb gris */
@media screen and (max-width: 767px) {
    #cart .breadcrumb-bg {
        display: none !important;
        min-height: 0 !important;
    }
}

/* DML POINT 105 - panier mobile : quantité plus large et tactile */
@media screen and (max-width: 767px) {
    #cart .product-line-grid-right .bootstrap-touchspin > .form-control,
    #cart .product-line-grid-right .bootstrap-touchspin > .input-group {
        width: 56px !important;
        min-width: 56px !important;
        height: 48px !important;
        font-size: 16px !important;
        text-align: center;
    }

    #cart .product-line-grid-right .bootstrap-touchspin .input-group-btn-vertical {
        width: 36px !important;
    }

    #cart .product-line-grid-right .bootstrap-touchspin .btn-touchspin {
        width: 36px !important;
        height: 24px !important;
        min-height: 24px !important;
        padding: 0 !important;
    }
}
