/* =============================================================================
   鑫易達企業網站 · 雅致中式美化（P0 純 CSS）
   -----------------------------------------------------------------------------
   依據：xinyida88_beautify/ui_plan.md v1.0（方向 A 雅致中式，P0 範圍）
   載入策略：本檔由 child theme functions.php 以最高順位 enqueue（priority 999，
            晚於 parent style / child style.css / style-responsive.css(12)），
            同 specificity 下本檔後載入即可覆寫；唯一例外是 <head> 尾端以
            wp_head:13 輸出的內聯 <style>（slider 高度），該處一律以
            !important + 相同/更高 specificity 取勝。
   注意：RTL 與舊瀏覽器（< Safari 15.4 等）不在本階段支援範圍。
   ========================================================================== */

/* =============================================================================
   §2.1 Design Tokens（:root）
   ========================================================================== */
:root {
    /* 色彩（值依 ui_plan §2.1 原值，未改） */
    --xyd-paper:          #F8F4EA;   /* 宣紙米白：頁面底色 */
    --xyd-paper-deep:     #F1EADA;   /* 卡片隔層 / 服務區塊底 */
    --xyd-card:           #FFFFFF;   /* 卡片底（三大服務） */
    --xyd-ink:            #2B241C;   /* 墨黑偏暖：主文字 / 標題 */
    --xyd-text:           #4A4238;   /* 次級說明文字 */
    --xyd-cinnabar:       #A63A2B;   /* 硃砂：主強調色（取代 #D33D33） */
    --xyd-cinnabar-deep:  #8C3023;   /* 硃砂深：hover / active */
    --xyd-gold:           #B08D57;   /* 描金：飾線 / 分隔 / 年份徽記（僅裝飾） */
    --xyd-line:           #E3DAC8;   /* 細邊框 / 分隔線 */
    --xyd-footer-bg:      #26221C;   /* footer 墨底 */
    --xyd-footer-text:    #B9AC8F;   /* footer 古銅金文字 */

    /* 字體（§2.2） */
    --xyd-font-serif: "Noto Serif SC", "Source Han Serif SC", "STSong", "SimSun", serif;
    --xyd-font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC",
                     "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;

    /* 陰影 / 動態（§2.4） */
    --xyd-shadow-card: 0 1px 2px rgba(43, 36, 28, .05), 0 6px 18px rgba(43, 36, 28, .06);
    --xyd-shadow-hover: 0 12px 28px rgba(43, 36, 28, .12);
    --xyd-transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease;
}

/* =============================================================================
   全站字型 / 底色（§2.2 / §2.1）
   -----------------------------------------------------------------------------
   覆寫：body 預設（parent alante/style.css）無中文字型棧；
         body.custom-background 內聯 style（wp_head:10 背景白.png 底紋）。
   ========================================================================== */
body {
    font-family: var(--xyd-font-sans);
    color: var(--xyd-text);
    background-color: var(--xyd-paper);
}

/* 蓋掉 背景白.png 底紋：內聯 custom-background-css 在 <head> 尾端輸出，
   同 specificity 必敗，故加 !important */
body.custom-background {
    background-color: var(--xyd-paper) !important;
    background-image: none !important;
}

/* 標題全面換成思源宋體系（覆寫舊 Latin 主題字型） */
h1, h2, h3, h4, h5, h6,
.page-title,
.services-builder .iconmain h3,
.wp-block-heading {
    font-family: var(--xyd-font-serif);
    color: var(--xyd-ink);
}

/* =============================================================================
   §3.1 導覽列（#header）
   -----------------------------------------------------------------------------
   覆寫：#header 舊陰影（灰糊）、nav 14px #444 / hover 純紅字、下拉白底
         純紅 hover；隱藏空的 #pre-header；隱藏 .custom-header（P1-1 拍板：留 logo）
   ========================================================================== */

/* 隱藏空的 #pre-header */
#pre-header {
    display: none;
}

/* P1-1 品牌圖決策（老闆拍板）：留 logo、隱藏頁眉橫幅（僅視覺隱藏，不動 DOM） */
.custom-header {
    display: none;
}

/* Header：細線 + 輕投影取代灰糊陰影（含 sticky 狀態） */
#header,
.is-sticky #header,
body.custom-background .is-sticky #header {
    box-shadow: 0 1px 0 var(--xyd-line), 0 8px 24px rgba(43, 36, 28, .06);
}

/* 主選單連結：字級 15px、字距 .06em、墨色（覆寫舊 14px #444） */
#header .header-links .menu > li > a {
    font-size: 15px;        /* 主題 html{font-size:62.5%}（1rem=10px），故用設計 px，下同 */
    letter-spacing: .06em;
    color: var(--xyd-ink);
    padding: 0 18px;
}

/* hover / current：墨字 + 2px 硃砂底線（text-decoration 繪製，無位移風險） */
#header .header-links .menu > li.current_page_item > a,
#header .header-links .menu > li.current-menu-ancestor > a,
#header .header-links .menu > li.menu-hover > a,
#header .header-links .menu > li > a:hover {
    box-shadow: none;
    color: var(--xyd-ink);
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-decoration-color: var(--xyd-cinnabar);
    text-underline-offset: 6px;
    background-color: transparent;
}

/* 下拉子選單：米白底、細框、輕投影；子項 hover 硃砂 */
#header .header-links .sub-menu {
    background-color: #FFFDF6;
    border: 1px solid var(--xyd-line);
    box-shadow: 0 10px 24px rgba(43, 36, 28, .10);
    border-radius: 0;
    padding: 4px 0;
}
#header .header-links .sub-menu .sub-menu {
    border-left: none;
    margin-top: 1px;
}
#header .header-links .sub-menu a {
    color: var(--xyd-text);
    border-bottom: 1px solid var(--xyd-line);
}
#header .header-links .sub-menu a:hover,
#header .header-links .sub-menu .current-menu-item a {
    color: var(--xyd-cinnabar);
}

/* 桌面 logo 顯示上限 56px（舊 54px；實體 1.9MB PNG 換圖屬 P1 媒體工作） */
#logo img {
    max-height: 56px;
    width: auto;
}

/* =============================================================================
   §3.3 三大服務卡片（#section-home）
   -----------------------------------------------------------------------------
   覆寫：child .services-builder.style1（灰底 #f4f4f4 / 無框 / radius 0）、
         .iconimage img 直貼無框、h3 15px、iconurl a 白底灰框按鈕。
   注意（依派單）：本階段「不加 aspect-ratio 裁切」，圖僅加細線內框；
                 三卡等高改由 #section-home-inner 以 flex 排列達成。
   ========================================================================== */
#section-home {
    padding: 64px 20px 8px;
}
#section-home-inner {
    max-width: 1140px;
    margin: 0 auto;
    display: flex;          /* 取代 float：三卡真正等高 */
    flex-wrap: wrap;
    align-items: stretch;
}
#section-home article.one_third {
    display: flex;
    flex-direction: column;
    /* float 由 flex item 取代；保留既有寬度語意由子規則控制 */
}
#section-home .clearboth {
    display: none;          /* flex 容器內不再需要 float clear */
}

/* 卡片本體：白卡 / 細框 / 6px 圓角 / 雙層輕陰影 */
#section-home .services-builder.style1 {
    background-color: var(--xyd-card);
    border: 1px solid var(--xyd-line);
    border-radius: 6px;
    box-shadow: var(--xyd-shadow-card);
    height: 100%;
    overflow: hidden;
    transition: var(--xyd-transition);
    display: flex;
    flex-direction: column;
}

/* 圖：裱框意象——四周留 6px 紙底，圖內縮 7px 細線框；暫不裁切 */
#section-home .iconimage {
    background-color: transparent;
    padding: 6px 6px 0;
}
#section-home .iconimage a {
    display: block;
    line-height: 0;
}
#section-home .iconimage img {
    width: 100%;
    height: auto;
    outline: 1px solid var(--xyd-line);
    outline-offset: -7px;   /* 中式內框 */
    transition: transform .4s ease;
}

/* 文字區：flex 撐滿剩餘高度，CTA 置底 */
#section-home .iconmain {
    padding: 24px 26px 28px;
    display: flex;
    flex-direction: column;
    flex: 1;
}
#section-home .iconmain h3 {
    font-size: 20px;        /* §2.3：服務卡標題 desktop＝1.25rem×16（見 CHANGES 內註：§3.3 內文範例為 1.375，此處以 §2.3 階梯為準） */
    font-weight: 700;
    letter-spacing: .1em;
    color: var(--xyd-ink);
    margin: 0 0 14px;
}
/* 標題前硃砂飾線（偽元素，非文案） */
#section-home .iconmain h3::before {
    content: "";
    display: inline-block;
    width: 26px;
    height: 2px;
    background-color: var(--xyd-cinnabar);
    vertical-align: middle;
    margin-right: 10px;
}
#section-home .iconmain p {
    color: var(--xyd-text);
    font-size: 15.5px;      /* 服務卡內文＝.96875rem×16 */
    line-height: 1.9;
}

/* CTA 置底：與卡高參差脫鉤 */
#section-home .iconmain p.iconurl {
    margin-top: auto;
    padding-top: 16px;
    margin-bottom: 0;
}

/* 按鈕本地化樣式：硃砂底 → hover 深硃砂＋細金邊
   （「Read More」文案未動，屬 P1-5 老闆確認後才替換） */
#section-home .services-builder.style1 .iconmain .iconurl a {
    padding: 12px 28px;
    min-height: 44px;                       /* §3.6 觸控目標 ≥44px */
    display: inline-block;
    margin-top: 0;
    color: #fff;
    border: 1px solid var(--xyd-cinnabar);
    background-color: var(--xyd-cinnabar);
    border-radius: 3px;
    font-weight: 600;
    letter-spacing: .12em;
    line-height: 1.4;
    box-sizing: border-box;
    touch-action: manipulation;
}
#section-home .services-builder.style1 .iconmain .iconurl a:hover {
    opacity: 1;
    background-color: var(--xyd-cinnabar-deep);
    border-color: var(--xyd-gold);
    color: #fff;
}

/* hover 微浮起 + 圖微縮放（僅限可 hover 裝置，防觸控殘留縮放） */
@media (hover: hover) {
    #section-home .services-builder.style1:hover {
        transform: translateY(-4px);
        box-shadow: var(--xyd-shadow-hover);
        border-color: var(--xyd-gold);
    }
    #section-home .services-builder.style1:hover .iconimage img {
        transform: scale(1.03);
    }
}

/* =============================================================================
   §3.4 內頁內容排版（公司简介 / 公司产品 / 古典家具）
   -----------------------------------------------------------------------------
   覆寫：#content 舊 padding 25px 10px、has-small-font-size 13px、
         page-id-60 垂直堆疊大圖、古典家具 is-cropped 1:1 照片牆。
   ========================================================================== */

/* 內頁節奏 + 行長：限非首頁的 page-template-default（避免動到首頁 #content） */
body.page-template-default:not(.home) #content {
    padding: 56px 24px 72px;
}
body.page-template-default:not(.home) #main-core {
    max-width: 860px;
    margin: 0 auto;
}

/* 13px 小字 → 15.5px 等效（覆寫 wp-block 內聯 .has-small-font-size !important，
   故本規則亦加 !important 且 specificity 更高：#content id + 前綴 class） */
.page-template-default:not(.home) #content .has-small-font-size {
    font-size: 15.5px !important;   /* 13px 小字→15.5px 等效 */
    line-height: 1.9 !important;
    color: var(--xyd-ink) !important;
}

/* --- 公司产品（page-id-60）：分類名置中章節 + 裱框大圖 --- */
.page-id-60 #content .has-medium-font-size {
    font-family: var(--xyd-font-serif);
    font-size: 24px !important;     /* page-60 章節標題＝1.5rem×16；覆寫 wp-block 內聯 !important */
    letter-spacing: .15em;
    text-align: center;
    color: var(--xyd-ink) !important;
    line-height: 1.6;
}
.page-id-60 #content .wp-block-image {
    width: min(720px, 100%);
    margin: 8px auto 40px;
    text-align: center;
}
.page-id-60 #content .wp-block-image img {
    border: 1px solid var(--xyd-line);
    padding: 10px;
    background-color: #FFFDF6;
    height: auto;
    max-width: 100%;
}

/* --- 古典家具（page-id-13）：wp-block-gallery 照片牆 4:3 grid 3/2/1 欄 ---
   覆寫核心 .is-cropped 預設 1:1（對立式藏品圖裁太多），改 4:3 安全比；
   規則以 .page-id-13 限定頁面，避免影響其他頁面的 gallery */
.page-id-13 .wp-block-gallery.is-cropped {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
}
.page-id-13 .wp-block-gallery.is-cropped .wp-block-image {
    width: 100% !important;
    margin: 0 !important;
}
.page-id-13 .wp-block-gallery.is-cropped .wp-block-image img {
    width: 100%;
    height: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(43, 36, 28, .08);
    transition: transform .4s ease;
}
@media (hover: hover) {
    .page-id-13 .wp-block-gallery.is-cropped .wp-block-image:hover img {
        transform: scale(1.04);
    }
}
@media (max-width: 768px) {
    .page-id-13 .wp-block-gallery.is-cropped {
        grid-template-columns: repeat(2, 1fr);
    }
}
@media (max-width: 480px) {
    .page-id-13 .wp-block-gallery.is-cropped {
        grid-template-columns: 1fr;
    }
}

/* =============================================================================
   §3.5 Footer 配色（#sub-footer）——僅配色，不改內容文字
   -----------------------------------------------------------------------------
   覆寫：child #sub-footer（#f4f4f4 底 / 1px #e7e7e7 頂線）、.copyright #aaa。
   注意：版權列文字（Think Up / WordPress credit）本階段不動（P1-5 老闆確認後
         由 footer.php child 覆寫）。
   ========================================================================== */
#sub-footer {
    background-color: var(--xyd-footer-bg);
    border-top: 3px solid var(--xyd-cinnabar);   /* 硃砂細頂線＝全站收尾記號 */
    color: var(--xyd-footer-text);
}
#sub-footer .copyright {
    color: var(--xyd-footer-text);
    font-size: 13px;        /* 輔助/版權＝.8125rem×16 */
    letter-spacing: .08em;
}
#sub-footer-core a {
    color: var(--xyd-footer-text);
    text-decoration: none;
}
#sub-footer-core a:hover {
    color: var(--xyd-gold);
}

/* =============================================================================
   §3.6 行動版（≤960 漢堡 / 輪播高度 / ≤640 卡片單欄）
   -----------------------------------------------------------------------------
   覆寫：responsive.css（enqueue priority 12）內 #header-responsive 深底 #292929、
         li a 灰字 #AAA、1px dotted #505050 分隔線。
   ========================================================================== */
@media (max-width: 960px) {

    /* 漢堡選單列：宣紙底 + 細頂線 */
    #header-responsive {
        background-color: var(--xyd-paper);
        border-top: 1px solid var(--xyd-line);
        padding: 0 20px;
    }
    #header-responsive li {
        border: none;
        background: none;
        box-shadow: none;
    }
    /* 連結：墨字、大觸控目標、細分隔線 */
    #header-responsive li a {
        color: var(--xyd-ink);
        border-bottom: 1px solid var(--xyd-line);
        padding: 14px 20px;
        min-height: 48px;               /* 觸控目標 ≥44px */
        display: flex;
        align-items: center;
        font-size: 16px;    /* 漢堡連結＝1rem×16 */
        line-height: 1.4;
        touch-action: manipulation;
    }
    /* hover / 展開 / 當前頁：硃砂 */
    #header-responsive li a:hover,
    #header-responsive li.current-menu-item > a,
    #header-responsive li.current_page_item > a,
    #header-responsive .menu-item-has-children.sub-menu-show > a {
        color: var(--xyd-cinnabar);
        background-color: transparent;
    }
    /* 當前頁左側 3px 硃砂條 */
    #header-responsive li.current-menu-item > a,
    #header-responsive li.current_page_item > a {
        border-left: 3px solid var(--xyd-cinnabar);
        padding-left: 17px;
    }
    /* 子選單縮排 */
    #header-responsive .sub-menu a {
        padding-left: 36px;
    }
    /* 下拉箭頭沿用主題機制，僅隨色調微調 */
    #header-responsive .menu-item-has-children > a:after {
        color: var(--xyd-gold);
    }
}

/* 輪播高度三斷點：540 → 380(≤1024) → 250(≤640)
   覆寫 theme options 內聯 <style>（wp_head:13 輸出，晚於所有 stylesheet link）
   ⇒ 一律 !important 取勝 */
#slider .rslides,
#slider .rslides li,
#slider .rslides-container .slides,
#slider .rslides-container .slides li {
    height: 540px !important;
    max-height: 540px !important;
}
#slider .rslides img,
#slider .rslides-container .slides img {
    height: 100%;
    max-height: 540px !important;
}
@media (max-width: 1024px) {
    #slider .rslides,
    #slider .rslides li,
    #slider .rslides-container .slides,
    #slider .rslides-container .slides li {
        height: 380px !important;
        max-height: 380px !important;
    }
    #slider .rslides img,
    #slider .rslides-container .slides img {
        max-height: 380px !important;
    }
}
@media (max-width: 640px) {
    #slider .rslides,
    #slider .rslides li,
    #slider .rslides-container .slides,
    #slider .rslides-container .slides li {
        height: 250px !important;
        max-height: 250px !important;
    }
    #slider .rslides img,
    #slider .rslides-container .slides img {
        max-height: 250px !important;
    }
    /* 觸控：保留 rslides 左右滑，禁止雙擊縮放觸發 */
    #slider img {
        touch-action: pan-y;
    }
}

/* ≤640：三卡單欄補強（主題 685px 斷點已把 .one_third 轉 100%，此為保險層） */
@media (max-width: 640px) {
    #section-home article.one_third {
        width: 100% !important;
        margin-right: 0 !important;
        float: none !important;
        margin-bottom: 28px;
    }
    #section-home article.one_third.last {
        margin-bottom: 8px;
    }
    #section-home .iconmain h3 {
        font-size: 17px;        /* §2.3：手機 服務卡標題＝1.0625rem×16 */
    }
    #section-home .iconmain p {
        font-size: 15px;        /* §2.3：手機 內文＝.9375rem×16 */
    }
    #logo img {
        max-height: 40px;       /* 手機 logo（舊 32px） */
    }
}

/* =============================================================================
   P2-1（提前收錄）a11y：動態全關 + focus-visible 硃砂
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition: none !important;
        animation: none !important;
    }
}
:focus-visible {
    outline: 2px solid var(--xyd-cinnabar);
    outline-offset: 3px;
}
