/*
 * mobile-patch.css
 * 手機版優化補丁 — v0.5.7+
 * 上傳至 WordPress 後台：外觀 > 自訂 > 額外 CSS
 * 或放入主題資料夾後在 functions.php 以 wp_enqueue_style 載入
 *
 * 修正範圍：
 *   1. 全站水平溢出（overflow-x）徹底封鎖
 *   2. Header 在小螢幕高度壓縮、品牌文字縮排
 *   3. Hero banner / 首頁大圖閱讀順序與文字大小
 *   4. 篩選側欄在手機完全收合（toggle 顯示）
 *   5. 商品卡片在手機切換為橫向縮圖 + 文字並排
 *   6. 商品詳情頁單欄化與按鈕全寬
 *   7. 頁尾單欄收合
 *   8. 觸控目標最小 44px
 *   9. 選取欄位與表單元素在 iOS 不縮放（font-size ≥ 16px）
 *  10. 分頁按鈕間距
 */

/* ═══════════════════════════════════════════
   0. 全域防溢出
═══════════════════════════════════════════ */
@media (max-width: 860px) {
  html,
  body {
    overflow-x: hidden;
    max-width: 100vw;
  }

  /* 讓所有大容器不超出視窗寬度 */
  .site-shell,
  .site-main,
  .site-header,
  .site-footer,
  .container,
  .container.shop-shell--demo,
  .shop-section--demo,
  .shop-results--demo,
  .shop-sidebar--demo {
    max-width: 100vw;
    overflow-x: hidden;
  }
}


/* ═══════════════════════════════════════════
   1. Header — 手機精簡化
═══════════════════════════════════════════ */
@media (max-width: 860px) {
  .site-header-inner {
    min-height: 3.6rem;
    padding: 0 0.85rem;
    gap: 0.7rem;
  }

  .brand-lockup {
    gap: 0.55rem;
    flex-shrink: 1;
    min-width: 0;
  }

  .brand-mark {
    width: 2.1rem;
    height: 2.1rem;
    flex-shrink: 0;
  }

  .brand-copy {
    min-width: 0;
    overflow: hidden;
  }

  .brand-title {
    font-size: 0.9rem;
    letter-spacing: 0.08em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .brand-subtitle {
    display: none;
  }

  /* 漢堡按鈕觸控區域 */
  .mobile-nav-toggle {
    width: 2.75rem;
    height: 2.75rem;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
  }

  /* 手機選單面板全寬 */
  .mobile-nav-panel {
    width: 100%;
    padding: 1rem 0.85rem 1.2rem;
  }

  .mobile-nav-content {
    display: grid;
    gap: 0.85rem;
    text-align: center;
  }

  .mobile-menu {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.1rem;
    width: 100%;
  }

  .mobile-menu li {
    width: 100%;
    display: flex;
    justify-content: center;
  }

  .mobile-menu li a {
    display: block !important;
    padding: 0.72rem 0.6rem;
    font-size: 0.95rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    text-align: center !important;
    width: 100%;
  }

  .mobile-menu li a {
    display: block;
    padding: 0.72rem 0.6rem;
    font-size: 0.95rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    text-align: center;
  }

  /* 手機選單預約按鈕 */
  .mobile-booking {
    width: 100%;
    justify-content: center;
    margin-top: 0.4rem;
  }
}


/* ═══════════════════════════════════════════
   2. Hero Banner — 手機閱讀節奏
═══════════════════════════════════════════ */
@media (max-width: 860px) {
  .hero-shell {
    border-radius: 1rem;
    overflow: hidden;
  }

  /* 圖片不設最低高度，依長寬比自然縮放 */
  .hero-slide-media,
  .hero-media {
    min-height: auto !important;
  }

  .hero-slide-media img,
  .hero-media img {
    min-height: auto !important;
    width: 100%;
    object-fit: cover;
  }

  .hero-copy {
    padding: 1.2rem 0.95rem 1rem;
    gap: 0.7rem;
  }

  .hero-copy h1 {
    font-size: clamp(1.55rem, 7.5vw, 2.2rem);
    line-height: 1.05;
    text-wrap: balance;
  }

  .hero-copy p {
    font-size: 0.9rem;
    line-height: 1.7;
    max-width: none;
  }

  .hero-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
  }

  .hero-actions .button,
  .hero-actions .button-booking,
  .hero-actions .button-booking--secondary,
  .hero-actions .button-secondary {
    width: 100%;
    justify-content: center;
    min-height: 2.9rem;
  }

  /* Hero 導航點縮小 */
  .hero-navigation {
    padding: 0.75rem 0.9rem 0.9rem;
    gap: 0.6rem;
  }

  .hero-dots {
    gap: 0.45rem;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .hero-dots::-webkit-scrollbar {
    display: none;
  }

  .hero-dot {
    flex: 0 0 auto;
    padding: 0.52rem 0.65rem;
    border-radius: 999px;
  }

  .hero-dot-title {
    display: none;
  }

  .hero-arrow-group {
    display: none;
  }
}


/* ═══════════════════════════════════════════
   3. 首頁各區塊 — 單欄化 & 間距壓縮
═══════════════════════════════════════════ */
@media (max-width: 860px) {
  .section-space {
    padding: 0.6rem 0;
  }

  /* 首頁精選卡片 2 欄 */
  .home-feature-grid,
  .product-grid--home {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 0.85rem;
  }

  .home-feature-card__header,
  .home-feature-card__footer {
    flex-direction: column;
    align-items: flex-start;
  }

  /* 地區導覽 2 欄 */
  .region-grid,
  .area-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  /* 統計 / 數字卡 2 欄 */
  .stats-grid,
  .metrics-grid--home {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  /* 預約流程 單欄 */
  .booking-steps-grid,
  .steps-grid {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 480px) {
  .home-feature-grid,
  .product-grid--home {
    grid-template-columns: 1fr !important;
  }

  .region-grid,
  .area-grid,
  .stats-grid,
  .metrics-grid--home {
    grid-template-columns: 1fr !important;
  }
}


/* ═══════════════════════════════════════════
   4. 菜單頁 (Shop) — 篩選 toggle & 結果區
═══════════════════════════════════════════ */
@media (max-width: 860px) {
  /* 整體 shop 容器單欄 */
  .container.shop-shell--demo {
    grid-template-columns: 1fr !important;
    width: min(100%, calc(100vw - 1rem)) !important;
    gap: 0.8rem;
  }

  /* 篩選側欄：手機預設收合，由 JS toggle 控制 */
  .shop-sidebar--demo {
    position: static;
  }

  /* 顯示 toggle 按鈕 */
  .shop-mobile-filter-toggle {
    display: inline-flex !important;
  }

  /* 篩選面板收合時不佔空間 */
  .shop-mobile-filter-panel[hidden] {
    display: none !important;
  }

  .shop-mobile-filter-panel {
    margin-top: 0.85rem;
  }

  /* 篩選欄位全寬 */
  .filter-form {
    gap: 0.65rem;
  }

  .filter-form label {
    width: 100%;
  }

  .filter-form select,
  .filter-form input[type="search"],
  .filter-form input[type="text"] {
    width: 100%;
    /* iOS 防縮放：font-size 需 ≥ 16px */
    font-size: 1rem !important;
    min-height: 2.85rem;
  }

  /* 結果列表 toolbar 全寬 */
  .shop-results-head {
    padding: 0.9rem;
    gap: 0.75rem;
    border-radius: 1.1rem;
  }

  .shop-results-head h2 {
    font-size: clamp(1.1rem, 5.5vw, 1.5rem);
  }

  .shop-results-toolbar {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    width: 100%;
    gap: 0.55rem;
  }

  .shop-results-toolbar__group,
  .shop-results-toolbar__group--per-page {
    width: 100%;
    min-width: 0;
  }

  .shop-results-toolbar select {
    width: 100%;
    font-size: 1rem !important;
    min-height: 2.85rem;
  }

  /* 商品格線 → 單欄 */
  .product-grid--menu-archive,
  .product-grid--menu-archive.two-cols,
  .product-grid--menu-archive.three-cols {
    grid-template-columns: 1fr !important;
    gap: 0.85rem;
  }

  /* 商品卡片：還原原始版面（圖片上、文字下） */
  .product-card--archive {
    display: block !important;
    padding: 0.85rem !important;
    border-radius: 1.1rem;
  }

  .product-card--archive .product-media {
    aspect-ratio: 3 / 4;
    min-height: auto !important;
    border-radius: 0.85rem;
    width: 100%;
  }

  .product-card--archive .product-card-body {
    display: grid;
    gap: 0.65rem;
    margin-top: 0.65rem;
  }

  .product-card--archive .product-card-title--menu {
    font-size: 1rem !important;
    line-height: 1.3;
  }

  .metrics-grid--archive {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 0.45rem !important;
  }

  .product-card--archive .metric-card,
  .product-card--archive .product-info-strip__item {
    padding: 0.55rem 0.6rem;
    border-radius: 0.75rem;
  }

  .product-card--archive .product-card-actions--archive {
    margin-top: 0.4rem;
    padding-top: 0.4rem;
    border-top: 1px solid rgba(255, 255, 255, 0.07);
    justify-content: flex-end;
  }

  .product-card--archive .product-card-actions--archive .text-link {
    font-size: 0.76rem !important;
    letter-spacing: 0.08em;
  }
}


/* ═══════════════════════════════════════════
   5. 商品詳情頁 — 單欄 + 可讀性
═══════════════════════════════════════════ */
@media (max-width: 860px) {
  .single-product-section--editorial {
    padding-top: 0.75rem;
  }

  /* 單欄佈局 */
  .single-product-section--editorial .product-detail-layout--editorial,
  .product-story-grid,
  .product-story-grid--detail {
    grid-template-columns: 1fr !important;
    gap: 0.9rem;
  }

  /* 主圖 */
  .product-stage-card--hero {
    padding: 0.75rem;
    border-radius: 1.1rem;
  }

  .product-media--editorial-stage {
    aspect-ratio: 4 / 5;
    min-height: auto !important;
  }

  /* 縮圖列 4 欄 */
  .gallery-thumbs--editorial {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: 0.45rem;
    margin-top: 0.6rem;
  }

  /* 右側摘要卡 */
  .product-summary-card--editorial {
    position: static !important;
    padding: 0.95rem;
    border-radius: 1.1rem;
  }

  .product-summary-top--name-price {
    gap: 0.4rem;
    margin-bottom: 0.85rem;
  }

  .product-summary-top--name-price .single-product-title {
    font-size: clamp(1.35rem, 6vw, 1.85rem);
  }

  /* 身分識別 & 指標 2欄 */
  .summary-identity-grid--editorial,
  .summary-metrics-grid--editorial {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 0.6rem;
  }

  /* 規格表改為 block 顯示 */
  .summary-spec-table--editorial tbody,
  .summary-spec-table--editorial tr {
    display: block;
    width: 100%;
  }

  .summary-spec-table--editorial tr {
    padding: 0.65rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  }

  .summary-spec-table--editorial tr:last-child {
    border-bottom: 0;
  }

  .summary-spec-table--editorial th,
  .summary-spec-table--editorial td {
    display: block;
    width: 100%;
    padding: 0;
    text-align: left !important;
  }

  .summary-spec-table--editorial td {
    margin-top: 0.22rem;
  }

  /* 行動按鈕全寬 */
  .single-actions--editorial {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.6rem;
    margin-top: 1rem;
  }

  .single-actions--editorial .button,
  .single-actions--editorial .button-booking,
  .single-actions--editorial .button-link {
    width: 100% !important;
    justify-content: center !important;
    min-height: 3rem;
  }

  /* 故事卡 */
  .product-story-card--overview,
  .product-story-card--services {
    padding: 0.9rem;
    border-radius: 1.1rem;
  }
}

@media (max-width: 560px) {
  /* 縮圖 4 欄（更小螢幕）*/
  .gallery-thumbs--editorial {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: 0.35rem !important;
  }

  /* 身分識別 1 欄 */
  .summary-identity-grid--editorial,
  .summary-metrics-grid--editorial,
  .product-story-grid--detail {
    grid-template-columns: 1fr !important;
  }
}


/* ═══════════════════════════════════════════
   6. 頁尾 — 單欄折疊
═══════════════════════════════════════════ */
@media (max-width: 860px) {
  .site-footer {
    padding: 2rem 0 1.2rem;
  }

  .footer-grid,
  .footer-columns {
    grid-template-columns: 1fr !important;
    gap: 1.4rem;
  }

  .footer-actions {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.65rem;
  }

  .footer-bottom {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.45rem;
    margin-top: 1.2rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 0.82rem;
  }
}


/* ═══════════════════════════════════════════
   7. 分頁 — 觸控友善
═══════════════════════════════════════════ */
@media (max-width: 860px) {
  .pagination-wrap .nav-links {
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
  }

  .pagination-wrap .page-numbers {
    min-width: 2.65rem;
    min-height: 2.65rem;
    font-size: 0.9rem;
  }
}


/* ═══════════════════════════════════════════
   8. 全域觸控目標 & 表單 iOS 防縮放
═══════════════════════════════════════════ */
@media (max-width: 860px) {
  /* 所有互動元素至少 44px */
  a,
  button,
  .toolbar-chip,
  .product-chip,
  .tag-pill,
  .page-numbers,
  .text-link {
    min-height: 16px;
  }

  /* iOS Safari：font-size < 16px 會自動縮放頁面，強制 >= 16px */
  select,
  input,
  textarea {
    font-size: 1rem !important;
  }

  /* 避免 iOS 圓角按鈕被瀏覽器覆寫 */
  input[type="search"],
  input[type="text"] {
    -webkit-appearance: none;
    appearance: none;
    border-radius: 14px;
  }
}


/* ═══════════════════════════════════════════
   9. 部落格列表 & 單篇文章
═══════════════════════════════════════════ */
@media (max-width: 860px) {
  .post-card-grid,
  .blog-grid {
    grid-template-columns: 1fr !important;
    gap: 0.75rem !important;
    align-items: start !important;
  }

  .content-with-sidebar {
    grid-template-columns: 1fr !important;
  }

  .sidebar {
    position: static !important;
    top: auto;
  }

  .single-post-card,
  .page-panel {
    padding: 1rem;
  }

  .post-thumb,
  .post-thumb-placeholder {
    min-height: 11rem;
  }

  .post-meta-row,
  .post-meta-row--single {
    flex-wrap: nowrap !important;
    white-space: nowrap !important;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.7rem !important;
    display: flex;
    flex-direction: row;
    letter-spacing: 0.06em !important;
  }
  /* 前往文章頁靠右 */
  .post-card-copy {
    display: flex;
    flex-direction: column;
  }
  .post-card-copy .text-link {
    align-self: flex-end;
    margin-top: auto;
  }
}


/* ═══════════════════════════════════════════
   10. 細節修正：shop intro panel
═══════════════════════════════════════════ */
@media (max-width: 860px) {
  .shop-intro-panel {
    grid-template-columns: 1fr !important;
    padding: 1rem 1.1rem;
    gap: 1rem;
    margin-bottom: 1rem;
  }

  .shop-intro-panel__stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.7rem;
  }

  .shop-intro-panel__stats strong {
    font-size: 1.5rem;
  }

  .shop-filter-bar {
    padding: 0.9rem 1rem;
    margin-bottom: 0.9rem;
  }
}

@media (max-width: 480px) {
  .shop-intro-panel__stats {
    grid-template-columns: 1fr !important;
  }
}


/* ═══════════════════════════════════════════
   11. 篩選欄位兩兩並排（手機版）
   縣市+區域 同一行，國籍+類型 同一行
═══════════════════════════════════════════ */


/* 手機版同樣保持 2欄（這是這個功能的核心目的） */
@media (max-width: 860px) {
}




/* ═══════════════════════════════════════════
   12. 修正：覆寫 theme.css 860px 裡強制 label width:100% 的規則
       讓 filter-row-pair 的 2欄 grid 真正生效
═══════════════════════════════════════════ */
@media (max-width: 860px) {
  .filter-form .filter-row-pair {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 0.55rem;
    width: 100%;
  }

  /* pair 內的 label 寬度由 grid 控制，不能再 width:100% 撐爆 */
  .filter-form .filter-row-pair label {
    width: auto !important;
    min-width: 0 !important;
  }

  .filter-form .filter-row-pair select {
    width: 100%;
    min-width: 0;
    font-size: 1rem !important;
    min-height: 2.85rem;
  }
}

@media (max-width: 359px) {
  .filter-form .filter-row-pair {
    grid-template-columns: 1fr !important;
  }
}


/* ═══════════════════════════════════════════
   國旗大小調整
═══════════════════════════════════════════ */
@media (max-width: 860px) {
  /* 首頁本週精選名單 縮小 30% */
  .home-feature-card .flag-badge {
    width: 2.1rem !important;
    height: 2.1rem !important;
  }
  /* /shop 商品卡片 縮小 20% */
  .product-card--archive .flag-badge {
    width: 2.24rem !important;
    height: 2.24rem !important;
    font-size: 1.6rem !important;
  }
}


/* ═══════════════════════════════════════════
   首頁介紹區 手機版縮小
═══════════════════════════════════════════ */
@media (max-width: 860px) {
  .stat-card {
    padding: 0.75rem !important;
  }
  .stat-card h3 {
    font-size: 0.85rem !important;
    margin-bottom: 0.25rem !important;
  }
  .stat-card p {
    font-size: 0.72rem !important;
    line-height: 1.4 !important;
  }
  .info-grid.two-cols {
    gap: 0.5rem !important;
  }
  .copy-block h2 {
    font-size: 1.4rem !important;
  }
  .copy-block p {
    font-size: 0.82rem !important;
  }
}


/* shop results head 手機版上下間距縮小 */
@media (max-width: 860px) {
  .shop-results-head {
    padding: 6px 16px !important;
    margin-bottom: 12px !important;
  }
}


/* 地區導覽：手機版兩欄緊湊 */
@media (max-width: 860px) {
  .category-grid.three-cols {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 0.6rem !important;
  }
  .category-card {
    padding: 0.8rem !important;
  }
  .category-card .eyebrow-index {
    font-size: 0.6rem !important;
    margin: 0 0 0.2rem !important;
  }
  .category-card h3 {
    font-size: 0.9rem !important;
    margin: 0 0 0.25rem !important;
    line-height: 1.2 !important;
  }
  .category-card p {
    font-size: 0.7rem !important;
    line-height: 1.4 !important;
    margin: 0 0 0.4rem !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
  }
  .category-card .card-footer-row {
    font-size: 0.7rem !important;
    margin-top: 0.3rem !important;
    gap: 0.3rem !important;
  }
}
