/* 嘉豐電腦｜全站流動式響應設計
   使用方式：貼在 WordPress.com → 外觀 → 自訂 → Additional CSS 的現有內容下方。
   保留原有 .stock.available-on-backorder 與 ul.products 商品列表規則。
*/
*, *::before, *::after { box-sizing: border-box; }
html { overflow-x: clip; }
body { overflow-x: hidden; }
img, svg, video, iframe { max-width: 100%; }
img { height: auto; }
.hp-container, article, .hp-content, .entry-content, .woocommerce, .site-main { min-width: 0; max-width: 100%; }
.hp-content a, .entry-content a, article a { overflow-wrap: anywhere; }

.hp-card, .wp-block-image, .woocommerce-product-gallery, .woocommerce div.product div.images {
  max-width: 100%;
  overflow: hidden;
}
.woocommerce div.product div.images img,
.woocommerce-product-gallery__image img,
.woocommerce ul.products li.product img,
.wp-block-image img {
  width: 100%;
  height: auto;
  display: block;
}

@media (max-width: 820px) {
  .hp-container {
    width: 100%;
    max-width: 100%;
    padding-left: 16px;
    padding-right: 16px;
  }
  .hp-header-inner {
    height: auto !important;
    min-height: 64px;
    padding-top: 8px;
    padding-bottom: 8px;
  }
  .hp-logo {
    flex: 1 1 auto;
    min-width: 0;
    max-width: calc(100% - 82px);
    gap: 8px;
    font-size: clamp(1rem, 3.8vw, 1.15rem);
    line-height: 1.15;
  }
  .hp-logo img {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
  }
  .hp-logo > span {
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .hp-logo .hp-logo-sub {
    max-width: 100%;
    font-size: clamp(0.56rem, 2.4vw, 0.7rem);
    line-height: 1.2;
    letter-spacing: 0.06em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .hp-menu-toggle {
    display: block !important;
    flex: 0 0 auto;
  }
  .hp-main-nav {
    display: none !important;
    top: 100%;
    left: 0;
    right: 0;
    padding: 12px 16px;
  }
  .hp-main-nav.open { display: block !important; }
  .hp-main-nav ul {
    flex-direction: column;
    gap: 4px;
    align-items: stretch;
  }
  .hp-main-nav a {
    display: block;
    padding: 10px 0;
  }
  .hp-cart-icon { flex: 0 0 auto; }

  body h1, body article > h1, body .woocommerce h1 {
    font-size: clamp(1.75rem, 4.2vw, 2.35rem);
    line-height: 1.22;
    overflow-wrap: anywhere;
  }
  body h2, body article h2, body .hp-content h2, body .entry-content h2 {
    font-size: clamp(1.35rem, 3.3vw, 1.85rem);
    line-height: 1.38;
    overflow-wrap: anywhere;
  }
  body h3, body article h3, body .hp-content h3, body .entry-content h3 {
    font-size: clamp(1.12rem, 2.7vw, 1.45rem);
    line-height: 1.4;
    overflow-wrap: anywhere;
  }
  .hp-content, .entry-content, article { line-height: 1.8; }
  .hp-content h2, .entry-content h2, article h2 { margin-top: 1.45em; margin-bottom: 0.65em; }
  .hp-content p, .entry-content p, article p { margin-top: 0.85em; margin-bottom: 0.85em; }

  .hp-grid-2, .hp-grid-3, .hp-grid-4 {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  }
  .wp-block-columns {
    flex-wrap: wrap !important;
    gap: clamp(16px, 4vw, 28px);
  }
  .wp-block-column {
    flex-basis: 100% !important;
    min-width: 0;
  }
  .hp-btn-row, .wp-block-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
  }

  article img, .hp-content img, .entry-content img,
  .woocommerce div.product div.images img,
  .woocommerce-product-gallery__image img {
    max-width: 100%;
    height: auto;
  }
  /* WooCommerce 的 zoomImg 是 1000px 放大層；觸控裝置沒有 hover，直接隱藏避免畫面被撐開。 */
  .zoomImg { display: none !important; }

  article table, .hp-content table, .entry-content table {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    white-space: normal;
    font-size: clamp(0.82rem, 2.4vw, 0.95rem);
    line-height: 1.55;
  }
  article th, article td, .hp-content th, .hp-content td, .entry-content th, .entry-content td {
    min-width: 120px;
    padding: 8px;
  }

  .woocommerce div.product div.images,
  .woocommerce div.product div.summary {
    width: 100% !important;
    float: none !important;
    clear: both;
  }
  .woocommerce div.product div.images { margin-bottom: 24px; }
  .woocommerce ul.products {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
  }
  .woocommerce ul.products::before,
  .woocommerce ul.products::after { display: none; }
}

@media (max-width: 480px) {
  .hp-container { padding-left: 14px; padding-right: 14px; }
  .hp-header-inner { min-height: 60px; }
  .hp-logo { max-width: calc(100% - 74px); }
  .hp-logo img { width: 36px; height: 36px; flex-basis: 36px; }
  .hp-content, .entry-content, article { line-height: 1.75; }
  .wp-block-buttons .wp-block-button,
  .wp-block-buttons .wp-block-button__link { width: 100%; }
  .woocommerce ul.products { grid-template-columns: 1fr; }
}
