/* KTC item cases (system/ktc/cases.php): the case card's odds (system/ktc/box/item_card.php), the
   case editor (system/box/edit_gift.php), the shop's case badge, the room announcement, and the
   opening stage (js/ktc/ktc_cases.js): the page blurred behind, a reel, and the reveal. */

/* the case card: what's inside, at what odds */
.case_tag { display: inline-flex; align-items: center; gap: 4px; margin-left: 6px; padding: 2px 8px; border-radius: 999px; background: rgba(18, 194, 233, .14); color: #12c2e9; font-size: 12px; font-weight: 700; }
.case_inside { margin-top: 12px; }
.case_inside_list { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 8px; scroll-snap-type: x proximity; scrollbar-width: thin; }
/* each tile: the item framed by its rarity (css/ktc/ktc-items.css), its odds, a bar for them, its name */
.case_inside_row { position: relative; flex: none; display: flex; flex-direction: column; align-items: center; gap: 4px; width: 92px; padding: 10px 6px 8px; box-sizing: border-box; border-radius: 12px; --gift-radius: 12px; --gift-border: 3px; border-width: 3px !important; background: rgba(255, 255, 255, .04); text-align: center; scroll-snap-align: start; }
.case_inside_art { display: flex; align-items: center; justify-content: center; width: 52px; height: 52px; }
.case_inside_art img { max-width: 52px; max-height: 52px; object-fit: contain; transform: scale(1.25); }
.case_inside_odds { font-size: 15px; font-weight: 800; line-height: 1.2; font-variant-numeric: tabular-nums; }
.case_inside_bar { display: block; width: 100%; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, .08); overflow: hidden; }
.case_inside_bar > span { display: block; height: 100%; background: var(--gift-rarity, #9aa0a6); }
.case_inside_name { width: 100%; overflow: hidden; font-size: 12px; font-weight: 600; line-height: 1.3; color: #ccc; text-overflow: ellipsis; white-space: nowrap; }
.case_inside_out { opacity: .45; }
.case_inside_note { margin: 8px 0 0; }
/* in the shop, when a case is chosen (system/box/gift.php): under its name, left aligned */
#gift_second .case_inside { max-width: 560px; margin: 16px auto 8px; }
#gift_second .case_inside > .item_card_label, #gift_second .case_inside_note { text-align: center; }
/* the row centred when it fits, scrolling from the start when it doesn't */
#gift_second .case_inside_row:first-child { margin-left: auto; }
#gift_second .case_inside_row:last-child { margin-right: auto; }
#gift_second .case_inside[hidden] { display: none; }
.case_open_count { display: inline-block; min-width: 20px; margin-left: 4px; padding: 0 6px; border-radius: 999px; background: rgba(0, 0, 0, .25); font-size: 12px; }
.case_open_btn.case_opening { opacity: .7; pointer-events: none; }

/* the shop's badge on a case */
.shop_card_case { position: absolute; top: 6px; right: 6px; z-index: 1; display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; background: rgba(18, 194, 233, .9); color: #fff; font-size: 11px; }

/* the case editor */
.case_rows { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.case_row { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 10px; background: rgba(255, 255, 255, .04); }
.case_row .gift_frame { padding: 2px; --gift-radius: 8px; }
.case_row .gift_frame img { width: 28px; height: 28px; object-fit: contain; display: block; }
.case_row_name { flex: 1; min-width: 0; overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.case_row_chance { width: 76px; padding: 6px 8px; text-align: right; }
.case_row_pct { font-size: 13px; color: #888; }
.case_row_remove { width: 32px; height: 32px; border: 0; border-radius: 50%; background: none; color: #888; cursor: pointer; }
.case_row_remove:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.case_total { margin: 8px 0 0; font-size: 14px; }
.case_total b { color: #74b20e; }
.case_total b.case_total_off { color: #ef4444; }

/* the room announcement */
.case_announce .gift_rarity_label { font-weight: 700; }
.case_announce_img { width: 20px; height: 20px; object-fit: contain; vertical-align: middle; }

/* the stage: everything behind it blurred and darkened */
body.case_open_now { overflow: hidden; }
.case_stage { position: fixed; inset: 0; z-index: 100000; display: flex; flex-direction: column; align-items: center; justify-content: center; overflow: hidden; background: rgba(8, 4, 16, .55); backdrop-filter: blur(14px) saturate(.7); -webkit-backdrop-filter: blur(14px) saturate(.7); font-family: var(--ktc-font); color: #fff; opacity: 0; transition: opacity .25s ease; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.case_stage.is_on { opacity: 1; }

/* open: the case drops in, squashes, shakes and bursts */
.case_intro { position: absolute; display: none; }
.case_stage.is_intro .case_intro { display: block; animation: caseDrop .9s cubic-bezier(.2, .8, .3, 1) both; }
.case_intro_img { display: block; width: 168px; height: 168px; object-fit: contain; filter: drop-shadow(0 16px 32px rgba(0, 0, 0, .5)); }
@keyframes caseDrop {
	0% { transform: translateY(-60vh) scale(.6); opacity: 0; }
	35% { transform: translateY(0) scale(1.08, .9); opacity: 1; }
	48% { transform: scale(.96, 1.05); }
	58%, 66%, 74% { transform: rotate(-6deg) scale(1.02); }
	62%, 70%, 78% { transform: rotate(6deg) scale(1.02); }
	88% { transform: scale(1.18); opacity: 1; }
	100% { transform: scale(1.6); opacity: 0; }
}

/* spin: the reel and its marker */
.case_reel_wrap { position: relative; display: none; width: 100%; max-width: 920px; overflow: hidden; -webkit-mask-image: linear-gradient(90deg, transparent, #000 18%, #000 82%, transparent); mask-image: linear-gradient(90deg, transparent, #000 18%, #000 82%, transparent); }
.case_stage.is_spin .case_reel_wrap, .case_stage.is_land .case_reel_wrap { display: block; animation: caseReelIn .3s ease-out both; }
@keyframes caseReelIn { from { opacity: 0; transform: scale(.92); } to { opacity: 1; transform: none; } }
.case_reel { display: flex; gap: 10px; padding: 18px 0; will-change: transform; }
.case_tile { flex: none; display: flex; align-items: center; justify-content: center; width: 116px; height: 116px; box-sizing: border-box; border-radius: 16px; --gift-radius: 16px; background: rgba(20, 16, 32, .9); transition: opacity .3s, transform .35s cubic-bezier(.2, .9, .3, 1.4), box-shadow .3s; }
.case_tile img { width: 76px; height: 76px; object-fit: contain; pointer-events: none; }
.case_marker { position: absolute; top: 0; bottom: 0; left: 50%; z-index: 2; width: 4px; margin-left: -2px; border-radius: 2px; background: linear-gradient(#fc00ff, #7a5cff, #00dbde); box-shadow: 0 0 12px rgba(122, 92, 255, .9), 0 0 28px rgba(0, 219, 222, .5); }
.case_marker::before, .case_marker::after { content: ''; position: absolute; left: 50%; margin-left: -9px; border: 9px solid transparent; }
.case_marker::before { top: 0; border-top-color: #fc00ff; }
.case_marker::after { bottom: 0; border-bottom-color: #00dbde; }

/* land: the winner grows and glows, the rest dim */
.case_stage.is_land .case_tile { opacity: .3; }
.case_stage.is_land .case_tile.is_won { opacity: 1; transform: scale(1.14); box-shadow: 0 0 24px var(--gift-rarity, #fff), 0 0 56px var(--gift-rarity, #fff); }
.case_stage.is_land .case_marker { animation: caseMarker .5s ease-out; }
@keyframes caseMarker { 50% { box-shadow: 0 0 24px #fff, 0 0 60px rgba(122, 92, 255, 1); } }

/* reveal */
.case_reveal { position: relative; display: none; flex-direction: column; align-items: center; width: min(420px, calc(100vw - 32px)); text-align: center; }
.case_stage.is_reveal .case_reveal { display: flex; animation: caseReveal .55s cubic-bezier(.2, .9, .3, 1.35) both; }
@keyframes caseReveal { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: none; } }
.case_rays { position: absolute; top: 40px; left: 50%; width: 520px; height: 520px; margin-left: -260px; border-radius: 50%; z-index: -1; opacity: .55; background: repeating-conic-gradient(from 0deg, var(--case-glow, #fff) 0 6deg, transparent 6deg 18deg); -webkit-mask-image: radial-gradient(circle, #000 0 30%, transparent 68%); mask-image: radial-gradient(circle, #000 0 30%, transparent 68%); animation: caseRays 14s linear infinite; }
@keyframes caseRays { to { transform: rotate(360deg); } }
.case_stage.tier_0 { --case-glow: rgba(154, 160, 166, .5); }
.case_stage.tier_1 { --case-glow: rgba(143, 224, 110, .55); }
.case_stage.tier_2 { --case-glow: rgba(239, 68, 68, .6); }
.case_stage.tier_3 { --case-glow: rgba(168, 85, 247, .7); }
.case_reveal_kicker { margin: 0 0 12px; font-size: 14px; font-weight: 600; color: rgba(255, 255, 255, .7); }
.case_reveal_art { margin-bottom: 16px; }
.case_reveal_frame { padding: 8px; --gift-radius: 24px; background: rgba(20, 16, 32, .85); box-shadow: 0 0 40px var(--case-glow), 0 20px 50px rgba(0, 0, 0, .5); }
.case_reveal_frame img { display: block; width: 168px; height: 168px; object-fit: contain; }
.case_stage.is_reveal .case_reveal_frame img { animation: caseFloat 3s ease-in-out .6s infinite; }
@keyframes caseFloat { 50% { transform: translateY(-6px); } }
.case_reveal_name { margin: 0; font-size: 26px; font-weight: 800; line-height: 1.2; text-shadow: 0 2px 12px rgba(0, 0, 0, .5); }
.case_reveal_meta { margin: 6px 0 0; font-size: 15px; font-weight: 700; }
.case_reveal_serial { color: rgba(255, 255, 255, .7); }
.case_reveal_odds { margin: 4px 0 24px; font-size: 13px; color: rgba(255, 255, 255, .55); }
.case_reveal_actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; width: 100%; }
.case_reveal_actions .reg_button { min-height: 44px; padding: 0 18px; }
.case_again { flex: 1 1 100%; font-size: 16px; }
.case_again_left { margin-left: 6px; padding: 2px 8px; border-radius: 999px; background: rgba(0, 0, 0, .25); font-size: 12px; }

/* feedback that grows with rarity: a flash and shake for Ultra rare, more for Unique */
.case_flash { position: absolute; inset: 0; z-index: 3; background: #fff; opacity: 0; pointer-events: none; }
.case_stage.is_reveal.tier_2 .case_flash { animation: caseFlash .35s ease-out; }
.case_stage.is_reveal.tier_3 .case_flash { animation: caseFlash .6s ease-out; }
@keyframes caseFlash { 0% { opacity: .55; } 100% { opacity: 0; } }
.case_stage.is_reveal.tier_2 .case_reveal { animation: caseReveal .55s cubic-bezier(.2, .9, .3, 1.35) both, caseShake .4s ease-out .05s; }
.case_stage.is_reveal.tier_3 .case_reveal { animation: caseReveal .65s cubic-bezier(.2, .9, .3, 1.45) both, caseShake .6s ease-out .05s; }
@keyframes caseShake {
	10%, 50%, 90% { translate: -6px 2px; }
	30%, 70% { translate: 6px -2px; }
	100% { translate: 0 0; }
}
.case_stage.tier_3 .case_rays { opacity: .8; }

/* confetti: thrown out from the item, falling under gravity */
.case_confetti { position: absolute; top: 42%; left: 50%; z-index: 4; pointer-events: none; }
.case_confetti i { position: absolute; display: block; animation: caseConfetti var(--d) cubic-bezier(.15, .6, .4, 1) forwards; }
@keyframes caseConfetti {
	0% { transform: translate(0, 0) rotate(0); opacity: 1; }
	70% { opacity: 1; }
	100% { transform: translate(var(--dx), calc(var(--dy) + 340px)) rotate(var(--r)); opacity: 0; }
}

@media (max-width: 640px) {
	.case_tile { width: 92px; height: 92px; border-radius: 14px; --gift-radius: 14px; }
	.case_tile img { width: 60px; height: 60px; }
	.case_reel { gap: 8px; }
	.case_intro_img { width: 136px; height: 136px; }
	.case_reveal_frame img { width: 140px; height: 140px; }
	.case_reveal_name { font-size: 22px; }
	.case_rays { width: 420px; height: 420px; margin-left: -210px; }
	.case_inside_row { width: 84px; }
}
@media (prefers-reduced-motion: reduce) {
	.case_stage.is_intro .case_intro, .case_reveal, .case_rays, .case_reveal_frame img, .case_flash { animation: none !important; }
	.case_tile { transition: opacity .2s; }
	.case_stage.is_land .case_tile.is_won { transform: none; }
}
