/* ══════════════════════════════════════════════════
   STAH GAMES — Design System
   Police: Inter | Palette: Bleu nuit + Orange chaud
   ══════════════════════════════════════════════════ */

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

:root {
  --bg:          #0f111a;
  --bg-2:        #161929;
  --bg-3:        #1e2235;
  --surface:     #252a40;
  --surface-2:   #2e3450;
  --border:      rgba(255,255,255,0.07);
  --border-2:    rgba(255,255,255,0.12);
  --accent:      #e07a5f;
  --accent-2:    #f4a261;
  --accent-glow: rgba(224,122,95,0.18);
  --text:        #f0f1f5;
  --text-2:      #9ba3bf;
  --text-3:      #636b88;
  --success:     #3bb87f;
  --radius-sm:   8px;
  --radius:      14px;
  --radius-lg:   20px;
  --shadow:      0 4px 24px rgba(0,0,0,0.4);
  --shadow-card: 0 2px 12px rgba(0,0,0,0.3);
  --transition:  0.18s ease;
  --header-h:    112px;
  --font: 'Inter', system-ui, sans-serif;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
img { display: block; max-width: 100%; }
input { font-family: inherit; }

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

/* ══════════════════ HEADER ══════════════════ */
.header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  background: rgba(15,17,26,0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1340px;
  margin: 0 auto;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 20px;
}

/* Brand */
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  transition: opacity var(--transition);
}
.brand:hover { opacity: 0.85; }
.brand-logo {
  width: 40px; height: 40px;
  border-radius: 10px;
  overflow: hidden;
  flex-shrink: 0;
}
.brand-logo svg { width: 100%; height: 100%; }
.brand-text { display: flex; flex-direction: column; gap: 1px; }
.brand-name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text);
}
.brand-sub {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Search */
.search-wrap {
  flex: 1;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
  display: flex;
  align-items: center;
}
.search-ico {
  position: absolute;
  left: 14px;
  color: var(--text-3);
  pointer-events: none;
  flex-shrink: 0;
}
.search-input {
  width: 100%;
  height: 42px;
  padding: 0 40px 0 44px;
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  border-radius: 99px;
  color: var(--text);
  font-size: 14px;
  font-weight: 400;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.search-input::placeholder { color: var(--text-3); }
.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.search-clear {
  position: absolute;
  right: 12px;
  color: var(--text-3);
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
  padding: 4px;
}
.search-clear.visible { opacity: 1; pointer-events: all; }
.search-clear:hover { color: var(--text); }

/* Nav right */
.nav-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.nav-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 16px;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: 99px;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.nav-btn:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border-2);
}

/* ── Categories bar ── */
.categories-bar {
  border-top: 1px solid var(--border);
  background: var(--bg);
}
.categories-inner {
  max-width: 1340px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 4px;
  height: 48px;
  overflow-x: auto;
  scrollbar-width: none;
}
.categories-inner::-webkit-scrollbar { display: none; }

.cat {
  flex-shrink: 0;
  padding: 6px 16px;
  border-radius: 99px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}
.cat:hover { background: var(--surface); color: var(--text); }
.cat.active {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

/* ══════════════════ MAIN / CATALOG ══════════════════ */
.main {
  flex: 1;
  margin-top: var(--header-h);
  min-height: calc(100vh - var(--header-h));
}

.catalog-view {
  max-width: 1340px;
  margin: 0 auto;
  padding: 36px 24px 48px;
}

/* Section header */
.section-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 24px;
}
.section-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.3px;
}
.section-count {
  font-size: 13px;
  color: var(--text-3);
  font-weight: 400;
}

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

/* ── Game Card ── */
.game-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
  position: relative;
}
.game-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-2);
  box-shadow: var(--shadow);
}
.game-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Cover */
.card-cover {
  position: relative;
  aspect-ratio: 4/3;
  overflow: hidden;
  background: var(--bg-3);
}
.card-cover-img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}
.game-card:hover .card-cover-img { transform: scale(1.04); }

/* Rating badge */
.card-rating {
  position: absolute;
  top: 10px; right: 10px;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(4px);
  border-radius: 99px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
  color: #fbbf24;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Genre badge */
.card-badge {
  position: absolute;
  top: 10px; left: 10px;
  border-radius: var(--radius-sm);
  padding: 3px 9px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.badge-parkour { background: #2563eb; color: #fff; }
.badge-morocco { background: #059669; color: #fff; }
.badge-action  { background: #dc2626; color: #fff; }
.badge-racing  { background: #7c3aed; color: #fff; }
.badge-puzzle  { background: #0891b2; color: #fff; }
.badge-hot     { background: var(--accent); color: #fff; }

/* Play overlay on hover */
.card-play-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  transition: opacity var(--transition);
}
.game-card:hover .card-play-overlay { opacity: 1; }
.play-btn-circle {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 20px rgba(224,122,95,0.5);
  transform: scale(0.85);
  transition: transform 0.2s ease;
}
.game-card:hover .play-btn-circle { transform: scale(1); }

/* Card info */
.card-info {
  padding: 14px 16px 16px;
}
.card-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text);
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-desc {
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 10px;
}
.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-3);
}
.card-plays { display: flex; align-items: center; gap: 5px; }

/* Featured card (first / large) */
.game-card.featured {
  grid-column: span 2;
}
.game-card.featured .card-cover { aspect-ratio: 16/9; }
.game-card.featured .card-title { font-size: 16px; }

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 80px 24px;
}
.empty-icon { font-size: 56px; margin-bottom: 20px; }
.empty-state h3 { font-size: 20px; margin-bottom: 8px; }
.empty-state p { color: var(--text-2); margin-bottom: 24px; }
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  background: var(--accent);
  color: #fff;
  border-radius: 99px;
  font-size: 14px;
  font-weight: 600;
  transition: opacity var(--transition);
}
.btn-primary:hover { opacity: 0.85; }

/* ══════════════════ PLAYER VIEW ══════════════════ */
.player-view {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--header-h));
  max-width: 1340px;
  margin: 0 auto;
  padding: 20px 24px;
  gap: 16px;
}

/* Player top bar */
.player-topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.btn-back {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: 99px;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
  flex-shrink: 0;
}
.btn-back:hover { background: var(--surface-2); color: var(--text); }

.active-game-info {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}
.active-cover {
  width: 42px; height: 42px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
}
.active-title {
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.active-genre {
  font-size: 12px;
  color: var(--text-3);
}

.player-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.btn-icon-sm {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: 99px;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
}
.btn-icon-sm:hover { background: var(--surface-2); color: var(--text); }
.btn-icon-sm.liked { color: #ef4444; border-color: #ef4444; background: rgba(239,68,68,0.08); }

/* Stage */
.stage-wrap {
  flex: 1;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: #000;
  min-height: 0;
}
.game-iframe {
  width: 100%; height: 100%;
  border: none;
  display: block;
}

/* Controls bar */
.controls-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 10px 16px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.controls-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}
.controls-keys {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.key-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-2);
}
.keycap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 24px;
  padding: 0 7px;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-bottom: 2px solid var(--border-2);
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  font-family: 'Courier New', monospace;
}

/* ══════════════════ FOOTER ══════════════════ */
.footer {
  background: var(--bg-2);
  border-top: 1px solid var(--border);
  padding: 24px 0;
  margin-top: auto;
}
.footer-inner {
  max-width: 1340px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}
.footer-brand { display: flex; align-items: center; gap: 12px; }
.footer-logo { font-size: 15px; font-weight: 700; color: var(--accent); }
.footer-copy { font-size: 12px; color: var(--text-3); }
.footer-links { display: flex; align-items: center; gap: 20px; }
.footer-links a { font-size: 13px; color: var(--text-3); transition: color var(--transition); }
.footer-links a:hover { color: var(--text); }

/* ══════════════════ "COMING SOON" card ══════════════════ */
.card-soon {
  opacity: 0.55;
  pointer-events: none;
  user-select: none;
}
.soon-pill {
  position: absolute;
  inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.5);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* ══════════════════ RESPONSIVE ══════════════════ */
@media (max-width: 860px) {
  :root { --header-h: 108px; }
  .header-inner { padding: 0 16px; height: 56px; gap: 12px; }
  .brand-sub, .nav-btn span { display: none; }
  .nav-btn { padding: 8px 10px; }
  .search-wrap { max-width: none; }
  .catalog-view { padding: 24px 16px 36px; }
  .games-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
  .game-card.featured { grid-column: span 2; }
  .player-view { padding: 12px 16px; gap: 12px; }
}

@media (max-width: 540px) {
  .games-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .game-card.featured { grid-column: span 2; }
  .active-title { font-size: 14px; }
  .btn-icon-sm span { display: none; }
  .footer-inner { flex-direction: column; align-items: flex-start; gap: 10px; }
}
