/* 11/26 使用者：「大部分試試用手機　太多按鍵會擋住經文　使用起來不方便　全螢幕也是
   然後我要任何手機都能使用　整個網站要很穩」
   這個檔放在最後面，同名的設定以這裡為準。
   「手機」＝窄畫面，或手機橫拿（很矮的橫畫面）。 */

/* 電腦上看不到、手機才出現的東西 */
.p-more, .pi-hint { display: none; }
.player-info { border: 0; background: none; padding: 0; text-align: left; color: inherit; font: inherit; }

/* 加到手機主畫面時，最上面是時間、電量那一條：按鈕不要被蓋住 */
.topbar { padding-top: calc(14px + env(safe-area-inset-top)); }
.chapter .ch-hero .topbar { padding-top: calc(14px + env(safe-area-inset-top)); }

@media (max-width: 760px), (orientation: landscape) and (max-height: 560px), (hover: none) and (max-width: 1100px) {
  /* ───── 一、讀經、聽故事：底下只留一條 ───── */
  body.with-player .jump-fab, body.with-player .notes-fab { display: none; }
  .chapter.has-player .ch-dock { display: none; }
  .chapter.has-player { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }

  .player {
    left: 0; right: 0; bottom: 0; transform: none; width: auto; gap: 6px;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    padding: 7px calc(10px + env(safe-area-inset-right)) calc(7px + env(safe-area-inset-bottom)) calc(10px + env(safe-area-inset-left));
    border-radius: 18px 18px 0 0; background: #0E1526; -webkit-backdrop-filter: none; backdrop-filter: none;
    box-shadow: 0 -1px 0 var(--line-strong), 0 -14px 30px -20px #000;
    transition: transform .25s var(--ease);
  }
  .player-info {
    display: flex; flex-direction: column; align-items: center; justify-content: center; justify-self: start;
    min-width: 62px; max-width: 100%; min-height: 48px; padding: 2px 8px; border-radius: 14px; background: rgba(255, 255, 255, .07); text-align: center;
  }
  .player .now { max-width: 100%; font-size: .92rem; line-height: 1.35; }
  .pi-hint { display: block; font-size: .66rem; line-height: 1.2; letter-spacing: .1em; color: var(--text-3); }
  .player .eq { display: none !important; }
  .player .keys { gap: 8px; }
  .btn-round { width: 44px; height: 44px; }
  .btn-round.is-main { width: 52px; height: 52px; }
  .player .side .btn-speed, .player .side .snd-pill { display: none; }
  .p-more {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0;
    min-width: 54px; min-height: 48px; padding: 2px 8px; border: 0; border-radius: 14px; background: rgba(255, 255, 255, .07);
  }
  .p-more small { font-size: .66rem; line-height: 1.2; letter-spacing: .1em; color: var(--text-3); }

  /* 「自動接下一章、經文語言、聲音」那一排收進「更多」 */
  .chapter.has-player .listen > div > .play-opts, .chapter.has-player .story > .play-opts { display: none; }
  .chapter.is-story .story { padding-bottom: 6px; }
  .chapter.is-story .filmstrip { padding-bottom: 12px; }
  .listen { padding-bottom: 12px; }
  .ch-hero .topbar-side, .rd-head .topbar-side { display: none; }
  .mk-toast { bottom: calc(80px + env(safe-area-inset-bottom)); }

  /* ───── 二、往下讀的時候按鈕收起來（js/mobile.js 看手指的動作）───── */
  html.chrome-away .player { transform: translateY(110%); }
  /* 正在播的時候留一顆小小的暫停鈕在右下角 */
  html.chrome-away .player.is-playing {
    display: block; left: auto; right: calc(10px + env(safe-area-inset-right)); bottom: calc(10px + env(safe-area-inset-bottom));
    transform: none; padding: 0; background: none; box-shadow: none;
  }
  html.chrome-away .player.is-playing .player-info, html.chrome-away .player.is-playing .side,
  html.chrome-away .player.is-playing .keys > :not(.is-main) { display: none; }
  html.chrome-away .player.is-playing .btn-round.is-main { width: 48px; height: 48px; opacity: .88; }

  /* 其他畫面（首頁、書卷、闖關、收藏）：跳轉、筆記兩顆小一點，往下滑就讓開 */
  .jump-fab, .notes-fab { width: 50px; height: 50px; transition: transform .25s var(--ease), opacity .25s; }
  .notes-fab { right: calc(72px + env(safe-area-inset-right)); }
  .jump-fab { right: calc(12px + env(safe-area-inset-right)); }
  .jump-ico { font-size: 1.05rem; }
  .jump-lbl, .notes-fab-lbl { font-size: .62rem; }
  .ch-dock a { min-height: 40px; }
  html.chrome-away .jump-fab, html.chrome-away .notes-fab, html.chrome-away .chapter:not(.has-player) .ch-dock a {
    opacity: 0; transform: translateY(18px); pointer-events: none;
  }

  /* ───── 三、「更多」面板 ───── */
  .more-chapters { display: flex; gap: 10px; }
}

/* 「更多」面板（外框和「跳轉」面板共用 .jump-sheet） */
.more-chapters { display: flex; gap: 10px; }
.more-chapters .ch-end-btn { min-height: 56px; }
.more-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.more-tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 66px; padding: 8px 4px;
  border: 0; border-radius: 14px; background: rgba(255, 255, 255, .06); box-shadow: inset 0 0 0 1px var(--line);
  font-size: .86rem; line-height: 1.3; color: var(--text); text-align: center;
}
.more-tile .icon { color: var(--light-hi); }
.more-h { margin: 18px 0 8px; font-size: .85rem; font-weight: 600; letter-spacing: .2em; color: var(--light-hi); }
.more-speeds { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
.more-speed { min-height: 44px; padding: 0; border: 0; border-radius: 12px; background: rgba(255, 255, 255, .06); font-size: .92rem; font-variant-numeric: tabular-nums; color: var(--text); }
.more-speed[aria-pressed="true"] { background: var(--light); color: var(--on-light); font-weight: 700; }
.more-opts .play-opts { display: flex; margin: 0; }
.more-extra { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; color: var(--text-2); font-size: .95rem; }
.more-extra .opt-toggle { padding: 0 10px; }
.more-extra .snd-pill { display: inline-flex; align-items: center; gap: 6px; min-height: 42px; padding: 0 16px 0 12px; }
.stage.is-tucked-away:not(.is-full) { display: none; }
.retry-row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 20px; }

/* ───── 四、手機直拿：聽經看圖的圖貼齊兩邊，節數和場景名寫在圖上，省下一行給經文 ───── */
@media (max-width: 760px) and (orientation: portrait) {
  .listen { --stage-h: calc(min(56.25vw, 30vh) + env(safe-area-inset-top) + 12px); padding-top: 6px; }
  .stage:not(.is-full) { margin: 0 calc(var(--gutter) * -1); padding: env(safe-area-inset-top) 0 10px; background: linear-gradient(var(--night-1) 94%, transparent); }
  .stage:not(.is-full) .art { width: 100%; max-height: 30vh; border-radius: 0; box-shadow: none; }
  .stage:not(.is-full) figcaption {
    position: absolute; left: 0; right: 0; bottom: 10px; flex-wrap: nowrap; margin: 0; padding: 24px 14px 6px;
    background: linear-gradient(to top, rgba(5, 8, 15, .86), transparent); text-shadow: 0 1px 8px #000; pointer-events: none;
  }
  .stage:not(.is-full) .stage-title { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .stage:not(.is-full) .art-credit { top: 8px; bottom: auto; right: auto; left: 8px; }
}

/* 平板直拿：圖不要大到把經文擠到下半頁 */
@media (min-width: 761px) and (max-width: 1100px) and (orientation: portrait) {
  .listen { --stage-h: calc(34vh + 80px); }
  .stage:not(.is-full) .art { width: min(100%, calc(34vh * 1.7778)); margin-inline: auto; }
}

/* ───── 五、手機橫拿：圖在左、經文在右（原本圖會把整個畫面蓋住）───── */
@media (orientation: landscape) and (max-height: 560px) {
  .ch-hero, .bk-hero, .bk-hero.is-plain { min-height: 0; }
  .ch-hero .ch-body { padding-top: 12px; }
  .ch-num { font-size: 4rem; }
  .ch-title-row h1 { font-size: 2rem; }
  .chapter.has-player .listen:not(.is-plain) {
    grid-template-columns: minmax(0, 46%) minmax(0, 1fr); align-items: start; gap: 18px; max-width: none; padding-top: 8px;
    padding-inline: calc(14px + env(safe-area-inset-left)) calc(14px + env(safe-area-inset-right));
  }
  .listen { --stage-h: 12px; }
  .stage:not(.is-full) { top: 6px; margin: 0; padding: 0; background: none; }
  .stage:not(.is-full) .art { width: 100%; max-height: calc(100vh - 130px); }
  .stage:not(.is-full) figcaption { margin-top: 6px; }
  .listen:has(.stage.is-tucked-away) { display: block; }
  .story .cinema:not(.is-full) { width: min(100%, calc((100vh - 90px) * 1.7778)); margin-inline: auto; }
  /* 橫拿的時候那一條縮在右下角，不要整排蓋住 */
  .player { left: auto; right: calc(8px + env(safe-area-inset-right)); bottom: calc(4px + env(safe-area-inset-bottom)); width: auto; grid-template-columns: auto auto auto; gap: 10px; padding: 4px 8px; border-radius: 999px; box-shadow: inset 0 0 0 1px var(--line-strong), 0 14px 30px -14px #000; }
  .player-info, .p-more { min-height: 44px; border-radius: 999px; }
  html.chrome-away .player { transform: translateY(130%); }
  html.chrome-away .player.is-playing { width: auto; padding: 0; box-shadow: none; transform: none; }
  .jump-panel { max-height: 96vh; }
}

@media (max-width: 760px), (orientation: landscape) and (max-height: 560px), (hover: none) and (max-width: 1100px) {
.full-btn .exit-text { display: none; }
/* ───── 六、全螢幕：平常什麼按鈕都沒有，點一下畫面才出現，過 3 秒自己收起來（js/screen.js）───── */
.is-full { touch-action: none; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
.is-full .full-bar, .is-full .ov-nav, .is-full .ov-big, .is-full .cinema-nav, .is-full .cinema-big, .is-full .cinema-chip { transition: opacity .25s; }
.is-full.ui-off .full-bar, .is-full.ui-off .ov-nav, .is-full.ui-off .ov-big,
.is-full.ui-off .cinema-nav, .is-full.ui-off .cinema-big, .is-full.ui-off .cinema-chip { opacity: 0 !important; pointer-events: none !important; }
.cinema.is-full.ui-off::before { background: transparent; }
.full-btn.is-exit { justify-content: center; width: 44px; padding: 0; }

.stage.is-full .ov-big, .stage.is-full:not(.is-playing) .ov-big, .cinema.is-full .cinema-big {
  position: absolute; z-index: 5; inset: 0; display: grid; place-items: center; width: 72px; height: 72px; margin: auto; padding: 0; border: 0; border-radius: 50%;
  background: rgba(8, 13, 25, .66); color: #fff; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .34);
}
.cinema.is-full .cinema-big .icon { width: 72px; height: 72px; background: none; color: #fff; box-shadow: none; }
.cinema.is-full .cinema-big > span:not(.icon) { display: none; }
.stage.is-full .ov-nav, .cinema.is-full .cinema-nav {
  position: absolute; z-index: 5; top: 50%; bottom: auto; display: grid; place-items: center; width: 52px; height: 52px; margin-top: -26px; padding: 0; border-radius: 50%;
  background: rgba(8, 13, 25, .66); color: #fff; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .24);
}
.stage.is-full .ov-nav.is-prev, .cinema.is-full .cinema-nav.is-prev { left: calc(14px + env(safe-area-inset-left)); }
.stage.is-full .ov-nav.is-next, .cinema.is-full .cinema-nav.is-next { right: calc(14px + env(safe-area-inset-right)); }
.cinema.is-full .cinema-chip { top: calc(30px + env(safe-area-inset-top)); max-width: 55%; }

/* 橫的畫面：經文疊在圖下緣；經文很長時最多佔一半，可以用手指往下看 */
.stage.is-full:not(.is-tall) figcaption { max-height: 52%; overflow-y: auto; padding-top: 34px; pointer-events: auto; touch-action: pan-y; }
.stage.is-full:not(.is-tall) .stage-verse { font-size: clamp(1.05rem, 2.7cqw, 2rem); }

/* 直的畫面：圖在上面、經文大字在圖下面、按鈕在最下面，三樣不互相蓋住 */
.stage.is-full.is-tall .stage-art { top: calc(68px + env(safe-area-inset-top)); bottom: auto; height: calc(var(--fw) * .5625); }
.stage.is-full.is-tall figcaption {
  top: calc(68px + env(safe-area-inset-top) + var(--fw) * .5625); bottom: calc(96px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; flex-wrap: nowrap; overflow-x: hidden; overflow-y: auto; padding: 8px 20px; background: none; pointer-events: auto; touch-action: pan-y;
}
.stage.is-full.is-tall figcaption .ref { flex: none; margin: auto auto 0; }
.stage.is-full.is-tall .stage-verse { flex: none; width: 100%; margin: 6px auto auto; font-size: 20px; line-height: 1.7; text-wrap: pretty; }
.stage.is-full.is-tall .ov-big, .cinema.is-full.is-tall .cinema-big { inset: auto 0 calc(20px + env(safe-area-inset-bottom)) 0; }
.stage.is-full.is-tall .ov-nav, .cinema.is-full.is-tall .cinema-nav { top: auto; bottom: calc(30px + env(safe-area-inset-bottom)); margin: 0; }
.stage.is-full.is-tall .ov-nav.is-prev, .cinema.is-full.is-tall .cinema-nav.is-prev { left: calc(50% - 112px); }
.stage.is-full.is-tall .ov-nav.is-next, .cinema.is-full.is-tall .cinema-nav.is-next { right: calc(50% - 112px); }
.cinema.is-full.is-tall .cinema-art { top: calc(104px + env(safe-area-inset-top)); bottom: auto; height: calc(var(--fw) * .5625); }
.cinema.is-full.is-tall::after { display: none; }
.cinema.is-full.is-tall .cinema-sub {
  top: calc(120px + env(safe-area-inset-top) + var(--fw) * .5625); bottom: auto; left: 20px; right: 20px; font-size: clamp(1.05rem, 5cqw, 1.5rem); line-height: 1.7;
}
}

/* ───── 七、舊一點的手機（iPhone 的系統 16.2 以前、安卓舊版瀏覽器）不認得新的調色寫法：給一般的顏色 ───── */
@supports not (background: color-mix(in oklab, red, blue)) {
  .verse.is-now { background: linear-gradient(90deg, rgba(242, 196, 109, .18), transparent 85%); }
  .verse.is-picked { background: rgba(242, 196, 109, .2); }
  .verse.hl .vtx { background-image: linear-gradient(transparent 52%, rgba(242, 196, 109, .42) 52%, rgba(242, 196, 109, .42) 94%, transparent 94%); }
  .verse.is-jumped { animation: none; background: rgba(242, 196, 109, .22); }
  .key-tag { background: rgba(242, 196, 109, .18); }
  .done-note { background: rgba(242, 196, 109, .12); box-shadow: inset 0 0 0 1px rgba(242, 196, 109, .4); }
  .poster, .art.is-empty, .cinema-pic.is-empty { background: linear-gradient(180deg, #223253, #0D1627); }
  .btn { box-shadow: none; }
  .jump-fab, .notes-fab, .stop-card, .game-card { box-shadow: inset 0 0 0 1px rgba(242, 196, 109, .45); }
  .ch-index a, .rd-grid a { box-shadow: inset 0 0 0 1px rgba(242, 196, 109, .55); }
  .nt-b.is-quote blockquote { background: rgba(242, 196, 109, .1); }
  .stage-art .art { box-shadow: none; }
  .mk-color[aria-pressed="true"] { background: rgba(255, 255, 255, .16); }
}
