/* 卡冊 ⇄ 盒組頁的過場、抽卡（使用者 11/18）。卡冊和盒組頁都要載入這一份；抽卡的程式在 card-pull.js（只有卡冊載入）。 */

/* 跨頁過場：兩頁都宣告了才會有。抽出來的那張卡（tll-card）飛到盒組頁大圖卡的位置；其他畫面舊的往後退淡出、新的從下面浮上來 */
@view-transition { navigation: auto; }
.sp-main #flip { view-transition-name: tll-card; }   /* 圖卡模式在 .sp-full-card、卡牌模式在 .sp-cardcol，都在 .sp-main 裡 */
::view-transition-group(tll-card) { animation-duration: .8s; animation-timing-function: cubic-bezier(.22,.8,.25,1); }
::view-transition-old(tll-card) { animation: tll-card-old .8s both; }   /* 飛過去的那張一直留到最後，盒組頁大圖卡畫好前不會空一塊 */
::view-transition-new(tll-card) { animation: tll-card-new .8s both; }
@keyframes tll-card-old { 0%, 90% { opacity: 1; } 100% { opacity: 0; } }
@keyframes tll-card-new { 0%, 55% { opacity: 0; } 100% { opacity: 1; } }
::view-transition-old(root) { animation: tll-root-out .42s cubic-bezier(.4,0,.2,1) both; }
::view-transition-new(root) { animation: tll-root-in .5s .14s cubic-bezier(.2,.8,.2,1) both; }
@keyframes tll-root-out { to { opacity: 0; transform: scale(.97); filter: blur(2px); } }
@keyframes tll-root-in { from { opacity: 0; transform: translateY(18px); } }
@media (prefers-reduced-motion: reduce) { @view-transition { navigation: none; } }

/* 抽卡：卡套裁切先打開，卡在塑膠上面滑出來；cp-lip 是卡套上緣的熱壓接縫和塑膠反光，壓在還沒抽出來的那段卡上 */
.al-spread .pocket.cp-pulling { overflow: visible; z-index: 20; transform: none !important; box-shadow: none !important; }
.al-spread .pocket.cp-pulling .slot { position: relative; z-index: 5; }
/* 放大飛出去時：那一頁疊到最上面（卡才不會被另一頁、索引蓋住），卡冊其他東西淡下去 */
.al-spread > .al-page.cp-host { z-index: 60 !important; }
.al-book, .al-tabs, .al-caption, .al-spread > .al-page > .pocket, .al-shelf-handle { transition: opacity .5s ease; }
body.cp-dim .al-spread > .al-page > .pocket:not(.cp-pulling), body.cp-dim .al-tabs, body.cp-dim .al-caption, body.cp-dim .al-shelf-handle { opacity: .18; }
/* 卡套上的框和標籤（漲價紅框、到價燈、分類框、名字）都留在卡套上，抽卡時先藏起來，不然會疊在飛出去的卡上 */
.al-spread .pocket.cp-pulling > :not(.slot):not(.cp-lip) { visibility: hidden !important; }
.pocket > .cp-lip { position: absolute; left: 0; right: 0; top: 0; bottom: 0; z-index: 6; pointer-events: none; border-radius: inherit;
  border-top: 2px solid rgba(190,182,198,.75);
  background: linear-gradient(180deg, rgba(255,255,255,.14), rgba(255,255,255,.03) 6%, transparent 14%),
    linear-gradient(115deg, rgba(255,255,255,.12) 0%, rgba(255,255,255,0) 24%, rgba(255,255,255,0) 62%, rgba(255,255,255,.07) 74%, rgba(255,255,255,0) 82%); }

/* 不支援跨頁過場時：淡出再換頁 */
.cp-veil { position: fixed; inset: 0; z-index: 9999; pointer-events: none; background: var(--bg, #0b1426); opacity: 0; }
html.theme-light .cp-veil { background: #f4f7fc; }

/* 從盒組頁回卡冊（card-pull.js 在卡冊的 pagereveal 標 tllback）：盒組頁的大圖卡 0.2 秒就淡掉，整頁也快一點，不拖（使用者 11/18：「返回 卡牌他會過幾秒才消失」） */
html:active-view-transition-type(tllback)::view-transition-group(tll-card) { animation-duration: .22s; }
html:active-view-transition-type(tllback)::view-transition-old(tll-card) { animation: tll-quick-out .22s ease-out both; }
html:active-view-transition-type(tllback)::view-transition-old(root) { animation: tll-quick-out .25s ease-out both; }
html:active-view-transition-type(tllback)::view-transition-new(root) { animation: tll-quick-in .3s ease-out both; }
@keyframes tll-quick-out { to { opacity: 0; transform: scale(.97); } }
@keyframes tll-quick-in { from { opacity: 0; } }
/* 卡整張抽出來以後（放大飛走時），卡套上緣那片塑膠反光不再蓋在卡上 */
.pocket.cp-out > .cp-lip { display: none; }
/* 回卡冊要等卡畫好才飛（tllhold）：盒組頁那張大圖卡留在原地不淡掉，card-pull.js 卡畫好就收掉過場、同一刻開始飛（使用者 11/18：「會先消失一下 然後才有飛回去的動畫」）；最多 4.5 秒 */
html:active-view-transition-type(tllhold)::view-transition-group(tll-card) { animation-duration: 4.5s; }
html:active-view-transition-type(tllhold)::view-transition-old(tll-card) { animation: tll-hold 4.5s both; }
@keyframes tll-hold { 0%, 97% { opacity: 1; } 100% { opacity: 0; } }
/* 五星外框現在掛在頁上（翻頁會跟著欄轉）：抽卡時其他卡的外框也一起淡下去，被抽的那張不動 */
#spread .ca-ring-wrap { transition: opacity .5s ease; }
body.cp-dim #spread .ca-ring-wrap { opacity: .18; }
body.cp-dim #spread .pocket.cp-pulling .ca-ring-wrap { opacity: 1; }
