/* ==========================================================
   portal.css · 门户首页样式
   ========================================================== */
.mh-portal {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

/* ---------- 头部 ---------- */
.mh-hero {
  background: linear-gradient(135deg, #2563eb 0%, #4f46e5 100%);
  color: #fff;
  padding: 34px 0 28px;
}

.mh-hero__inner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.mh-hero h1 {
  margin: 0 0 6px;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.mh-hero p {
  margin: 0;
  opacity: 0.9;
  font-size: 14.5px;
}

.mh-hero__login {
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.45);
  color: #fff;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 14px;
  white-space: nowrap;
}

.mh-hero__login:hover {
  background: rgba(255, 255, 255, 0.28);
}

/* 已登录：昵称 + 剩余天数 */
.mh-hero__login--user {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.22);
}

.mh-hero__who {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* v0.9.4：剩余天数小胶囊与「个人中心›」小框已去掉，顶栏只留头像+昵称 */

/* ---------- 年级切换 ---------- */
.mh-grades {
  display: flex;
  gap: 10px;
  margin: 22px 0 6px;
  flex-wrap: wrap;
}

.mh-grade {
  padding: 9px 22px;
  border-radius: 999px;
  border: 1px solid var(--mh-border-strong);
  background: #fff;
  font-size: 15px;
  color: var(--mh-text-soft);
  transition: all 0.15s ease;
}

.mh-grade.is-active {
  background: var(--mh-primary);
  border-color: var(--mh-primary);
  color: #fff;
  font-weight: 600;
}

/* 次级 tab（年级/册），样式更轻、更紧凑 */
.mh-grades--sub {
  margin-top: 10px;
  gap: 8px;
}

.mh-grades--sub .mh-grade {
  padding: 6px 16px;
  font-size: 13.5px;
  border-color: var(--mh-border);
  background: #f8fafc;
}

.mh-grades--sub .mh-grade.is-active {
  background: var(--mh-primary-soft);
  border-color: var(--mh-primary);
  color: var(--mh-primary-dark);
  font-weight: 600;
}

/* ---------- 章节 ---------- */
.mh-chapter {
  margin-top: 16px;
}

/* 章节标题是按钮（可折叠），所以重置掉浏览器默认样式 */
.mh-chapter__head {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin-bottom: 12px;
  padding: 12px 14px;
  font-family: inherit;
  text-align: left;
  background: var(--mh-card);
  border: 1px solid var(--mh-border);
  border-radius: var(--mh-radius);
  box-shadow: var(--mh-shadow);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.mh-chapter__head:hover {
  border-color: var(--mh-primary);
  background: #fbfdff;
}

.mh-chapter__head:focus-visible {
  outline: 2px solid var(--mh-primary);
  outline-offset: 2px;
}

.mh-chapter__arrow {
  flex: 0 0 auto;
  width: 18px;
  font-size: 13px;
  color: var(--mh-text-faint);
  transition: transform 0.18s ease;
}

.mh-chapter__head.is-collapsed .mh-chapter__arrow {
  transform: rotate(-90deg);
}

.mh-chapter__titlewrap {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex: 1 1 auto;
  min-width: 0;
  flex-wrap: wrap;
}

.mh-chapter__name {
  font-size: 17px;
  font-weight: 700;
  color: var(--mh-text);
}

.mh-chapter__count {
  font-size: 13px;
  color: var(--mh-text-faint);
}

.mh-chapter__free {
  flex: 0 0 auto;
  padding: 2px 8px;
  font-size: 11.5px;
  font-weight: 600;
  color: #047857;
  background: var(--mh-green-soft);
  border-radius: 999px;
}

/* ---------- 章节工具条（全部展开 / 收起） ---------- */
.mh-chapter-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 14px 0 4px;
  font-size: 13px;
}

.mh-chapter-toolbar__sep {
  color: var(--mh-border-strong);
}

.mh-chapter-toolbar__grow {
  flex: 1 1 auto;
}

.mh-chapter-toolbar__count {
  color: var(--mh-text-faint);
  font-size: 12.5px;
}

/* ---------- 搜索框 ---------- */
.mh-search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 18px 0 0;
  padding: 0 12px;
  height: 46px;
  background: var(--mh-card);
  border: 1.5px solid var(--mh-border);
  border-radius: 999px;
  box-shadow: var(--mh-shadow);
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.mh-search:focus-within {
  border-color: var(--mh-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.mh-search__icon {
  flex: 0 0 auto;
  font-size: 15px;
  opacity: 0.6;
}

.mh-search__input {
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  font-family: inherit;
  font-size: 15px;
  color: var(--mh-text);
  background: transparent;
  border: 0;
  outline: none;
  /* 去掉 Safari/Chrome 自带的搜索清空按钮，用我们自己的 */
  -webkit-appearance: none;
  appearance: none;
}

.mh-search__input::-webkit-search-decoration,
.mh-search__input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}

.mh-search__input::placeholder {
  color: var(--mh-text-faint);
}

.mh-search__clear {
  flex: 0 0 auto;
  display: none;
  width: 24px;
  height: 24px;
  padding: 0;
  font-size: 17px;
  line-height: 1;
  color: var(--mh-text-soft);
  background: #eef2f9;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}

.mh-search__clear.is-show {
  display: block;
}

.mh-search__clear:hover {
  background: #e2e8f3;
  color: var(--mh-text);
}

.mh-search__hint {
  margin: 10px 2px 0;
  font-size: 13px;
  color: var(--mh-text-soft);
  line-height: 1.7;
}

.mh-search__hint b {
  color: var(--mh-primary-dark);
}

.mh-search__hint.is-empty {
  color: #92400e;
}

.mh-search__tips {
  font-size: 12.5px;
  color: var(--mh-text-faint);
}

/* 搜索结果里的高亮片段 */
.mh-mod mark {
  padding: 0 2px;
  color: inherit;
  background: #fde68a;
  border-radius: 3px;
}

/* 搜索结果卡片上的面包屑 */
.mh-mod__crumb {
  margin: -2px 0 8px;
  font-size: 12px;
  color: var(--mh-primary);
}

.mh-modules--search {
  margin-top: 14px;
}

/* 空年级提示 */
.mh-empty-grade {
  margin-top: 18px;
  padding: 26px 20px;
  text-align: center;
  font-size: 14px;
  line-height: 1.9;
  color: var(--mh-text-soft);
  background: var(--mh-card);
  border: 1px dashed var(--mh-border-strong);
  border-radius: var(--mh-radius);
}

.mh-empty-grade b {
  color: var(--mh-text);
}

/* 年级标签里没有模块的那个，弱化显示但仍可点 */
.mh-grades .mh-grade.is-empty {
  color: var(--mh-text-faint);
}

.mh-modules {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

/* ---------- 模块卡片 ---------- */
.mh-mod {
  display: block;
  background: var(--mh-card);
  border: 1px solid var(--mh-border);
  border-radius: var(--mh-radius);
  padding: 16px 18px;
  box-shadow: var(--mh-shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  color: var(--mh-text);
}

.mh-mod:hover {
  transform: translateY(-2px);
  box-shadow: var(--mh-shadow-lg);
  border-color: var(--mh-primary);
  color: var(--mh-text);
}

/* 免费模块：左侧一条绿色细边，扫一眼就知道哪些能白看 */
.mh-mod.is-free {
  border-left: 3px solid var(--mh-green);
}

/* 到期后需要续期的模块：整块压暗，但仍可点进（进去看续期引导） */
.mh-mod.is-locked {
  background: #fbfcfe;
  box-shadow: none;
}

.mh-mod.is-locked .mh-mod__title,
.mh-mod.is-locked .mh-mod__desc {
  color: var(--mh-text-faint);
}

/* 标签：免费 / 需续期 */
.mh-tag--free {
  color: #047857 !important;
  background: var(--mh-green-soft) !important;
  font-weight: 600;
}

.mh-tag--lock {
  color: #b45309 !important;
  background: var(--mh-accent-soft) !important;
  font-weight: 600;
}

.mh-mod__title {
  font-size: 16.5px;
  font-weight: 700;
  margin: 0 0 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.mh-mod__desc {
  font-size: 13.5px;
  color: var(--mh-text-soft);
  margin: 0 0 12px;
  line-height: 1.65;
  min-height: 44px;
}

.mh-mod__meta {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* ---------- 难度星级（v0.9.1） ---------- */
.mh-mod__stars {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  line-height: 1;
  user-select: none;
}

.mh-star {
  font-style: normal;
  font-size: 13px;
  color: #d3dbe6; /* 未点亮的空心星 */
}

.mh-star.is-on {
  color: #f59e0b; /* 点亮的实心星（琥珀色，和「提高」等档位的暖色一致） */
}

.mh-mod__levelname {
  margin-left: 4px;
  font-size: 12px;
  color: var(--mh-text-faint);
}

/* ---------- 卡片收藏心形（v0.9.1） ---------- */
.mh-mod__fav {
  margin-left: auto; /* 推到卡片 meta 行的最右边 */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: #9aa7b8;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.1s;
}

.mh-mod__fav:hover {
  background: rgba(244, 63, 94, 0.08); /* 玫红底，暗示这是「喜欢」类操作 */
  color: #f43f5e;
}

.mh-mod__fav:active {
  transform: scale(0.86);
}

.mh-mod__fav.is-on {
  color: #f43f5e;
}

/* 锁定卡片上的心形随卡片一起淡化，但保证仍可点（游客点了去注册） */
.mh-mod.is-locked .mh-mod__fav {
  color: #b3becd;
}

/* 空状态占位卡片 */
.mh-mod--soon {
  border-style: dashed;
  background: #fbfcfe;
  box-shadow: none;
  cursor: default;
  color: var(--mh-text-faint);
}

.mh-mod--soon:hover {
  transform: none;
  box-shadow: none;
  border-color: var(--mh-border);
}

.mh-mod--soon .mh-mod__title {
  color: var(--mh-text-faint);
  font-weight: 600;
}

/* ---------- 页脚 ---------- */
.mh-footer {
  margin-top: 34px;
  padding: 20px 0 34px;
  text-align: center;
  font-size: 13px;
  color: var(--mh-text-faint);
  line-height: 1.8;
}

/* 页脚 ICP 备案号链接（工信部跳转），保证可点击且可见 */
.mh-footer a {
  color: var(--mh-primary, #2563eb);
  text-decoration: none;
  border-bottom: 1px solid currentColor;
}
.mh-footer a:hover { opacity: .8; }

/* ---------- 移动端 ---------- */
@media (max-width: 860px) {
  .mh-hero {
    padding: 24px 0 20px;
  }
  .mh-hero h1 {
    font-size: 21px;
  }
  .mh-hero__inner {
    flex-direction: column;
    align-items: stretch;
  }
  .mh-hero__login {
    align-self: flex-start;
  }
  .mh-modules {
    grid-template-columns: minmax(0, 1fr);
  }
  .mh-mod__desc {
    min-height: 0;
  }
}

/* ---------- v0.9.1 两级章节导航 ---------- */
/* 防护：任何加了 hidden 属性的元素必须真的消失，
   防止 display:grid/flex 这类作者样式压过 UA 的 display:none
   （此前手风琴"收起了却看不见收起"就是这个原因） */
[hidden] {
  display: none !important;
}

/* 章节列表行（首页第一层） */
.mh-chapter-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin-bottom: 10px;
  padding: 15px 16px;
  border: 1px solid var(--mh-line, #e3e9f2);
  border-radius: 12px;
  background: #fff;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}
.mh-chapter-row:hover {
  border-color: var(--mh-primary);
  box-shadow: 0 2px 10px rgba(37, 99, 235, 0.08);
}
.mh-chapter-row:active {
  transform: scale(0.995);
}
.mh-chapter-row__arrow {
  flex: 0 0 auto;
  font-size: 11px;
  color: var(--mh-primary);
}
.mh-chapter-row__name {
  font-weight: 700;
  font-size: 15px;
  color: var(--mh-text, #1e293b);
}
.mh-chapter-row__count {
  color: #8a95a6;
  font-size: 13px;
}
.mh-chapter-row__free {
  margin-left: auto;
  padding: 2px 9px;
  border-radius: 999px;
  background: #e8f7ef;
  color: #0f9960;
  font-size: 12px;
  font-weight: 600;
}
.mh-chapter-row__chevron {
  flex: 0 0 auto;
  margin-left: auto;
  color: #b3bdcc;
  font-size: 20px;
  line-height: 1;
}
/* 有免费角标时，箭头不再抢 margin-left:auto */
.mh-chapter-row__free + .mh-chapter-row__chevron {
  margin-left: 8px;
}

/* 返回章节列表 */
.mh-chapter-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
  padding: 7px 14px;
  border: 1px solid var(--mh-line, #e3e9f2);
  border-radius: 999px;
  background: #fff;
  font: inherit;
  font-size: 14px;
  color: #55617a;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.mh-chapter-back:hover {
  border-color: var(--mh-primary);
  color: var(--mh-primary);
}

/* 章节内页标题条（不可点，纯展示） */
.mh-chapter__head.is-static {
  cursor: default;
  margin-bottom: 16px;
  padding: 14px 16px;
  background: #f7faff;
  border: 1px solid #e3ecfb;
  border-radius: 12px;
}
.mh-chapter__head.is-static:hover {
  border-color: #e3ecfb;
  background: #f7faff;
}

/* 卡片红心旁的收藏人数（登录后可见，0 人时不显示） */
.mh-mod__fav-num {
  min-width: 14px;
  color: #94a3b8;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.mh-mod__fav.is-on + .mh-mod__fav-num {
  color: #f43f5e;
}

/* ---------- v0.9.3 右上角个人中心入口 ---------- */
.mh-hero__login--user {
  padding: 5px 14px 5px 5px;
}
.mh-hero__avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #fff;
  color: var(--mh-primary, #2563eb);
  font-weight: 800;
  font-size: 14px;
  flex: 0 0 auto;
}

/* 登录态按钮：昵称旁一个轻量箭头，提示可点进个人中心 */
.mh-hero__login--user .mh-hero__who::after {
  content: " ›";
  opacity: 0.7;
  font-weight: 400;
}
