/* ============================================================
   وناااسة Dashboard — styles
   ============================================================ */

@font-face {
  font-family: "Blabeloo";
  src: url("Blabeloo-font-v.1.0.ttf") format("truetype");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

:root {
  --brand-1: #f9d82e;
  --brand-2: #2b539f;
  --brand-3: #c64a22;
  --brand-4: #296230;
  --brand-5: #f2eadf;
  --brand-6: #401311;
  --brand-7: #7cb2d8;
  --brand-8: #eeb8b6;
  --bg: var(--brand-7);
  --bg-card: var(--brand-5);
  --text: #e65100;
  --text-muted: #6b5d58;
  --radius: 16px;
  --shadow: 0 4px 16px rgba(64,19,17,.07);
  --shadow-hover: 0 8px 32px rgba(64,19,17,.14);
  --font: "Tajawal", "Cairo", "Segoe UI", Arial, sans-serif;
}

/* UX-3: smooth scroll */
html { font-size: 16px; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}
button { font-family: inherit; cursor: pointer; border: none; outline: none; }
input { font-family: inherit; }

.brand-font { font-family: "Blabeloo", "Tajawal", sans-serif; }

/* ========== شاشة الدخول ========== */
.auth-screen {
  min-height: 80vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}
.auth-card {
  background: var(--bg-card);
  border-radius: 24px;
  box-shadow: var(--shadow-hover);
  padding: 2.5rem 2rem;
  max-width: 420px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  border-top: 5px solid var(--brand-2);
}
.auth-logo {
  display: block;
  width: 110px;
  height: 110px;
  margin: 0 auto 0.25rem;
  object-fit: contain;
  border-radius: 24px;
}
.auth-title {
  font-size: 2.2rem;
  color: var(--brand-3);
  margin-bottom: 0;
  text-align: center;
  letter-spacing: 1px;
}
.auth-subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin: 0;
  text-align: center;
}
.auth-error {
  color: #c62828;
  font-size: 0.9rem;
  padding: 0.6rem 0.75rem;
  background: rgba(198,40,40,.08);
  border-radius: 10px;
}
.auth-input {
  width: 100%;
  padding: 0.8rem 1rem;
  border: 2px solid #e0d8d2;
  border-radius: 12px;
  font-size: 1rem;
  transition: border-color 0.2s;
}
.auth-input:focus { outline: none; border-color: var(--brand-2); }
.auth-buttons { display: flex; margin-top: 0.5rem; }

/* UX-1: password toggle */
.password-wrap { position: relative; }
.password-wrap .auth-input { padding-left: 2.8rem; }
.toggle-pw {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2.8rem;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  min-height: 44px;
}
.toggle-pw:hover { color: var(--text); }
.toggle-pw svg { width: 20px; height: 20px; flex-shrink: 0; }

/* RESP-2: touch targets */
.btn {
  position: relative;
  overflow: hidden;
  padding: 0.65rem 1.25rem;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 700;
  min-height: 44px;
  transition: transform 0.15s, box-shadow 0.15s, background 0.2s;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--brand-2); color: #fff; width: 100%; }
.btn-primary:hover { background: #1e3f7a; }
.btn-primary:disabled { opacity: 0.7; cursor: not-allowed; transform: none; }
.btn-outline-dark { background: transparent; color: var(--text); border: 2px solid #d0c8c2; }
.btn-outline-dark:hover { background: rgba(64,19,17,.04); border-color: var(--text-muted); }

.auth-card--blocked { border-top-color: var(--brand-3); }
.auth-card--blocked .auth-title { color: var(--brand-3); }

/* ========== الهيدر ========== */
.dashboard-header {
  background: linear-gradient(135deg, var(--brand-2) 0%, #1e3f7a 100%);
  color: #fff;
  padding: 1rem 1.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  box-shadow: 0 2px 12px rgba(43,83,159,.2);
}
.header-right { display: flex; align-items: center; gap: 0.75rem; }
.header-logo { width: 48px; height: 48px; object-fit: contain; border-radius: 12px; }
.header-brand { font-size: 1.75rem; color: var(--brand-1); }
.header-right h1 { font-size: 1.3rem; font-weight: 800; }
.header-left { display: flex; align-items: center; gap: 0.75rem; }
.user-email { font-size: 0.85rem; opacity: 0.85; }
.btn-signout {
  position: relative;
  overflow: hidden;
  background: rgba(255,255,255,.15);
  color: #fff;
  border: 1px solid rgba(255,255,255,.4);
  padding: 0.45rem 1rem;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  min-height: 44px;
  transition: background 0.2s, border-color 0.2s;
}
.btn-signout:hover { background: rgba(255,255,255,.25); border-color: #fff; }

/* UI-3: max-width on headings */
.section-title {
  font-family: "Blabeloo", "Tajawal", sans-serif;
  text-align: center;
  padding: 2rem 1rem 0.5rem;
  font-size: 1.85rem;
  color: var(--text);
  max-width: 700px;
  margin-left: auto;
  margin-right: auto;
}
.section-subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 1.1rem;
  margin-bottom: 1.5rem;
  max-width: 700px;
  margin-left: auto;
  margin-right: auto;
  padding: 0 1rem;
}

/* ========== شبكة البطاقات ========== */
.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
  padding: 0 1.5rem 2.5rem;
  max-width: 1200px;
  margin: 0 auto;
}

/* ANIM-1: staggered entrance */
@keyframes cardEnter {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ========== بطاقة مسابقة ========== */
.game-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow);
  border: 1px solid rgba(0,0,0,.04);
  transition: transform 0.25s, box-shadow 0.25s;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  animation: cardEnter 0.4s ease both;
}
/* PERF-1: will-change only on interactive cards */
.game-card--allowed { will-change: transform; }
.game-card--allowed:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-hover);
  cursor: pointer;
}

/* بريفيو iframe */
.game-preview {
  width: 100%;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  position: relative;
  background: #f8f5f0;
  border-bottom: 1px solid rgba(0,0,0,.06);
}
.game-preview iframe {
  position: absolute;
  top: 0;
  right: 0;
  left: auto;
  width: 400%;
  height: 400%;
  transform: scale(0.25);
  transform-origin: top right;
  border: none;
  pointer-events: none;
}
.game-preview::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 50%, rgba(255,255,255,.3) 100%);
  pointer-events: none;
}
.game-color-bar {
  height: 4px;
  background: var(--game-color, var(--brand-2));
}
.game-body {
  padding: 1.1rem 1.3rem 1.3rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.game-title {
  font-family: "Blabeloo", "Tajawal", sans-serif;
  font-size: 1.5rem;
  color: var(--text);
}
.game-desc { font-size: 1rem; color: var(--text-muted); line-height: 1.7; }
.game-cta {
  font-family: "Blabeloo", "Tajawal", sans-serif;
  display: inline-block;
  margin-top: 0.5rem;
  font-size: 1rem;
  color: var(--game-color, var(--brand-2));
}
.game-card--allowed:hover .game-cta { text-decoration: underline; }

/* UI-2: بطاقة مقفلة */
.game-card--locked { cursor: not-allowed; }
.game-card--locked .game-preview {
  filter: blur(1.5px) grayscale(0.35);
  opacity: 0.65;
}
.game-card--locked .game-body { opacity: 0.6; }
.game-card--locked:hover { transform: none; box-shadow: var(--shadow); }
.lock-banner {
  font-family: "Blabeloo", "Tajawal", sans-serif;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  background: var(--brand-5);
  color: var(--brand-3);
  text-align: center;
  padding: 0.45rem 0.6rem;
  font-size: 1rem;
  z-index: 2;
}

/* Price Badge */
.price-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: var(--brand-1);
  color: var(--brand-6);
  font-family: "Blabeloo", "Tajawal", sans-serif;
  font-size: 0.82rem;
  font-weight: 900;
  padding: 0.22rem 0.55rem 0.22rem 0.45rem;
  border-radius: 20px;
  box-shadow: 0 2px 8px rgba(64,19,17,.18);
  z-index: 3;
  letter-spacing: 0.01em;
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.sar-icon {
  width: 14px;
  height: 16px;
  flex-shrink: 0;
  color: var(--brand-6);
}

/* UI-1: Skeleton Loading */
.game-card--skeleton { pointer-events: none; }
@keyframes skeletonShimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}
.skeleton-preview {
  width: 100%;
  aspect-ratio: 16 / 10;
  background: linear-gradient(90deg, #ddd5c8 25%, #ede5dc 50%, #ddd5c8 75%);
  background-size: 200% 100%;
  animation: skeletonShimmer 1.5s infinite;
}
.skeleton-body { padding: 1.1rem 1.3rem 1.3rem; display: flex; flex-direction: column; gap: 0.6rem; }
.skeleton-line {
  height: 14px;
  border-radius: 7px;
  background: linear-gradient(90deg, #ddd5c8 25%, #ede5dc 50%, #ddd5c8 75%);
  background-size: 200% 100%;
  animation: skeletonShimmer 1.5s infinite;
}
.skeleton-line.title { height: 22px; width: 65%; }
.skeleton-line.short { width: 40%; }

/* ANIM-3: Toast — scale spring */
.lock-toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(120%) scale(0.85);
  background: var(--brand-5);
  color: var(--brand-3);
  padding: 0.9rem 1.75rem;
  border-radius: 14px;
  font-size: 0.95rem;
  font-weight: 700;
  font-family: "Blabeloo", "Tajawal", sans-serif;
  box-shadow: 0 8px 28px rgba(64,19,17,.25);
  z-index: 999;
  opacity: 0;
  transition: transform 0.35s cubic-bezier(.22,.68,0,1.2), opacity 0.3s;
  pointer-events: auto;
  text-align: center;
  max-width: 90vw;
}
.lock-toast a { color: inherit; text-decoration: underline; white-space: nowrap; }
.lock-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0) scale(1);
}

/* ANIM-2: Ripple */
.ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,.4);
  transform: scale(0);
  animation: rippleAnim 0.5s linear;
  pointer-events: none;
}
@keyframes rippleAnim { to { transform: scale(4); opacity: 0; } }

/* ========== متجاوب ========== */
@media (max-width: 700px) {
  .dashboard-header { flex-direction: column; text-align: center; padding: 0.85rem 1rem; gap: 0.6rem; }
  .header-right { flex-wrap: wrap; justify-content: center; }
  .header-brand { font-size: 1.5rem; }
  .header-logo { width: 42px; height: 42px; }
  .header-left { justify-content: center; flex-wrap: wrap; gap: 0.5rem; }
  .user-email { font-size: 0.85rem; }
  .btn-signout { font-size: 0.85rem; padding: 0.4rem 0.85rem; }
  .section-title { font-size: 1.5rem; padding-top: 1.25rem; }
  .section-subtitle { font-size: 0.95rem; }
  .games-grid { grid-template-columns: repeat(2, 1fr); gap: 0.75rem; padding: 0 0.6rem 2rem; }
  .game-preview { aspect-ratio: 4 / 3; }
  .game-body { padding: 0.75rem 0.7rem 0.85rem; }
  .game-title { font-size: 1.15rem; }
  .game-desc { font-size: 0.85rem; }
  .game-cta { font-size: 0.85rem; }
  .auth-card { padding: 2rem 1.25rem; margin: 0 0.5rem; }
  .auth-logo { width: 90px; height: 90px; }
  .auth-title { font-size: 1.8rem; }
}
/* RESP-1: single column < 400px */
@media (max-width: 400px) {
  .games-grid { grid-template-columns: 1fr; }
}
@media (max-width: 380px) {
  .dashboard-header { padding: 0.7rem 0.75rem; }
  .header-brand { font-size: 1.35rem; }
  .header-logo { width: 38px; height: 38px; }
  .games-grid { padding: 0 0.4rem 1.5rem; gap: 0.6rem; }
  .game-body { padding: 0.65rem 0.6rem 0.75rem; }
  .game-title { font-size: 1.05rem; }
  .game-desc { font-size: 0.8rem; }
  .lock-toast { font-size: 0.9rem; padding: 0.75rem 1.25rem; }
}
@media (min-width: 701px) and (max-width: 1000px) {
  .games-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ========== شاشة التحميل ========== */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  z-index: 600;
  transition: opacity 0.4s;
}
.loading-overlay.fade-out { opacity: 0; pointer-events: none; }
.loading-spinner {
  width: 52px;
  height: 52px;
  border: 4px solid rgba(255,255,255,.25);
  border-top-color: var(--brand-1);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
/* UI-6: loading text */
.loading-text { color: #fff; font-size: 1rem; font-weight: 600; opacity: 0.8; font-family: "Blabeloo", "Tajawal", sans-serif; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ========== انتقال ناعم ========== */
@keyframes screenFadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.auth-screen:not([hidden]),
#appScreen:not([hidden]) {
  animation: screenFadeIn 0.35s ease;
}

/* UI-5: زر واتساب بـ pulse */
@keyframes waPulse {
  0%, 100% { box-shadow: 0 4px 18px rgba(37,211,102,.45); }
  50%       { box-shadow: 0 4px 28px rgba(37,211,102,.75), 0 0 0 8px rgba(37,211,102,.15); }
}
.wa-fab {
  position: fixed;
  /* RESP-3: safe-area */
  bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px));
  left: 1.5rem;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: #25d366;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 18px rgba(37,211,102,.45);
  z-index: 500;
  transition: transform 0.2s, box-shadow 0.2s;
  text-decoration: none;
  animation: waPulse 2.5s ease-in-out infinite;
}
.wa-fab:hover { transform: scale(1.1); animation: none; box-shadow: 0 6px 26px rgba(37,211,102,.65); }
.wa-fab svg { width: 30px; height: 30px; fill: #fff; }

/* ========== مودال تكبير الصورة ========== */
.img-modal {
  position: fixed;
  inset: 0;
  z-index: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  animation: screenFadeIn 0.25s ease;
}
.img-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.75);
  backdrop-filter: blur(4px);
}
.img-modal img {
  position: relative;
  max-width: min(420px, 90vw);
  max-height: 80vh;
  border-radius: 20px;
  box-shadow: 0 16px 48px rgba(0,0,0,.4);
  object-fit: contain;
}
.img-modal-close {
  position: absolute;
  top: 1rem;
  left: 1rem;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,.15);
  color: #fff;
  font-size: 1.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  transition: background 0.2s;
  z-index: 1;
}
.img-modal-close:hover { background: rgba(255,255,255,.3); }

.auth-logo, .header-logo { cursor: zoom-in; }

/* ========== الفوتر ========== */
.dash-footer { text-align: center; padding: 14px 12px; font-size: 12px; color: var(--text-muted); opacity: 0.8; }
.dash-footer .brand-mark { font-family: "Blabeloo", "Tajawal", sans-serif; color: var(--brand-1); font-weight: 700; }
.dash-footer a { color: inherit; text-decoration: none; }
.dash-footer a:hover { text-decoration: underline; }
