/* 花月 · 三端自适应层（iPhone 基座 → iPad → Mac）
   ─────────────────────────────────────────────────────────────
   只放「随设备档位变化」的规则；页面自身样式不要写进来。

   档位（实测依据：设计系统-三端自适应.md）
     compact  iPhone 竖屏        ≤480px
     rotate   iPhone 横屏        触摸 + 视口高度 ≤500px
     medium   iPad               触摸 + 宽 >480
     regular  Mac                鼠标 + 宽 ≥1025

   2026-12-02 用户定的方向：
     - 旋转不能切到 Mac 版（这是原 bug：只认宽度，852px 就掉进桌面版）。
     - 不单独做横屏版式：没人会横着拿 iPhone 看网站。横屏仍用竖屏版式，居中并限宽，
       两侧留底色即可，不做横向重排。
     - iPad 是「大一号的 iPhone」，Mac 只微调（首页流动照片墙原样保留）。
*/

/* ===== iPhone 横屏：不重排，按竖屏版式居中限宽 ===== */
@media (pointer: coarse) and (max-height: 500px) {
  /* 底栏不横贯全屏 */
  #fmc-tabbar { max-width: 560px; }

  /* 内容按竖屏宽度居中；两侧留底色，不做横向重排 */
  body > main,
  body > main.discovery-main {
    max-width: 560px;
    margin-left: auto;
    margin-right: auto;
  }

  /* 首页海报区在手机版是 width:100vw（竖屏无所谓，横屏会横出屏幕 314px）。
     限宽后必须改成 100%，否则整页被浏览器缩放着看。 */
  .fmc-tv-app .fca-art {
    width: 100% !important;
    height: 62dvh !important;
    display: flex !important;
    align-items: flex-start !important;
    justify-content: center !important;
  }
  .fmc-tv-app .fca-art img { height: 100% !important; width: auto !important; }
}

/* ===== iPad：大一号的 iPhone（同一套组件，只把尺寸放大到合适） ===== */
@media (pointer: coarse) and (min-width: 481px) {
  /* 竖屏海报在手机上是满宽出血；iPad 上满宽会变成一张巨型海报，按宽度比例收住 */
  .fmc-tv-app .fca-art { height: auto !important; min-height: 0 !important; }
  .fmc-tv-app .fca-art img {
    width: min(52vw, 460px) !important;
    height: auto !important;
  }
}

/* ===== iPad 微调：同一套版式，留白与尺寸放大到平板该有的呼吸 ===== */
@media (pointer: coarse) and (min-width: 481px) {
  /* 底栏：iPad 上 736px 宽会像 Mac 导航栏，收到 640 居中更像手机那一条 */
  #fmc-tabbar { max-width: 640px; }

  /* 横滑行的左右留白：手机 20 → iPad 32（海报不再贴边） */
  .fca-track,
  .fmc-history-wall-track,
  .fmc-history-wall-grid {
    padding-left: 32px !important;
    padding-right: 32px !important;
    scroll-padding-left: 32px !important;
  }
  .fca-row h3,
  .fca-year h4 { padding-left: 32px !important; padding-right: 32px !important; }

  /* 海报：手机封顶 190，iPad 放到 216（一屏仍能看到 3～4 张） */
  .fca-poster,
  .fmc-history-wall-tile { max-width: 216px !important; }

  /* 阅读列表：760 满宽 → 版心 720 居中 */
  main.fmc-read { max-width: 720px !important; }
}

/* ===== iPad 横屏：触摸设备的横屏版式（不是 Mac 版，也不是竖屏拉宽） =====
   用户 2026-12-02 定：iPad 竖屏 = 大号 iPhone；横屏 = 为横屏重排过的触摸版式。
   判定用 orientation + 宽度≥900，把 iPhone 横屏（874 及以下）排除在外。 */
@media (pointer: coarse) and (orientation: landscape) and (min-width: 900px) {
  /* ---- 首页 hero：海报在左、文案在右（横屏的阅读顺序是从左到右） ---- */
  .fmc-tv-app .fca-hero {
    display: grid !important;
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
    align-items: center;
    gap: clamp(32px, 4vw, 80px);
    padding: 0 clamp(32px, 5vw, 88px) !important;
    min-height: min(100dvh, 780px) !important;
    max-width: 1240px;
    margin-inline: auto;
    box-sizing: border-box;
  }
  .fmc-tv-app .fca-art {
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    overflow: visible !important;
  }
  .fmc-tv-app .fca-art img {
    width: auto !important;
    height: min(66dvh, 640px) !important;
    max-width: 100% !important;
    border-radius: 10px !important;
    /* 竖屏那条「海报下沿渐隐」是给压在海报上的文案用的；横屏文案在右列，海报要完整 */
    -webkit-mask-image: none !important;
    mask-image: none !important;
  }
  /* 手机版的文案是绝对定位叠在海报下沿的渐变上；横屏它要回到正常流里做右列 */
  .fmc-tv-app .fca-hero-copy {
    position: static !important;
    left: auto !important; right: auto !important; bottom: auto !important;
    margin-top: 0 !important;
    padding: 0 !important;
    background: none !important;
    text-align: left;
    max-width: 640px;
  }
  .fmc-tv-app .fca-meta,
  .fmc-tv-app .fca-actions,
  .fmc-tv-app .fca-dots { justify-content: flex-start !important; }
  .fmc-tv-app .fca-title { font-size: clamp(40px, 4.6vw, 64px) !important; }
  .fmc-tv-app .fca-caption { margin-bottom: 20px !important; }

  /* ---- 横屏的横向行：海报更大，一屏看到 4～5 张 ---- */
  .fca-poster,
  .fmc-history-wall-tile { max-width: 260px !important; }
}

/* 横屏的内容页：正文行宽收在 720，居中即可读懂，不必横贯 1024 */
@media (pointer: coarse) and (orientation: landscape) and (min-width: 900px) {
  main.wrap,
  main.reader,
  main.fmc-read { max-width: 720px !important; margin-left: auto !important; margin-right: auto !important; }
}

/* ===== Mac 历史页：年份分节 + 横向海报行 =====
   2026-12-02 用户定：横滑要保留（Mac 触控板两指横滑是原生操作，Apple TV Mac 版也是横滑行）。
   结构＝年份分节 + 横向行，与手机同构；尺寸按桌面放大：海报 232×348、行距更大。
   只作用于 .fmc-years，不碰旧的 .fmc-history-wall。 */
@media (pointer: fine) and (min-width: 641px) {
  .fmc-years { display: block; padding: 4px 0 52px; }
  .fmc-years .fca-year { margin: 0 0 clamp(28px, 2.6vw, 40px); }
  .fmc-years .fca-year:last-child { margin-bottom: 0; }

  .fmc-years .fca-year h4 {
    margin: 0 0 12px;
    font-size: 15px;
    line-height: 1.3;
    font-weight: 600;
    letter-spacing: .02em;
    color: var(--fm-muted, #86868b);
  }

  .fmc-years .fca-track {
    display: flex;
    gap: 18px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 2px 2px 12px;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    overscroll-behavior-x: contain;
  }
  .fmc-years .fca-track::-webkit-scrollbar { display: none; }
  .fmc-years .fca-track:focus-visible {
    outline: 2px solid var(--fm-action, #0071e3);
    outline-offset: 4px;
    border-radius: 10px;
  }

  .fmc-years .fca-poster {
    position: relative;
    flex: none;
    /* 220 宽：1120 版心一行 4 张后还露出第 5 张的一角，提示「还能横滑」 */
    width: 220px;
    max-width: 220px;
    scroll-snap-align: start;
    border-radius: 12px;
    overflow: hidden;
    text-decoration: none !important;
    background: #111;
    transition: transform var(--dur-1, 120ms) var(--ease-out, ease-out);
  }
  .fmc-years .fca-poster:hover { transform: translateY(-2px); }
  .fmc-years .fca-poster:focus-visible { outline: 2px solid var(--fm-action, #0071e3); outline-offset: 3px; }
  .fmc-years .fca-poster img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 2 / 3;
    object-fit: cover;
  }
  .fmc-years .fca-poster-title {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    padding: 26px 10px 9px;
    font-size: 12px;
    line-height: 1.3;
    color: #fff !important;
    background: linear-gradient(transparent, rgba(0, 0, 0, .82));
    text-shadow: 0 1px 4px rgba(0, 0, 0, .6);
  }
}

/* ===== Mac 宽屏：电视报放开版心，让「容器 ≥1000 变 3 栏」真正生效 =====
   tv/style.css 想给日历 1320 版心，但 fmc-apple-spec.css 把全站 .wrap 压到 980，
   于是 3 栏的容器查询永远触发不了——1920 屏上只用中间 980，右边全空。
   只在宽屏放开，1366 及以下维持现状。 */
@media (pointer: fine) and (min-width: 1400px) {
  body.fmc-separators-tv main.wrap {
    max-width: none !important;
  }
}

/* ===== Mac 宽屏：页脚贴到屏幕两侧 + 首页「捐赠」与「近期放映」拉开 ===== */

/* 1) 页脚：宽屏上不再被 74rem 版心挤在中间，关注句/宣言贴左下、FAQ/外观贴右下 */
@media (pointer: fine) and (min-width: 1200px) {
  footer.fmc-site-end.fmc-appearance-footer[data-fmc-appearance] {
    padding-inline: clamp(28px, 2.4vw, 64px) !important;
  }
}

/* 2) 首页：近期放映链接与「捐赠」按钮之间只有约 5px，挤在一起；拉开一档间距 */
@media (pointer: fine) {
  main section.home-links.fmc-ticket-entry { margin-top: 22px !important; }
}

/* 3) 页眉：宽屏上贴到窗口两侧（左上是 FMC 标，右上是语言），不再挤在 74rem 中间 */
@media (pointer: fine) and (min-width: 1200px) {
  body header.edition-header .edition-nav-inner {
    width: 100% !important;
    max-width: none !important;
    margin-inline: 0 !important;
    padding-inline: clamp(28px, 2.4vw, 64px) !important;
  }
  body header.edition-header .edition-nav-inner .edition-symbol {
    flex: 0 0 auto !important;
    justify-content: flex-start !important;
  }
}

/* ===== Mac：只有「列表页」贴左（用户定）=====
   历史页与电视报是列表/表格，贴左排布才对；首页、影片页、FAQ、阅读保持居中版心。
   左线与页眉 logo 同一个 gutter。 */
@media (pointer: fine) and (min-width: 1024px) {
  body[data-fmc-wall] > main {
    margin-left: clamp(28px, 2.4vw, 64px) !important;
    margin-right: auto !important;
    /* 贴左之后把宽度也放开，别让右边空一大片；上限 1600 免得行太长。
       宽度要减掉左边这份 gutter：body 是 flex 容器，`width:100%` 再加 margin-left
       会把页面撑出 34px 的横向滚动条（2026-12-04 实测 1440 下 scrollWidth 1475），
       而 `width:auto` 又会被 flex 撑到 max-width 1600（实测 scrollWidth 1635）。 */
    width: calc(100% - clamp(28px, 2.4vw, 64px)) !important;
    max-width: 1600px !important;
  }
  /* 电视报是表格型内容，铺满窗口：左右各一个 gutter，右边不再留空 */
  body.fmc-separators-tv > main {
    margin-left: clamp(28px, 2.4vw, 64px) !important;
    margin-right: clamp(28px, 2.4vw, 64px) !important;
    width: auto !important;
    max-width: none !important;
  }
}

/* 历史页宽屏：海报跟着版心放大，4 张片就能铺满一行（原来固定 220 会留一大片空） */
@media (pointer: fine) and (min-width: 1400px) {
  body[data-fmc-wall] .fmc-years .fca-poster {
    width: 340px;
    max-width: 340px;
  }
}

/* 创刊词（首页宣言）在 Mac 上放大：
   18px 在 1905 宽的窗口里太小，读起来像附注；这是首页门面，按海报文案的尺度给。
   注意：字号由 manifesto-reference.css 里的 `font-size: var(--quote-size) !important` 控制，
   且那段在 @layer 里——层内 !important 压过层外，所以**改字号要改 `--quote-size` 这个变量**，
   直接在层外写 font-size 是无效的（踩过）。 */
@media (pointer: fine) and (min-width: 1024px) {
  body main.discovery-home section.hero .quote-block {
    --quote-size: 26px;
    --quote-gap: 36px;
  }
}

/* Mac 上不需要「回到顶部」浮钮（鼠标/触控板滚动、页面也不长）；
   浮钮本身是全站共用的，不能删，只能在细指针设备上隐藏。 */
@media (pointer: fine) and (min-width: 1024px) {
  .fmc-film-top { display: none !important; }
}

/* 语言切换（页眉右上「中文」）在 Mac 上偏小：组件里有一条高权重规则压到 12px，
   这里用同等选择器 + 无 layer（层外压层内）把桌面拉回 14px。 */
@media (pointer: fine) and (min-width: 641px) {
  html:root body details.fmc-locale[data-site-language] > summary {
    font-size: 14px;
  }
}

/* 创刊词：按设计意图控制换行。三行分别是
     ① …献给那些朝圣者。
     ② 献给那些能给四岁孩子讲故事并吸引他们注意力的人。献给内心
     ③ 燃烧着火焰的人。
   第一行约 44 字，26px 下需要约 1180px，比 960 的版心宽，所以把文案块放宽（居中，溢出到照片墙上）。 */
@media (pointer: fine) and (min-width: 1024px) {
}

/* 历史页 / 电视报的 h1：任何设备都只留给读屏，不做视觉标题。
   2026-12-02：手机端这两页本来没有标题，为 Mac 补的 h1 被手机层放大，先在触屏上隐藏。
   2026-12-03 用户定：**Mac 也不要**——「顶栏就在眼前，观众一眼知道自己在哪」，
   页面里再写一遍「放映结束 / 电视报」是重复。所以不再是「只在触屏隐藏」，
   而是全局视觉隐藏（保留 h1 给读屏与 SEO，不删元素）。 */
body[data-fmc-wall] main > .fmc-history-title,
body.fmc-separators-tv .discovery-tv > h1 {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* ==========================================================================
   2026-12-02 · 手机端「正文终点 → 悬浮底栏」的净空
   参数依据：/events（历史页）手机端实测——最后一行海报下沿到栏顶 44px；
   44 同时是 HIG 的最小命中尺寸，三端通用，记进 --fmc-tab-clear。
   底栏 58 + 距屏幕底 8 = 66px，所以内容终点距文档末尾应为 66 + 44 = 110px；
   body 已经有 12px（底栏组件那条旧规则），缺的差额由页面自己补。
   实测（iPhone 16 Pro / Safari，2026-12-02）：电视报差 80px、影片页差 64px。
   ========================================================================== */
:root {
  --fmc-tap-min: 44px;   /* 最小命中区（HIG） */
  --fmc-tab-clear: 44px; /* 正文终点与底栏顶的净空（历史页实测） */
}

@media (max-width: 640px), (pointer: coarse) {
  /* 页面自己的 main 底部 18px 是 fmc-mobile-layout 用 !important 锁的，这里必须同样 !important；
     选择器更具体，后置胜出。 */
  html.fmc-has-tabbar[data-fmc-tabbar-mode="site"] body.fmc-separators-tv main.discovery-main {
    padding-bottom: calc(var(--fmc-tab-clear) + 54px) !important; /* 98px：98 + 12 = 110 */
  }
  /* 影片页的「上一期 / 下一期」：原 margin-block 3rem/1rem + main 18 + body 12 = 46，
     实测末行压进栏内 20px；补到 80 → 80 + 18 + 12 = 110（= 66 + 44 净空）。 */
  html.fmc-has-tabbar[data-fmc-tabbar-mode="site"] nav.film-neighbors {
    margin-bottom: calc(var(--fmc-tab-clear) + 36px) !important;
  }
}

/* ==========================================================================
   2026-12-02 · 信息页（FAQ / 规则 / 宣言）底部净空
   和电视报、影片页同一个毛病：正文最后一段压在悬浮底栏下面（实测 FAQ -36px、规则页 -20px）。
   口径统一为 --fmc-tab-clear（44）：内容终点距文档末尾 = 底栏 58 + 距底 8 + 44 = 110。
   这里作用在 main.wrap.reader 上——影片页是 main.wrap（无 reader），不会被连带。
   ========================================================================== */
@media (max-width: 640px), (pointer: coarse) {
  html.fmc-has-tabbar[data-fmc-tabbar-mode="site"] main.wrap.reader {
    padding-bottom: calc(var(--fmc-tab-clear, 44px) + 54px) !important;
  }
}

/* ===== Mac：底栏是手指的产物，桌面已有顶栏就不再出现第二份导航 =====
   2026-12-03 用户定「三端以 iPhone 为基准、Mac 与 iPhone 对齐」。
   底栏（#fmc-tabbar）在城市语言里是 iPhone 的外壳；桌面换成顶栏，底栏必须让位，
   否则同一套导航在一页里出现两次（首页已单独隐藏，这里补齐全站）。
   例外：阅读页没有顶栏（`main.fmc-read` 那套只有底栏），保持原样，避免桌面无导航。 */
@media (min-width: 641px) and (pointer: fine) {
  body:has(> header.site-header) #fmc-tabbar {
    display: none !important;
  }
}

/* ===== 历史页海报墙（Mac）：一条不断行、不重叠、放不下就横滑的海报行 =====
   2026-12-03 用户指出：Mac 上两边留白太多。
   2026-12-04 用户反馈：2024 年那排（8 张）「叠在一起」了。
   根因（2026-12-04 实测 1440）：改成 grid + auto-fit 后列宽由容器反推
   （repeat(auto-fit, minmax(180px,1fr)) → 7 列 × 192px），但海报宽度仍是
   fmc-appletv-home.css 里的 `width:232px !important`（这里写的 width:auto 被它压掉），
   于是每张比自己的格子宽 40px，向右压住下一张 24px；8 张还多出第 8 张掉到第二行
   （2024 是唯一超过 7 张的年份，所以只有它坏）。
   2026-12-04 15:25 用户定：**所有年份海报一样大**（232，与首页通栏同尺寸），行尾留白可以接受。
   所以这里只保留「一条不断行的 flex 行」：卡片定宽 232，一个年份超过容器就整行横向滚动，
   绝不重叠、绝不掉行。触屏仍是原来的横滑带，不动。 */
@media (pointer: fine) and (min-width: 1024px) {
  .fmc-years .fca-track {
    display: flex;
    flex-wrap: nowrap;
    align-items: flex-start;
    gap: clamp(16px, 1.4vw, 24px);
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x proximity;
    padding: 2px 0 12px;
    scrollbar-width: none;
  }
  .fmc-years .fca-track::-webkit-scrollbar { display: none; }
  .fmc-years .fca-poster {
    /* 所有年份同宽：跟首页通栏的卡片一样 232（2026-12-04 用户定「一样大、行尾留白可以」） */
    flex: 0 0 232px;
    width: 232px !important;
    max-width: 232px !important;
  }
}

/* 2026-12-03 用户定：电视报顶部工具栏离页眉太远（实测 main 顶内边距 72px，工具栏落在 136）。
   工具栏自己已经带 12px 下边距，这里只留一档标准间距——和首页 hero 的上间距对齐。 */
@media (pointer: fine) and (min-width: 641px) {
  body.fmc-separators-tv main.discovery-main { padding-top: var(--sp-6) !important; }
}
