
/* study999-guest-nav-v1
   未登录首页导航。登录后的四个个人按钮保持原样。
*/

/* 隐藏新增导航时，不允许其他样式将其强行显示。 */
#study999-guest-nav[hidden] {
  display: none !important;
}

/* 用户登录后，不再显示未登录导航。 */
body.study999-logged-nav #study999-guest-nav {
  display: none !important;
}

/* 未登录时，用三个新按钮替代原来的顶部按钮。 */
body.study999-guest-nav-ready:not(.study999-logged-nav)
> header #home,

body.study999-guest-nav-ready:not(.study999-logged-nav)
> header #account,

body.study999-guest-nav-ready:not(.study999-logged-nav)
> header #logout {
  display: none !important;
}

/* 隐藏原来顶部另行生成的账户链接，防止重复显示。
   找回密码仍可从注册页面原有入口访问。 */
body.study999-guest-nav-ready:not(.study999-logged-nav)
> header #portal-links {
  display: none !important;
}

body.study999-guest-nav-ready:not(.study999-logged-nav)
> header a[href="/portal-recover.html"] {
  display: none !important;
}

/* 未登录：Logo 与名称保持原样，导航使用独立区域。 */
body.study999-guest-nav-ready:not(.study999-logged-nav)
> header {
  box-sizing: border-box;
  min-width: 0;
  flex-wrap: wrap;
}

/* 导航容器 */
body.study999-guest-nav-ready:not(.study999-logged-nav)
> header > nav {
  box-sizing: border-box;
  min-width: 0;
}

#study999-guest-nav {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: stretch;
  gap: 9px;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

#study999-guest-nav .study999-guest-btn {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;

  width: 100%;
  min-width: 0;
  min-height: 44px;

  margin: 0;
  padding: 9px 12px;

  border: 1px solid transparent;
  border-radius: 11px;

  font: 600 14px/1.3 system-ui, "Microsoft YaHei", sans-serif;
  white-space: nowrap;
  cursor: pointer;
}

#study999-guest-nav .study999-guest-btn svg {
  flex: none;
}

#study999-guest-nav .study999-guest-btn span {
  min-width: 0;
}

/* 课程库：蓝色 */
#study999-guest-nav .guest-library {
  color: #1d4ed8;
  background: #e9f3ff;
  border-color: #bfdbfe;
}

/* 注册／登录：绿色 */
#study999-guest-nav .guest-login {
  color: #047857;
  background: #ecfdf5;
  border-color: #a7f3d0;
}

/* 忘记密码：紫色 */
#study999-guest-nav .guest-recover {
  color: #6d28d9;
  background: #f5f3ff;
  border-color: #ddd6fe;
}

#study999-guest-nav .study999-guest-btn:hover {
  filter: brightness(.96);
}

#study999-guest-nav .study999-guest-btn:focus-visible {
  outline: 3px solid #93c5fd;
  outline-offset: 2px;
}

/* 手机端：第一行 Logo＋网站名，第二行三个导航按钮。 */
@media screen and (max-width: 720px) {

  body.study999-guest-nav-ready:not(.study999-logged-nav)
  > header {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    justify-content: flex-start !important;

    box-sizing: border-box !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;

    padding: 12px 14px !important;
    gap: 10px !important;
  }

  /* 使用原有 Logo，只限制手机端显示大小。 */
  body.study999-guest-nav-ready:not(.study999-logged-nav)
  > header img {
    width: auto;
    height: auto;
    max-width: 68px !important;
    max-height: 60px !important;
    object-fit: contain;
    flex-shrink: 0;
  }

  body.study999-guest-nav-ready:not(.study999-logged-nav)
  > header .study999-site-title {
    min-width: 0 !important;
    max-width: 100% !important;

    font-size: clamp(18px, 5vw, 25px) !important;
    line-height: 1.3 !important;
    white-space: normal !important;
    overflow-wrap: anywhere;
  }

  /* 将三个导航按钮放到品牌信息的下一行。 */
  body.study999-guest-nav-ready:not(.study999-logged-nav)
  > header > nav {
    display: block !important;
    flex: 0 0 100% !important;

    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;

    box-sizing: border-box !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  #study999-guest-nav {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;

    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;

    gap: 7px !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  #study999-guest-nav[hidden] {
    display: none !important;
  }

  /* 图标在上、文字在下，避免三个按钮并排时挤压文字。 */
  #study999-guest-nav .study999-guest-btn {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;

    width: 100% !important;
    min-width: 0 !important;
    min-height: 67px !important;

    margin: 0 !important;
    padding: 8px 3px !important;
    gap: 5px !important;

    font-size: clamp(11px, 3.1vw, 13px) !important;
    line-height: 1.25 !important;
    white-space: nowrap !important;
    text-align: center !important;
  }

  #study999-guest-nav .study999-guest-btn svg {
    width: 19px;
    height: 19px;
    flex: none;
  }
}
