/* 1. 导航栏 */
nav {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: calc(20px + env(safe-area-inset-top, 0px)) 5% 20px 5%;
    transition: all 0.4s ease;
}

nav.scrolled {
    background: rgba(247, 245, 240, 0.7);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.03);
    padding: calc(16px + env(safe-area-inset-top, 0px)) 5% 16px 5%;
}

.logo {
    display: flex;
    align-items: center;
    margin-left: 50px;
    /* 进一步向右移动 */
}

.logo-img {
    height: 55px;
    /* 恢复合理的占位高度，避免撑开导航栏 */
    width: auto;
    object-fit: contain;
    transform: scale(2.2) translateY(4px);
    /* 增加 translateY(4px) 让未下拉时 Logo 整体下移一点 */
    transform-origin: left center;
    transition: all 0.4s ease;
}

.logo-dark {
    display: none;
}

nav.scrolled .logo-light {
    display: none;
}

nav.scrolled .logo-dark {
    display: block;
}

nav.scrolled .logo-img {
    height: 45px;
    /* 滚动时导航栏高度减小，Logo占位高度也同步减小 */
    transform: scale(2) translateX(12px);
    /* 增加 translateX(12px) 补偿缩放倍率变化引起的视觉左移，使其与未下拉时对齐 */
}

.nav-links {
    display: flex;
    gap: 40px;
    list-style: none;
}

.nav-links a {
    color: var(--bg-card);
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 1px;
    transition: color 0.3s;
    position: relative;
    padding-bottom: 6px;
}

nav.scrolled .nav-links a {
    color: var(--dark);
}

/* 导航项划过及选中的高级下划线特效 */
.nav-links a::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 1.5px;
    bottom: 0;
    left: 0;
    background: var(--gold-gradient);
    transform: scaleX(0);
    transform-origin: right;
    transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1);
}

.nav-links a:hover::after,
.nav-links a.active::after {
    transform: scaleX(1);
    transform-origin: left;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--gold) !important;
}

/* 顶层导航栏：当悬停在其他顶层菜单（非自身下拉菜单）时，取消原本顶层 active 项的高亮效果 */
.nav-links:has(> li:not(:hover) a:hover)>li>a.active:not(:hover)::after {
    transform: scaleX(0);
}

.nav-links:has(> li:not(:hover) a:hover)>li>a.active:not(:hover) {
    color: var(--bg-card) !important;
}

nav.scrolled .nav-links:has(> li:not(:hover) a:hover)>li>a.active:not(:hover) {
    color: var(--dark) !important;
}

/* --- Dropdown Menu Styles (Crisp White Card) --- */
.nav-links .dropdown {
    position: relative;
    padding-bottom: 25px;
    margin-bottom: -25px;
}

.nav-links .dropdown-menu {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    background: rgba(255, 255, 255, 0.98);
    /* Pure white for contrast against cream */
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(212, 175, 55, 0.15);
    /* Subtle gold border */
    min-width: 140px;
    padding: 10px 0;
    list-style: none;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.12);
    /* Stronger shadow for depth */
    border-radius: 8px;
    pointer-events: none;
    z-index: 100;
}

/* Little triangle pointer */
.nav-links .dropdown-menu::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%) rotate(45deg);
    width: 12px;
    height: 12px;
    background: rgba(255, 255, 255, 0.98);
    border-top: 1px solid rgba(212, 175, 55, 0.15);
    border-left: 1px solid rgba(212, 175, 55, 0.15);
    z-index: -1;
}

/* Dropdown link styling */
.nav-links .dropdown-menu a {
    display: block;
    padding: 10px 24px;
    color: var(--dark) !important;
    font-size: 14px;
    text-align: center;
    transition: all 0.3s ease;
    letter-spacing: 1px;
    position: relative;
}

/* Remove hover underline effect for dropdown links */
.nav-links .dropdown-menu a::after {
    display: none;
}

/* Hover & Active effect for dropdown links */
.nav-links .dropdown-menu a:hover,
.nav-links .dropdown-menu a.active {
    color: var(--gold) !important;
    background: rgba(197, 168, 128, 0.08);
    font-weight: 600;
}

/* 当鼠标选中的时候（悬停在下拉菜单内任意子菜单项时），取消该下拉菜单内其他的 active 项高亮，解决多个选项同时高亮的痛点 */
.nav-links .dropdown-menu:has(a:hover) a.active:not(:hover) {
    color: var(--dark) !important;
    background: transparent !important;
    font-weight: normal;
}

.nav-links .dropdown:hover .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}

/* Small arrow adjustment */
.nav-links .arrow {
    font-size: 14px;
    margin-left: 1px;
    vertical-align: middle;
    display: inline-block;
    transition: transform 0.3s ease;
    opacity: 0.9;
}

.nav-links .dropdown:hover .arrow,
.nav-links .dropdown.open .arrow {
    transform: rotate(180deg);
}

.btn-nav {
    padding: 10px 24px;
    background: var(--gold-gradient);
    color: var(--dark);
    border-radius: 2px;
    transition: all 0.3s;
    font-weight: 600;
    border: none;
    box-shadow: 0 4px 15px rgba(197, 168, 128, 0.2);
}

nav.scrolled .btn-nav {
    background: var(--dark);
    color: var(--gold);
    box-shadow: none;
}

.btn-nav:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(197, 168, 128, 0.4);
}

nav.scrolled .btn-nav:hover {
    background: var(--gold-gradient);
    color: var(--dark);
    box-shadow: 0 6px 20px rgba(197, 168, 128, 0.3);
}

/* 汉堡菜单 (移动端) */
.menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    width: 30px;
    height: 20px;
    cursor: pointer;
    z-index: 1000;
    filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.5));
    /* 确保在菜单之上 */
}

.menu-toggle span {
    display: block;
    width: 100%;
    height: 2px;
    background: var(--bg-card);
    transition: 0.3s;
}

nav.scrolled .menu-toggle {
    filter: none;
}

nav.scrolled .menu-toggle span {
    background-color: var(--dark);
}

.menu-toggle.active span:nth-child(1) {
    transform: translateY(9px) rotate(45deg);
    background: var(--dark);
}

.menu-toggle.active span:nth-child(2) {
    opacity: 0;
}

.menu-toggle.active span:nth-child(3) {
    transform: translateY(-9px) rotate(-45deg);
    background: var(--dark);
}

/* Footer */
footer {
    background: #111;
    color: rgba(255, 255, 255, 0.5);
    padding: 40px 5%;
    text-align: center;
    font-size: 13px;
}

.footer-links {
    margin-bottom: 20px;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 24px;
}

.footer-links a {
    white-space: nowrap;
}

.footer-links a:hover {
    color: var(--gold);
}

/* ==========================================================================
   侧边悬浮工具栏 (Floating Action Bar)
   ========================================================================== */
.floating-bar {
    position: fixed;
    bottom: 35%;
    transform: translateY(50%);
    right: 30px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 40px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    padding: 15px 0;
    z-index: 999;
    border: 1px solid rgba(197, 168, 128, 0.2);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}


.floating-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    color: var(--dark);
    text-decoration: none;
    transition: all 0.3s ease;
    cursor: pointer;
}

.floating-item:not(:last-child)::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 1px;
    background: rgba(0, 0, 0, 0.05);
}

.floating-item svg {
    width: 20px;
    height: 20px;
    margin-bottom: 4px;
    transition: all 0.3s ease;
}

.floating-item span {
    font-size: 11px;
    font-weight: 500;
    transition: all 0.3s ease;
}

/* 微信颜色定制 */
.floating-item.wechat-item svg {
    width: 22px;
    height: 22px;
}

.floating-item:hover {
    color: var(--gold);
}

.floating-item:hover svg {
    transform: translateY(-2px) scale(1.1);
}

/* 二维码悬浮窗 (支持微信和QQ) */
.qr-popover {
    position: absolute;
    right: calc(100% + 20px);
    top: 50%;
    transform: translateY(-50%) translateX(20px);
    background: #fff;
    padding: 15px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: none;
}

.qr-popover::after {
    content: '';
    position: absolute;
    top: 50%;
    right: -6px;
    transform: translateY(-50%) rotate(45deg);
    width: 12px;
    height: 12px;
    background: #fff;
}

.qr-placeholder {
    width: 100px;
    height: 100px;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 12px;
    border-radius: 8px;
    margin-bottom: 10px;
}

.tel-popover {
    padding: 20px 25px;
}

.tel-number {
    font-size: 20px;
    font-weight: 600;
    color: var(--gold);
    margin: 5px 0 10px 0;
    letter-spacing: 1px;
    white-space: nowrap;
}

.qr-popover p {
    font-size: 12px;
    color: var(--text-sec);
    white-space: nowrap;
    margin: 0;
}

.qr-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 20px;
    height: 20px;
    cursor: pointer;
    color: #999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.3s ease;
}

.qr-close:hover {
    color: var(--dark);
}

.qr-close svg {
    width: 14px;
    height: 14px;
    margin: 0;
}

.floating-item:hover .qr-popover:not(.closed) {
    opacity: 1;
    visibility: visible;
    transform: translateY(-50%) translateX(0);
}

/* 返回顶部按钮默认隐藏，滚动后显示 */
#back-to-top {
    height: 0;
    opacity: 0;
    padding: 0;
    overflow: hidden;
    transition: all 0.4s ease;
    border-top: 1px solid transparent;
}

#back-to-top.visible {
    height: 60px;
    opacity: 1;
    margin-top: 10px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

#back-to-top svg {
    margin-bottom: 0;
    width: 24px;
    height: 24px;
}

@media (max-width: 768px) {
    .floating-bar {
        right: 15px;
        padding: 10px 0;
    }

    .floating-item {
        width: 50px;
        height: 50px;
    }

    .floating-item span {
        font-size: 10px;
    }

    .floating-item svg {
        width: 18px;
        height: 18px;
    }

    .qr-popover {
        display: none;
        /* 移动端考虑直接跳微信或点击弹窗，默认不悬停弹出 */
    }
}

@media (max-width: 1024px) {
    .hero-title {
        font-size: 48px;
    }

    .adv-layout {
        flex-direction: column;
    }

    .adv-badge {
        right: 20px;
        bottom: -20px;
    }

    .contact-wrap {
        flex-direction: column;
    }
}

@media (max-width: 768px) {
    :root {
        --section-padding: 60px 5%;
    }

    nav {
        padding: calc(20px + env(safe-area-inset-top, 0px)) 5% 20px 5%;
    }

    nav.scrolled {
        background: #F7F5F0;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }

    .logo {
        margin-left: 0;
        /* 手机端恢复靠左 */
    }

    .logo-img {
        transform: scale(1.5) translateY(2px);
        /* 手机端适当缩小初始放大倍率 */
    }

    nav.scrolled .logo-img {
        height: 60px;
        transform: scale(1.2);
        /* 手机端下拉时取消额外的 translateX 补偿，直接左对齐 */
    }

    .nav-links {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        background: #fff;
        flex-direction: column;
        padding: 10px 0;
        box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
        gap: 0;
        /* 覆盖电脑端的 40px 间距 */
    }

    .nav-links.active {
        display: flex;
    }

    .nav-links li {
        margin: 12px 30px;
    }

    .nav-links a {
        color: var(--dark);
        font-size: 16px;
    }

    /* 防止移动端点击时触发 PC 端的 hover 特效导致 active 链接变白消失 */
    .nav-links:has(a:hover) a.active:not(:hover),
    .nav-links .dropdown-menu:has(a:hover) a.active:not(:hover) {
        color: var(--dark) !important;
        background: transparent !important;
        font-weight: normal;
    }

    /* Mobile Dropdown Adjustments */
    .nav-links .dropdown>a {
        display: flex;
        justify-content: flex-start;
        align-items: center;
        width: 100%;
    }

    .nav-links .dropdown .arrow {
        font-size: 16px;
        /* 增大箭头图标 */
        padding: 0 4px;
        /* 适度保留点击热区，取消左右大空白 */
        background-color: transparent;
        /* 去除背景色 */
        display: inline-flex;
        align-items: center;
        justify-content: center;
        height: 28px;
        margin-left: 2px;
    }

    .nav-links .dropdown {
        padding-bottom: 0;
        margin-bottom: 0;
    }

    .nav-links .dropdown-menu {
        position: static;
        transform: none;
        box-shadow: none;
        border: none;
        background: transparent;
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        display: none;
        margin-top: 15px;
        padding: 0;
        min-width: 100%;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }

    .nav-links .dropdown-menu::before {
        display: none;
    }

    .nav-links .dropdown.open .dropdown-menu {
        display: block;
        transform: none !important;
        /* Prevent desktop transform from shifting it offscreen */
        opacity: 1 !important;
        visibility: visible !important;
    }

    /* 防止移动端点击触发的 hover 状态导致菜单无法关闭 */
    .nav-links .dropdown:not(.open):hover .dropdown-menu {
        display: none !important;
    }

    .nav-links .dropdown:not(.open):hover .arrow {
        transform: rotate(0) !important;
    }

    .nav-links .dropdown-menu a {
        color: var(--text-sec) !important;
        /* Lighter color to show hierarchy */
        padding: 6px 0 6px 20px;
        transform: none !important;
        text-align: left;
        font-size: 15px;
        border-left: 2px solid rgba(212, 175, 55, 0.2);
        /* Gold indented line */
        margin-left: 5px;
        margin-bottom: 5px;
    }

    .nav-links .dropdown-menu li:last-child a {
        margin-bottom: 0;
    }

    .nav-links .dropdown-menu a:hover,
    .nav-links .dropdown-menu a:active {
        background: transparent;
        color: var(--gold) !important;
        border-left-color: var(--gold);
    }

    .btn-nav {
        display: none;
    }

    .menu-toggle {
        display: flex;
    }

    .hero-title {
        font-size: 36px;
        line-height: 1.4;
        /* 修复文字重叠问题 */
        margin-bottom: 20px;
    }

    .hero-desc {
        font-size: 15px;
        margin-bottom: 30px;
    }

    .hero-actions {
        flex-direction: column;
        gap: 15px;
    }

    .hero-actions a {
        width: 100%;
        text-align: center;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 30px;
    }

    .stat-item:nth-child(2)::after {
        display: none;
    }

    .services-grid {
        grid-template-columns: 1fr;
    }

    .portfolio-grid {
        grid-template-columns: 1fr;
    }

    .contact-form {
        padding: 30px 20px;
    }
}