/* ═══════════════════════════════════════════════════════════
   Kiwi Games — Stylesheet
   Palette: navy #0D0F1A | lime #BFFF00 | white #F0F0E8 | slate #2A2D3E
   Type: Space Grotesk (display) · Inter (body)
═══════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Inter:wght@400;500&display=swap');

/* ── Reset & Base ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #0D0F1A;
  --bg2:      #141623;
  --card:     #1C1F30;
  --border:   #2A2D3E;
  --lime:     #BFFF00;
  --lime-dim: #8AB800;
  --text:     #F0F0E8;
  --muted:    #7A7D8D;
  --danger:   #FF4757;

  --r-card:   12px;
  --r-btn:    8px;
  --transition: 180ms cubic-bezier(.4,0,.2,1);

  --nav-h: 60px;
  --tray-z: 100;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Typography ─────────────────────────────────────────── */
.font-display { font-family: 'Space Grotesk', sans-serif; }

h1,h2,h3 { font-family: 'Space Grotesk', sans-serif; font-weight: 700; }

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

/* ── Nav ────────────────────────────────────────────────── */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: rgba(13,15,26,.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  z-index: 50;
}

.nav-logo {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--lime);
  text-decoration: none;
  letter-spacing: -.5px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.nav-logo span { color: var(--text); }

.nav-search {
  flex: 1;
  max-width: 440px;
  margin-left: auto;
  position: relative;
}

.nav-search input {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-btn);
  color: var(--text);
  padding: 9px 16px 9px 40px;
  font-family: 'Inter', sans-serif;
  font-size: .9rem;
  outline: none;
  transition: border-color var(--transition);
}
.nav-search input:focus { border-color: var(--lime); }
.nav-search input::placeholder { color: var(--muted); }

.nav-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.btn-random {
  flex-shrink: 0;
  background: var(--lime);
  color: #000;
  border: none;
  border-radius: var(--r-btn);
  padding: 9px 18px;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: .85rem;
  cursor: pointer;
  transition: opacity var(--transition), transform var(--transition);
  white-space: nowrap;
}
.btn-random:hover { opacity: .85; transform: translateY(-1px); }
.btn-random:active { transform: translateY(0); }

/* ── Layout ─────────────────────────────────────────────── */
.page {
  padding-top: calc(var(--nav-h) + 32px);
  padding-bottom: 80px;
  max-width: 1400px;
  margin: 0 auto;
  padding-left: 24px;
  padding-right: 24px;
}

/* ── Hero ───────────────────────────────────────────────── */
.hero {
  margin-bottom: 48px;
}

.hero-eyebrow {
  font-size: .75rem;
  font-weight: 500;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--lime);
  margin-bottom: 12px;
}

.hero-title {
  font-size: clamp(2rem, 5vw, 3.5rem);
  line-height: 1.05;
  letter-spacing: -.03em;
  color: var(--text);
  margin-bottom: 12px;
}
.hero-title em {
  color: var(--lime);
  font-style: normal;
}

.hero-sub {
  color: var(--muted);
  font-size: 1rem;
  max-width: 480px;
  line-height: 1.6;
}

/* ── Category Pills ─────────────────────────────────────── */
.category-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 32px;
}

.cat-pill {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 99px;
  padding: 6px 16px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: .82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  text-transform: capitalize;
}
.cat-pill:hover { border-color: var(--lime); color: var(--lime); }
.cat-pill.active {
  background: var(--lime);
  border-color: var(--lime);
  color: #000;
}

/* ── Section Header ─────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 20px;
}
.section-title {
  font-size: 1.1rem;
  color: var(--text);
}
.section-count {
  font-size: .8rem;
  color: var(--muted);
  font-family: 'Inter', sans-serif;
  font-weight: 400;
}

/* ── Game Grid ──────────────────────────────────────────── */
.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

/* ── Game Card ──────────────────────────────────────────── */
.game-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  overflow: hidden;
  cursor: pointer;
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
  position: relative;
}
.game-card:hover {
  border-color: var(--lime);
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,.4), 0 0 0 1px var(--lime-dim);
}

.card-thumb {
  aspect-ratio: 16/9;
  background: var(--bg2);
  overflow: hidden;
  position: relative;
}
.card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .3s ease;
}
.game-card:hover .card-thumb img { transform: scale(1.04); }

/* Fallback thumbnail when no image */
.card-thumb-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  background: linear-gradient(135deg, var(--bg2) 0%, #1a1d2e 100%);
}

.card-cat-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(13,15,26,.75);
  backdrop-filter: blur(6px);
  border: 1px solid var(--border);
  border-radius: 99px;
  font-size: .65rem;
  font-weight: 600;
  font-family: 'Space Grotesk', sans-serif;
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: 3px 8px;
  color: var(--lime);
}

.card-body {
  padding: 12px 14px;
}
.card-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: .95rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-desc {
  font-size: .78rem;
  color: var(--muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-play-btn {
  display: block;
  margin: 10px 14px 14px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--r-btn);
  color: var(--text);
  font-family: 'Space Grotesk', sans-serif;
  font-size: .82rem;
  font-weight: 600;
  padding: 7px 0;
  text-align: center;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
  width: calc(100% - 28px);
}
.game-card:hover .card-play-btn {
  background: var(--lime);
  border-color: var(--lime);
  color: #000;
}

/* ── Game Tray (slide-up overlay) ───────────────────────── */
.tray-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(4px);
  z-index: calc(var(--tray-z) - 1);
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s ease;
}
.tray-backdrop.visible {
  opacity: 1;
  pointer-events: all;
}

.game-tray {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 92vh;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
  z-index: var(--tray-z);
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform .38s cubic-bezier(.22,1,.36,1);
}
.game-tray.open { transform: translateY(0); }

.tray-handle {
  width: 40px;
  height: 4px;
  background: var(--border);
  border-radius: 99px;
  margin: 12px auto 0;
  flex-shrink: 0;
}

.tray-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.tray-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}

.tray-url {
  font-size: .75rem;
  color: var(--muted);
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tray-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.tray-btn {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-btn);
  color: var(--text);
  font-size: .8rem;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 500;
  padding: 6px 14px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: border-color var(--transition), color var(--transition);
  white-space: nowrap;
}
.tray-btn:hover { border-color: var(--lime); color: var(--lime); }
.tray-btn.close-btn:hover { border-color: var(--danger); color: var(--danger); }

.tray-iframe-wrap {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.tray-iframe-wrap iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

.tray-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: var(--bg2);
  z-index: 2;
}

.tray-loading.hidden { display: none; }

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--lime);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.tray-loading p {
  color: var(--muted);
  font-size: .85rem;
}

/* ── Empty state ────────────────────────────────────────── */
.empty-state {
  grid-column: 1/-1;
  text-align: center;
  padding: 80px 20px;
  color: var(--muted);
}
.empty-state .emoji { font-size: 3rem; display: block; margin-bottom: 12px; }
.empty-state h3 { color: var(--text); margin-bottom: 6px; font-size: 1.1rem; }
.empty-state p { font-size: .9rem; }

/* ── Skeleton loader ────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--card) 0%, #22253a 50%, var(--card) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--r-card);
}
@keyframes shimmer { to { background-position: -200% 0; } }

.skeleton-card {
  aspect-ratio: 200/240;
  border-radius: var(--r-card);
}

/* ── Featured badge ─────────────────────────────────────── */
.featured-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 6px var(--lime);
}

/* ── Toast ──────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-btn);
  padding: 12px 18px;
  font-size: .85rem;
  color: var(--text);
  z-index: 200;
  transform: translateY(80px);
  opacity: 0;
  transition: all .3s ease;
  pointer-events: none;
}
.toast.show { transform: translateY(0); opacity: 1; }

/* ── Category emoji map (CSS custom props fallback) ─────── */
/* Emojis injected via JS for flexibility */

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 640px) {
  .nav { padding: 0 16px; gap: 10px; }
  .nav-logo span { display: none; }
  .page { padding-left: 16px; padding-right: 16px; }
  .game-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .tray-url { display: none; }
  .btn-random { padding: 9px 12px; font-size: .78rem; }
}

@media (max-width: 400px) {
  .game-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Reduced motion ─────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0ms !important; animation-duration: 0ms !important; }
}
