/*
 * Header / 漢堡選單 共用樣式
 * 提供桌面下拉選單動效與手機子選單動畫，供 hf-components.js 注入元件使用。
 */

/* 桌面下拉選單樣式 */
.hf-header-brand {
    min-height: 2.5rem;
    color: #465B40;
}

/* Header 內容不可被 flex 壓縮成多行；手機版再以短文案保留單行版面。 */
.hf-header-brand-copy,
.hf-header-brand-title,
.hf-header-brand-subtitle,
.hf-header-actions,
.hf-header-phone,
.hf-header-phone-copy,
.hf-header-phone-label,
.hf-header-phone-title,
.hf-header-menu-button {
    white-space: nowrap;
}

.hf-header-brand-copy {
    min-width: 0;
}

.hf-header-brand-subtitle-short {
    display: none;
}

.hf-header-actions,
.hf-header-phone,
.hf-header-phone-copy,
.hf-header-menu-button {
    flex-shrink: 0;
}

.hf-header-brand--with-back {
    padding-right: 2.5rem;
}

.hf-header-brand-default,
.hf-header-back-home {
    transition: opacity 0.25s ease, visibility 0s linear 0.25s, transform 0.25s ease;
}

.hf-header-brand-default {
    opacity: 1;
    visibility: visible;
    transform: translateX(0) scale(1.1);
    transform-origin: left center;
}

.hf-header-back-home {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    display: inline-flex;
    align-items: center;
    gap: .55rem;
    color: #788275;
    font-family: "Noto Sans TC", sans-serif;
    font-size: 1rem;
    font-weight: 500;
    letter-spacing: .12em;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transform: translateX(-8px);
    pointer-events: none;
    transition-delay: 0s, 0s, 0s;
}

.hf-header-back-home i,
.hf-header-back-home .hf-icon {
    color: #465B40;
    font-size: 3.2rem;
    line-height: 1;
}

.hf-header-brand--with-back:hover .hf-header-brand-default,
.hf-header-brand--with-back:focus-visible .hf-header-brand-default {
    opacity: 0;
    visibility: hidden;
    transform: translateX(8px) scale(1.1);
    transition-delay: 0s, 0.25s, 0s;
}

.hf-header-brand--with-back:hover .hf-header-back-home,
.hf-header-brand--with-back:focus-visible .hf-header-back-home {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
    transition-delay: 0.08s, 0s, 0s;
}

.hf-header-nav-underline {
    right: 0;
    width: auto;
    transform: scaleX(0);
    transform-origin: left center;
    transition: transform 0.3s ease;
}

.hf-header-nav-link:hover > .hf-header-nav-underline,
.hf-header-nav-link:focus-visible > .hf-header-nav-underline {
    transform: scaleX(1);
}

.hf-header-nav-link.hf-header-nav-current {
    color: #465B40;
    font-weight: 700;
}

.nav-dropdown-item {
    opacity: 0;
    transform: translateY(-5px);
    transition: all 0.3s ease-out;
    position: relative;
    padding-left: 28px;
}

.nav-item-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translate(-6px, -50%);
    opacity: 0;
    color: #C5A670;
    font-size: 12px;
    transition: all 0.2s ease;
}

.nav-item-line {
    position: absolute;
    left: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 1px;
    height: 60%;
    background: #C5A670;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.nav-dropdown-text {
    transition: transform 0.2s ease;
}

.nav-dropdown-item:hover .nav-item-icon {
    transform: translate(0, -50%);
    opacity: 0.9;
}

.nav-dropdown-item:hover .nav-item-line {
    opacity: 0.9;
}

.nav-dropdown-item:hover .nav-dropdown-text {
    transform: translateX(2px);
}

.group:hover .nav-dropdown-item {
    opacity: 1;
    transform: translateY(0);
}

.group:hover .nav-dropdown-item:nth-child(1) { transition-delay: 0.05s; }
.group:hover .nav-dropdown-item:nth-child(2) { transition-delay: 0.1s; }
.group:hover .nav-dropdown-item:nth-child(3) { transition-delay: 0.15s; }
.group:hover .nav-dropdown-item:nth-child(4) { transition-delay: 0.2s; }
.group:hover .nav-dropdown-item:nth-child(5) { transition-delay: 0.25s; }

/*
 * 下拉選單「連往其他頁面」項目（例如「最新消息」）：
 * 與同選單中「頁內錨點」項目做視覺區隔，但沿用同一套金色／墨綠語彙，
 * 避免突兀 —— 僅以一條金色分隔線 + 文字改為主色系 + 小型外部連結圖示標示。
 */
.nav-dropdown-item--link {
    margin-top: 6px;
    padding-top: 12px;
    border-top: 1px solid rgba(197, 166, 112, 0.32);
}

.nav-dropdown-extlink {
    font-size: 9px;
    margin-left: 4px;
    opacity: 0.7;
    vertical-align: 1px;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.nav-dropdown-item--link:hover .nav-dropdown-extlink {
    opacity: 1;
    transform: translate(1px, -1px);
}

/* 手機版子選單動畫 */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.submenu-item-fade {
    animation: fadeInUp 0.4s ease-out forwards;
    opacity: 0;
}

/*
 * 頁尾前螢幕網屏底圖（footer_screentone）
 * 桌面（md 以上）維持依比例隨寬度縮放（沿用元件 inline style：width:100% + aspect-ratio）。
 * 手機（md 以下）改為固定高度 + object-fit: cover，讓網屏點點維持一致大小，
 * 不會隨螢幕變窄而縮小到幾乎看不見。
 */
@media (max-width: 1320px) {
    .hf-footer-screentone {
        height: 480px !important;
        aspect-ratio: auto !important;
        object-fit: cover !important;
        object-position: center bottom !important;
    }
}

/* 手機版只取消品牌容器的桌面放大比例，保留原本 logo 與文字尺寸。 */
@media (max-width: 767px) {
    #navbar > .container {
        gap: .5rem;
    }

    .hf-header-brand {
        min-width: 0;
        flex: 1 1 auto;
        overflow: hidden;
    }

    .hf-header-brand-default {
        min-width: 0;
        gap: .5rem !important;
    }

    .hf-header-brand-default picture {
        flex: 0 0 auto;
    }

    .hf-header-brand-subtitle-full {
        display: none;
    }

    .hf-header-brand-subtitle-short {
        display: block;
    }

    .hf-header-actions {
        gap: .4rem !important;
    }

    .hf-header-phone {
        gap: .45rem !important;
        padding: .5rem .65rem !important;
    }

    .hf-header-phone-icon {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 1.15rem;
        height: 1.15rem;
        flex: 0 0 1.15rem;
        line-height: 1 !important;
        font-size: 1.15rem !important;
    }

    .hf-header-phone-label {
        margin-bottom: 0 !important;
        font-size: .55rem !important;
        letter-spacing: .06em !important;
    }

    .hf-header-phone-title {
        font-size: 1rem !important;
        letter-spacing: .04em !important;
    }

    .hf-header-menu-button {
        padding: .35rem !important;
        margin-left: 0 !important;
    }

    .hf-header-menu-button i,
    .hf-header-menu-button .hf-icon {
        font-size: 1.8rem !important;
    }

    .hf-header-brand-default {
        transform: scale(1);
    }

    .hf-header-brand--with-back:hover .hf-header-brand-default,
    .hf-header-brand--with-back:focus-visible .hf-header-brand-default {
        transform: translateX(8px) scale(1);
    }
}

/* 極窄手機再縮小非文字空間，仍保留「Hua Fan／24H／專線」單行。 */
@media (max-width: 380px) {
    #navbar > .container {
        padding-left: .65rem;
        padding-right: .65rem;
        gap: .35rem;
    }

    .hf-header-brand-default {
        gap: .35rem !important;
    }

    .hf-header-phone {
        gap: .35rem !important;
        padding-left: .5rem !important;
        padding-right: .5rem !important;
    }

    .hf-header-phone-icon {
        width: 1rem;
        height: 1rem;
        flex-basis: 1rem;
        font-size: 1rem !important;
    }

    .hf-header-phone-title {
        font-size: .9rem !important;
    }

    .hf-header-menu-button {
        padding: .25rem !important;
    }
}

/* 手機版不切換成「回到首頁」，避免 hover／focus 顯示替代內容。 */
@media (max-width: 1023px) {
    /* 手機不顯示回到首頁替代內容，也不應保留桌面的預留寬度。 */
    .hf-header-brand--with-back {
        padding-right: 0;
    }

    .hf-header-brand--with-back .hf-header-back-home {
        display: none;
    }

    .hf-header-brand--with-back:hover .hf-header-brand-default,
    .hf-header-brand--with-back:focus-visible .hf-header-brand-default {
        opacity: 1;
        visibility: visible;
        transform: translateX(0) scale(1);
        transition-delay: 0s;
    }
}
