/* 隐藏 Goya 原本为 Header 预留的空白，避免自定义 Header 下方出现多余间距。 */
body.hddjt-hfcode-header-active .header-spacer {
    display: none !important;
}

/*
 * 隐藏 Goya 原来的轮播标语。
 * 文件版 Header 自己输出标语区域。
 */
body .campaign-bar.et-global-campaign {
    display: none !important;
}

/* 标语和 Header 共用的桌面端高度变量。 */
body.hddjt-hfcode-header-active {
    --hddjt-custom-campaign-height: 34px;
}

/* 新的单行标语区域。 */
.hddjt-campaign-row {
    position: relative;
    z-index: 9999;
    box-sizing: border-box;
    width: 100%;
    min-height: var(--hddjt-custom-campaign-height);
    background: #A0A17F;
    color: #ffffff;
    font-family: Urbanist, Arial, sans-serif;
    font-size: 12px;
    line-height: 1.35;
    letter-spacing: 0.02em;
    transform: translate3d(0, 0, 0);
    opacity: 1;
    visibility: visible;
    will-change: transform, opacity;
    transition:
        transform 360ms cubic-bezier(0.22, 1, 0.36, 1),
        opacity 220ms ease,
        visibility 0s linear 0s;
}

.hddjt-campaign-row__inner {
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    overflow: hidden;
    width: 100%;
    min-height: var(--hddjt-custom-campaign-height);
    padding: 8px 44px;
}

.hddjt-campaign-row__text {
    overflow: hidden;
    width: 100%;
    white-space: nowrap;
    color: inherit;
    cursor: pointer;
    text-align: center;
    text-overflow: ellipsis;
}

/* 标语中的折扣信息加粗显示。 */
.hddjt-campaign-row__discount {
    font-weight: 600;
}

/*
 * 顶部轮播标语的隐藏动画。
 * 页面离开顶部后，JavaScript 会给 body 添加 hddjt-campaign-hidden 类。
 */
body.hddjt-campaign-hidden .hddjt-campaign-row {
    transform: translate3d(0, -100%, 0);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition:
        transform 360ms cubic-bezier(0.22, 1, 0.36, 1),
        opacity 220ms ease,
        visibility 0s linear 360ms;
}

/* Header 第二行的颜色、高度和字体都可以在这里统一修改。 */
.hddjt-header-row {
    --hddjt-header-height: 78px;
    --hddjt-header-background: #F7F7F2;
    --hddjt-header-text: #363632;

    position: sticky;
    top: 0;
    z-index: 9998;
    box-sizing: border-box;
    width: 100%;
    min-height: var(--hddjt-header-height);
    background: var(--hddjt-header-background);
    color: var(--hddjt-header-text);
    font-family: Urbanist, Arial, sans-serif;
    transition: box-shadow 260ms ease;
}

/* Header 内部采用左侧 Logo、中间导航、右侧功能区的三栏结构。 */
.hddjt-header-row__inner {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(0, auto) minmax(180px, 1fr);
    align-items: center;
    column-gap: 32px;
    box-sizing: border-box;
    width: 100%;
    min-height: var(--hddjt-header-height);
    margin: 0 auto;
    padding-right: 16px;
    padding-left: 16px;
}

/* Header 内边距随视口宽度逐级增加。 */
@media (min-width: 640px) {
    .hddjt-header-row__inner {
        padding-right: 24px;
        padding-left: 24px;
    }
}

@media (min-width: 768px) {
    .hddjt-header-row__inner {
        padding-right: 32px;
        padding-left: 32px;
    }
}

@media (min-width: 1280px) {
    .hddjt-header-row__inner {
        padding-right: clamp(80px, 4.9vw, 126px);
        padding-left: clamp(80px, 4.9vw, 126px);
    }
}

/* Goya 原始 Logo 图片样式。 */
.hddjt-header-logo {
    justify-self: start;
    min-width: 0;
}

.hddjt-header-logo .logo-holder,
.hddjt-header-logo .logolink {
    display: flex;
    align-items: center;
    margin: 0;
}

.hddjt-header-logo .logolink img {
    display: block;
    width: auto;
    max-width: 140px;
    max-height: 36px;
}

/* 当前浅色背景使用原来的浅色 Logo，隐藏深色和备用 Logo，防止图片重叠。 */
.hddjt-header-logo .logoimg.bg--dark,
.hddjt-header-logo .logoimg.bg--alt {
    display: none;
}

/* 桌面端主导航。 */
.hddjt-header-navigation {
    display: flex;
    align-items: center;
    align-self: stretch;
    justify-content: center;
    gap: 34px;
}

/* Shop 项占满 Header 高度，让鼠标从文字移动到下拉菜单时不会意外关闭。 */
.hddjt-header-navigation__shop {
    display: flex;
    align-items: center;
    align-self: stretch;
}

.hddjt-header-navigation__item {
    position: relative;
    color: #2C2A27;
    font-size: 16px;
    font-weight: 500 !important;
    line-height: 1.4;
    white-space: nowrap;
    cursor: pointer;
    transition: color 180ms ease;
}

.hddjt-header-navigation__shop-trigger {
    color: inherit;
    text-decoration: none;
}

/* 鼠标经过或键盘选中时改变文字颜色。 */
.hddjt-header-navigation__item:hover,
.hddjt-header-navigation__item:focus {
    color: #2C2A27;
    outline: none;
}

/* 仅桌面端：导航文字悬停时，下划线从左向右展开。 */
@media (min-width: 992px) {
    .hddjt-header-navigation__item::after {
        content: "";
        position: absolute;
        right: 0;
        bottom: -5px;
        left: 0;
        height: 1px;
        background: currentColor;
        transform: scaleX(0);
        transform-origin: left center;
        transition: transform 260ms cubic-bezier(0.22, 1, 0.36, 1);
        pointer-events: none;
    }

    .hddjt-header-navigation__item:hover::after,
    .hddjt-header-navigation__item:focus-visible::after,
    .hddjt-header-navigation__shop:focus-within .hddjt-header-navigation__item::after,
    .hddjt-header-navigation__shop.is-open .hddjt-header-navigation__item::after {
        transform: scaleX(1);
    }
}

/*
 * Shop 全宽下拉菜单。面板相对整个 Header 定位，因此始终铺满一整行，
 * 不受中间导航栏宽度限制。
 */
.hddjt-shop-menu {
    position: absolute;
    top: 100%;
    right: 0;
    left: 0;
    z-index: 30;
    box-sizing: border-box;
    border-top: 1px solid rgba(44, 42, 39, 0.1);
    background: #F7F7F2;
    box-shadow: 0 18px 32px rgba(54, 54, 50, 0.12);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    pointer-events: none;
    transition:
        opacity 180ms ease,
        transform 220ms cubic-bezier(0.22, 1, 0.36, 1),
        visibility 0s linear 220ms;
}

.hddjt-header-navigation__shop:hover .hddjt-shop-menu,
.hddjt-header-navigation__shop:focus-within .hddjt-shop-menu,
.hddjt-header-navigation__shop.is-open .hddjt-shop-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
    transition-delay: 0s;
}

/* 按 Esc 后即使焦点回到 Shop，也先保持菜单关闭；再次聚焦或悬停会重新打开。 */
.hddjt-header-navigation__shop.is-escape-closed .hddjt-shop-menu {
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    pointer-events: none;
}

.hddjt-shop-menu__inner {
    display: grid;
    grid-template-columns: minmax(230px, 0.8fr) minmax(420px, 2fr) minmax(180px, 0.7fr);
    gap: clamp(36px, 5vw, 88px);
    box-sizing: border-box;
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    padding: 34px clamp(32px, 7vw, 126px) 40px;
}

.hddjt-shop-menu__intro,
.hddjt-shop-menu__group {
    min-width: 0;
}

.hddjt-shop-menu__eyebrow,
.hddjt-shop-menu__title {
    margin: 0 0 16px;
    color: #77766f;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.4;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.hddjt-shop-menu__all {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: #2C2A27;
    font-size: clamp(21px, 1.7vw, 28px);
    font-weight: 500;
    line-height: 1.2;
    text-decoration: none;
}

.hddjt-shop-menu__all span {
    transition: transform 180ms ease;
}

.hddjt-shop-menu__all:hover span,
.hddjt-shop-menu__all:focus-visible span {
    transform: translateX(4px);
}

.hddjt-shop-menu__links {
    display: grid;
    grid-template-columns: repeat(2, minmax(110px, 1fr));
    gap: 12px 28px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.hddjt-shop-menu__links--collections {
    grid-template-columns: repeat(3, minmax(100px, 1fr));
}

.hddjt-shop-menu__links a {
    display: inline-block;
    position: relative;
    padding: 2px 0;
    color: #2C2A27;
    font-size: 15px;
    font-weight: 500;
    line-height: 1.5;
    text-decoration: none;
}

.hddjt-shop-menu__links a::after {
    content: "";
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    height: 1px;
    background: currentColor;
    transform: scaleX(0);
    transform-origin: left center;
    transition: transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
}

.hddjt-shop-menu__links a:hover::after,
.hddjt-shop-menu__links a:focus-visible::after {
    transform: scaleX(1);
}

.hddjt-shop-menu a:focus-visible {
    border-radius: 2px;
    outline: 2px solid rgba(44, 42, 39, 0.42);
    outline-offset: 4px;
}

/* Sale 默认使用强调色，需要普通颜色时可删除这一段。 */
.hddjt-header-navigation__item--sale {
    color: #EF0B14;
}

.hddjt-header-navigation__item--sale:hover,
.hddjt-header-navigation__item--sale:focus {
    color: #EF0B14;
}

/* 右侧功能文字横向排列。 */
.hddjt-header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
}

/* 清除 Goya 图标原来所在 Header 的布局间距。 */
.hddjt-header-actions > *,
.hddjt-header-actions .account-links,
.hddjt-header-actions .account-links > li {
    margin: 0;
    padding: 0;
}

.hddjt-header-actions .account-links {
    list-style: none;
}

/* 隐藏原图标旁边的文字，只保留 Goya 原始 SVG。 */
.hddjt-header-actions .text,
.hddjt-header-actions .icon-text {
    display: none;
}

.hddjt-header-actions .icon {
    display: inline-flex;
    position: relative;
    align-items: center;
    justify-content: center;
    color: var(--hddjt-header-text);
}

.hddjt-header-actions .icon svg {
    display: block;
    width: 22px;
    height: 22px;
}

/* 只在文件版 Header 中隐藏收藏图标。 */
.hddjt-header-actions .quick_wishlist {
    display: none !important;
}

/* 保留购物车数量角标。 */
.hddjt-header-actions .item-counter {
    position: absolute;
    top: -8px;
    right: -9px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: var(--hddjt-header-accent);
    color: #ffffff;
    font-size: 10px;
    line-height: 16px;
    text-align: center;
}

/* 手机端的汉堡菜单和搜索入口在桌面端隐藏。 */
.hddjt-header-mobile-controls {
    display: none;
}

/* 页面滚动后显示一条轻微阴影。 */
.hddjt-header-row.is-scrolled {
    box-shadow: 0 4px 18px rgba(54, 54, 50, 0.08);
}

/* 购物车打开时，遮罩和侧栏在所有视口下都覆盖促销条与顶部导航。 */
body.panel-open-cart .click-capture {
    position: fixed;
    z-index: 10002;
    inset: 0;
    width: 100%;
    height: 100%;
}

#side-cart,
#side-cart.side-panel {
    z-index: 10003 !important;
}

/* 手机和平板布局。 */
@media (max-width: 991px) {
    body.hddjt-hfcode-header-active {
        --hddjt-custom-campaign-height: 32px;
    }

    /* Goya 默认面板层级较低；提高侧栏和遮罩，使其覆盖促销条与顶部导航。 */
    body.panel-open-menu .click-capture {
        position: fixed;
        z-index: 10000;
        inset: 0;
        width: 100%;
        height: 100%;
    }

    #mobile-menu.side-panel {
        z-index: 10001;
    }

    /* 移动端购物车占据视口宽度的 80%。 */
    #side-cart,
    #side-cart.side-panel {
        width: 80vw !important;
        max-width: 80vw !important;
    }

    .side-panel .side-panel-content {
        padding: 0 !important;
    }

    /* 参考移动端侧栏：顶部工具栏 + 下方纵向菜单两个模块。 */
    #mobile-menu.hddjt-mobile-drawer {
        display: flex;
        flex-direction: column;
        width: min(92vw, 400px);
        max-width: 400px;
        background: #ffffff;
        color: #2c2a27;
        font-family: Urbanist, Arial, sans-serif;
    }

    #mobile-menu.hddjt-mobile-drawer > .mobile-bar,
    #mobile-menu.hddjt-mobile-drawer > header {
        display: none;
    }

    .hddjt-mobile-drawer__toolbar {
        display: flex;
        position: relative;
        z-index: 2;
        align-items: center;
        flex: 0 0 70px;
        width: 100%;
        min-height: 70px;
        padding: 0 20px;
        border-bottom: 1px solid rgba(44, 42, 39, 0.14);
        background: #ffffff;
    }

    #mobile-menu .hddjt-mobile-drawer__close {
        flex: 0 0 auto;
        width: 20px;
        height: 20px;
        margin: 0;
        padding: 0;
        border: 0;
        border-radius: 0;
        background: transparent;
    }

    .hddjt-mobile-drawer__logo {
        position: absolute;
        top: 50%;
        left: 50%;
        max-width: 150px;
        transform: translate(-50%, -50%);
    }

    .hddjt-mobile-drawer__logo .logolink {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .hddjt-mobile-drawer__logo img {
        display: block;
        width: auto;
        max-width: 150px;
        max-height: 32px;
    }

    .hddjt-mobile-drawer__logo .logoimg.bg--dark,
    .hddjt-mobile-drawer__logo .logoimg.bg--alt {
        display: none;
    }

    .hddjt-mobile-drawer__actions {
        display: flex;
        align-items: center;
        gap: 16px;
        margin-left: auto;
    }

    .hddjt-mobile-drawer__actions .icon {
        display: inline-flex;
        position: relative;
        align-items: center;
        justify-content: center;
        width: 24px;
        height: 34px;
        margin: 0;
        color: #2c2a27;
    }

    .hddjt-mobile-drawer__actions .text,
    .hddjt-mobile-drawer__actions .icon-text,
    .hddjt-mobile-drawer__actions .sub-menu {
        display: none;
    }

    .hddjt-mobile-drawer__actions svg {
        display: block !important;
        width: 23px;
        height: 23px;
    }

    .hddjt-mobile-drawer__account {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
    }

    .hddjt-mobile-drawer__actions .item-counter {
        position: absolute;
        top: -2px;
        right: -7px;
        min-width: 15px;
        height: 15px;
        padding: 0 3px;
        border-radius: 8px;
        background: var(--hddjt-header-accent);
        color: #ffffff;
        font-size: 9px;
        line-height: 15px;
        text-align: center;
    }

    /* 原 Goya 菜单可能为空，侧栏内容统一使用 header.html 中的模板。 */
    #mobile-menu.hddjt-mobile-drawer > .side-panel-content {
        display: none;
    }

    .hddjt-mobile-drawer__content {
        overflow-x: hidden;
        overflow-y: auto;
        flex: 1 1 auto;
        width: 100%;
        padding: 0;
    }

    .hddjt-mobile-drawer__menu {
        width: 100%;
        margin: 0;
        padding: 0;
    }

    .hddjt-mobile-drawer__menu > a {
        border-bottom: 1px solid rgba(44, 42, 39, 0.12);
    }

    .hddjt-mobile-drawer__menu > a,
    .hddjt-mobile-drawer__auth a {
        display: flex;
        align-items: center;
        box-sizing: border-box;
        width: 100%;
        min-height: 59px;
        padding: 14px 20px;
        color: #303745;
        font-size: 16px;
        font-weight: 400;
        line-height: 1.35;
        text-decoration: none;
    }

    .hddjt-mobile-drawer__menu > a:hover,
    .hddjt-mobile-drawer__menu > a:focus,
    .hddjt-mobile-drawer__auth a:hover,
    .hddjt-mobile-drawer__auth a:focus {
        background: rgba(163, 163, 128, 0.09);
        color: #303745;
        outline: none;
    }

    .hddjt-mobile-drawer__auth {
        width: 100%;
        border-bottom: 1px solid rgba(44, 42, 39, 0.12);
    }

    .hddjt-mobile-drawer__auth:empty {
        display: none;
    }

    .hddjt-mobile-drawer__sale {
        color: #ef0b14 !important;
    }

    .hddjt-campaign-row {
        font-size: 11px;
    }

    .hddjt-campaign-row__inner {
        padding: 8px 34px;
    }

    .hddjt-header-row {
        --hddjt-header-height: 66px;
    }

    .hddjt-header-row__inner {
        grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
        column-gap: 18px;
    }

    /* 手机端 Logo 放在中间。 */
    .hddjt-header-logo {
        grid-column: 2;
        grid-row: 1;
        justify-self: center;
    }

    .hddjt-header-logo .logolink img {
        max-width: 126px;
        max-height: 33px;
    }

    /* 手机端左侧显示 Goya 原生汉堡菜单，搜索图标紧随其右。 */
    .hddjt-header-mobile-controls {
        display: flex;
        grid-column: 1;
        grid-row: 1;
        align-items: center;
        justify-self: start;
        gap: 8px;
        min-width: 0;
    }

    .hddjt-header-mobile-controls .hamburger-menu {
        display: flex;
        align-items: center;
        margin: 0;
    }

    .hddjt-header-mobile-controls .menu-toggle,
    .hddjt-header-mobile-search .quick_search {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 28px;
        height: 34px;
        margin: 0;
        padding: 0;
        border: 0;
        background: transparent;
        color: var(--hddjt-header-text);
        cursor: pointer;
    }

    .hddjt-header-mobile-controls .menu-toggle .name,
    .hddjt-header-mobile-search .quick_search .text {
        display: none;
    }

    .hddjt-header-mobile-controls svg,
    .hddjt-header-mobile-search svg {
        display: block;
        width: 24px;
        height: 24px;
    }

    /* 手机端只在右侧保留 Cart，其他功能放进展开菜单。 */
    .hddjt-header-actions {
        grid-column: 3;
        grid-row: 1;
    }

    /* 搜索入口已经放到左侧；账户与购物车继续保留在移动端导航栏。 */
    .hddjt-header-actions .quick_search {
        display: none;
    }

    /* 手机端使用 Goya 原生侧边栏菜单，因此隐藏桌面导航。 */
    .hddjt-header-navigation {
        display: none;
    }

    .hddjt-shop-menu {
        display: none;
    }
}
