/**
 * 片段：header.template.html（全站顶栏导航）
 */

/* ========== 1200px 以下：容器收窄 ========== */
@media screen and (max-width: 1200px) {
  #header {
    width: 100% !important;
    max-width: 100%;
    padding-left: 8px;
    padding-right: 8px;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
  }

  #top_nav_div table[width="1200"] {
    width: 100% !important;
    max-width: 1200px;
  }
}

/* ========== 1024px 以下：平板 / 移动主布局入口 ========== */
@media screen and (max-width: 1024px) {
  #header {
    width: 100% !important;
    height: auto !important;
    padding-left: 12px;
    padding-right: 12px;
    padding-bottom: 6px;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
  }

  #header .header-top-row {
    height: auto;
    min-height: 0;
  }

  #header #blank {
    display: none;
  }

  #header #top_time {
    width: 100% !important;
    height: auto !important;
    min-height: 36px;
    padding-top: 6px;
    padding-bottom: 6px;
    text-align: center;
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    -webkit-box-pack: center;
    -webkit-justify-content: center;
    justify-content: center;
    -webkit-flex-wrap: wrap;
    flex-wrap: wrap;
    -webkit-box-align: center;
    -webkit-align-items: center;
    align-items: center;
  }

  #header #top_time span {
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    -webkit-flex-wrap: wrap;
    flex-wrap: wrap;
    -webkit-box-pack: center;
    -webkit-justify-content: center;
    justify-content: center;
    -webkit-box-align: center;
    -webkit-align-items: center;
    align-items: center;
    line-height: 1.5;
  }

  #header #top_time a {
    display: inline-block;
    min-height: 36px;
    line-height: 36px;
    padding-left: 8px;
    padding-right: 8px;
    white-space: nowrap;
  }

  #header .header-middle-row {
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -webkit-flex-direction: column;
    flex-direction: column;
    -webkit-box-align: stretch;
    -webkit-align-items: stretch;
    align-items: stretch;
    width: 100%;
  }

  #header .header-logo-section {
    width: 100% !important;
    text-align: center;
    padding-top: 4px;
    padding-bottom: 8px;
  }

  #header .header-logo-section img {
    max-width: 360px;
    width: 100%;
    height: auto;
  }

  #header .header-search-section {
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    -webkit-box-pack: center;
    -webkit-justify-content: center;
    justify-content: center;
    -webkit-box-align: center;
    -webkit-align-items: center;
    align-items: center;
  }

  #header .search-form-container {
    width: 100% !important;
    max-width: 640px;
  }

  #header .search-input-container {
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    -webkit-box-flex: 1;
    -webkit-flex: 1;
    flex: 1;
    min-width: 0;
  }

  #header .search-button-container {
    margin-left: 8px;
  }

  #header #key {
    width: 100% !important;
    max-width: 100%;
    height: 40px !important;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
  }

  #header #search {
    width: 84px !important;
    min-width: 84px;
    height: 40px !important;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
  }

  #top_nav_div {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-bottom: 1px solid #51B9FF;
  }

  #top_nav_div table {
    width: auto !important;
    min-width: 100%;
    height: auto !important;
  }

  #top_nav_div table tr + tr {
    display: none;
  }

  #top_nav_div table td[width="150"] {
    width: auto !important;
    white-space: nowrap;
  }

  #top_nav_div .menu,
  #top_nav_div .menu:link,
  #top_nav_div .menu:visited,
  #top_nav_div .menu:hover,
  #top_nav_div .menu:active {
    width: auto !important;
    min-width: 88px;
    height: 46px !important;
    line-height: 46px !important;
    padding-left: 12px;
    padding-right: 12px;
    letter-spacing: 0 !important;
    text-align: center !important;
    white-space: nowrap;
    display: block;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
  }

  #top_nav_div #a1 {
    letter-spacing: 0 !important;
    text-align: center !important;
  }
}

/* ========== 768px 以下：手机布局 ========== */
@media screen and (max-width: 768px) {
  /* rem 换算基准：1rem = 16px */
  html {
    font-size: 16px;
  }

  /* 防止顶栏撑出横向滚动 */
  #header {
    max-width: 100%;
    overflow: hidden;
  }

  #top_nav_div {
    max-width: 100%;
  }

  /* ---------- 顶栏容器 ---------- */
  #header {
    width: 100% !important;
    height: auto !important;
    margin-left: auto;
    margin-right: auto;
    padding-left: 10px;
    padding-right: 10px;
    padding-bottom: 4px;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
  }

  #header .header-top-row {
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    width: 100%;
    height: auto;
    min-height: 0;
    -webkit-box-align: center;
    -webkit-align-items: center;
    align-items: center;
  }

  #header #blank {
    display: none;
  }

  /* 顶部工具链接：长者专区 / 简繁 / 个人中心 / 网站地图 */
  #header #top_time {
    width: 100% !important;
    height: auto !important;
    min-height: 32px;
    padding-top: 4px;
    padding-bottom: 4px;
    font-size: 0.9375rem;
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    -webkit-box-pack: center;
    -webkit-justify-content: center;
    justify-content: center;
    -webkit-flex-wrap: wrap;
    flex-wrap: wrap;
    -webkit-box-align: center;
    -webkit-align-items: center;
    align-items: center;
  }

  #header #top_time span {
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    -webkit-flex-wrap: wrap;
    flex-wrap: wrap;
    -webkit-box-pack: center;
    -webkit-justify-content: center;
    justify-content: center;
    -webkit-box-align: center;
    -webkit-align-items: center;
    align-items: center;
    line-height: 1.4;
  }

  #header #top_time a {
    display: inline-block;
    min-height: 32px;
    line-height: 32px;
    padding-left: 6px;
    padding-right: 6px;
    font-size: 0.9375rem;
    white-space: nowrap;
    touch-action: manipulation;
  }

  /* ---------- Logo + 搜索 ---------- */
  #top_middle {
    width: 100%;
    padding-left: 6%;
    padding-right: 6%;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
  }

  #header .header-middle-row {
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -webkit-flex-direction: column;
    flex-direction: column;
    -webkit-box-align: stretch;
    -webkit-align-items: stretch;
    align-items: stretch;
    width: 100%;
  }

  #header .header-logo-section {
    width: 100% !important;
    text-align: center;
    padding-top: 4px;
    padding-bottom: 6px;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
  }

  #header .header-logo-section img {
    width: 78%;
    max-width: 78%;
    height: auto;
  }

  #header .header-search-section {
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    padding-bottom: 6px;
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    -webkit-box-pack: center;
    -webkit-justify-content: center;
    justify-content: center;
    -webkit-box-align: center;
    -webkit-align-items: center;
    align-items: center;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
  }

  #header .header-search-section form {
    display: block;
    width: 100%;
    margin: 0;
    padding: 0;
  }

  #header .search-form-container {
    width: 88% !important;
    max-width: none;
    margin-left: auto;
    margin-right: auto;
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    -webkit-box-orient: horizontal;
    -webkit-box-direction: normal;
    -webkit-flex-direction: row;
    flex-direction: row;
    -webkit-box-align: center;
    -webkit-align-items: center;
    align-items: center;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
  }

  #header .search-input-container {
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    -webkit-box-flex: 1;
    -webkit-flex: 1;
    flex: 1;
    min-width: 0;
  }

  #header .search-button-container {
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    -webkit-flex-shrink: 0;
    flex-shrink: 0;
    margin-left: 6px;
  }

  /* 覆盖搜索框内联 width:296px */
  #header #key {
    width: 100% !important;
    max-width: 100%;
    height: 40px !important;
    font-size: 1rem;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
    -webkit-appearance: none;
    appearance: none;
    border-radius: 0;
  }

  /* 覆盖搜索按钮内联 width:85px */
  #header #search {
    width: 68px !important;
    min-width: 68px;
    height: 40px !important;
    font-size: 0.9375rem;
    padding-left: 0;
    padding-right: 0;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
    touch-action: manipulation;
  }

  /* 主导航横滑 */
  #top_nav_div {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-bottom: 1px solid #51B9FF;
  }

  #top_nav_div table {
    width: auto !important;
    min-width: 100%;
    height: auto !important;
    border-collapse: collapse;
  }

  /* 仅保留导航菜单行，收起下拉占位行 */
  #top_nav_div table tr + tr {
    display: none;
  }

  #top_nav_div table td[width="150"] {
    width: auto !important;
    padding-left: 0;
    padding-right: 0;
    white-space: nowrap;
    vertical-align: middle;
  }

  /* 覆盖 style.css .menu 固定宽高 + chcolor() 内联样式 + #a1 字间距 */
  #top_nav_div .menu,
  #top_nav_div .menu:link,
  #top_nav_div .menu:visited,
  #top_nav_div .menu:hover,
  #top_nav_div .menu:active {
    width: auto !important;
    min-width: 72px;
    height: 44px !important;
    min-height: 44px;
    line-height: 44px !important;
    padding-left: 8px;
    padding-right: 8px;
    letter-spacing: 0 !important;
    text-align: center !important;
    white-space: nowrap;
    font-size: 0.9375rem;
    display: block;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
    touch-action: manipulation;
  }

  #top_nav_div #a1 {
    letter-spacing: 0 !important;
    text-align: center !important;
  }
}

/* ========== 480px 以下：小屏手机（字号/高度继承 768px 档） ========== */
@media screen and (max-width: 480px) {
  #header {
    padding-left: 4px;
    padding-right: 4px;
  }

  #top_middle {
    padding-left: 4%;
    padding-right: 4%;
  }

  #header .header-logo-section img {
    width: 84%;
    max-width: 84%;
  }

  #header .search-form-container {
    width: 92% !important;
  }

  #header #top_time a {
    padding-left: 3px;
    padding-right: 3px;
  }

  #top_nav_div .menu,
  #top_nav_div .menu:link,
  #top_nav_div .menu:visited,
  #top_nav_div .menu:hover,
  #top_nav_div .menu:active {
    min-width: 60px;
    padding-left: 4px;
    padding-right: 4px;
  }
}
