/**
 * 手机端 / 窄屏专用页面布局（独立样式文件）
 * 说明：与桌面端共用同一套页面结构与数据，只覆盖 ≤900px 的版式，
 * 避免另建模板造成功能与内容不同步。加载顺序 style.css → mobile.css。
 * ≤640px 再叠加一层「紧凑」规则，适配常见手机宽度。
 */

/* 手机顶栏快捷入口：默认隐藏，只在 ≤900px 的手机 / 窄屏版式里放行，桌面导航保持原样 */
.m-head-follow, .header-actions > a.m-head-profile { display: none; }

/* 公告通知 + 荣誉榜的「新位置」：默认隐藏，只在手机端显示（见文件末尾第五节） */
.home-notice-mobile { display: none; }

/* ======================= 一、移动版基础与右上角下拉菜单 ======================= */
@media (max-width: 900px) {
  .header-inner { height: 58px; gap: 6px; }
  .brand { gap: 6px; }
  /* 后台上传的是图片 logo 时也要压到和默认 SVG 一样宽，避免顶栏四个元素挤不下 */
  .brand-mark { width: 30px; height: 30px; }
  .brand-mark svg { width: 29px; height: 29px; }
  .brand-text strong { font-size: 13.5px; }
  .brand-text small { display: none; }
  .header-actions { margin-left: auto; gap: 5px; }
  /* 登录、投稿、头像、后台入口全部收进右上角下拉菜单，只额外放行「个人中心」 */
  .header-actions > a { display: none; }
  /* 两个顶栏入口做成一组等高胶囊：实心青绿 + 淡蓝描边，配图标、内高光与按下反馈 */
  .m-head-ico { flex: 0 0 auto; display: block; }
  .header-actions > a.m-head-profile {
    display: inline-flex; align-items: center; justify-content: center; gap: 3px;
    height: 29px; padding: 0 8px;
    border: 1px solid #d7e2f8; border-radius: 999px;
    background: linear-gradient(180deg, #fff, #f1f6ff);
    color: var(--primary); font-size: 12px; font-weight: 700; line-height: 1;
    white-space: nowrap; box-shadow: 0 2px 6px rgba(27, 58, 143, .06);
  }
  button.m-head-follow {
    display: inline-flex; align-items: center; justify-content: center; gap: 3px;
    height: 29px; padding: 0 9px; border: 0; border-radius: 999px;
    background: linear-gradient(135deg, #0aa88f 0%, #17bfa5 55%, #2dd6bd 100%);
    color: #fff; font-size: 12px; font-weight: 700; line-height: 1;
    white-space: nowrap; cursor: pointer;
    box-shadow: 0 3px 9px rgba(13, 168, 145, .26), inset 0 1px 0 rgba(255, 255, 255, .32);
    -webkit-tap-highlight-color: transparent;
  }
  button.m-head-follow .m-head-ico { opacity: .95; }
  button.m-head-follow:active,
  .header-actions > a.m-head-profile:active {
    transform: translateY(1px); box-shadow: 0 1px 4px rgba(13, 168, 145, .18);
  }
  .header-actions > a.m-head-profile:active { background: #e8f0ff; }

  .mobile-toggle {
    display: grid; place-items: center; width: 34px; height: 34px; padding: 0;
    border: 1px solid var(--line); border-radius: 10px; background: #fff;
    color: var(--primary); font-size: 17px; line-height: 1; cursor: pointer;
  }
  .mobile-toggle.open { background: #eaf1ff; border-color: #cdd9ef; }

  /* 下拉面板：固定在右上角，浮于页面之上，不占文档流 */
  body.front-body > .mobile-nav {
    display: none; position: fixed; top: 62px; right: max(10px, env(safe-area-inset-right));
    left: auto; width: min(280px, calc(100vw - 20px)); max-height: calc(100vh - 76px);
    overflow-y: auto; z-index: 60; box-sizing: border-box;
    flex-direction: column; gap: 1px; padding: 10px;
    background: #fff; border: 1px solid var(--line); border-radius: 14px;
    box-shadow: 0 18px 46px rgba(12, 30, 70, .22);
  }
  body.front-body > .mobile-nav.open { display: flex; }
  .mobile-nav a { padding: 9px 10px; border-bottom: 0; border-radius: 8px; font-size: 14px; }
  .mobile-nav a:hover, .mobile-nav a.active { background: #eaf1ff; color: var(--primary); font-weight: 700; }
  .mnav-search { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; padding: 4px 6px 4px 10px; background: var(--soft); border: 1px solid var(--line); border-radius: 9px; }
  .mnav-search input { flex: 1; min-width: 0; border: 0; background: transparent; outline: 0; font-size: 13px; }
  .mnav-search button { border: 0; background: transparent; color: var(--primary); font-size: 18px; cursor: pointer; }
  .mnav-label { padding: 8px 10px 3px; font-size: 11px; letter-spacing: 1px; font-weight: 700; color: var(--light); }

  /* 首屏：隐藏纯装饰的浮动卡片组，正文占满宽度 */
  .hero { padding: 18px 0 10px; }
  .hero-visual { display: none; }
  .hero-badge { margin-bottom: 12px; padding: 4px 10px; font-size: 11px; }
  .hero h1 { font-size: clamp(27px, 8vw, 34px); margin-bottom: 10px; }
  .hero-desc { font-size: 13.5px; line-height: 1.65; margin-bottom: 14px; }
  .hero-actions { gap: 8px; margin-bottom: 12px; }
  .hero-actions .btn-lg { padding: 9px 14px; font-size: 13px; border-radius: 10px; }
  .hero-search { padding: 3px 3px 3px 10px; border-radius: 11px; }
  .hero-search input { font-size: 13px; padding: 8px 6px; }
  .hero-hot { margin-top: 8px; gap: 8px; font-size: 11.5px; }

  /* 五项统计：强制一行，紧凑排布 */
  .stat-strip { display: flex; flex-wrap: nowrap; align-items: stretch; gap: 0; padding: 11px 4px; border-radius: 12px; }
  .stat-strip > div { flex: 1 1 0; min-width: 0; padding: 0 2px; border-right: 1px solid var(--line); }
  .stat-strip > div:last-child { border-right: 0; }
  .stat-strip strong { font-size: 17px; line-height: 1.25; }
  .stat-strip span { display: block; font-size: 10px; line-height: 1.3; white-space: nowrap; }

  /* 公众号窄条：图标 + 文字 + 小按钮保持同一行 */
  .oa-strip { flex-wrap: nowrap; gap: 9px; margin-top: 12px; padding: 8px 10px; border-radius: 12px; }
  .oa-ico { flex: 0 0 30px; width: 30px; height: 30px; border-radius: 9px; }
  .oa-ico svg { width: 18px; height: 18px; }
  .oa-text { flex: 1; min-width: 0; flex-direction: column; align-items: flex-start; gap: 1px; }
  .oa-text strong { font-size: 13px; }
  .oa-text span { font-size: 10.5px; line-height: 1.35; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .oa-btn { width: auto; flex: 0 0 auto; padding: 6px 11px; font-size: 12px; border-radius: 8px; }
  .oa-btn span { display: none; }

  /* 二维码图片弹窗：始终浮在网页上一层，居中覆盖，不进入文档流 */
  body.front-body > .oa-mask {
    position: fixed; inset: 0; z-index: 9999; display: flex; align-items: center; justify-content: center;
    padding: 16px; box-sizing: border-box; background: rgba(12, 25, 55, .62);
    -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
  }
  .oa-modal { width: min(300px, calc(100vw - 36px)); padding: 22px 18px 18px; }
  .oa-qr { width: 180px; height: 180px; }
  body.front-body > .wb-toast { position: fixed; z-index: 10000; }

  /* 公告通知 / 优秀教师荣誉榜：手机端各只显示 2 条，其余走「更多」 */
  .notice-box > a:nth-of-type(n+3) { display: none; }
  .honor-box .honor-row:nth-of-type(n+3) { display: none; }

  /* 筛选区：搜索整行，学科 / 分类两个选择框并排，排序另起一行 */
  .filter-bar { padding: 10px 12px; }
  .filter-tools { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 0; padding-top: 0; border-top: 0; }
  .filter-tools > form:first-child { grid-column: 1 / -1; }
  .filter-tools .inline-search { min-width: 0; }
  .filter-tools .inline-search input { min-width: 0; width: 100%; flex: 1; font-size: 12.5px; }
  .inline-search.subj-filter select, .inline-search.cat-filter select { width: 100%; min-width: 0; padding: 7px 8px; font-size: 12.5px; }
  .sort-group { grid-column: 1 / -1; justify-content: flex-start; gap: 2px; }
  .sort-group a { padding: 5px 10px; font-size: 12px; }
  .filter-tools.single { grid-template-columns: 1fr; }
  .filter-tools.single > .cat-filter select { width: 100%; }
}

/* ======================= 二、手机窄屏紧凑排版 ======================= */
@media (max-width: 640px) {
  .container { width: calc(100% - 20px); }
  .main-wrap { padding-top: 12px; padding-bottom: 22px; }
  .section { margin-top: 20px; }
  /* 标题与「更多」同一行，省掉竖排时额外占的一行 */
  .section-head { flex-direction: row; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
  .section-head h2 { font-size: 18px; margin: 0; }
  .section-head p { display: none; }
  .section-head .more-link { font-size: 12px; white-space: nowrap; }
  .kicker { font-size: 10px; letter-spacing: 1.6px; margin-bottom: 3px; }
  .two-col { gap: 18px; }
  .btn { padding: 8px 13px; font-size: 13px; }
  .btn-lg { padding: 10px 16px; font-size: 14px; }

  .page-hero { padding: 14px 0 16px; margin-bottom: 14px; }
  .page-hero h1 { font-size: 21px; }
  .page-hero p { font-size: 12px; }
  .detail-card, .article-card, .card-block, .learn-main { padding: 16px; }
  .result-line { font-size: 12px; margin: 10px 0; }

  /* 四步路径 2×2，比四行竖排更紧凑 */
  .path-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .path-card { padding: 13px; }
  .path-card h3 { font-size: 14px; margin: 6px 0 4px; }
  .path-card p { font-size: 11.5px; line-height: 1.55; }
  .path-card b { font-size: 11.5px; }
  .path-no { font-size: 11px; }
  .path-ico { font-size: 20px; }

  /* 卡片紧凑规则统一放在文件末尾的 ≤900px 块，避免重复覆盖 */
  .course-row { padding: 10px 0; }
  .course-cover { width: 42px; height: 42px; flex: 0 0 42px; }

  .notice-box, .honor-box { padding: 6px 12px; }
  .notice-box a { padding: 9px 0; font-size: 13px; }
  .honor-box { margin-top: 10px; padding-top: 12px; }
  .honor-box h3 { font-size: 14px; }
  .honor-row { font-size: 12.5px; padding: 6px 0; }

  .cta-band { margin-top: 24px; padding: 18px; }
  .cta-band h2 { font-size: 17px; }
  .cta-band p { font-size: 12px; }
  .warning-wrap { margin: 14px 0; }
  .achievement-strip { padding: 16px; }

  .site-footer .footer-inner { padding: 22px 0 12px; gap: 14px; }
  .footer-links { gap: 6px 12px; }
  .footer-beian { padding: 10px 0 18px; font-size: 11px; }
}

/* 超窄屏（≤360px）：统计与路径进一步压缩，保证不横向溢出 */
@media (max-width: 360px) {
  .stat-strip { padding: 9px 2px; }
  .stat-strip strong { font-size: 15px; }
  .stat-strip span { font-size: 9px; }
  .hero-actions .btn-lg { padding: 8px 10px; font-size: 12px; }
  .oa-text span { font-size: 10px; }
  .oa-btn { padding: 6px 8px; font-size: 11px; }
  /* 顶栏四段内容在超窄屏继续收紧：收掉图标、压小内边距，保证一行放得下 */
  .brand-text strong { font-size: 12.5px; }
  .m-head-ico { display: none; }
  button.m-head-follow { padding: 0 7px; font-size: 11.5px; }
  .header-actions > a.m-head-profile { padding: 0 6px; font-size: 11.5px; }
  .mobile-toggle { width: 30px; height: 30px; }
}

/* ======================= 三、手机端卡片紧凑化 =======================
   桌面提示词卡片有 min-height:190px，正文段落还有 flex:1 把中间撑开；
   手机上会显得又高又空。这里去掉下限与弹性撑开，并统一收紧卡片内部间距。 */
@media (max-width: 900px) {
  .prompt-grid, .case-grid, .tool-grid { gap: 10px; align-items: start; }

  .prompt-card, .tool-card { min-height: 0; padding: 12px 13px; border-radius: 12px; }
  .pc-top { gap: 5px; margin-bottom: 8px; }
  .prompt-card .chip, .case-body .chip, .tool-card .chip { padding: 2px 8px; font-size: 11px; }
  .prompt-card h3 { font-size: 14.5px; line-height: 1.4; margin: 0 0 5px; }
  .prompt-card > p { flex: 0 0 auto; font-size: 11.5px; line-height: 1.55; margin: 0 0 8px; }
  .pc-preview { font-size: 11.5px; padding: 7px 9px; margin-bottom: 8px; line-height: 1.5; }
  .pc-foot { padding-top: 7px; font-size: 11px; }

  .case-card { border-radius: 12px; }
  .case-cover { width: 62px; gap: 3px; }
  .case-cover i { font-size: 16px; letter-spacing: 1px; }
  .case-cover small { font-size: 9.5px; }
  .case-body { padding: 10px 12px; }
  .case-body h3 { font-size: 14px; line-height: 1.4; margin: 5px 0 4px; }
  .case-body p { font-size: 11.5px; line-height: 1.5; margin: 0 0 7px; }
  .case-meta { font-size: 10.5px; }
}

/* ======================= 四、手机端首屏精简版式 =======================
   首屏只保留标题 / 两个按钮 / 搜索框 / 热门词 / 五项统计：
   徽标、说明文字、公众号窄条在手机上不再占位，关注入口改由顶栏按钮承担。
   桌面端仍是完整首屏，不受本节影响；需要恢复时删掉本节即可。 */
@media (max-width: 900px) {
  .hero-badge, .hero-desc, .oa-strip { display: none; }
  .hero { padding: 14px 0 8px; }
  .hero h1 { margin-bottom: 12px; }
  .hero-actions { margin-bottom: 12px; }
  .hero-hot { margin-top: 8px; }
  .stat-strip { margin-top: 12px; }
}

/* ======================= 五、手机端内容顺序 =======================
   把「公告通知 + 优秀教师荣誉榜」从「最新学习课程」下方移到「实战案例」
   之后、投稿 CTA 之前。home.php 把同一份 HTML 片段输出两处，靠这里
   切换显示，桌面端首页布局与内容位置完全不变。 */
@media (max-width: 900px) {
  .home-notice-desktop { display: none; }
  .home-notice-mobile { display: block; }
}

/* ======================= 六、手机端搜索结果行 =======================
   桌面端 .search-row 是「类型标签 | 标题+描述 | 分类 | 箭头」四列横排，
   375px 下中间文字列只剩 100px 出头，标题与描述会被挤成竖条。
   这里让文字块换到第二行并撑满整行宽度，标签 / 分类 / 箭头留在上面
   一行：文字行变长、折行明显减少。仅 ≤900px 生效，桌面端保持原样。 */
@media (max-width: 900px) {
  .search-rows { border-radius: 12px; }
  .search-row {
    flex-wrap: wrap; align-items: flex-start;
    gap: 7px 10px; padding: 12px 14px; font-size: 14px;
  }
  .sr-type { width: auto; flex: none; padding: 2px 8px; font-size: 11px; white-space: nowrap; }
  /* 标题 + 描述独占一整行，宽度 = 卡片内容区，不再被分类和箭头挤压 */
  .search-row > span:nth-child(2) { flex: 1 1 100%; order: 3; min-width: 0; }
  .search-row > span:nth-child(2) b { font-size: 14px; line-height: 1.45; word-break: break-word; }
  .search-row > span:nth-child(2) small { margin-top: 3px; font-size: 12px; line-height: 1.55; }
  .sr-cat { font-size: 11px; white-space: nowrap; }
  .search-row > .arrow { margin-left: auto; align-self: center; }
}

/* ======================= 七、手机端四步卡片：文字挪到图标右侧 =======================
   桌面端是「图标在上、标题与描述在下」；手机 2×2 卡片很窄，图标右侧
   会空出一条。这里让图标左浮动，标题与描述自然环绕到图标右侧，
   描述的后续行仍可占满整行（不会整段被挤成竖条），链接回到下方整行。
   右上角的大编号会和挪上来的标题打架，手机端收掉；2×2 顺序本身已清楚。
   仅 ≤900px 生效，桌面端仍是原来的竖排卡片。 */
@media (max-width: 900px) {
  .path-ico {
    float: left; width: 32px; height: 32px;
    margin: 0 8px 3px 0; border-radius: 9px; font-size: 17px;
  }
  .path-card h3 { margin: 0 0 3px; font-size: 13.5px; line-height: 1.35; }
  .path-card p { margin: 0; font-size: 11.5px; line-height: 1.5; }
  .path-card b { clear: both; display: block; margin-top: 8px; font-size: 11.5px; }
  .path-no { display: none; }
}

/* ≤360px：图标再收一圈，尽量给右侧文字多留宽度（放在第七节之后以覆盖它） */
@media (max-width: 360px) {
  .path-ico { width: 28px; height: 28px; margin-right: 6px; font-size: 15px; }
  .path-card h3 { font-size: 12.5px; }
  .path-card p { font-size: 11px; }
}

/* ======================= 八、手机端最新学习课程：固定 3 行 =======================
   原版式把「分类 / 标题 / 描述」都塞在封面右侧的窄列里，375px 下
   标题折 2 行、描述折 2 行，一条课程要占 5 行高。这里改成 3 行网格：
   分类长条在第一行、标题与「N 分钟」在第二行、描述跨整行在第三行，
   标题和描述都单行省略，整体高度明显压缩。仅 ≤900px 生效，桌面端原样。 */
@media (max-width: 900px) {
  .course-list { gap: 8px; }
  .course-row {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) auto;
    grid-template-areas:
      "cover chip   chip"
      "cover title  min"
      "desc  desc   desc";
    column-gap: 10px; row-gap: 3px;
    align-items: center;
    padding: 10px 12px;
    border-radius: 12px;
  }
  /* 让分类 / 标题 / 描述直接参与网格，描述才能跨整行 */
  .course-info { display: contents; }
  .course-cover { grid-area: cover; width: 42px; height: 42px; font-size: 18px; }
  .course-info .chip { grid-area: chip; padding: 2px 10px; font-size: 11px; }
  .course-info strong {
    grid-area: title; min-width: 0;
    font-size: 13.5px; line-height: 1.35;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .course-info small {
    grid-area: desc; min-width: 0;
    font-size: 11.5px; line-height: 1.45;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .course-min { grid-area: min; font-size: 11px; white-space: nowrap; }
}
