/**
 * Mobile / H5: safe areas, touch targets, readability, overflow control.
 * Loaded last so it can override main.css, home.css, pages.css, woocommerce.css.
 */

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}

.site-main {
  padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
}

/* Softer tap flash; focus-visible still handled per-component */
a,
button,
input,
select,
textarea,
.es-filter__item {
  -webkit-tap-highlight-color: rgba(10, 111, 174, 0.12);
}

@media (max-width: 992px) {
  .es-header {
    padding-top: env(safe-area-inset-top, 0px);
  }

  .es-header__inner {
    flex-wrap: wrap;
    row-gap: 10px;
  }

  .es-menu-toggle {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 11px;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
  }

  .es-nav {
    max-height: min(70vh, 520px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .es-nav .es-menu li a {
    min-height: 48px;
    padding: 14px 6px;
    display: flex;
    align-items: center;
    font-size: 16px;
    line-height: 1.35;
  }

  .es-brand__text {
    font-size: clamp(18px, 5vw, 22px);
  }

  .es-topbar {
    font-size: clamp(12px, 3.4vw, 13px);
  }

  .es-topbar__inner {
    flex-wrap: wrap;
    justify-content: center;
    row-gap: 6px;
    column-gap: 12px;
    text-align: center;
  }

  .es-btn {
    min-height: 44px;
    padding: 12px 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
  }

  .es-header__account-register {
    min-height: 44px;
    padding: 10px 16px;
  }

  .es-header__account-link,
  .es-header__account-link--quiet {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    padding: 10px 6px;
    box-sizing: border-box;
  }

  .es-header__account-profile {
    min-height: 44px;
    padding: 6px 8px 6px 6px;
  }

  .es-header__cart {
    min-height: 44px;
    padding: 10px 12px;
    box-sizing: border-box;
  }

  .es-section h2 {
    font-size: clamp(24px, 6.5vw, 34px);
    line-height: 1.22;
  }

  .es-lead {
    font-size: clamp(15px, 4vw, 17px);
    line-height: 1.65;
  }

  .es-footer {
    padding-bottom: calc(36px + env(safe-area-inset-bottom, 0px));
  }

  body.es-has-mobile-sticky-cta .site-main {
    padding-bottom: calc(68px + env(safe-area-inset-bottom, 0px));
  }

  body.es-has-mobile-sticky-cta .es-footer {
    padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px));
  }

  .es-mobile-sticky-cta {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 110;
    gap: 10px;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
    background: rgba(255, 255, 255, 0.96);
    border-top: 1px solid #dbe7f0;
    box-shadow: 0 -8px 24px rgba(13, 42, 67, 0.12);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: transform 0.25s ease, opacity 0.2s ease;
  }

  body.es-quote-modal-open .es-mobile-sticky-cta {
    transform: translateY(110%);
    opacity: 0;
    pointer-events: none;
  }

  .es-mobile-sticky-cta__btn {
    flex: 1;
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 12px;
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #0d2a43;
    font: inherit;
    font-size: 15px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    box-sizing: border-box;
  }

  .es-mobile-sticky-cta__btn--quote {
    background: #0a6fae;
    border-color: #0a6fae;
    color: #fff;
  }

  .es-mobile-sticky-cta__btn--call {
    flex: 0 0 auto;
    min-width: 108px;
    padding-inline: 14px;
  }

  .es-mobile-sticky-cta__icon {
    font-size: 16px;
    line-height: 1;
  }

  .es-page-cta,
  #quote-form {
    scroll-margin-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  }

  .es-footer__social a {
    min-height: 44px;
    padding: 10px 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
  }

  .es-footer-menu a {
    display: inline-block;
    padding: 8px 0;
    min-height: 44px;
    line-height: 1.45;
    box-sizing: border-box;
  }

  .es-footer__form input {
    font-size: 16px;
    min-height: 48px;
    padding: 12px 14px;
  }

  /* Home / sections: horizontal strips easier to swipe without gradient clipping taps */
  .es-hscroll {
    mask-image: none;
    -webkit-mask-image: none;
    scroll-padding-inline: 8px;
  }

  .es-hscroll-nav {
    justify-content: space-between;
    width: 100%;
  }

  .es-form input,
  .es-form textarea {
    font-size: 16px;
    min-height: 48px;
    padding: 14px 14px;
  }

  .es-form textarea {
    min-height: 140px;
  }

  .es-faq summary {
    min-height: 48px;
    display: flex;
    align-items: center;
    padding: 4px 0;
    box-sizing: border-box;
  }
}

@media (max-width: 640px) {
  .es-pagination .page-numbers {
    min-width: 44px;
    min-height: 44px;
  }

  .es-filter__item {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 10px 16px;
    font-size: 14px;
  }

  .woocommerce ul.products li.product .woocommerce-loop-product__title {
    font-size: clamp(16px, 4.2vw, 18px);
    line-height: 1.35;
  }

  .woocommerce div.product .product_title {
    font-size: clamp(22px, 6vw, 28px);
    line-height: 1.2;
  }

  .woocommerce div.product .woocommerce-tabs ul.tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    gap: 8px;
    padding: 12px 12px 4px;
    scrollbar-width: thin;
  }

  .woocommerce div.product .woocommerce-tabs ul.tabs li {
    flex: 0 0 auto;
  }

  .woocommerce div.product .woocommerce-tabs ul.tabs li a {
    white-space: nowrap;
    padding: 12px 16px;
    font-size: 14px;
  }

  .woocommerce div.product .woocommerce-tabs .panel {
    padding: 16px 16px 18px;
    font-size: 15px;
    line-height: 1.65;
  }

  .woocommerce .quantity .qty {
    font-size: 16px;
  }

  .woocommerce-checkout .form-row input.input-text,
  .woocommerce-checkout .form-row textarea,
  .woocommerce-checkout .form-row select {
    font-size: 16px;
    min-height: 48px;
  }

  .woocommerce-checkout .form-row textarea {
    min-height: 120px;
  }

  .woocommerce-account .woocommerce-MyAccount-content {
    padding: 16px;
    font-size: 15px;
    line-height: 1.6;
  }

  .woocommerce-message,
  .woocommerce-info,
  .woocommerce-error {
    font-size: 14px;
    line-height: 1.55;
    padding: 14px 16px;
  }

  .wc-block-components-text-input input,
  .wc-block-components-text-input textarea,
  .wc-block-checkout input[type="text"],
  .wc-block-checkout input[type="email"],
  .wc-block-checkout input[type="tel"],
  .wc-block-checkout textarea,
  .wc-block-checkout select {
    min-height: 48px;
  }

  .wc-block-checkout textarea {
    min-height: 120px;
  }

  .es-topbar__inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .es-topbar__trust {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .es-header__search {
    display: none;
  }

  .es-trust-partners__head h2 {
    font-size: clamp(24px, 6.5vw, 32px);
    line-height: 1.2;
  }

  .es-trust-partners__grid {
    grid-template-columns: 1fr;
  }

  .es-trust-partners__metrics {
    grid-template-columns: 1fr;
  }

  .es-trust-partners__panel--logos.es-trust-partners__logos {
    grid-template-columns: 1fr;
  }

  .es-trust-badges {
    flex-direction: column;
    align-items: flex-start;
  }

  .es-footer__legal {
    flex-direction: column;
    gap: 8px;
  }

  .es-chat-widgets {
    right: 12px;
    bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  }

  body:not(.es-has-mobile-sticky-cta) .es-chat-widgets {
    bottom: 12px;
  }

  .es-chat-widgets__btn span:last-child {
    display: none;
  }
}
