/* ── Variables ─────────────────────────────── */
:root {
  --bg:           #090913;
  --bg-card:      #0f0f1f;
  --bg-card-h:    #141430;
  --accent:       #7c6fff;
  --accent-dim:   rgba(124,111,255,.14);
  --accent-glow:  rgba(124,111,255,.28);
  --accent2:      #ff6b9d;
  --text:         #dde0f0;
  --text-sub:     #6a6d90;
  --border:       #1a1a30;
  --border-h:     #7c6fff;
  --radius:       14px;
  --t:            .28s cubic-bezier(.4,0,.2,1);
}

/* ── Reset ─────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html  { scroll-behavior: smooth; }
body  {
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}
a { color: inherit; }
img { display: block; }
button { font: inherit; }

/* ── Stars canvas ──────────────────────────── */
#stars {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: .7;
}

/* ── Stacking context ──────────────────────── */
.site-header,
.site-main,
.site-footer { position: relative; z-index: 1; }

/* ── Scrollbar ─────────────────────────────── */
::-webkit-scrollbar       { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: #2a2a4a; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ══════════════════════════════════════════════
   NAV
══════════════════════════════════════════════ */
.site-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 36px;
  max-width: 1200px;
  margin: 0 auto;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -.02em;
  color: var(--text);
  transition: opacity var(--t);
}
.nav-brand:hover { opacity: .8; }

.nav-gh {
  color: var(--text-sub);
  text-decoration: none;
  display: flex;
  transition: color var(--t);
}
.nav-gh:hover { color: var(--text); }

/* ══════════════════════════════════════════════
   HERO
══════════════════════════════════════════════ */
.hero {
  text-align: center;
  padding: 72px 24px 96px;
  max-width: 700px;
  margin: 0 auto;
}

.hero-eyebrow {
  font-size: .75rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 18px;
  animation: fadeUp .55s ease both;
}

.hero-title {
  font-size: clamp(3.2rem, 9vw, 6rem);
  font-weight: 900;
  letter-spacing: -.05em;
  line-height: 1;
  background: linear-gradient(140deg, #ffffff 0%, var(--accent) 55%, var(--accent2) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 22px;
  animation: fadeUp .55s .1s ease both;
}

.hero-sub {
  color: var(--text-sub);
  font-size: 1rem;
  max-width: 440px;
  margin: 0 auto;
  animation: fadeUp .55s .2s ease both;
}

/* ══════════════════════════════════════════════
   MAIN / GRID
══════════════════════════════════════════════ */
.site-main {
  padding: 0 24px 100px;
  max-width: 1200px;
  margin: 0 auto;
}

.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(275px, 1fr));
  gap: 18px;
}

/* ══════════════════════════════════════════════
   CARD
══════════════════════════════════════════════ */
.card {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  overflow: hidden;

  /* Hover transitions */
  transition:
    transform var(--t),
    box-shadow var(--t),
    border-color var(--t),
    background var(--t);

  /* Scroll-reveal start state (JS adds .visible) */
  opacity: 0;
  transform: translateY(28px);
}

.card.visible {
  opacity: 1;
  transform: translateY(0);
  /* Override transition for reveal, then restore hover transitions */
  transition:
    opacity .45s ease,
    transform .45s ease,
    box-shadow var(--t),
    border-color var(--t),
    background var(--t);
}

.card:hover {
  transform: translateY(-7px);
  border-color: var(--border-h);
  box-shadow:
    0 20px 48px rgba(0,0,0,.45),
    0 0 0 1px var(--accent-dim),
    0 0 24px var(--accent-glow);
  background: var(--bg-card-h);
}

/* Thumbnail */
.card-thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.card-emoji {
  font-size: 3.2rem;
  line-height: 1;
  position: relative;
  z-index: 0;
  user-select: none;
  transition: transform .35s ease;
}
.card:hover .card-emoji { transform: scale(1.12); }

.card-thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
  transition: transform .4s ease;
}
.card:hover .card-thumb img { transform: scale(1.06); }

/* Body */
.card-body {
  padding: 16px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  flex: 1;
}

.card-body h3 {
  font-size: .95rem;
  font-weight: 700;
  letter-spacing: -.01em;
  line-height: 1.3;
}

.card-body p {
  color: var(--text-sub);
  font-size: .82rem;
  line-height: 1.55;
  flex: 1;
}

/* Tags */
.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
}

.tag {
  font-size: .67rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 99px;
  background: var(--tag-bg, var(--accent-dim));
  color:       var(--tag-color, var(--accent));
}

/* Tag palette */
.tag[data-t="Puzzle"]      { --tag-color:#60a5fa; --tag-bg:rgba(96,165,250,.12); }
.tag[data-t="Quran"]       { --tag-color:#34d399; --tag-bg:rgba(52,211,153,.12); }
.tag[data-t="Educational"] { --tag-color:#a78bfa; --tag-bg:rgba(167,139,250,.12); }
.tag[data-t="js13k"]       { --tag-color:#fbbf24; --tag-bg:rgba(251,191,36,.12); }
.tag[data-t="Action"]      { --tag-color:#f87171; --tag-bg:rgba(248,113,113,.12); }
.tag[data-t="Strategy"]    { --tag-color:#2dd4bf; --tag-bg:rgba(45,212,191,.12); }
.tag[data-t="Card Game"]   { --tag-color:#fb923c; --tag-bg:rgba(251,146,60,.12); }
.tag[data-t="Math"]        { --tag-color:#facc15; --tag-bg:rgba(250,204,21,.12); }
.tag[data-t="Multiplayer"] { --tag-color:#f472b6; --tag-bg:rgba(244,114,182,.12); }

/* ══════════════════════════════════════════════
   FOOTER
══════════════════════════════════════════════ */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 36px 36px;
}

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.footer-social {
  display: flex;
  gap: 14px;
  margin-left: auto;
}

.footer-social a {
  color: var(--text-sub);
  text-decoration: none;
  display: flex;
  transition: color var(--t);
}
.footer-social a:hover { color: var(--accent); }

.footer-copy {
  width: 100%;
  font-size: .78rem;
  color: var(--text-sub);
  margin-top: 4px;
}
.footer-copy a {
  color: var(--text-sub);
  text-decoration: none;
  transition: color var(--t);
}
.footer-copy a:hover { color: var(--accent); }

/* ══════════════════════════════════════════════
   PWA INSTALL BANNER
══════════════════════════════════════════════ */
.pwa-banner {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  border: 1px solid var(--border-h);
  border-radius: var(--radius);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 8px 40px rgba(0,0,0,.5), 0 0 20px var(--accent-glow);
  z-index: 200;
  animation: slideUp .4s ease both;
  white-space: nowrap;
}
.pwa-banner[hidden] { display: none; }

.pwa-icon { font-size: 1.4rem; }

.pwa-banner p { font-size: .875rem; }

.pwa-actions { display: flex; gap: 8px; margin-left: 4px; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 7px 16px;
  font-size: .825rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--t), transform var(--t);
}
.btn-primary:hover { opacity: .85; transform: translateY(-1px); }

.btn-ghost {
  background: transparent;
  color: var(--text-sub);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 14px;
  font-size: .825rem;
  cursor: pointer;
  transition: color var(--t), border-color var(--t);
}
.btn-ghost:hover { color: var(--text); border-color: var(--text-sub); }

/* ══════════════════════════════════════════════
   ANIMATIONS
══════════════════════════════════════════════ */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateX(-50%) translateY(14px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ══════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════ */
@media (max-width: 640px) {
  .site-nav  { padding: 16px 20px; }
  .hero      { padding: 56px 20px 72px; }
  .site-main { padding: 0 16px 72px; }
  .games-grid { gap: 12px; }
  .site-footer { padding: 32px 20px; }

  .pwa-banner {
    width: calc(100% - 32px);
    flex-direction: column;
    text-align: center;
    white-space: normal;
  }
  .pwa-actions { justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  #stars { display: none; }
}
