/* ============================================================
   CLEAN WARM MINIMAL — Gaming Dashboard
   A hand-crafted, warm palette that doesn't scream "AI"
   ============================================================ */

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

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

/* --- Tokens --- */
:root {
  /* Warm light palette */
  --bg-body: #faf8f4;
  --bg-surface: #ffffff;
  --bg-surface-hover: #f5f3ef;
  --bg-inset: #f0ede8;

  /* Accent — burnt orange */
  --accent: #d4622b;
  --accent-muted: #e8915c;
  --accent-bg: rgba(212, 98, 43, 0.08);
  --accent-border: rgba(212, 98, 43, 0.2);

  /* Neutral text */
  --text-primary: #1a1816;
  --text-secondary: #6b6560;
  --text-muted: #9e9890;
  --text-inverse: #faf8f4;

  /* Borders */
  --border: #e8e4de;
  --border-strong: #d4d0c8;

  /* Shadows — warm tinted */
  --shadow-sm: 0 1px 2px rgba(26, 24, 22, 0.04);
  --shadow-md: 0 4px 12px rgba(26, 24, 22, 0.06);
  --shadow-lg: 0 12px 32px rgba(26, 24, 22, 0.08);

  /* Semantic */
  --green: #2d8a4e;
  --green-bg: rgba(45, 138, 78, 0.08);
  --green-border: rgba(45, 138, 78, 0.2);
  --yellow: #b88a1a;
  --yellow-bg: rgba(184, 138, 26, 0.08);
  --yellow-border: rgba(184, 138, 26, 0.2);
  --red: #c43b3b;
  --red-bg: rgba(196, 59, 59, 0.08);
  --red-border: rgba(196, 59, 59, 0.2);

  /* Sizing */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --sidebar-w: 64px;

  /* Motion */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --duration: 0.2s;

  /* Font */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* --- Dark mode (warm charcoal, NOT blue) --- */
.dark-theme {
  --bg-body: #161514;
  --bg-surface: #1e1d1b;
  --bg-surface-hover: #282724;
  --bg-inset: #121110;

  --accent: #e07840;
  --accent-muted: #c46a34;
  --accent-bg: rgba(224, 120, 64, 0.1);
  --accent-border: rgba(224, 120, 64, 0.25);

  --text-primary: #ece8e1;
  --text-secondary: #9e9890;
  --text-muted: #6b6560;
  --text-inverse: #1a1816;

  --border: #2a2826;
  --border-strong: #3a3836;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.35);

  --green: #4eba6f;
  --green-bg: rgba(78, 186, 111, 0.12);
  --green-border: rgba(78, 186, 111, 0.25);
  --yellow: #d4a82a;
  --yellow-bg: rgba(212, 168, 42, 0.12);
  --yellow-border: rgba(212, 168, 42, 0.25);
  --red: #e05555;
  --red-bg: rgba(224, 85, 85, 0.12);
  --red-border: rgba(224, 85, 85, 0.25);
}


/* ============================================================
   BASE
   ============================================================ */
html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  font-size: 15px;
  background: var(--bg-body);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  transition: background var(--duration) var(--ease), color var(--duration) var(--ease);
}

body.modal-open { overflow: hidden; }

.hidden { display: none !important; }


/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 0;
  z-index: 100;
  transition: background var(--duration) var(--ease), border-color var(--duration) var(--ease);
}

.sidebar-logo {
  font-family: var(--font);
  font-weight: 800;
  font-size: 16px;
  color: var(--accent);
  margin-bottom: 28px;
  cursor: pointer;
  letter-spacing: -0.5px;
  user-select: none;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  padding: 0 10px;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin: 0 auto;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  border: none;
  background: none;
  transition: all var(--duration) var(--ease);
  position: relative;
}

.nav-item:hover {
  color: var(--text-primary);
  background: var(--bg-surface-hover);
}

.nav-item.active {
  color: var(--accent);
  background: var(--accent-bg);
}

.nav-item.active::after {
  content: '';
  position: absolute;
  left: -10px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}

.nav-tooltip {
  position: absolute;
  left: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--text-primary);
  color: var(--text-inverse);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s var(--ease);
}

.nav-item:hover .nav-tooltip { opacity: 1; }

.sidebar-bottom {
  margin-top: auto;
  padding: 0 10px;
  width: 100%;
}


/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
}

.page-container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 28px 36px;
}


/* ============================================================
   TOP BAR
   ============================================================ */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.top-bar-left { display: flex; flex-direction: column; }

.page-title {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.page-title span { color: var(--accent); }

.page-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 1px;
  font-weight: 500;
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Search */
.search-wrapper { position: relative; display: flex; align-items: center; }

.search-input {
  width: 260px;
  padding: 9px 14px 9px 38px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
  transition: all var(--duration) var(--ease);
}

.search-input::placeholder { color: var(--text-muted); }

.search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
  width: 320px;
}

.search-icon {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
  font-size: 14px;
  pointer-events: none;
}

.search-button {
  padding: 9px 18px;
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 700;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--duration) var(--ease);
}

.search-button:hover {
  opacity: 0.9;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

/* Theme toggle */
.theme-toggle-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--duration) var(--ease);
}

.theme-toggle-btn:hover {
  border-color: var(--border-strong);
  background: var(--bg-surface-hover);
}


/* ============================================================
   HERO
   ============================================================ */
.hero-section {
  position: relative;
  width: 100%;
  height: 300px;
  border-radius: var(--radius-xl);
  overflow: hidden;
  margin-bottom: 28px;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: box-shadow var(--duration) var(--ease);
}

.hero-section:hover {
  box-shadow: var(--shadow-lg);
}

.hero-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  transition: transform 0.5s var(--ease);
}

.hero-section:hover .hero-bg { transform: scale(1.03); }

.hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to right,
    rgba(26, 24, 22, 0.92) 0%,
    rgba(26, 24, 22, 0.6) 45%,
    rgba(26, 24, 22, 0.1) 100%
  );
}

.hero-content {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: center;
  height: 100%;
  padding: 36px 44px;
  max-width: 480px;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-bg);
  border: 1px solid var(--accent-border);
  padding: 4px 12px;
  border-radius: var(--radius-lg);
  margin-bottom: 14px;
  width: fit-content;
}

.hero-title {
  font-size: 2rem;
  font-weight: 800;
  color: #fff;
  line-height: 1.15;
  margin-bottom: 14px;
  letter-spacing: -0.5px;
}

.hero-meta {
  display: flex;
  gap: 14px;
  align-items: center;
  font-size: 0.85rem;
  color: rgba(255,255,255,0.65);
}

.hero-meta-item { display: flex; align-items: center; gap: 4px; }

.hero-rating-value { font-weight: 700; color: #4eba6f; }

.hero-metacritic {
  padding: 2px 9px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.8rem;
}

.metacritic-high { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-border); }
.metacritic-mid  { background: var(--yellow-bg); color: var(--yellow); border: 1px solid var(--yellow-border); }
.metacritic-low  { background: var(--red-bg); color: var(--red); border: 1px solid var(--red-border); }


/* ============================================================
   STAT CARDS
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  transition: all var(--duration) var(--ease);
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}

.stat-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  background: var(--accent-bg);
  color: var(--accent);
}

.stat-icon.green  { background: var(--green-bg); color: var(--green); }
.stat-icon.yellow { background: var(--yellow-bg); color: var(--yellow); }

.stat-info { flex: 1; min-width: 0; }

.stat-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.stat-value {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}


/* ============================================================
   CHARTS
   ============================================================ */
.charts-row {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 16px;
  margin-bottom: 16px;
}

.chart-solo { margin-bottom: 28px; }

.chart-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  transition: all var(--duration) var(--ease);
}

.chart-card:hover {
  box-shadow: var(--shadow-md);
}

.chart-header {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 14px;
}

.chart-container {
  position: relative;
  width: 100%;
  height: 320px;
}

.chart-card-tall .chart-container { height: 380px; }


/* ============================================================
   SECTION HEADER
   ============================================================ */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.section-title {
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title::before {
  content: '';
  display: inline-block;
  width: 3px;
  height: 16px;
  background: var(--accent);
  border-radius: 2px;
}


/* ============================================================
   GAME CARDS
   ============================================================ */
#game-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  margin-bottom: 28px;
}

.game-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--duration) var(--ease);
}

.game-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--border-strong);
}

.game-card:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.game-card-img-wrapper {
  position: relative;
  width: 100%;
  height: 170px;
  overflow: hidden;
}

.game-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s var(--ease);
}

.game-card:hover img { transform: scale(1.05); }

.game-card-img-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 50%;
  background: linear-gradient(to top, var(--bg-surface) 0%, transparent 100%);
  pointer-events: none;
}

.game-card-content { padding: 14px 16px 16px; }

.game-card h3 {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: -0.2px;
}

.game-card-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.game-card-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  font-weight: 600;
}

.game-card-rating { font-weight: 700; font-size: 0.85rem; }

.game-card-metacritic {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 700;
}

.game-card-popularity {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.game-card-popularity span {
  font-weight: 600;
  color: var(--text-secondary);
}

/* Color classes */
.text-green  { color: var(--green); }
.text-yellow { color: var(--yellow); }
.text-red    { color: var(--red); }

.bg-green  { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-border); }
.bg-yellow { background: var(--yellow-bg); color: var(--yellow); border: 1px solid var(--yellow-border); }
.bg-red    { background: var(--red-bg); color: var(--red); border: 1px solid var(--red-border); }


/* ============================================================
   MODAL
   ============================================================ */
#modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 24, 22, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 500;
  opacity: 0;
  transition: opacity var(--duration) var(--ease);
}

#modal-box {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.96);
  width: 90%;
  max-width: 720px;
  max-height: 86vh;
  overflow-y: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  z-index: 510;
  opacity: 0;
  transition: all var(--duration) var(--ease);
}

#modal-overlay.modal-visible,
#modal-box.modal-visible { opacity: 1; }
#modal-box.modal-visible { transform: translate(-50%, -50%) scale(1); }

#modal-close-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 34px;
  height: 34px;
  background: var(--bg-surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 50%;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 520;
  transition: all var(--duration) var(--ease);
}

#modal-close-btn:hover {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}

#modal-content { padding: 28px; }

#modal-image {
  width: 100%;
  height: 260px;
  object-fit: cover;
  border-radius: var(--radius-md);
  margin-bottom: 20px;
  border: 1px solid var(--border);
}

#modal-title {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 14px;
  letter-spacing: -0.3px;
}

#modal-description {
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--text-secondary);
  white-space: pre-wrap;
}

#modal-loader {
  width: 100%;
  height: 320px;
  display: flex;
  align-items: center;
  justify-content: center;
}


/* ============================================================
   LOADER
   ============================================================ */
.status-box {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 50vh;
}

.loader-spinner {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}

.loader-spinner.large { width: 52px; height: 52px; }

@keyframes spin { to { transform: rotate(360deg); } }

#modal-loader .loader-spinner { width: 36px; height: 36px; }


/* ============================================================
   ERROR
   ============================================================ */
#error-message .error-box {
  background: var(--red-bg);
  border: 1px solid var(--red-border);
  color: var(--red);
  border-radius: var(--radius-lg);
  padding: 20px 28px;
  max-width: 380px;
  text-align: center;
}

#error-message h3 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 6px;
}


/* ============================================================
   FOOTER
   ============================================================ */
.site-footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 28px 0;
  border-top: 1px solid var(--border);
  margin-top: 20px;
}

.site-footer a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.site-footer a:hover { text-decoration: underline; }


/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-in {
  animation: fadeIn 0.35s var(--ease) forwards;
}


/* ============================================================
   RESPONSIVE — TABLET
   ============================================================ */
@media (max-width: 1024px) {
  .charts-row { grid-template-columns: 1fr; }
  .hero-title { font-size: 1.6rem; }
}

/* ============================================================
   RESPONSIVE — MOBILE
   ============================================================ */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 56px;
    flex-direction: row;
    border-right: none;
    border-top: 1px solid var(--border);
    padding: 0 4px;
    justify-content: space-around;
  }

  .sidebar-logo { display: none; }

  .sidebar-nav {
    flex-direction: row;
    gap: 0;
    padding: 0;
    justify-content: space-around;
    width: 100%;
  }

  .nav-item { width: 40px; height: 40px; }
  .nav-item.active::after { display: none; }
  .nav-tooltip { display: none; }
  .sidebar-bottom { display: none; }

  .main-content { margin-left: 0; padding-bottom: 72px; }
  .page-container { padding: 16px; }

  .top-bar { flex-direction: column; align-items: flex-start; gap: 10px; }
  .top-bar-right { width: 100%; }
  .search-wrapper { flex: 1; }
  .search-input, .search-input:focus { width: 100%; }

  .hero-section { height: 220px; }
  .hero-content { padding: 20px; }
  .hero-title { font-size: 1.3rem; }

  .stats-grid { grid-template-columns: 1fr; }

  #game-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
  .game-card-img-wrapper { height: 140px; }
}

@media (max-width: 480px) {
  .hero-section { height: 190px; }
  .hero-title { font-size: 1.1rem; }
  .hero-meta { flex-wrap: wrap; gap: 6px; }
}


/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
