/* =========================================================
   Games Hub — landing page styles
   Vanilla CSS, no build step. Theme via custom properties.
   Default: light. Add data-theme="dark" on <html> to invert.
   ========================================================= */

:root {
  /* light theme — soft, slightly cool off-white with violet/pink accents */
  --bg: #f5f6fb;
  --bg-elev: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #fbfaff;
  --border: #e6e8f1;
  --border-strong: #d1d5e4;
  --text: #14172b;
  --text-dim: #525a73;
  --text-faint: #8088a3;
  --accent: #6366f1;
  --accent-2: #c026d3;
  --danger: #ef4444;
  --shadow-card: 0 1px 0 rgba(255, 255, 255, 0.7) inset, 0 4px 14px rgba(80, 70, 180, 0.08);
  --shadow-card-hover: 0 1px 0 rgba(255, 255, 255, 0.9) inset, 0 18px 40px rgba(99, 102, 241, 0.18);
  --radius: 16px;
  --radius-lg: 24px;
  --max-w: 1240px;
  --grad: linear-gradient(120deg, #6366f1 0%, #c026d3 50%, #ec4899 100%);

  /* per-category accent (set by JS data-category on cards) */
  --c-puzzle: #7c3aed;
  --c-arcade: #ec4899;
  --c-shooter: #ef4444;
  --c-racing: #f59e0b;
  --c-sports: #10b981;
  --c-platformer: #06b6d4;
  --c-casual: #f472b6;
  --c-board: #64748b;
  --c-word-quiz: #3b82f6;
  --c-3d: #8b5cf6;
}

[data-theme="dark"] {
  --bg: #0b0d12;
  --bg-elev: #11141b;
  --bg-card: #161a23;
  --bg-card-hover: #1c2231;
  --border: #232938;
  --border-strong: #2e364a;
  --text: #e6e8ee;
  --text-dim: #9aa2b4;
  --text-faint: #6b7589;
  --accent: #818cf8;
  --accent-2: #d946ef;
  --shadow-card: 0 1px 0 rgba(255, 255, 255, 0.03), 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-card-hover: 0 1px 0 rgba(255, 255, 255, 0.05), 0 18px 40px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button { font: inherit; color: inherit; cursor: pointer; }

kbd {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.78em;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 6px;
  color: var(--text-dim);
}

/* ---------- HERO ---------- */
.hero {
  position: relative;
  overflow: hidden;
  padding: 28px 24px 72px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
/* animated gradient orbs */
.hero::before,
.hero::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.55;
  pointer-events: none;
  z-index: 0;
}
.hero::before {
  width: 520px; height: 520px;
  top: -160px; right: -120px;
  background: radial-gradient(circle, #c4b5fd, #f0abfc 60%, transparent 70%);
  animation: float-a 18s ease-in-out infinite;
}
.hero::after {
  width: 460px; height: 460px;
  top: -100px; left: -140px;
  background: radial-gradient(circle, #a5b4fc, #fbcfe8 60%, transparent 70%);
  animation: float-b 22s ease-in-out infinite;
}
[data-theme="dark"] .hero::before { opacity: 0.22; }
[data-theme="dark"] .hero::after { opacity: 0.22; }

.hero__inner {
  position: relative;
  z-index: 1;
  max-width: var(--max-w);
  margin: 0 auto;
}
.hero__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 56px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 18px;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.brand:hover { text-decoration: none; }
.brand__logo {
  font-size: 22px;
  filter: drop-shadow(0 4px 10px rgba(99, 102, 241, 0.4));
}

.hero__actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-card);
  color: var(--text);
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}
.btn-icon:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-strong);
  text-decoration: none;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.12);
}
.btn-icon:active { transform: translateY(1px); }
.btn-icon--danger:hover { color: var(--danger); border-color: var(--danger); }

.theme-icon { font-size: 16px; line-height: 1; }
.star-count {
  font-size: 13px;
  color: var(--text-dim);
}
.star-count em { font-style: normal; color: var(--text); font-weight: 700; }

.hero__title {
  font-size: clamp(34px, 5.5vw, 68px);
  line-height: 1.05;
  font-weight: 800;
  letter-spacing: -0.025em;
  margin: 0 0 16px;
}
.grad {
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero__sub {
  font-size: clamp(15px, 1.4vw, 18px);
  color: var(--text-dim);
  max-width: 640px;
  margin: 0 0 28px;
}
.hero__cta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 13px 22px;
  border: 0;
  border-radius: 12px;
  background: var(--grad);
  color: white;
  font-weight: 600;
  font-size: 15px;
  box-shadow: 0 8px 22px rgba(99, 102, 241, 0.35), 0 2px 6px rgba(192, 38, 211, 0.25);
  transition: transform 0.12s ease, box-shadow 0.15s ease, filter 0.15s ease;
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 30px rgba(99, 102, 241, 0.45), 0 4px 10px rgba(236, 72, 153, 0.3);
  filter: brightness(1.06);
}
.btn-primary:active { transform: translateY(0); }
.btn-ghost {
  padding: 13px 18px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  color: var(--text);
  font-weight: 500;
  font-size: 15px;
  background: var(--bg-card);
  transition: border-color 0.15s ease, background 0.15s ease;
}
.btn-ghost:hover { background: var(--bg-card-hover); border-color: var(--accent); text-decoration: none; }

.stats {
  display: flex;
  gap: 24px 32px;
  flex-wrap: wrap;
  margin-top: 36px;
  color: var(--text-dim);
  font-size: 14px;
}
.stat { display: inline-flex; align-items: center; gap: 8px; }
.stat__num { color: var(--text); font-weight: 700; font-size: 18px; }

/* ---------- CONTROLS ---------- */
.controls {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 16px 24px;
  background: color-mix(in oklab, var(--bg) 72%, transparent);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid var(--border);
}
.controls__inner {
  max-width: var(--max-w);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.search {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-dim);
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.search:focus-within {
  border-color: var(--accent);
  background: var(--bg-elev);
  box-shadow: 0 0 0 4px color-mix(in oklab, var(--accent) 18%, transparent);
}
.search input {
  flex: 1;
  background: transparent;
  border: 0;
  outline: none;
  color: var(--text);
  font-size: 15px;
  min-width: 0;
}
.search input::placeholder { color: var(--text-faint); }
.search__kbd { display: none; }
@media (min-width: 640px) {
  .search__kbd { display: inline-block; }
}

.filters {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 4px;
}
.filters::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-card);
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: all 0.15s ease;
}
.chip:hover {
  border-color: var(--border-strong);
  color: var(--text);
  transform: translateY(-1px);
}
.chip[aria-pressed="true"] {
  background: var(--grad);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}
.chip__count {
  font-size: 11px;
  opacity: 0.7;
  font-variant-numeric: tabular-nums;
}

/* ---------- GAMES GRID ---------- */
.games { padding: 36px 24px 64px; }
.games__inner { max-width: var(--max-w); margin: 0 auto; }

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

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  text-align: left;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  box-shadow: var(--shadow-card);
  padding: 0;
  width: 100%;
  font: inherit;
  color: inherit;
}
.card:hover {
  transform: translateY(-4px);
  box-shadow:
    var(--shadow-card-hover),
    0 0 0 1px color-mix(in oklab, var(--card-c1, var(--accent)) 30%, transparent);
  border-color: transparent;
}
.card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.card__art {
  position: relative;
  aspect-ratio: 16 / 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--card-c1, #888), var(--card-c2, #555));
  overflow: hidden;
}
.card__art::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(80% 60% at 80% 100%, rgba(255,255,255,0.18), transparent 60%),
    radial-gradient(60% 80% at 20% 0%, rgba(255,255,255,0.28), transparent 65%);
  pointer-events: none;
}
.card__art::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(60% 80% at 30% 20%, rgba(255,255,255,0.22), transparent 70%);
  pointer-events: none;
  mix-blend-mode: overlay;
}
.card__emoji {
  position: relative;
  z-index: 1;
  font-size: 56px;
  line-height: 1;
  filter: drop-shadow(0 6px 14px rgba(0,0,0,0.28));
  transition: transform 0.3s cubic-bezier(.2,.9,.3,1.4);
}
.card:hover .card__emoji { transform: scale(1.12) rotate(-4deg); }

.card__play {
  position: absolute;
  inset: auto 12px 12px auto;
  width: 36px; height: 36px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: #14172b;
  backdrop-filter: blur(4px);
  font-size: 14px;
  font-weight: 700;
  opacity: 0;
  transform: translateY(4px) scale(0.9);
  transition: opacity 0.18s ease, transform 0.18s ease;
  box-shadow: 0 4px 14px rgba(0,0,0,0.18);
  z-index: 2;
}
.card:hover .card__play { opacity: 1; transform: translateY(0) scale(1); }

.card__body {
  padding: 14px 14px 16px;
}
.card__title {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 4px;
  color: var(--text);
  letter-spacing: -0.005em;
}
.card__desc {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.45;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card__meta {
  margin-top: 10px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}
.card__chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  background: color-mix(in oklab, var(--card-c1, var(--accent)) 14%, var(--bg-card));
  color: color-mix(in oklab, var(--card-c1, var(--accent)) 70%, var(--text));
  border: 1px solid color-mix(in oklab, var(--card-c1, var(--accent)) 22%, var(--border));
}
.card__tech {
  font-size: 11px;
  color: var(--text-faint);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.games__empty {
  text-align: center;
  color: var(--text-dim);
  padding: 60px 20px;
}
.link {
  background: none;
  border: 0;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
}

/* ---------- FOOTER ---------- */
.footer {
  border-top: 1px solid var(--border);
  padding: 28px 24px 40px;
  color: var(--text-dim);
  font-size: 14px;
}
.footer__inner {
  max-width: var(--max-w);
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  align-items: center;
}
.footer__hint { margin: 0; color: var(--text-faint); font-size: 13px; }

/* ---------- MODAL ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
}
.modal[hidden] { display: none; }
.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 23, 43, 0.45);
  backdrop-filter: blur(6px);
  animation: fadeIn 0.18s ease;
}
[data-theme="dark"] .modal__backdrop { background: rgba(5, 7, 12, 0.78); }
.modal__panel {
  position: relative;
  width: min(1100px, 100%);
  height: min(820px, 100%);
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  box-shadow: 0 30px 70px rgba(80, 70, 180, 0.35);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: pop 0.22s cubic-bezier(.2,.9,.3,1.2);
}
[data-theme="dark"] .modal__panel { box-shadow: 0 30px 70px rgba(0,0,0,0.6); }
.modal__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  gap: 10px;
}
.modal__meta {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.modal__chip {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  color: white;
  background: var(--grad);
  text-transform: capitalize;
}
.modal__title {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.modal__tools { display: flex; gap: 6px; }
.modal__frame-wrap {
  flex: 1;
  background: #000;
  position: relative;
  min-height: 0;
}
.modal__frame {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes pop {
  from { opacity: 0; transform: translateY(10px) scale(.98) }
  to   { opacity: 1; transform: translateY(0) scale(1) }
}
@keyframes float-a {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50%      { transform: translate(-30px, 40px) scale(1.08); }
}
@keyframes float-b {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50%      { transform: translate(40px, 30px) scale(1.12); }
}

/* ---------- RESPONSIVE ---------- */
@media (max-width: 640px) {
  .hero { padding: 20px 16px 48px; }
  .hero__top { margin-bottom: 36px; }
  .hero::before { width: 320px; height: 320px; }
  .hero::after { width: 280px; height: 280px; }
  .controls { padding: 12px 16px; }
  .games { padding: 24px 16px 48px; }
  .games__grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .card__emoji { font-size: 44px; }
  .card__body { padding: 12px; }
  .card__title { font-size: 14px; }
  .card__desc { font-size: 12px; -webkit-line-clamp: 2; }
  .modal { padding: 0; }
  .modal__panel { height: 100%; width: 100%; border-radius: 0; border: 0; }
  .footer__inner { flex-direction: column; align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
