/**
 * EazyPCB — 全站移動端排版與觸控優化
 *
 * @package EAZYPCB
 */

:root {
    /* 由 assets/js/nav-admin-bar-offset.js 依 #wpadminbar 實際可見高度更新；未登入時為 0 */
    --eazypcb-nav-offset: 0px;
}

html {
    overflow-x: clip;
}

/* 固定頂欄：不依賴 Tailwind 的 .fixed；實心白底避免透出下方滾動內容 */
nav.fixed,
nav.eazypcb-header-en {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    box-sizing: border-box !important;
    background-color: #ffffff !important;
    top: var(--eazypcb-nav-offset) !important;
}

/* 首頁 PCB/SMT 快報：小屏縱向堆疊，避免橫向裁切 */
@media (max-width: 767px) {
    #quick-quote-form,
    #smt-quote-form {
        flex-direction: column !important;
        align-items: stretch !important;
        justify-content: flex-start !important;
        flex-wrap: nowrap !important;
        gap: 1.25rem !important;
        max-width: 100%;
    }

    #quick-quote-form > div,
    #smt-quote-form > div {
        width: 100% !important;
        max-width: 100%;
    }

    #quick-quote-form .custom-dropdown,
    #smt-quote-form .custom-dropdown {
        width: 100% !important;
        max-width: 100%;
    }

    #quick-quote-form .layer-btn {
        flex: 1 1 auto;
        min-width: 0;
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    #quick-quote-form .flex.items-center.gap-1,
    #quick-quote-form .flex.items-center.gap-2 {
        flex-wrap: wrap !important;
        justify-content: flex-start !important;
        row-gap: 0.5rem;
    }

    #quick-quote-form button[type="submit"],
    #smt-quote-form #smt-quote-submit-btn {
        width: 100% !important;
        justify-content: center;
    }
}

body {
    overflow-x: clip;
    -webkit-text-size-adjust: 100%;
}

/* 文章詳情：PHP 輸出的雙欄改為單欄 */
.article-main-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    align-items: start;
}

@media (min-width: 1024px) {
    .article-main-grid {
        grid-template-columns: 1fr 240px;
        gap: 2.5rem;
    }

    .article-sidebar {
        position: sticky;
        top: 90px;
    }
}

@media (max-width: 1023px) {
    .article-sidebar {
        position: static !important;
    }
}

/* 新聞封面區：小屏降低高度、避免標題溢出 */
.eazypcb-news-article-cover {
    min-height: 260px;
    height: auto !important;
    padding-bottom: 2rem !important;
    align-items: flex-end !important;
}

@media (min-width: 768px) {
    .eazypcb-news-article-cover {
        min-height: 360px;
        height: 420px !important;
        padding-bottom: 3rem !important;
    }
}

@media (max-width: 767px) {
    .eazypcb-news-article-cover h1 {
        font-size: 1.35rem !important;
        line-height: 1.35 !important;
    }
}

/* 首頁：產品分類 — 橫向滑動，避免小屏裁字、擠成多行錯位 */
#product-categories {
    display: flex;
    flex-wrap: nowrap;
    justify-content: flex-start;
    gap: 0.5rem;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    padding-bottom: 0.5rem;
    margin-left: -0.25rem;
    margin-right: -0.25rem;
    padding-left: 0.25rem;
    padding-right: 0.25rem;
    scrollbar-width: thin;
}

@media (min-width: 768px) {
    #product-categories {
        flex-wrap: wrap;
        justify-content: center;
        overflow-x: visible;
    }
}

#product-categories .category-btn {
    flex: 0 0 auto;
    white-space: nowrap;
    scroll-snap-align: start;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
    line-height: 1.25;
    min-height: 2.75rem;
    align-items: center;
    display: inline-flex;
}

/* 首頁區塊：固定頂欄下標題不被遮擋（錨點滾動同理） */
#en-products-section,
#static-hero {
    scroll-margin-top: 5rem;
}

.eazypcb-products-section-anchor {
    scroll-margin-top: 5rem;
}

/* Core Advantages：保險單列（CDN/舊快取未帶 Tailwind 響應式時仍正確） */
@media (max-width: 767px) {
    .eazypcb-home-advantages-grid {
        grid-template-columns: 1fr !important;
    }
}

/* Hero 賣點列：仍為 flex 的語言版 — 小屏縱向堆疊（英文首頁已改為 grid，此段對 grid 無效） */
@media (max-width: 767px) {
    #static-hero .eazypcb-hero-stats {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.75rem !important;
    }

    #static-hero .eazypcb-hero-stats > div {
        border-left-width: 3px;
        padding-left: 0.75rem;
    }

    #static-hero .eazypcb-hero-ctas {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.75rem !important;
    }

    #static-hero .eazypcb-hero-ctas > button {
        width: 100%;
        min-height: 2.75rem;
    }
}

/* 英文首頁（eazypcb-home-en）：賣點為 2×2 grid，修正子元素邊框、小平板橫排按鈕 */
@media (max-width: 767px) {
    .eazypcb-home-en #static-hero .eazypcb-hero-stats {
        gap: 0.75rem 0.75rem !important;
    }

    .eazypcb-home-en #static-hero .eazypcb-hero-stats > div {
        border-left-width: 3px;
    }
}

@media (min-width: 640px) and (max-width: 767px) {
    .eazypcb-home-en #static-hero .eazypcb-hero-ctas {
        flex-direction: row !important;
        align-items: center !important;
        justify-content: center !important;
        flex-wrap: wrap !important;
    }

    .eazypcb-home-en #static-hero .eazypcb-hero-ctas > button {
        width: auto !important;
        min-width: 11rem;
    }
}

/* 公告欄：勿對 .eazypcb-announcement-inner 設 flex-wrap —— JS 會插入 4 份相同內容做無縫橫向滾動，換行會變成 4 行重複。樣式以 assets/css/custom.css 為準。 */
@media (max-width: 639px) {
    .eazypcb-announcement-bar {
        /* 小屏僅略增左內邊距，減輕左側色條與文案貼邊感，不影響跑馬燈 */
        padding-left: 14px;
    }
}

/* 首頁 Hero 內文保險（無 Tailwind JIT 時仍生效） */
@media (max-width: 639px) {
    #static-hero .max-w-2xl h1 {
        font-size: 1.65rem !important;
        line-height: 1.25 !important;
    }

    #static-hero .max-w-2xl h2 {
        font-size: 1.125rem !important;
    }
}

/* 浮動聯繫條：模板內已用 Tailwind 響應式 class；此處僅補 safe-area */
@supports (padding: max(0px)) {
    .eazypcb-floating-contact {
        bottom: max(1rem, env(safe-area-inset-bottom, 0px));
    }
}

/* 移動端導航抽屜 */
.eazypcb-mobile-nav:not(.hidden) {
    animation: eazypcb-nav-in 0.2s ease-out;
}

@keyframes eazypcb-nav-in {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.eazypcb-nav-toggle:focus-visible {
    outline: 2px solid #1a5f7a;
    outline-offset: 2px;
}

/* 表格與寬圖不撐破視口 */
.article-body img,
.article-body video,
.entry-content img {
    max-width: 100%;
    height: auto;
}

/* 報價 / 訂單等橫向表單：允許橫向捲動而非撐破版面 */
@media (max-width: 767px) {
    .overflow-x-auto,
    form.flex.flex-wrap {
        max-width: 100%;
    }
}
