/* 學習獎勵卡包 opening (2026-11-21). Soft pastel style (美術風格指南 v1); no flashing, no casino effects.
   Art: assets/pack/ (卡包美術 v1). Pack canvas 1132×1754, card canvas 1000×1500 (2:3). */
.pack-overlay { position: fixed; inset: 0; z-index: 60; background: radial-gradient(circle at 50% 40%, #fdf6ea 0%, #e9e2f3 70%, #d9d2ea 100%);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 24px 16px; }
.pack-skip { position: fixed; z-index: 3; top: max(14px, env(safe-area-inset-top)); right: 14px; border: 1.5px solid #6b5a8a; background: rgba(255,255,255,.8);
  color: #4a3d63; border-radius: 999px; padding: 6px 14px; font: inherit; font-size: .9rem; font-weight: 700; }
/* 開包方式 toggle (trial): small and quiet, only while the pack is sealed */
.pack-mode { position: fixed; z-index: 3; top: max(16px, env(safe-area-inset-top)); left: 14px; border: 1px solid rgba(107,90,138,.35);
  background: rgba(255,255,255,.55); color: #5a4f6e; border-radius: 999px; padding: 4px 10px; font: inherit; font-size: .75rem; }
.pack-stage { --pw: min(72vw, 280px); position: relative; width: var(--pw); aspect-ratio: 2 / 3; perspective: 1200px; }

/* sealed pack (CSS placeholder foil, used when the pack art cannot load) */
.pack { position: absolute; inset: 0; touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab; }
.pack-top, .pack-body { position: absolute; left: 0; right: 0; background-size: 100% auto; border-radius: 18px;
  background-color: #cfeee2; background-image: linear-gradient(135deg, #cfeee2 0%, #fbd9c9 45%, #e7dcfa 70%, #cfeee2 100%); }
.pack-top { top: 0; height: 16%; border-radius: 18px 18px 6px 6px; background-position: top;
  transform-origin: 0% 100%; transform: rotate(calc(var(--tear, 0) * -14deg)) translateY(calc(var(--tear, 0) * -6px)); transition: transform .08s linear;
  box-shadow: inset 0 -2px 0 rgba(255,255,255,.7); }
.pack-body { top: 16%; bottom: 0; border-radius: 6px 6px 18px 18px; background-position: bottom; box-shadow: 0 14px 30px rgba(74,61,99,.25); overflow: hidden; }
.pack-body::after { content: ''; position: absolute; inset: 0; background: linear-gradient(115deg, transparent 30%, rgba(255,255,255,.55) 45%, transparent 60%);
  background-size: 250% 100%; animation: foil 3.2s ease-in-out infinite; pointer-events: none; }
@keyframes foil { 0%, 100% { background-position: 120% 0; } 50% { background-position: -20% 0; } }
.pack-ph { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: #4a3d63; }
.pack-ph b { font-size: 1.15rem; } .pack-ph small { font-size: .8rem; opacity: .8; }
.pack-fly { font-size: 3rem; filter: drop-shadow(0 0 10px rgba(255,236,150,.9)); }
.pack-hint { position: absolute; z-index: 2; left: 0; right: 0; bottom: -44px; text-align: center; font-size: .85rem; color: #5a4f6e; }
.stage-tearing .pack-top { transform: rotate(-28deg) translate(-30px, -60px); opacity: 0; transition: transform .25s ease-out, opacity .25s ease-out; }
.stage-tearing .pack-body, .stage-card .pack-body { transform: translateY(40%); opacity: 0; transition: transform .35s ease-in .15s, opacity .35s ease-in .15s; }
.stage-card .pack-top { opacity: 0; }

/* drawn pack: front / open body + tear strip share one 1132×1754 box, so the layers line up exactly */
.pack.has-art { inset: 0 1.6%; } /* 2:3 stage → 1132:1754 box */
.pk-layer { position: absolute; inset: 0; width: 100%; height: 100%; display: block; pointer-events: none; -webkit-user-drag: none; }
.pk-front, .pk-body { filter: drop-shadow(0 14px 18px rgba(74,61,99,.22)); }
/* slow, low-contrast foil + holo sheen, clipped to the pack shape */
.pk-holo, .pk-shine { position: absolute; inset: 0; pointer-events: none;
  -webkit-mask: url(../assets/pack/pack_front.webp?v=20261121231136) 0 0 / 100% 100% no-repeat; mask: url(../assets/pack/pack_front.webp?v=20261121231136) 0 0 / 100% 100% no-repeat; }
.pk-holo { background: url(../assets/pack/holo_rainbow.webp?v=20261121231136) 0 0 / 200px 200px repeat; mix-blend-mode: soft-light; opacity: .3; animation: holo-drift 16s linear infinite; }
.pk-shine { background: linear-gradient(115deg, transparent 32%, rgba(255,255,255,.32) 45%, transparent 58%) 0 0 / 250% 100% no-repeat; animation: foil 4.5s ease-in-out infinite; }
@keyframes holo-drift { from { background-position: 0 0; } to { background-position: 200px 200px; } }
/* tear strip follows the finger: it pivots on its right end, the left end lifts (--tear 0..1) */
.pk-strip { transform-origin: 99% 7.6%; transform: translateY(calc(var(--tear, 0) * -1.5%)) rotate(calc(var(--tear, 0) * 9deg)); transition: transform .08s linear; }
.stage-tearing .pk-strip, .stage-card .pk-strip { transform: translate(5%, -36%) rotate(14deg); opacity: 0; transition: transform .25s ease-out, opacity .25s ease-in; }
/* warm glow from the pack mouth: behind the body, 1.45× pack width, bottom edge ~40 px (of 1754) below the tear line */
.pk-glow { position: absolute; left: 50%; top: 9.86%; width: 145%; height: auto; aspect-ratio: 1200 / 700; transform: translate(-50%, -100%);
  opacity: 0; transition: opacity .3s ease-out; pointer-events: none; -webkit-user-drag: none; }
/* the drag rule is limited to the sealed stage so the tearing / card rules below are not outranked (the pack keeps is-open) */
.stage-sealed .pack.is-open .pk-glow { opacity: calc(.2 + var(--tear, 0) * .5); }
.stage-tearing .pk-glow { opacity: .85; transition: opacity .3s ease-out; }
.stage-card .pk-glow { opacity: 0; transition: opacity .25s ease-in; }
.stage-card .pk-body { transform: translateY(40%); opacity: 0; transition: transform .3s ease-in, opacity .3s ease-in; }

/* trial video: 9:16 clip placed so the pack in the clip sits on the stage's pack box; soft edges blend into the overlay */
.pack-video { position: absolute; left: -17.7%; top: -26.4%; width: 131%; aspect-ratio: 9 / 16; cursor: pointer; transition: opacity .3s ease-out;
  -webkit-mask-image: linear-gradient(to bottom, transparent 2%, #000 14%, #000 86%, transparent 98%), linear-gradient(to right, transparent 2%, #000 13%, #000 87%, transparent 98%);
  -webkit-mask-composite: source-in; mask-image: linear-gradient(to bottom, transparent 2%, #000 14%, #000 86%, transparent 98%), linear-gradient(to right, transparent 2%, #000 13%, #000 87%, transparent 98%);
  mask-composite: intersect; }
.pack-video video { display: block; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.stage-card .pack-video { opacity: 0; pointer-events: none; }

/* card: slides up face-down, then flips. A7 (遊戲化 UI 改版方案 v2, 2026-11-21): flip .55 s → .3 s and slide .5 s → .3 s,
   and the hand-tear steps above shortened in the same proportion, so the face shows ~1.2 s after the tap. */
.pack-card { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform .3s cubic-bezier(.2,.7,.2,1);
  animation: card-up .3s ease-out both; cursor: pointer; }
@keyframes card-up { from { transform: translateY(30%) scale(.92); opacity: 0; } to { transform: none; opacity: 1; } }
.pack-card.from-video { animation: card-fade .3s ease-out both; } /* the clip already showed the card rising */
@keyframes card-fade { from { transform: scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }
.pack-card.flipped { transform: rotateY(180deg); animation: none; }
.pc-face { position: absolute; inset: 0; border-radius: 16px; backface-visibility: hidden; -webkit-backface-visibility: hidden; overflow: hidden;
  box-shadow: 0 14px 30px rgba(74,61,99,.25); }
.pc-back { display: grid; place-items: center; background: #f6eedf center / cover; background-image: repeating-linear-gradient(45deg, #f3e7d3 0 10px, #efe0c8 10px 20px);
  border: 6px solid #e8d6b4; color: #8a6a3a; font-weight: 700; letter-spacing: .1em; }
.pc-front { transform: rotateY(180deg); background: #fffaf2; border: 7px solid var(--pc-rim, #d9d2c3); display: flex; flex-direction: column; }
.pack-card.rare .pc-front { --pc-rim: #9cc7ef; } .pack-card.epic .pc-front { --pc-rim: #f0c86a; }
.pc-art { flex: 1; display: grid; place-items: center; background: #f4efe6; margin: 8px; border-radius: 10px; overflow: hidden; }
.pc-art img { width: 100%; height: 100%; object-fit: cover; } .pc-emoji { font-size: 4rem; }
.pc-label { padding: 6px 12px 12px; text-align: center; display: flex; flex-direction: column; gap: 2px; color: #3a2a10; }
.pc-label b { font-size: 1.05rem; } .pc-label small { font-size: .8rem; }
/* soft holographic sheen for 稀有 / 珍貴 only (no flashing: slow, low-contrast) */
.pc-holo { position: absolute; inset: 0; pointer-events: none; mix-blend-mode: soft-light; opacity: .55;
  background: linear-gradient(120deg, rgba(255,175,200,.0) 10%, rgba(255,175,200,.55) 25%, rgba(170,220,255,.55) 40%, rgba(200,255,210,.5) 55%, rgba(255,240,170,.55) 70%, rgba(255,175,200,.0) 85%);
  background-size: 300% 300%; animation: holo 4s ease-in-out infinite; }
.pack-card.epic .pc-holo { opacity: .75; }
@keyframes holo { 0%, 100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }

/* drawn card: card_back, then the rarity frame with the item art in its transparent window and the name on the ribbon.
   Corner radii follow each drawn card (px on the 1000-wide canvas) so the shadow and holo stop at the card edge. */
.pack-card.has-art .pc-face { border: 0; background: none; overflow: visible; display: block; border-radius: 8.5% / 5.67%; }
.pack-card.has-art.common .pc-front { border-radius: 12.3% / 8.2%; }
.pack-card.has-art.rare .pc-front { border-radius: 14.3% / 9.53%; }
.pack-card.has-art.epic .pc-front { border-radius: 15.4% / 10.27%; }
.pc-img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; pointer-events: none; -webkit-user-drag: none; }
.pc-win { position: absolute; display: grid; place-items: center; overflow: hidden; background: #f4efe6; }
.pc-win img { width: 100%; height: 100%; display: block; object-fit: cover; }
.pc-win.is-frame img { object-fit: contain; }
.pc-rainbow, .pc-sparkle { position: absolute; inset: 0; border-radius: inherit; pointer-events: none; }
.pc-rainbow { background: url(../assets/pack/holo_rainbow.webp?v=20261121231136) 0 0 / 220px 220px repeat; mix-blend-mode: soft-light; opacity: .35; animation: rainbow-drift 18s linear infinite; }
@keyframes rainbow-drift { from { background-position: 0 0; } to { background-position: 220px 220px; } }
.pc-sparkle { background: url(../assets/pack/sparkle_mask.webp?v=20261121231136) 0 0 / 180px 180px repeat; mix-blend-mode: screen; opacity: .3; animation: sparkle-drift 24s linear infinite; }
@keyframes sparkle-drift { from { background-position: 0 0; } to { background-position: -180px 180px; } }
.pc-ribbon { position: absolute; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  line-height: 1.1; color: #5b3c12; overflow: hidden; }
.pc-ribbon b { max-width: 100%; font-size: calc(var(--pw) * .054); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pc-ribbon small { font-size: calc(var(--pw) * .036); font-weight: 700; }
.pack-card.epic .pc-ribbon b { font-size: calc(var(--pw) * .05); }

.pack-actions { width: min(80vw, 320px); display: flex; flex-direction: column; gap: 8px; text-align: center; }

@media (prefers-reduced-motion: reduce) {
  .pack-body::after, .pc-holo, .pack-card, .pk-holo, .pk-shine, .pc-rainbow, .pc-sparkle { animation: none !important; }
  .pack-card, .pack-top, .pack-body, .pk-strip, .pk-glow, .pk-body, .pack-video { transition: none !important; }
}
.odds-line { margin: 4px 0 8px; } .odds-items { columns: 2; font-size: .8rem; padding-left: 1.1em; }
.pc-art.is-frame img { object-fit: contain; }

/* Frame-type items are mostly transparent: give the window a soft backdrop and inner edge so thin frames read clearly
   (美術設計 suggestion, 2026-11-21). CSS only, because the frame PNGs are also used as the pet-card overlay. */
.pc-win.is-frameitem, .pc-art.is-frameitem { background: linear-gradient(#E3DAF2, #FFF6E5);
  box-shadow: inset 0 0 0 2px #E8CF97, inset 0 6px 18px rgba(122, 82, 54, .18); }

/* 系列卡包 (2026-11-21): series name above the pack, soft series tint on the drawn pack, picker thumbnail, reward card.
   The tint is a flat pastel multiplied onto the art and clipped to each layer's own shape (inline mask), so the drawn
   pack stays visible underneath. No flashing: the tint never animates on its own. */
.pack-series { margin: 0; text-align: center; }
.pack-series span { display: inline-block; padding: 4px 16px; border-radius: 999px; font-weight: 800; letter-spacing: .08em; color: #3d3352;
  background: #fff; background: color-mix(in srgb, var(--series, #e9e2f3) 45%, #fff); border: 1.5px solid var(--series, #cfc6e0); }
.pk-layer.pk-tint { filter: none; mix-blend-mode: multiply; pointer-events: none;
  -webkit-mask-size: 100% 100%; mask-size: 100% 100%; -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat; -webkit-mask-position: 0 0; mask-position: 0 0; }
/* CSS placeholder pack (art failed to load): use the series colour in the foil gradient */
.pack.tinted .pack-top, .pack.tinted .pack-body { background-color: var(--series);
  background-image: linear-gradient(135deg, var(--series) 0%, #fff6ec 50%, var(--series) 100%); }
/* picker thumbnail */
.pack-thumb { position: relative; width: 64px; aspect-ratio: 1132 / 1754; flex-shrink: 0; }
.pack-thumb img, .pack-thumb .pk-tint { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.pack-thumb img { filter: drop-shadow(0 4px 6px rgba(74,61,99,.2)); }
.pack-thumb .pk-tint { mix-blend-mode: multiply; -webkit-mask-size: 100% 100%; mask-size: 100% 100%; -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat; }
.pack-thumb.ph { display: grid; place-items: center; border-radius: 10px; font-size: 1.6rem;
  background: linear-gradient(135deg, var(--series) 0%, #fff6ec 50%, var(--series) 100%); }
/* 集齊系列 reward card, shown under the revealed card */
.pack-reward { background: #fffaf2; border: 2px solid var(--series, #f0c86a); border-radius: 14px; padding: 8px 12px; text-align: center; color: #3a2a10; }
.pack-reward p { margin: 2px 0; }
.pack-reward-frame { display: flex; align-items: center; gap: 10px; justify-content: center; margin-top: 6px !important; text-align: left; }
.pack-reward-frame img { width: 96px; aspect-ratio: 3 / 2; object-fit: contain; border-radius: 6px; background: linear-gradient(#E3DAF2, #FFF6E5);
  box-shadow: inset 0 0 0 2px #E8CF97, inset 0 6px 18px rgba(122, 82, 54, .18); }
.pack-reward-frame span { display: flex; flex-direction: column; } .pack-reward-frame small { font-size: .75rem; color: #6b5a8a; }
/* short screens: the reward card must fit under the card, so the card shrinks a little and the overlay can scroll.
   .pack-skip / .pack-mode are position: fixed so 「略過」/「關閉」 stays on screen while the overlay scrolls. */
.pack-overlay { overflow-y: auto; }
.pack-overlay.has-reward .pack-stage { --pw: min(56vw, 230px); }
.pack-overlay { justify-content: safe center; }

.pack-reward-medal { display: flex; align-items: center; justify-content: center; gap: 8px; }
.pack-reward-medal img { width: 44px; height: 44px; object-fit: contain; }
