/* ============================================
   湖北盛科律师事务所 - 顶部导航栏 + 下拉菜单
   白底固定悬浮、金色下划线、多级下拉
   ============================================ */

/* ===== 顶部通栏 ===== */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 1000;
  overflow: visible;
  height: var(--topbar-height);
  background: var(--color-primary-dark);
  color: #fff;
  font-size: 0.8rem;
  line-height: var(--topbar-height);
  transition: height 0.3s ease, opacity 0.3s ease;
}

.top-bar .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 100%;
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 4px;
}

.top-bar-left .icon {
  width: 14px;
  height: 14px;
  color: var(--color-gold);
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.top-bar-right a {
  color: rgba(255, 255, 255, 0.92);
  font-size: 0.8rem;
  transition: color var(--transition-fast);
  white-space: nowrap;
}

.top-bar-right a:hover {
  color: #fff;
  text-decoration: underline;
}

.top-bar-right .divider {
  width: 1px;
  height: 14px;
  background: rgba(255, 255, 255, 0.2);
}

/* 公众号二维码悬浮卡片 */
.qr-popover {
  background: #fff;
  border-radius: 8px;
  box-shadow: var(--shadow-popup);
  padding: 14px;
  text-align: center;
  z-index: 99999;
  animation: qr-in .2s ease;
  min-width: 160px;
}
.qr-popover img {
  width: 130px;
  height: 130px;
  border-radius: 4px;
  display: block;
}
.qr-popover span {
  display: block;
  font-size: 0.75rem;
  color: var(--color-text-secondary);
  margin-top: 8px;
}
.qr-popover-arrow {
  position: absolute;
  top: -6px;
  right: 24px;
  width: 12px;
  height: 12px;
  background: #fff;
  transform: rotate(45deg);
  box-shadow: -2px -2px 4px rgba(0,0,0,0.06);
}
@keyframes qr-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== 主导航栏 ===== */
.main-nav {
  z-index: 1000;
  background: var(--color-bg-white);
  box-shadow: var(--shadow-nav);
  height: var(--nav-height);
  transition: box-shadow 0.3s ease;
}

.main-nav .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  padding-left: 0;
}

/* LOGO */
.nav-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.nav-logo .logo-icon {
  width: 42px;
  height: 42px;
  background: var(--color-primary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-gold);
  font-family: var(--font-sans);
  font-weight: 900;
  font-size: 1.25rem;
}

.nav-logo .logo-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  min-width: 0;
}

.nav-logo .logo-title {
  display: block;
  font-family: var(--font-sans);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--color-primary);
  line-height: 1.2;
  white-space: nowrap;
}

.nav-logo .logo-subtitle {
  display: block;
  font-size: 0.65rem;
  color: var(--color-text-secondary);
  white-space: nowrap;
}

/* ===== 一级菜单列表 ===== */
.nav-list {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 100%;
}
.nav-list > li {
  position: relative;
  height: 100%;
  display: flex;
  align-items: center;
  transition: background var(--transition-fast);
  border-radius: var(--radius-sm);
}
.nav-list > li:hover {
  background: rgba(148, 120, 73,0.06);
}
.nav-list > li > a {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 14px;
  height: 100%;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--color-text-main);
  white-space: nowrap;
  position: relative;
  transition: color var(--transition-fast);
}
.nav-list > li > a::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 3px;
  background: var(--color-gold);
  border-radius: 2px 2px 0 0;
  transition: width var(--transition-normal);
}
.nav-list > li > a:hover,
.nav-list > li.active > a {
  color: var(--color-primary);
}
.nav-list > li > a:hover::after,
.nav-list > li.active > a::after {
  width: calc(100% - 28px);
}
/* 下拉箭头 */
.nav-list > li.has-dropdown > a .arrow {
  display: inline-block;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
  margin-left: 4px;
  transition: transform var(--transition-fast);
}
.nav-list > li.has-dropdown:hover > a .arrow {
  transform: rotate(180deg);
}
/* ===== 下拉菜单面板 ===== */
.nav-dropdown {
  position: absolute;
  top: calc(100% + 10px);                    /* 向下偏移10px，与父导航留出间隙 */
  left: 50%;
  transform: translateX(-50%);               /* 仅水平居中，垂直偏移由top控制 */
  width: max-content;                         /* 宽度自适应最长子菜单项，不留右侧空白 */
  background: #fff;                          /* 纯白背景 */
  border-radius: 8px;                        /* 8px圆角，商务柔和 */
  /* 多层柔和阴影，提升悬浮层次感与高端质感 */
  box-shadow: 0 8px 32px rgba(16, 24, 32, 0.12),
              0 2px 8px rgba(16, 24, 32, 0.08),
              0 0 0 0.5px rgba(0, 0, 0, 0.04);
  padding: 12px 0;                           /* 上下12px内边距 */
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
  z-index: 10001;                            /* 确保浮于页面所有内容之上 */
}

/* 透明缓冲热区：填补下拉菜单与父导航之间的10px间隙
   鼠标从主菜单滑向子菜单时经过此区域，下拉框不会闪烁消失 */
.nav-dropdown::before {
  content: '';
  position: absolute;
  top: -10px;                                /* 向上延伸10px覆盖间隙 */
  left: 0;
  right: 0;
  height: 10px;
  background: transparent;                   /* 完全透明，不可见但可交互 */
}

.nav-list > li:hover .nav-dropdown,
.nav-list > li:focus-within .nav-dropdown {
  opacity: 1;
  visibility: visible;
  /* 不改变transform，下拉框保持原位，不再向上吸附 */
}

/* 键盘 Tab 导航：下拉菜单内的链接可聚焦 */
.nav-list > li > a:focus {
  outline: 2px solid var(--color-gold);
  outline-offset: 2px;
}

/* ===== 下拉菜单子项 ===== */
.nav-dropdown li a {
  display: block;
  padding: 0 20px;                           /* 左右20px内边距 */
  line-height: 40px;                         /* 行高40px */
  font-size: 0.875rem;
  color: var(--color-primary-dark);          /* 深海军蓝文字 */
  white-space: nowrap;
  transition: background 0.2s ease;
  position: static;                          /* 移除旧有相对定位（左金条不再需要） */
}
/* 移除旧的左侧金色竖条效果 */
.nav-dropdown li a::before {
  display: none;
}
/* hover：仅背景变为浅米黄色，文字颜色不变 */
.nav-dropdown li a:hover {
  background: #f8f5ee;                       /* 浅米黄色背景高亮 */
  color: var(--color-primary-dark);          /* 文字颜色保持不变 */
  padding-left: 20px;                        /* 不再向右位移，保持对齐 */
}

/* ===== 下拉菜单分类标签 ===== */
.nav-dropdown .dropdown-section-label {
  display: block;
  padding: 6px 20px 4px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-gold);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  pointer-events: none;
}

/* ===== 下拉菜单分隔线 ===== */
.nav-dropdown .dropdown-divider {
  height: 1px;
  margin: 4px 20px;
  background: var(--color-border);
  pointer-events: none;
}
/* ===== 导航右侧CTA按钮 ===== */
.nav-cta {
  flex-shrink: 0;
  margin-left: 20px;
}
.nav-cta .btn-primary {
  background: var(--color-primary);
  color: #fff;
  padding: 10px 24px;
  border-radius: var(--radius-full);
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: all var(--transition-normal);
}
.nav-cta .btn-primary:hover {
  background: var(--color-primary-light);
}
/* ===== 移动端汉堡菜单 ===== */
.nav-mobile-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  z-index: 1002;
}
.nav-mobile-toggle span {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--color-primary);
  border-radius: 2px;
  transition: all var(--transition-normal);
  transform-origin: center;
}
/* ---- 响应式：四级渐进收缩，避免导航挤压/折行/隐藏 ---- */

/* 1200px：第一级缩窄 — 减小左右间距，字号微降 */
@media (max-width: 1200px) {
  .nav-list > li > a {
    padding: 0 11px;
    font-size: 0.85rem;
  }
  .nav-cta {
    margin-left: 12px;
  }
}

/* 1100px：第二级缩窄 — 进一步压缩间距和字号 */
@media (max-width: 1100px) {
  .nav-list {
    gap: 2px;
  }
  .nav-list > li > a {
    padding: 0 8px;
    font-size: 0.8rem;
  }
  .nav-cta .btn-primary {
    padding: 10px 14px;
    font-size: 0.8rem;
  }
  .nav-logo .logo-title {
    font-size: 1.05rem;
  }
  .nav-logo .logo-icon {
    width: 38px;
    height: 38px;
  }
}

/* 1024px：第三级缩窄 — 顶栏字号缩小（高度保持36px不变），导航最大化压缩 */
@media (max-width: 1024px) {
  /* ✅ 修复：顶栏保持固定36px高度 + sticky定位，只缩小内部字号间距 */
  .top-bar {
    font-size: 0.7rem;
    /* 不改变 height / position / line-height，粘性定位链完整 */
  }
  .top-bar-right {
    gap: 12px;
  }
  .top-bar-right a {
    font-size: 0.7rem;
  }
  .top-bar-right .divider {
    height: 12px;
  }
  /* 粘性导航偏移保持：顶栏始终36px，主导航固定在顶栏下方 */
  html.is-scrolled .main-nav {
    top: var(--topbar-height);               /* 36px，紧贴顶栏下方 */
  }
  html.is-scrolled .breadcrumb {
    top: calc(var(--nav-height) + var(--topbar-height));
  }
  .nav-list {
    gap: 0;
  }
  .nav-list > li > a {
    padding: 0 6px;
    font-size: 0.78rem;
  }
  .nav-cta .btn-primary {
    padding: 8px 12px;
    font-size: 0.78rem;
  }
  .nav-logo .logo-icon {
    width: 34px;
    height: 34px;
    font-size: 1rem;
  }
  .nav-logo .logo-title {
    font-size: 0.9rem;
  }
  .nav-logo .logo-subtitle {
    font-size: 0.55rem;
  }
}

/* 860px：第四级 — 切换汉堡菜单，PC导航项全部收入抽屉 */
@media (max-width: 860px) {
  /* ✅ 修复：顶栏保持36px + sticky，与白色导航栏一起常驻 */
  .top-bar {
    font-size: 0.65rem;
    /* 不改变 height / position / line-height */
  }
  .top-bar .container {
    padding: 0 12px;
  }
  .top-bar-right {
    gap: 8px;
  }
  .top-bar-right a {
    font-size: 0.65rem;
  }
  .top-bar-right .divider {
    height: 10px;
  }
  /* 粘性导航双层常驻：顶栏36px + 主导航紧跟其下 */
  html.is-scrolled .main-nav {
    top: var(--topbar-height);
  }
  html.is-scrolled .breadcrumb {
    top: calc(var(--nav-height) + var(--topbar-height));
  }

  .nav-mobile-toggle {
    display: flex;
  }
  .nav-list {
    display: none;              /* 桌面菜单在移动端完全隐藏，改用抽屉 */
  }
  .nav-cta {
    display: none;
  }
  /* 恢复 logo 可读尺寸（抽屉模式下 logo 仍显示在主导航栏） */
  .nav-logo .logo-icon {
    width: 36px;
    height: 36px;
    font-size: 1.1rem;
  }
  .nav-logo .logo-title {
    font-size: 1rem;
  }
  .nav-logo .logo-subtitle {
    font-size: 0.6rem;
  }
}

/* 400px：极小屏 — 顶栏最紧凑字号，高度保持36px不变 */
@media (max-width: 400px) {
  .top-bar {
    font-size: 0.58rem;
    /* 不改变 height / position / line-height */
  }
  .top-bar .container {
    padding: 0 8px;
  }
  .top-bar-right {
    gap: 4px;
  }
  .top-bar-right a {
    font-size: 0.58rem;
  }
  .top-bar-right .divider {
    height: 8px;
  }
}

/* ============================================
   移动端右侧滑出抽屉（独立于桌面导航）
   抽屉始终存在于DOM，通过CSS transform控制显隐
   无头部Logo，菜单直接从第一条导航开始
   高度自适应内容，底部不留白
   ============================================ */

/* ----- 遮罩层 ----- */
.drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: rgba(0, 0, 0, 0.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  -webkit-tap-highlight-color: transparent;   /* 消除移动端点击高亮 */
}
.drawer-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

/* ----- 抽屉容器（精致收窄宽度，高度自适应内容，底部紧贴最后一项） ----- */
.mobile-drawer {
  position: fixed;
  top: 10px;                                   /* 距顶部微量留白 */
  right: 10px;                                 /* 距右侧微量留白 */
  z-index: 9999;
  width: 150px;                                /* 收窄：贴字，刚好容纳菜单/二级字体 */
  max-width: 72vw;                             /* 移动端最多72vw，窄屏不挤压 */
  max-height: calc(100vh - 20px);              /* 最大高度不超出屏幕 */
  max-height: calc(100dvh - 20px);
  background: #fff;
  /* 不使用flex，让高度自然跟随内容；内容超长时由max-height+overflow约束 */
  transform: translateX(calc(100% + 20px));    /* 默认隐藏在右侧（含间距） */
  transition: transform 0.3s ease;
  box-shadow: -4px 0 36px rgba(16, 24, 32, 0.18);
  border-radius: 8px;                          /* 保留圆角，商务简约 */
  overflow: hidden;                            /* 圆角裁边 + 超长内容由内部nav滚动 */
}
.mobile-drawer.show {
  transform: translateX(0);
}

/* ----- X 关闭按钮（独立置于顶部右上角，在圆角容器内） ----- */
.drawer-close {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 10;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--color-text-secondary);
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}
.drawer-close:hover {
  background: rgba(148, 120, 73, 0.1);
  color: var(--color-primary);
}

/* ----- 抽屉菜单滚动区（隐藏滚动条，内容超max-height时滚动） ----- */
.drawer-nav {
  overflow-y: auto;
  max-height: inherit;                         /* 继承父级max-height约束 */
  padding-top: 40px;                           /* 为X按钮留出紧凑空间 */
  /* 隐藏滚动条：兼容Edge、Chrome、360 */
  scrollbar-width: none;                       /* Firefox */
  -ms-overflow-style: none;                    /* IE/Edge 旧版 */
}
.drawer-nav::-webkit-scrollbar {
  display: none;                               /* Chrome/Safari/新Edge/360 */
}

/* ----- 菜单列表 ----- */
.drawer-menu {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* ----- 父菜单项外容器（细金色分割线） ----- */
.drawer-item {
  border-bottom: 1px solid var(--color-gold);  /* 金色分割线，固定在父级底部 */
}

/* ----- 父菜单链接（深蓝加粗，清晰可读，统一左对齐） ----- */
.drawer-parent {
  display: flex;
  align-items: center;
  justify-content: flex-start;                 /* 强制左对齐 */
  width: 100%;
  height: 46px;                                /* 行高46px，紧凑精致 */
  padding: 0 12px;                             /* 左右内边距缩减至12px（贴字） */
  font-size: 16px;                             /* 字号略缩小但清晰可读 */
  font-weight: 700;                            /* 加粗 */
  color: var(--color-primary-dark);            /* 深灰蓝文字 */
  background: #fff;
  border: none;
  cursor: pointer;
  text-align: left;                            /* 文字左对齐 */
  text-decoration: none;
  transition: background 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}
.drawer-parent:hover,
.drawer-parent:active {
  background: rgba(148, 120, 73, 0.06);        /* 金色浅底色hover反馈 */
}

/* 展开状态：父菜单行高亮浅米黄色调（与PC下拉hover一致） */
.drawer-item.open > .drawer-parent,
.drawer-item.open > a.drawer-parent {
  background: #f8f5eb;
  color: var(--color-primary-dark);
}

/* ----- 金色圆点展开指示器（替代箭头，紧贴右边缘） ----- */
.drawer-arrow {
  display: inline-block;
  margin-left: auto;                           /* 推到最右侧 */
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-gold);              /* 金色实心圆点 */
  flex-shrink: 0;
  transition: background 0.25s ease, transform 0.25s ease;
}
/* 展开时圆点颜色加深 */
.drawer-item.open > .drawer-parent .drawer-arrow,
.drawer-item.open > a.drawer-parent .drawer-arrow {
  background: var(--color-gold-dark);
}

/* ----- 子菜单容器（默认收起，展开时在父菜单正下方） ----- */
.drawer-submenu {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 0;
  overflow: hidden;                            /* 子菜单绝不溢出抽屉容器 */
  /* 平滑展开/收起动画，ease-out 收尾不生硬 */
  transition: max-height 0.35s ease-out;
  background: #f8f5eb;                         /* 浅米黄色，与PC下拉hover背景统一 */
}
.drawer-item.open > .drawer-submenu {
  max-height: 600px;                           /* 足够容纳所有子项 */
}

/* ----- 子菜单项（向左缩进，字体小于父级，与PC下拉统一样式） ----- */
.drawer-submenu li {
  border-bottom: 1px solid rgba(148, 120, 73, 0.15);  /* 子项间浅金色分割 */
}
.drawer-submenu li:last-child {
  border-bottom: none;                         /* 最后一项无分割线 */
}
.drawer-submenu a {
  display: flex;
  align-items: center;
  height: 40px;                                /* 行高40px，与PC下拉子菜单统一 */
  padding: 0 16px 0 34px;                      /* 左侧缩进18px（16→34，比父级多18） */
  font-size: 14px;                             /* 字号0.875rem，与PC一致 */
  font-weight: 400;
  color: var(--color-primary-dark);            /* 深海军蓝文字，与PC一致 */
  text-decoration: none;
  text-align: left;                            /* 强制左对齐 */
  transition: background 0.2s ease;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
/* hover：浅米黄背景高亮，与PC下拉hover完全一致 */
.drawer-submenu a:hover {
  background: rgba(148, 120, 73, 0.12);
  color: var(--color-primary-dark);            /* 文字颜色不变 */
}
/* click/active：背景加深，还原PC端点击反馈 */
.drawer-submenu a:active {
  background: rgba(148, 120, 73, 0.18);
}

/* ----- 当前页面激活项高亮 ----- */
.drawer-parent.active {
  color: var(--color-primary);
}
.drawer-submenu a.active {
  color: var(--color-primary);
  font-weight: 600;
}

/* ============================================
   滚动粘性导航 — 三层联动
   ============================================ */

/* 占位容器：补偿固定定位脱离文档流的高度 */
.nav-placeholder {
  display: none;
  width: 100%;
}

/* ---- 滚动超过顶栏高度后 ---- */

/* 顶栏固定悬浮（不再折叠隐藏） */

/* 主导航栏固定悬浮 */
html.is-scrolled .main-nav {
  position: fixed;
  top: var(--topbar-height);
  left: 0;
  right: 0;
  width: 100%;
  box-shadow: 0 4px 24px rgba(26, 36, 54,0.15);
}

/* 面包屑固定悬浮（紧贴主导航下方） */
html.is-scrolled .breadcrumb {
  position: fixed;
  top: calc(var(--nav-height) + var(--topbar-height));
  left: 0;
  right: 0;
  width: 100%;
  z-index: 999;
  box-shadow: 0 2px 12px rgba(26, 36, 54,0.08);
}

/* 占位展开：补偿主导航+面包屑脱离流后的高度 */
html.is-scrolled .nav-placeholder {
  display: block;
}

/* 有面包屑时占位高度 = nav高度 + 面包屑高度 */
html.is-scrolled .nav-placeholder.has-breadcrumb {
  height: calc(var(--nav-height) + 48px);
}

/* 无面包屑时占位高度 = nav高度 */
html.is-scrolled .nav-placeholder:not(.has-breadcrumb) {
  height: var(--nav-height);
}
