/* بطاقات الأدوار — مشهد الكشف وعرضها في صفحة طريقة اللعب */

/* ---------- مشهد الكشف ---------- */
#overlay-card.wide { max-width: 520px; }

.card-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-xs);
}
.card-hint {
  color: var(--body);
  font-size: 0.88rem;
  margin: 0;
  min-height: 1.4em;
}

/* البطاقة القابلة للقلب */
.card-flip {
  position: relative;
  width: min(240px, 62vw);
  aspect-ratio: 1728 / 2432;
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform 0.75s cubic-bezier(0.4, 0.1, 0.2, 1);
  animation: cardArrive 0.6s cubic-bezier(0.2, 1, 0.3, 1);
  outline: none;
}
.card-flip:focus-visible { box-shadow: 0 0 0 3px var(--primary); }
.card-flip:not(.revealed):hover { transform: translateY(-6px) rotateY(-8deg); }
.card-flip.revealed { transform: rotateY(180deg); }

.card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.7);
}
.card-face img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-front { transform: rotateY(180deg); }

/* اسم الدور للبطاقات التي لم تُرسم بعد */
.card-name {
  position: absolute;
  left: 0; right: 0; bottom: 8%;
  text-align: center;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
  text-shadow: 0 2px 6px #000;
}

/* نبضة خفيفة تدعو للنقر قبل الكشف */
.card-flip:not(.revealed)::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 14px;
  border: 2px solid rgba(218, 41, 28, 0.5);
  animation: cardPulse 1.8s ease-in-out infinite;
  pointer-events: none;
}
@keyframes cardPulse {
  0%, 100% { opacity: 0.25; transform: scale(1); }
  50% { opacity: 0.8; transform: scale(1.03); }
}
@keyframes cardArrive {
  from { opacity: 0; transform: translateY(26px) scale(0.9) rotate(-4deg); }
}

/* تفاصيل الدور تظهر بعد الكشف فقط */
.card-info {
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  transition: opacity 0.5s ease 0.35s, max-height 0.5s ease 0.35s;
  width: 100%;
}
.card-info.show { opacity: 1; max-height: 340px; }
.card-info h3 { font-size: 1.3rem; font-weight: 500; margin-bottom: 6px; }
.card-info p { color: var(--body); line-height: 1.7; font-size: 0.92rem; margin-bottom: var(--sp-xs); }
.card-info .card-mates b { color: var(--ink); }
.card-info button { width: 100%; }

/* ---------- شبكة البطاقات في صفحة طريقة اللعب ---------- */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--sp-sm);
}
.role-card { text-align: center; }
.role-card .card-img {
  position: relative;
  width: 100%;
  aspect-ratio: 1728 / 2432;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
  transition: transform 0.3s cubic-bezier(0.2, 1, 0.3, 1), box-shadow 0.3s ease;
}
.role-card:hover .card-img {
  transform: translateY(-8px) rotate(-1.5deg);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.7);
}
.role-card .card-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.role-card .card-img .fallback-name {
  position: absolute;
  left: 0; right: 0; bottom: 8%;
  font-size: 0.95rem;
  font-weight: 700;
  text-shadow: 0 2px 6px #000;
}
.role-card h3 { margin-top: var(--sp-xxs); font-size: 1rem; font-weight: 700; }
.role-card p { color: var(--body); font-size: 0.84rem; line-height: 1.6; margin-top: 4px; }
.role-card .team {
  display: inline-block;
  border-radius: 9999px;
  padding: 2px 10px;
  font-size: 0.82rem;
  font-weight: 700;
  margin-top: 6px;
}
.role-card .team.bad { background: rgba(218, 41, 28, 0.18); color: #ff8a80; }
.role-card .team.good { background: rgba(3, 144, 74, 0.18); color: #57d99a; }
.role-card .team.solo { background: rgba(246, 229, 0, 0.14); color: #d8cf6a; }

@media (prefers-reduced-motion: reduce) {
  .card-flip, .card-face, .role-card .card-img { transition: none !important; animation: none !important; }
  .card-flip:not(.revealed)::after { animation: none !important; }
}
