/* ============================================================
   KeyJagt – Global Styles
   Mobile-first, dark gaming aesthetic
   ============================================================ */

:root {
  --bg:        #0d0f14;
  --bg2:       #161a22;
  --bg3:       #1e2330;
  --border:    #2a2f3e;
  --accent:    #4ade80;
  --accent2:   #22c55e;
  --accent-dim:#166534;
  --red:       #ef4444;
  --yellow:    #facc15;
  --text:      #e2e8f0;
  --muted:     #64748b;
  --card-hover:#1a2035;
  --radius:    8px;
  --shadow:    0 4px 24px rgba(0,0,0,.4);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  line-height: 1.6;
  min-height: 100vh;
}

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

img { max-width: 100%; display: block; }

/* ---- Layout ---- */
.container { max-width: 1100px; margin: 0 auto; padding: 0 16px; }

/* ---- Header ---- */
.site-header {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.site-header .inner {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.logo {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -.5px;
  white-space: nowrap;
}
.logo span { color: var(--text); }

.header-search {
  flex: 1;
  min-width: 200px;
  position: relative;
}

.header-search input {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 14px 9px 38px;
  color: var(--text);
  font-size: .95rem;
  outline: none;
  transition: border-color .2s;
}
.header-search input:focus { border-color: var(--accent); }
.header-search input::placeholder { color: var(--muted); }

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

.search-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  z-index: 200;
  display: none;
}
.search-dropdown.open { display: block; }

.search-result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background .15s;
  text-decoration: none;
  color: var(--text);
}
.search-result-item:hover { background: var(--card-hover); }
.search-result-item img {
  width: 48px;
  height: 27px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}
.search-result-item .title { font-size: .9rem; }
.search-result-item .best-price {
  margin-left: auto;
  color: var(--accent);
  font-weight: 700;
  font-size: .85rem;
  white-space: nowrap;
}

/* ---- Hero (Homepage) ---- */
.hero {
  text-align: center;
  padding: 56px 16px 40px;
}
.hero h1 {
  font-size: clamp(1.8rem, 5vw, 3rem);
  font-weight: 800;
  line-height: 1.15;
}
.hero h1 span { color: var(--accent); }
.hero p {
  color: var(--muted);
  margin-top: 12px;
  font-size: 1.05rem;
}

/* ---- Section Heading ---- */
.section-heading {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 32px 0 16px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-heading::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

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

.game-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform .2s, border-color .2s, box-shadow .2s;
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
}
.game-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: 0 8px 32px rgba(74,222,128,.1);
  color: var(--text);
}

.game-card .cover {
  aspect-ratio: 460/215;
  overflow: hidden;
  background: var(--bg3);
}
.game-card .cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .3s;
}
.game-card:hover .cover img { transform: scale(1.04); }

.game-card .info {
  padding: 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.game-card .info .name {
  font-size: .9rem;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.price-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-top: auto;
}
.price-best {
  color: var(--accent);
  font-weight: 800;
  font-size: 1.05rem;
}
.price-original {
  color: var(--muted);
  font-size: .8rem;
  text-decoration: line-through;
}
.badge-discount {
  background: var(--accent-dim);
  color: var(--accent);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: .72rem;
  font-weight: 700;
}
.badge-free {
  background: #1e3a5f;
  color: #60a5fa;
  border-radius: 4px;
  padding: 1px 6px;
  font-size: .72rem;
  font-weight: 700;
}

/* ---- Pagination ---- */
.pagination {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 16px 0 48px;
  flex-wrap: wrap;
}
.pagination a, .pagination span {
  padding: 6px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  font-size: .9rem;
  color: var(--text);
  transition: background .15s, border-color .15s;
}
.pagination a:hover { background: var(--bg3); color: var(--text); }
.pagination .active { background: var(--accent); border-color: var(--accent); color: #000; font-weight: 700; }

/* ---- Game Detail Page ---- */
.game-hero {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 28px 0;
}
.game-hero .inner {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  flex-wrap: wrap;
}
.game-hero .cover-big {
  width: 280px;
  flex-shrink: 0;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.game-hero .cover-big img { width: 100%; }

.game-hero .meta { flex: 1; min-width: 220px; }
.game-hero .meta h1 {
  font-size: clamp(1.3rem, 3vw, 2rem);
  font-weight: 800;
  line-height: 1.2;
}
.game-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
  font-size: .85rem;
  color: var(--muted);
}
.game-meta-row span { display: flex; align-items: center; gap: 4px; }

.genre-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}
.genre-tag {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2px 10px;
  font-size: .75rem;
  color: var(--muted);
}

.description-text {
  margin-top: 14px;
  font-size: .9rem;
  color: var(--muted);
  line-height: 1.65;
  max-width: 560px;
}

.rating-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 12px;
  font-size: .85rem;
  margin-top: 14px;
}
.rating-badge .score {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--accent);
}

/* ---- Price Table ---- */
.price-table-wrap {
  margin: 28px 0;
}

.price-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}
.price-table thead th {
  background: var(--bg2);
  border-bottom: 2px solid var(--border);
  padding: 10px 14px;
  text-align: left;
  color: var(--muted);
  font-weight: 600;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.price-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .15s;
}
.price-table tbody tr:hover { background: var(--card-hover); }
.price-table tbody td { padding: 12px 14px; vertical-align: middle; }

.shop-name { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.shop-untrusted {
  font-size: .7rem;
  background: #7c2d12;
  color: #fca5a5;
  border-radius: 4px;
  padding: 1px 5px;
}
.best-deal-row { background: rgba(74,222,128,.05) !important; }
.best-deal-row td:first-child { border-left: 3px solid var(--accent); }

.btn-buy {
  display: inline-block;
  background: var(--accent);
  color: #000;
  font-weight: 700;
  font-size: .82rem;
  padding: 7px 16px;
  border-radius: var(--radius);
  transition: background .15s, transform .1s;
  white-space: nowrap;
}
.btn-buy:hover { background: var(--accent2); color: #000; transform: scale(1.03); }

/* ---- Price Chart ---- */
.chart-section {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin: 28px 0;
}
.chart-section h2 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}
.chart-wrap { position: relative; height: 220px; }

/* ---- Footer ---- */
.site-footer {
  background: var(--bg2);
  border-top: 1px solid var(--border);
  text-align: center;
  padding: 24px 16px;
  font-size: .82rem;
  color: var(--muted);
  margin-top: 48px;
}

/* ---- Loader / Skeleton ---- */
.skeleton {
  background: linear-gradient(90deg, var(--bg2) 25%, var(--bg3) 50%, var(--bg2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 4px;
}
@keyframes shimmer { to { background-position: -200% 0; } }

.loading-spinner {
  text-align: center;
  padding: 40px;
  color: var(--muted);
}

/* ---- Responsive ---- */
@media (min-width: 640px) {
  .game-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
}

@media (max-width: 600px) {
  .game-hero .cover-big { width: 100%; }
  .price-table thead { display: none; }
  .price-table tbody tr { display: block; padding: 12px 0; }
  .price-table tbody td { display: block; padding: 4px 14px; border: none; }
  .price-table tbody td::before {
    content: attr(data-label) ': ';
    color: var(--muted);
    font-size: .8rem;
  }
  .btn-buy { margin-top: 6px; }
}
