/* 手机端版面规则（从 fmc-mobile-glass-nav.css 里抽出的**非底栏**部分，逐条原样保留）。
   底栏已迁到 assets/fmc-tabbar.*（见交接文档 §8.3）；这里只留与底栏无关的手机端版面：
   - 正文/页脚在固定底栏下的留白与隐藏
   - 电视报页的可见大标题
   - 历史海报墙 / 影片视频卡的横向滑动行
   历史：2026-12-01 从 fmc-mobile-glass-nav.css 拆出，选择器与取值未改动。 */
@media (max-width: 640px), (pointer: coarse) {
  html body:has(> footer.fmc-site-end) { padding-bottom: 20px !important; }
  html body:has(> footer.fmc-site-end) > footer { padding-bottom: 8px !important; }
}
/* 手机端 main 的 96px 底部内边距会在页脚前留一大块空白 */
@media (max-width: 640px), (pointer: coarse) {
  html body main,
  html body main.discovery-main { padding-bottom: 18px !important; }
}
/* TV 页手机端：把视觉隐藏的 h1 显示为大标题 */
@media (max-width: 640px), (pointer: coarse) {
  .discovery-tv > h1.sr-only {
    position: static !important;
    width: auto !important; height: auto !important;
    clip: auto !important; clip-path: none !important;
    overflow: visible !important;
    padding: 18px 20px 6px !important;
    font-size: 34px !important; line-height: 1.1 !important;
    font-weight: 700 !important; letter-spacing: -.02em !important;
  }
}
/* 手机端：完全隐藏页脚（含 FAQ / 宣言 / 语言等），只保留悬浮底栏 */
@media (max-width: 640px), (pointer: coarse) {
  html body > footer,
  html body:has(> footer.fmc-site-end) > footer { display: none !important; }
  html body:has(> footer.fmc-site-end) {
    display: block !important;
    min-height: 0 !important;
    padding-bottom: calc(env(safe-area-inset-bottom) + 12px) !important;
  }
  html body:has(> footer.fmc-site-end) > main { flex: none !important; }
}
/* 历史页手机端：海报墙改为横向滑动行（Apple TV 形态） */
@media (max-width: 640px), (pointer: coarse) {
  .fmc-history-wall { padding-bottom: 4px !important; }
  .fmc-history-wall-track {
    overflow-x: auto !important;
    overflow-y: hidden !important;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .fmc-history-wall-track::-webkit-scrollbar { display: none; }
  .fmc-history-wall-grid {
    display: flex !important;
    grid-template-columns: none !important;
    gap: 10px !important;
    padding: 0 20px 8px !important;
    width: max-content !important;
  }
  .fmc-history-wall-tile {
    flex: none !important;
    width: 42vw !important;
    max-width: 190px !important;
    scroll-snap-align: start;
  }
  .fmc-history-wall-tile img { width: 100% !important; height: auto !important; }
}
/* 浮钮避让底部导航条：播客 dock / 影片顶栏浮钮抬到胶囊栏之上 */
@media (max-width: 640px), (pointer: coarse) {
  .fmc-film-top { bottom: calc(84px + env(safe-area-inset-bottom)) !important; }
  .fmc-podcast-dock, .fmc-podcast-reopen { bottom: calc(84px + env(safe-area-inset-bottom)) !important; }
}
/* 片详情页手机端：大标题 + 视频卡片横向行（Apple TV 形态） */
@media (max-width: 640px), (pointer: coarse) {
  body.record-simple main h1,
  body.record-simple .fmc-film-hero-content h1 {
    font-size: 34px !important;
    line-height: 1.1 !important;
    letter-spacing: -.02em;
  }
  .fmc-video-grid {
    display: flex !important;
    grid-template-columns: none !important;
    gap: 10px !important;
    overflow-x: auto !important;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding: 0 20px 8px !important;
    scrollbar-width: none;
  }
  .fmc-video-grid::-webkit-scrollbar { display: none; }
  .fmc-video-card {
    flex: none !important;
    width: 78vw !important;
    max-width: 340px !important;
    scroll-snap-align: start;
  }
}

/* 海报行左对齐（2026-12-01）
   症状：首张海报比上方小标题（.fca-row h3 / .fca-year h4）少缩进 20px，
   直接贴死在容器左边；历史页 /events 尤甚（容器本身还有 16px 内缩）。
   原因：首项 scroll-snap-align:start，吸附位置按内容边算，浏览器把
   scrollLeft 吸附到 20，正好吃掉 padding-left:20px。
   首页曾用 .fmc-tv-app .fca-track 的 scroll-padding-left 局部修过，
   但历史页的 .fca-track 是 fmc-events-mobile.js 动态生成的，不在
   .fmc-tv-app 里，所以一直没修上。这里统一到 .fca-track 本身。 */
@media (max-width: 640px), (pointer: coarse) {
  .fca-track {
    padding-left: 20px !important;
    padding-right: 20px !important;
    scroll-padding-left: 20px !important;
    scroll-padding-inline-start: 20px !important;
  }
  .fca-row h3,
  .fca-year h4 {
    padding-left: 20px !important;
    padding-right: 20px !important;
  }
  .fmc-history-wall-track { scroll-padding-inline-start: 20px !important; }
  .fmc-history-wall-grid {
    padding-left: 20px !important;
    padding-right: 20px !important;
  }
}

/* 历史页海报行与首页对齐（2026-12-01）
   以首页为准：海报距屏幕左边 20px。
   历史页 main 自带 16px 左右外边距（bg 与 body 同为 #1d1d1f，去掉后无视觉接缝），
   叠加 .fca-track 的 20px 后海报就到了 36px，比首页多 16px。
   不能用 .fmc-years 当判据：wechat-reading 也带这套墙，会被误伤。
   所以只认 events 系列页在 <body> 上打的 data-fmc-wall 标记。 */
@media (max-width: 640px), (pointer: coarse) {
  body[data-fmc-wall] main.discovery-main.discovery-archive {
    margin-left: 0 !important;
    margin-right: 0 !important;
    /* 只清外边距会留下 32px 右真空（main 本身宽 100%-32px），
       所以宽度一起放开：轨道与首页一样铺满屏宽，右侧不再缺一截。 */
    width: 100% !important;
    max-width: 100% !important;
  }
}

/* 历史页底色：夜间与首页一致，日间回到纸面白（2026-12-01 修正）
   上一版为"与首页同黑"把 html/body/main 无条件写死 #000 !important，
   结果日期主题切到白天也不生效：纸面 --paper 是 #fff、页头文字 --ink 是 #1d1d1f，
   深字压在纯黑上对比度只有 1.03:1，等于整页看不见，刷新多少次都一样。
   首页是常暗的影视墙（不分昼夜），历史页不是——必须跟 data-theme 走。
   同样只认 body[data-fmc-wall]（15 个 events 页）。 */
@media (max-width: 640px), (pointer: coarse) {
  /* 注意：:has() 不能嵌套（html:has(body > main:has(.x)) 会让整条规则作废），
     所以拆成并列几条，每条最多一个 :has()。 */
  html[data-theme="day"]:has(> body[data-fmc-wall]),
  html[data-theme="day"] body[data-fmc-wall],
  html[data-theme="day"] body[data-fmc-wall] main.discovery-main.discovery-archive {
    background-color: #fff !important;
  }
  /* 夜间（以及没有 data-theme 属性的降级情况）：与首页同黑，缝里不留灰边。 */
  html:not([data-theme="day"]):has(> body[data-fmc-wall]),
  html:not([data-theme="day"]) body[data-fmc-wall],
  html:not([data-theme="day"]) body[data-fmc-wall] main.discovery-main.discovery-archive {
    background-color: #000 !important;
  }
}

/* 历史页底部留白（2026-12-01）
   滚到底时最后一排海报底边压在胶囊栏上（实测 787.8 vs 栏顶 778，被盖 9.8px）。
   首页有 body.fmc-separators-home 的 88px 兜底，历史页没人管，只有 main 的 18px。
   这里补到与首页同级的间隙（约 52px）。 */
@media (max-width: 640px), (pointer: coarse) {
  body[data-fmc-wall] main.discovery-main.discovery-archive {
    padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px)) !important;
  }
}
