/* XD_CARD_TRANSITION_V1 — انتقال ناعم من كرت اللعبة إلى صفحة اللعبة */
@media(prefers-reduced-motion:no-preference){

/* ===== الخروج من صفحة الألعاب ===== */
body.xd-card-leaving{overflow:hidden}
body.xd-card-leaving .games-grid{perspective:1200px}

/* كل شيء غير الكرت المختار ينسحب */
body.xd-card-leaving .xd-card-fade{
 animation:xdCardFade .34s cubic-bezier(.4,0,.9,.4) both;
 pointer-events:none;
}
@keyframes xdCardFade{
 from{opacity:1;transform:none;filter:blur(0)}
 to{opacity:0;transform:translateY(14px) scale(.965);filter:blur(3px)}
}

/* الكرت المختار يبقى، يلمع، ثم يصغر لين يختفي */
body.xd-card-leaving .xd-card-chosen{
 position:relative;
 z-index:90;
 pointer-events:none;
 transform-origin:center center;
 animation:xdCardChosen .62s cubic-bezier(.55,.02,.36,1) both;
 animation-delay:.06s;
}
@keyframes xdCardChosen{
 0%{opacity:1;transform:none;box-shadow:0 14px 36px rgba(0,0,0,.24)}
 26%{opacity:1;transform:scale(1.035);box-shadow:0 26px 70px rgba(0,0,0,.42),0 0 0 1px rgba(245,158,11,.5)}
 100%{opacity:0;transform:scale(.34);box-shadow:0 0 0 rgba(0,0,0,0)}
}
body.xd-card-leaving .xd-card-chosen:after{
 content:'';position:absolute;inset:0;border-radius:inherit;pointer-events:none;
 background:radial-gradient(circle at 50% 50%,rgba(245,158,11,.24),transparent 62%);
 animation:xdCardGlow .62s ease-out both;animation-delay:.06s;
}
@keyframes xdCardGlow{0%{opacity:0}30%{opacity:1}100%{opacity:0}}

/* ستارة تغطي الصفحة بنهاية الانتقال حتى لا تومض قبل التنقل */
.xd-card-veil{
 position:fixed;inset:0;z-index:2147483000;pointer-events:none;
 background:radial-gradient(circle at 50% -15%,rgba(245,158,11,.12),transparent 34%),radial-gradient(circle at 110% 80%,rgba(234,88,12,.055),transparent 32%),#0f0f0f;
 opacity:0;animation:xdVeilIn .30s ease-out both;animation-delay:.34s;
}
@keyframes xdVeilIn{from{opacity:0}to{opacity:1}}

/* ===== الدخول لصفحة اللعبة: ＋ و # يطلعون من تحت ===== */
.xd-enter-stage{animation:xdStageIn .44s cubic-bezier(.2,.85,.3,1) both}
@keyframes xdStageIn{from{opacity:0;transform:translateY(-10px)}to{opacity:1;transform:none}}

.xd-enter-card{animation:xdCardRise .62s cubic-bezier(.16,.86,.24,1) both}
.xd-enter-card:nth-of-type(1){animation-delay:.10s}
.xd-enter-card:nth-of-type(2){animation-delay:.19s}
.xd-enter-card:nth-of-type(3){animation-delay:.28s}
.xd-enter-card:nth-of-type(4){animation-delay:.37s}
@keyframes xdCardRise{
 from{opacity:0;transform:translateY(46px) scale(.94)}
 60%{opacity:1}
 to{opacity:1;transform:none}
}

/* الأيقونة نفسها (＋ / #) تنبض بلطف بعد ما يستقر الكرت */
.xd-enter-card .xd-home-icon,.xd-enter-card .xd-room-entry-art{animation:xdIconPop .5s cubic-bezier(.2,1.5,.4,1) both;animation-delay:.34s}
@keyframes xdIconPop{from{opacity:0;transform:scale(.55)}to{opacity:1;transform:none}}

}
/* /XD_CARD_TRANSITION_V1 */

/* XD_CARD_AMBIENT_V1 — كروت الألعاب تتحرك من نفسها بدون ما تأشر عليها
   كل الحركة على transform/opacity فقط (تشتغل على كرت الرسم مو المعالج). */
@media(prefers-reduced-motion:no-preference){

.games-grid .game-card{will-change:transform}
.games-grid .game-cover>.cover-scene,
.games-grid .game-cover>img{
 animation:xdCoverDrift 7.5s ease-in-out infinite;
 transform-origin:52% 48%;
}
.games-grid .game-card:nth-child(2n) .game-cover>.cover-scene,
.games-grid .game-card:nth-child(2n) .game-cover>img{animation-delay:-1.9s}
.games-grid .game-card:nth-child(3n) .game-cover>.cover-scene,
.games-grid .game-card:nth-child(3n) .game-cover>img{animation-delay:-3.7s}
.games-grid .game-card:nth-child(4n) .game-cover>.cover-scene,
.games-grid .game-card:nth-child(4n) .game-cover>img{animation-delay:-5.4s}
@keyframes xdCoverDrift{
 0%,100%{transform:scale(1.012) translate3d(0,0,0)}
 50%    {transform:scale(1.055) translate3d(0,-4px,0)}
}
/* كرت مين الكذاب مرسوم بعناصر مستقلة — نعطيه نبضة توهّج بدل التكبير */
.games-grid .game-cover>.liar-glow{animation:xdLiarPulse 5.2s ease-in-out infinite}
@keyframes xdLiarPulse{0%,100%{opacity:.55;transform:scale(1)}50%{opacity:1;transform:scale(1.08)}}
.games-grid .game-cover>.liar-mini{animation:xdLiarFloat 6.4s ease-in-out infinite}
.games-grid .game-cover>.liar-mini:nth-of-type(2){animation-delay:-1.6s}
.games-grid .game-cover>.liar-mini:nth-of-type(3){animation-delay:-3.2s}
.games-grid .game-cover>.liar-mini:nth-of-type(4){animation-delay:-4.8s}
@keyframes xdLiarFloat{0%,100%{transform:translateY(0)}50%{transform:translateY(-5px)}}

/* السهم يتنفس بدل ما ينتظر المؤشر */
.games-grid .game-title span{animation:xdArrowNudge 3.4s ease-in-out infinite}
.games-grid .game-card:nth-child(2n) .game-title span{animation-delay:-1.1s}
.games-grid .game-card:nth-child(3n) .game-title span{animation-delay:-2.2s}
@keyframes xdArrowNudge{
 0%,72%,100%{transform:translateX(0)}
 84%{transform:translateX(-4px)}
}

/* توهّج خفيف يمر على الحافة — طبقة opacity فقط، بدون box-shadow متحرك */
.games-grid .game-card:before{
 content:'';position:absolute;inset:0;z-index:3;border-radius:inherit;pointer-events:none;
 box-shadow:inset 0 0 0 1px rgba(245,158,11,.42);
 opacity:0;animation:xdEdgeGlow 6s ease-in-out infinite;
}
.games-grid .game-card:nth-child(2n):before{animation-delay:-1.5s}
.games-grid .game-card:nth-child(3n):before{animation-delay:-3s}
.games-grid .game-card:nth-child(4n):before{animation-delay:-4.5s}
@keyframes xdEdgeGlow{0%,64%,100%{opacity:0}80%{opacity:.85}}

/* على الماوس تبقى الاستجابة أقوى: نوقف التنفّس ونعطي التكبير الكامل */
@media(hover:hover){
 .games-grid .game-card:hover .game-cover>.cover-scene,
 .games-grid .game-card:hover .game-cover>img,
 .games-grid .game-card:hover .game-cover>.liar-glow,
 .games-grid .game-card:hover .game-cover>.liar-mini{animation-play-state:paused}
 .games-grid .game-card:hover .game-title span{animation-play-state:paused}
 .games-grid .game-card:hover:before{animation-play-state:paused;opacity:0}
}

/* أثناء الخروج نوقف كل الحركة المحيطة حتى لا تتضارب مع انيميشن الانتقال */
body.xd-card-leaving .games-grid .game-cover>.cover-scene,
body.xd-card-leaving .games-grid .game-cover>img,
body.xd-card-leaving .games-grid .game-cover>.liar-glow,
body.xd-card-leaving .games-grid .game-cover>.liar-mini,
body.xd-card-leaving .games-grid .game-title span,
body.xd-card-leaving .games-grid .game-card:before{animation:none!important;opacity:0}
body.xd-card-leaving .xd-card-chosen:before{opacity:0!important}

/* كروت الصفحة الرئيسية تطلع من تحت أول ما تفتح */
.games-grid.xd-hub-in .game-card{animation:xdCardRise .58s cubic-bezier(.16,.86,.24,1) both}
.games-grid.xd-hub-in .game-card:nth-child(1){animation-delay:.04s}
.games-grid.xd-hub-in .game-card:nth-child(2){animation-delay:.10s}
.games-grid.xd-hub-in .game-card:nth-child(3){animation-delay:.16s}
.games-grid.xd-hub-in .game-card:nth-child(4){animation-delay:.22s}
.games-grid.xd-hub-in .game-card:nth-child(5){animation-delay:.28s}
.games-grid.xd-hub-in .game-card:nth-child(6){animation-delay:.34s}

/* الرجوع للألعاب: كرتا ＋ و # ينزلون ويختفون قبل التنقل */
body.xd-back-leaving .xd-home-card,
body.xd-back-leaving .xd-room-entry-card{animation:xdCardSink .40s cubic-bezier(.4,0,.9,.4) both;pointer-events:none}
body.xd-back-leaving .xd-home-card:nth-of-type(2),
body.xd-back-leaving .xd-room-entry-card:nth-of-type(2){animation-delay:.05s}
@keyframes xdCardSink{from{opacity:1;transform:none}to{opacity:0;transform:translateY(34px) scale(.95)}}
body.xd-back-leaving .xd-card-veil{animation-duration:.26s;animation-delay:.12s}
body.xd-back-leaving .xd-home-hero,
body.xd-back-leaving #homeScreen .hero{animation:xdCardFade .34s ease-in both}

}
/* /XD_CARD_AMBIENT_V1 */

/* XD_GAME_END_RETURN_V1 — زر العودة لصفحة دخول اللعبة بعد نهاية الجولة */
.xd-end-return{
 display:inline-flex!important;align-items:center;justify-content:center;
 margin:22px auto 4px;padding:12px 26px;min-height:46px;
 border-radius:12px;text-decoration:none;white-space:nowrap;
 font:900 .68rem/1 Cairo,sans-serif;cursor:pointer;
}
#resultsScreen>.xd-end-return,#galleryScreen>.xd-end-return,
#finishedScreen>.xd-end-return,#finished>.xd-end-return{display:flex!important;width:fit-content}
/* /XD_GAME_END_RETURN_V1 */

/* XD_CODENAMES_LOBBY_CROWN_V52 — التاج في كود نيمز معناه «القائد»،
   فما نعرضه في غرفة الانتظار حتى لا يختلط بمالك السيرفر. */
body.xd-codenames #lobbyScreen .xd-server-owner-badge{display:none!important}
body.xd-codenames #lobbyScreen .player-card>em,
body.xd-codenames #lobbyScreen .cn-server-player>em{display:none!important}
/* /XD_CODENAMES_LOBBY_CROWN_V52 */
