/* A2Z E-Com Store responsive refinements.
   Deliberately additive: desktop rules and existing component styling remain the source of truth. */
@media (max-width: 680px) {
  html, body { max-width: 100%; overflow-x: clip; }
  .container { width: min(100% - 28px, var(--max)); }
  .site-header .header-main {
    display: grid !important;
    position: relative;
    grid-template-columns: 40px minmax(0, 1fr) auto !important;
    grid-template-rows: auto;
    align-items: center;
    gap: 10px;
    min-height: 0;
    height: auto !important;
    padding-top: 12px;
    padding-bottom: 12px;
  }
  .site-header .header-main > .menu-toggle {
    display: inline-flex !important;
    grid-column: 1;
    grid-row: 1;
    width: 38px;
    min-width: 38px;
    height: 38px;
    padding: 0;
    align-items: center;
    justify-content: center;
    font-size: 19px;
    line-height: 1;
    border-radius: 8px;
  }
  .site-header .header-main > .brand {
    grid-column: 2;
    grid-row: 1;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    justify-self: auto;
    width: max-content;
    max-width: calc(100% - 150px);
    min-width: 0;
    font-size: clamp(20px, 5.2vw, 25px);
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .site-header .header-main > .header-actions {
    grid-column: 3;
    grid-row: 1;
    display: flex !important;
    align-items: center;
    justify-content: flex-end;
    gap: clamp(7px, 2vw, 12px) !important;
    margin: 0 !important;
    min-width: 0;
  }
  /* Keep the full-width desktop search out of the compact mobile header.
     The matching search control is available at the top of the drawer. */
  .site-header .header-main > .search { display: none !important; }
  .site-header .header-actions .action-label { display: none; }
  .site-header .header-actions .icon-action,
  .site-header .header-actions .account-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    min-height: 34px;
    padding: 3px;
    white-space: nowrap;
  }
  .site-header .header-actions .count { margin-left: 2px; }
  .site-header .category-nav-wrap { display: none !important; }
  .site-header .category-nav-wrap.mobile-open { display: block !important; }
  .site-header .category-nav { display: flex; }
  .site-header .account-panel { right: 0; left: auto; }
  .maison-ribbon-inner { min-width: 0; }
  .section { padding-top: 38px; padding-bottom: 38px; }
  .section-head { align-items: flex-start; flex-wrap: wrap; gap: 10px; }
  .hero { padding: 32px 0; }
  .hero-grid { grid-template-columns: minmax(0, 1fr); gap: 22px; }
  .hero-art img { height: auto; aspect-ratio: 16 / 9; object-fit: cover; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .product-card { min-width: 0; }
  .product-card .card-body { padding: 11px 10px; }
  .product-card h3 { overflow-wrap: anywhere; }
  .product-card .product-image { padding: 9px; }
  .card-actions { flex-wrap: wrap; }
  .card-actions button { min-width: 0; }
  .footer-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .footer-grid > div { min-width: 0; }
  .a2z-tutorial-home-grid, .a2z-video-grid { grid-template-columns: minmax(0, 1fr); }
  .a2z-review-testimonials { grid-template-columns: minmax(0, 1fr); }
  .editorial-grid, .network-grid { grid-template-columns: minmax(0, 1fr); }
  .woocommerce, .woocommerce-page, .a2z-woo-page-content { min-width: 0; max-width: 100%; }
  .woocommerce table.shop_table, .woocommerce table.my_account_orders { display: block; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .woocommerce form .form-row,
  .woocommerce .col2-set,
  .woocommerce .col2-set .col-1,
  .woocommerce .col2-set .col-2 { float: none; width: 100%; max-width: 100%; }
  .cart-layout, .checkout-layout, .product-layout, .shop-layout, .account-layout { grid-template-columns: minmax(0, 1fr) !important; }
  .cart-item, .cart-row { min-width: 0; }
  input, select, textarea { max-width: 100%; }
  .pagination, .woocommerce nav.woocommerce-pagination ul { flex-wrap: wrap; }
  .a2z-shop-slideshow, .hero-slider, .slider, .slideshow { aspect-ratio: 16 / 9; }
  .a2z-shop-slideshow img, .hero-slider img, .slider img, .slideshow img { width: 100%; height: 100%; object-fit: cover; }
}
@media (min-width: 681px) and (max-width: 1024px) {
  .container { width: min(100% - 36px, var(--max)); }
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
  .hero-grid { gap: 28px; }
  .cart-layout, .checkout-layout, .product-layout, .shop-layout, .account-layout { gap: 20px; }
  .woocommerce table.shop_table { width: 100%; }
}
@media (max-width: 420px) {
  .site-header .header-main { grid-template-columns: 34px minmax(0, 1fr) auto !important; gap: 7px; }
  .site-header .header-main > .brand { max-width: calc(100% - 128px); font-size: clamp(18px, 5vw, 23px); }
  .site-header .header-main > .menu-toggle { width: 34px; min-width: 34px; height: 34px; }
  .site-header .header-actions { gap: 5px !important; }
  .site-header .header-actions .icon-action { min-width: 25px; }
  .grid { gap: 9px; }
  .product-card .card-body { padding: 9px 7px; }
  .card-actions { gap: 5px; }
  .card-actions button { padding: 8px 6px; font-size: 11px; }
  .footer-grid { grid-template-columns: minmax(0, 1fr); }
}
/* Off-canvas navigation uses the existing category links and mega-menu content. */
.a2z-mobile-drawer,
.a2z-mobile-backdrop { display: none; }
@media (max-width: 680px) {
  .a2z-mobile-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(35, 25, 32, .42);
    opacity: 0;
    visibility: hidden;
    transition: opacity .22s ease, visibility .22s ease;
  }
  .a2z-mobile-drawer {
    display: flex;
    position: fixed;
    z-index: 1001;
    inset: 0 auto 0 0;
    width: min(88vw, 360px);
    max-width: 100%;
    flex-direction: column;
    overflow: hidden;
    background: #fff;
    border-right: 1px solid var(--line);
    box-shadow: 14px 0 38px rgba(42, 25, 36, .16);
    transform: translateX(-102%);
    transition: transform .24s ease;
    visibility: hidden;
  }
  body.a2z-drawer-open { overflow: hidden; }
  body.a2z-drawer-open .a2z-mobile-backdrop { opacity: 1; visibility: visible; }
  body.a2z-drawer-open .a2z-mobile-drawer { transform: translateX(0); visibility: visible; }
  .a2z-mobile-drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--line);
    color: var(--pink-dark);
    font: 700 20px 'Playfair Display', Georgia, serif;
  }
  .a2z-mobile-drawer-close {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 8px;
    background: var(--pink-soft);
    color: var(--pink-dark);
    font-size: 22px;
  }
  .a2z-mobile-drawer-search { padding: 14px 16px 10px; border-bottom: 1px solid var(--line); }
  .a2z-mobile-drawer-search .search {
    display: flex !important; position: relative; overflow: hidden; z-index: 5;
    width: 100%; max-width: none; min-width: 0; height: 48px;
    align-items: center; border: 1px solid #e8dbe2; border-radius: 999px;
    background: #fff; box-shadow: 0 5px 18px #4a29370b;
  }
  .a2z-mobile-drawer-search .search:focus-within { border-color: #c77d9e; box-shadow: 0 0 0 3px #d98eae20; }
  .a2z-mobile-drawer-search .search input {
    display: block; flex: 1 1 auto; width: 100%; min-width: 0; height: 100%;
    border: 0 !important; outline: 0 !important; background: transparent !important;
    padding: 0 54px 0 20px !important; box-shadow: none !important; font-size: 13px;
  }
  .a2z-mobile-drawer-search .search .search-submit {
    position: absolute; right: 3px; top: 4px; width: 38px; height: 38px;
    display: grid; place-items: center; flex: 0 0 38px; padding: 0;
    border: 0; border-radius: 50%; background: #c77d9e; color: #fff;
  }
  .a2z-mobile-drawer-search .search .search-submit svg {
    display: block; width: 18px; height: 18px; fill: none; stroke: currentColor;
    stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
  }
  .a2z-mobile-drawer-nav { display: block; min-height: 0; overflow-y: auto; padding: 8px 16px 24px; }
  .a2z-mobile-drawer-nav .category-nav { display: block !important; height: auto !important; overflow: visible !important; }
  .a2z-mobile-drawer-nav .category-nav-utility { display: block !important; }
  .a2z-mobile-drawer-nav .category-nav-utility { display: block; }
  .a2z-mobile-drawer-nav .category-nav-item { display: block; border-bottom: 1px solid #f0e7ec; }
  .a2z-mobile-drawer-nav .category-nav-item > a { display: inline-flex; max-width: calc(100% - 44px); padding: 13px 0; color: #514750; font-size: 14px; font-weight: 600; }
  .a2z-mobile-drawer-nav .category-nav-item > a::after { content: none !important; display: none !important; }
  .a2z-mobile-drawer-nav .nav-panel-toggle,
  .a2z-mobile-drawer-nav .a2z-nav-panel-toggle { display: none !important; }
  .a2z-mobile-drawer-nav .a2z-drawer-submenu-toggle {
    float: right;
    width: 36px;
    height: 36px;
    margin-top: 7px;
    padding: 0;
    background: var(--pink-pale);
    color: var(--pink-dark);
    border: 1px solid var(--line);
    border-radius: 7px;
  }
  .a2z-mobile-drawer-nav .mega-panel,
  .a2z-mobile-drawer-nav .mega-panel[hidden] {
    display: none !important;
    position: static !important;
    width: 100% !important;
    max-height: none !important;
    padding: 0 0 12px !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
    grid-template-columns: minmax(0, 1fr) !important;
  }
  .a2z-mobile-drawer-nav .category-nav-item.is-expanded > .mega-panel:not([hidden]) { display: grid !important; }
  .a2z-mobile-drawer-nav .utility-mega-panel,
  .a2z-mobile-drawer-nav .utility-mega-panel[hidden] { display: none !important; }
  .a2z-mobile-drawer-nav .utility-mega-item.is-expanded > .utility-mega-panel:not([hidden]) { display: grid !important; }
  .a2z-mobile-drawer-nav .mega-products { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
  .a2z-mobile-drawer, .a2z-mobile-backdrop { transition: none !important; }
}

/* WooCommerce archive and native single-product markup in the PHP wrapper. */
@media (min-width: 681px) and (max-width: 1024px) {
  .a2z-woocommerce-page .a2z-woo-main .woocommerce ul.products {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
  }
  .a2z-woocommerce-page .a2z-woo-main .woocommerce ul.products li.product {
    float: none;
    width: auto;
    margin: 0;
    min-width: 0;
  }
}
@media (max-width: 680px) {
  .a2z-woocommerce-page .a2z-woo-main .woocommerce ul.products {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }
  .a2z-woocommerce-page .a2z-woo-main .woocommerce ul.products li.product {
    float: none;
    width: auto;
    margin: 0;
    min-width: 0;
  }
  .a2z-woocommerce-page.single-product .a2z-woo-main .woocommerce div.product {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 22px;
  }
  .a2z-woocommerce-page.single-product .a2z-woo-main .woocommerce div.product .images,
  .a2z-woocommerce-page.single-product .a2z-woo-main .woocommerce div.product .summary {
    float: none;
    width: 100%;
    min-width: 0;
  }
  .a2z-woocommerce-page .a2z-woo-main .woocommerce ul.products li.product a img {
    width: 100%;
    height: auto;
    object-fit: contain;
  }
}


/* Product artwork: reduce excess frame padding without cropping or distorting images. */
.product-card .product-image { padding: 5px; }
.product-card .product-image > a { display: block; min-width: 0; }
.product-card .product-image img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: auto;
  object-fit: contain;
  object-position: center;
}
.woocommerce ul.products li.product a img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
  object-position: center;
}


/* Targeted mobile corrections: keep listing filters beside the product results. */
@media (max-width: 680px) {
  .content-grid:has(> .sidebar) {
    grid-template-columns: minmax(0, 38%) minmax(0, 1fr) !important;
    align-items: start;
    column-gap: 10px;
  }
  .content-grid:has(> .sidebar) > .sidebar {
    order: 0 !important;
    min-width: 0;
    padding: 10px 7px;
    overflow-wrap: anywhere;
  }
  .content-grid:has(> .sidebar) > .sidebar h3 { font-size: 14px; line-height: 1.25; }
  .content-grid:has(> .sidebar) > .sidebar .sidebar-catalog-controls,
  .content-grid:has(> .sidebar) > .sidebar .filter-group { min-width: 0; }
  .content-grid:has(> .sidebar) > .sidebar .filter-group { padding: 9px 0; }
  .content-grid:has(> .sidebar) > .sidebar .filter-group strong { font-size: 11px; }
  .content-grid:has(> .sidebar) > .sidebar .filter-group label {
    display: flex;
    align-items: flex-start;
    gap: 4px;
    margin: 7px 0;
    font-size: 10px;
    line-height: 1.3;
    overflow-wrap: anywhere;
  }
  .content-grid:has(> .sidebar) > .sidebar .filter-group input { flex: 0 0 auto; margin: 1px 0 0; }
  .content-grid:has(> .sidebar) > .sidebar .btn,
  .content-grid:has(> .sidebar) > .sidebar button { max-width: 100%; padding: 7px 6px; font-size: 10px; line-height: 1.25; }
  .content-grid:has(> .sidebar) > :not(.sidebar) { order: 1; min-width: 0; }
  .content-grid:has(> .sidebar) > :not(.sidebar) .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .content-grid:has(> .sidebar) .toolbar { min-width: 0; margin-bottom: 10px; }
  .content-grid:has(> .sidebar) .toolbar select { min-width: 0; padding: 8px 6px; font-size: 11px; }

  /* Align the logo in the true space between the menu control and action group. */
  .site-header .header-main {
    grid-template-columns: 38px minmax(0, 1fr) auto !important;
    align-items: center !important;
  }
  .site-header .header-main > .brand {
    position: static !important;
    grid-column: 2;
    grid-row: 1;
    justify-self: center !important;
    align-self: center !important;
    transform: none !important;
    margin: 0 !important;
    line-height: 1.15;
    max-width: 100%;
  }

  /* Only the +/- control remains visible; remove inherited desktop carets. */
  .a2z-mobile-drawer-nav .category-nav-item > a::before,
  .a2z-mobile-drawer-nav .category-nav-item > a::after,
  .a2z-mobile-drawer-nav .category-nav-item > .nav-panel-toggle,
  .a2z-mobile-drawer-nav .category-nav-item > .a2z-nav-panel-toggle {
    content: none !important;
    display: none !important;
  }
  .a2z-mobile-drawer-nav .mega-panel[hidden] { display: none !important; }
  .a2z-mobile-drawer-nav .category-nav-item.is-expanded > .mega-panel:not([hidden]) {
    display: grid !important;
    position: static !important;
    visibility: visible !important;
    opacity: 1 !important;
    transform: none !important;
  }
  .a2z-mobile-drawer-nav .a2z-drawer-submenu-toggle {
    display: inline-flex !important;
    float: right;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
  }
}
@media (max-width: 420px) {
  .content-grid:has(> .sidebar) > :not(.sidebar) .grid { grid-template-columns: minmax(0, 1fr); }
  .content-grid:has(> .sidebar) { column-gap: 8px; }
  .content-grid:has(> .sidebar) > .sidebar { padding: 9px 6px; }
}


/* Final mobile-only request: hide catalog filter sidebar and give results full width. */
@media (max-width: 680px) {
  .content-grid:has(> .sidebar) {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    column-gap: 0 !important;
  }
  .content-grid:has(> .sidebar) > .sidebar {
    display: none !important;
  }
  .content-grid:has(> .sidebar) > :not(.sidebar) {
    grid-column: 1 / -1;
    min-width: 0;
    width: 100%;
  }
}
