/**
 * Mobile-first responsive enhancements.
 */

@media (max-width: 768px) {
  :root {
    --e47-container-gutter: 1.25rem;
  }
}

@media (max-width: 480px) {
  :root {
    --e47-container-gutter: 1rem;
  }
}

/* Prevent horizontal scroll sitewide */
html {
  overflow-x: clip;
}

.site-shell,
.site-main {
  overflow-x: clip;
  max-width: 100%;
}

/* —— Header: mobile drawer —— */
.site-header__menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  margin: 0;
  padding: 0;
  border: 1px solid #ddd5c8;
  border-radius: 0;
  background: #fffef9;
  color: #29251f;
  cursor: pointer;
  flex-shrink: 0;
}

.site-header__menu-icon,
.site-header__menu-icon::before,
.site-header__menu-icon::after {
  display: block;
  width: 1.15rem;
  height: 1px;
  background: currentColor;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.site-header__menu-icon {
  position: relative;
}

.site-header__menu-icon::before,
.site-header__menu-icon::after {
  content: "";
  position: absolute;
  left: 0;
}

.site-header__menu-icon::before {
  top: -0.35rem;
}

.site-header__menu-icon::after {
  top: 0.35rem;
}

body.is-mobile-nav-open .site-header__menu-icon {
  background: transparent;
}

body.is-mobile-nav-open .site-header__menu-icon::before {
  top: 0;
  transform: rotate(45deg);
}

body.is-mobile-nav-open .site-header__menu-icon::after {
  top: 0;
  transform: rotate(-45deg);
}

.site-header__nav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 240;
  background: rgba(20, 18, 16, 0.45);
  border: 0;
}

body.is-mobile-nav-open .site-header__nav-backdrop {
  display: block;
}

.site-header__search--mobile {
  display: none;
}

@media (min-width: 769px) {
  .site-header__menu-toggle,
  .site-header__nav-backdrop,
  .site-header__search--mobile {
    display: none !important;
  }
}

@media (max-width: 768px) {
  body.is-mobile-nav-open .site-header {
    z-index: 260;
  }

  .site-header__inner {
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
    min-height: 0;
    padding: 0.65rem 0;
  }

  .site-header__menu-toggle {
    display: inline-flex;
    order: 2;
  }

  .site-branding {
    flex: 1 1 auto;
    min-width: 0;
    order: 1;
    justify-content: flex-start;
  }

  .site-header__utilities {
    order: 3;
    position: relative;
    z-index: 252;
  }

  .site-branding img,
  .site-branding .custom-logo {
    height: 44px;
    max-width: min(180px, 52vw);
    width: auto;
    object-fit: contain;
  }

  .site-header__utilities {
    flex-shrink: 0;
    gap: 0.5rem;
  }

  .site-header__search--desktop {
    display: none;
  }

  .site-header__utility-link {
    font-size: 0.75rem;
    min-height: 2.75rem;
    display: inline-flex;
    align-items: center;
  }

  .main-nav {
    flex: none;
    order: 4;
    position: fixed;
    top: 0;
    right: 0;
    z-index: 250;
    width: min(100%, 22rem);
    max-width: 100vw;
    height: 100dvh;
    margin: 0;
    justify-content: flex-start;
    padding: calc(4.5rem + env(safe-area-inset-top, 0)) 1.25rem calc(1.25rem + env(safe-area-inset-bottom, 0));
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: #fffef9;
    border-left: 1px solid #ddd5c8;
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.12);
    transform: translate3d(105%, 0, 0);
    transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
    visibility: hidden;
    pointer-events: none;
  }

  body.is-mobile-nav-open .main-nav {
    transform: translate3d(0, 0, 0);
    visibility: visible;
    pointer-events: auto;
  }

  .site-header__search--mobile {
    display: block;
    width: 100%;
    margin: 0 0 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #ebe6dc;
  }

  .site-header__search--mobile input[type="search"] {
    width: 100%;
    min-height: 2.75rem;
    font-size: 1rem;
  }

  .main-nav ul {
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 0;
    min-width: 0;
    padding: 0;
  }

  .main-nav > ul > li {
    border-bottom: 1px solid #ebe6dc;
  }

  .main-nav a {
    display: flex;
    align-items: center;
    min-height: 2.75rem;
    padding: 0.5rem 0;
    font-size: 0.82rem;
    white-space: normal;
  }

  .main-nav a::after {
    display: none;
  }

  .e47-mega {
    position: static;
    width: 100%;
    max-width: none;
    max-height: none;
    transform: none !important;
    margin: 0.5rem 0 0;
    box-shadow: none;
    border: 1px solid #ebe6dc;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    display: none;
  }

  .e47-has-mega.is-open .e47-mega {
    display: block;
  }

  .e47-mega__inner {
    width: 100%;
  }

  .e47-mega-hub__inner {
    width: 100%;
    padding-left: 0;
    padding-right: 0;
  }
}

/* —— Typography & touch targets —— */
@media (max-width: 768px) {
  .about-intro__title {
    font-size: clamp(1.85rem, 8vw, 2.75rem);
  }

  .about-intro__lead {
    font-size: 0.92rem;
  }

  .page-title-banner__title {
    font-size: clamp(1.35rem, 5.5vw, 1.85rem);
    line-height: 1.2;
    word-wrap: break-word;
  }

  .home-video-banner__actions {
    flex-direction: column;
    align-items: stretch;
  }

  .home-video-banner__btn {
    width: 100%;
    min-height: 2.85rem;
  }

  .faq-page__layout {
    grid-template-columns: 1fr;
  }

  .faq-page__nav {
    position: static;
  }

  .faq-page__nav-list {
    flex-direction: row;
    flex-wrap: wrap;
    max-height: none;
    overflow: visible;
  }

  .faq-page__contact-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .faq-page__btn {
    width: 100%;
  }

  .policy-contact__card {
    display: block;
    width: 100%;
    padding: 1.35rem 1.15rem;
  }

  .brand-arch-foundation,
  .brand-arch-blocks,
  .brand-arch-sections {
    grid-template-columns: 1fr;
  }

  .brand-arch-block,
  .brand-arch-section {
    border-right: 0 !important;
  }

  .manifesto-closing__lines {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .about-explore__links {
    flex-wrap: wrap;
  }
}

@media (max-width: 600px) {
  .single-product .e47-product__form .single_add_to_cart_button,
  .single-product .e47-product__form .button {
    width: 100%;
    min-height: 2.85rem;
  }

  .single-product .e47-product__quantity-row {
    flex-wrap: wrap;
  }

  .woocommerce-message,
  .woocommerce-info,
  .woocommerce-error {
    font-size: 0.88rem;
  }

  .e47-blog-content {
    font-size: 0.92rem;
  }

  .e47-blog-content h2 {
    font-size: 1.35rem;
  }

  .blog-post-hero__title {
    font-size: clamp(1.65rem, 7vw, 2.25rem);
  }
}

/* Tables & media */
.e47-blog-content img,
.e47-blog-content iframe,
.e47-blog-content video,
.about-static-content__inner img {
  max-width: 100%;
  height: auto;
}

.woocommerce table.shop_table {
  display: block;
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

@media (prefers-reduced-motion: reduce) {
  .main-nav,
  .site-header__menu-icon,
  .site-header__menu-icon::before,
  .site-header__menu-icon::after {
    transition: none;
  }
}

/* —— Sitewide mobile compatibility —— */

/* Prevent iOS zoom on form focus */
@media (max-width: 768px) {
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="search"],
  input[type="number"],
  input[type="password"],
  select,
  textarea {
    font-size: 16px;
  }
}

/* Safe areas for notched devices */
@supports (padding: max(0px)) {
  .site-footer {
    padding-bottom: max(1.8rem, calc(1.8rem + env(safe-area-inset-bottom, 0)));
  }

  .main-nav {
    padding-bottom: max(1.25rem, calc(1.25rem + env(safe-area-inset-bottom, 0)));
  }
}

@media (max-width: 768px) {
  /* Mobile nav: expand/collapse affordance */
  .main-nav > ul > li.menu-item-has-children > a,
  .main-nav > ul > li.e47-has-mega > a {
    position: relative;
    padding-right: 1.75rem;
  }

  .main-nav > ul > li.menu-item-has-children > a::before,
  .main-nav > ul > li.e47-has-mega > a::before {
    content: "+";
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 1.25rem;
    text-align: center;
    font-size: 1.1rem;
    line-height: 1;
    color: #8a8377;
  }

  .main-nav > ul > li.menu-item-has-children.is-open > a::before,
  .main-nav > ul > li.e47-has-mega.is-open > a::before {
    content: "−";
  }

  .e47-mega__featured {
    padding: 1rem 0 0;
  }

  .e47-mega__featured-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .e47-mega__btn {
    width: 100%;
    min-height: 2.75rem;
    justify-content: center;
  }

  .home-testimonials__header {
    flex-direction: column;
    align-items: flex-start;
  }

  .home-testimonials__card-footer {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.65rem;
  }

  .home-collection__actions {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .home-collection__actions a.button,
  .home-collection__actions a.add_to_cart_button {
    flex: 1 1 auto;
    min-width: 0;
  }

  .footer-follow {
    flex-direction: column;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 0.65rem;
  }

  .footer-follow__links {
    flex-wrap: wrap;
    width: 100%;
  }

  .footer-social-link {
    flex-shrink: 1;
    min-width: 0;
  }

  .footer-contact-item span,
  .footer-links a {
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .contact-page .footer-follow__links {
    flex-wrap: wrap;
  }

  .woocommerce form .form-row {
    width: 100%;
    float: none;
    margin-right: 0;
  }

  .woocommerce-checkout #payment .payment_methods li {
    padding: 0.85rem 0;
  }

  .woocommerce-checkout #place_order,
  .woocommerce-cart .checkout-button,
  .woocommerce-cart .button {
    width: 100%;
    min-height: 2.85rem;
  }

  .single-product .e47-product-ingredients__cell {
    padding: 1.35rem 1rem;
  }

  .single-product .e47-product-clinical__item {
    grid-template-columns: 1fr;
    align-items: start;
    gap: 0.5rem;
  }

  .e47-faqs__question {
    padding: 0.95rem 2.5rem 0.95rem 0;
    font-size: 0.92rem;
  }
}

@media (max-width: 480px) {
  .announcement-bar__track {
    font-size: 0.66rem;
    gap: 1rem;
  }

  .site-header__utility-link {
    font-size: 0.7rem;
  }

  .site-header__cart-link {
    font-size: 0.7rem;
  }

  .home-video-banner__title {
    font-size: clamp(1.65rem, 8vw, 2.35rem);
  }

  .home-philosophy__cell,
  .home-science__cell,
  .home-why__cell {
    padding: 1.35rem 1rem;
  }

  .footer-retailer-link {
    min-width: 0;
    flex: 1 1 calc(50% - 0.5rem);
  }

  .footer-retailers__logos {
    flex-wrap: wrap;
    width: 100%;
  }
}
