/* ==========================================
   1. MASTER COLOR VARIABLES & LIGHT THEME
   ========================================== */
:root {
  /* Dynamic Accent Colors (Updated by Hex Swatches) */
  --main-accent: #00ff88;
  --bg-accent: #000000; /* Dynamic accent tint for background */

  /* Base Theme Variables (Default Dark: Pitch Black) */
  --bg: #000000;
  --bg-raised: #121212;
  --text: #ffffff;
  --text-dim: #a1a1aa;
  --border: rgba(255, 255, 255, 0.12);
  --card-bg: #0d0d0d;
  --card-border: #27272a;
  --slot: #17121F;
  --radius: 14px;

  /* Cartridge Accent Colors */
  --clay: #D66B4B;
  --moss: #7A9B6B;
  --aqua: #A1FFFF;
  --purple: #66023C;
  --teal: #4F8C99;
}

/* LIGHT MODE OVERRIDES */
body.light-theme {
  --bg: #ffffff;
  --bg-raised: #f4f4f5;
  --text: #09090b;
  --text-dim: #71717a;
  --border: rgba(0, 0, 0, 0.1);
  --card-bg: #fdfdfd;
  --card-border: #e4e4e7;
}

/* ==========================================
   2. GLOBAL RESET & BASE STYLES
   ========================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

html, body {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  min-height: 100vh;
}

body {
  /* 50% lighter overlay (reduced from 0.82/0.92 down to 0.45/0.55) */
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.45) 0%, rgba(0, 0, 0, 0.55) 100%), var(--bg-accent, var(--bg));
  background-attachment: fixed;
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  line-height: 1.5;
  transition: background 0.4s ease, color 0.3s ease;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: rgba(255,255,255,0.08);
  padding: 0.1em 0.4em;
  border-radius: 4px;
  font-size: 0.9em;
}

/* ==========================================
   3. HERO SECTION & HEADER
   ========================================== */
.hero {
  padding: 5rem 1.5rem 3.5rem;
  border-bottom: 1px solid var(--border);
}

.hero-inner {
  max-width: 680px;
  margin: 0 auto;
}

.hero-eyebrow {
  margin: 0 0 0.5rem;
  color: var(--text-dim);
  font-size: 0.95rem;
}

.hero-title {
  font-family: 'Fredoka', sans-serif;
  font-weight: 700;
  font-size: clamp(2.75rem, 6vw, 4rem);
  margin: 0 0 1rem;
  color: var(--text);
  letter-spacing: -0.01em;
}

.hero-sub {
  color: var(--text-dim);
  font-size: 1.05rem;
  max-width: 56ch;
  margin: 0;
}

.logo-container {
  display: flex;
  align-items: center;
  gap: 15px;
}

.site-logo {
  height: 50px;
  width: auto;
  object-fit: contain;
  transition: opacity 0.3s ease;
}

.site-logo.hidden {
  display: none;
}

/* ==========================================
   4. SEARCH & GAME SHELF GRID
   ========================================== */
.search-container {
  max-width: 1200px;
  margin: 0 auto 20px;
  padding: 0 20px;
}

#game-search {
  width: 100%;
  padding: 12px 18px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-raised);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#game-search:focus {
  border-color: var(--main-accent);
  box-shadow: 0 0 10px var(--main-accent);
}

.shelf, #shelf-container, .shelf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

/* ==========================================
   5. CARTRIDGE & GAME CARDS
   ========================================== */
.cartridge, .game-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 1.25rem 1.25rem 1.5rem;
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--card-border);
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.cartridge-image {
  width: 100%;
  border-radius: 6px;
  margin-bottom: 0.5rem;
  display: block;
}

.cartridge:hover,
.cartridge:focus-visible {
  transform: translateY(-4px);
  border-color: var(--main-accent);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4), 0 0 12px var(--main-accent);
}

.cartridge:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

.cartridge-notch {
  width: 36px;
  height: 8px;
  border-radius: 0 0 6px 6px;
  margin-bottom: 1rem;
}

.cartridge-label {
  border-radius: 8px;
  padding: 0.9rem 1rem 1rem;
  margin-bottom: 0.75rem;
}

.cartridge-title {
  font-family: 'Fredoka', sans-serif;
  font-weight: 600;
  font-size: 1.25rem;
  margin: 0 0 0.35rem;
  color: #1B1626;
}

.cartridge-desc {
  margin: 0;
  font-size: 0.9rem;
  color: rgba(27,22,38,0.75);
}

.cartridge-play {
  align-self: flex-start;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  transition: color 0.2s ease;
}

.cartridge:hover .cartridge-play {
  color: var(--main-accent);
}

/* Cartridge Color Classes */
.cartridge--clay .cartridge-notch, .cartridge--clay .cartridge-label { background: var(--clay); }
.cartridge--moss .cartridge-notch, .cartridge--moss .cartridge-label { background: var(--moss); }
.cartridge--teal .cartridge-notch, .cartridge--teal .cartridge-label { background: var(--teal); }
.cartridge--aqua .cartridge-notch, .cartridge--aqua .cartridge-label { background: var(--aqua); }
.cartridge--purple .cartridge-notch, .cartridge--purple .cartridge-label { background: var(--purple); }

/* ==========================================
   6. SIDEBAR & NAVIGATION LAYERS
   ========================================== */
#sidebar-toggle {
  position: fixed;
  top: 15px;
  left: 15px;
  z-index: 1000;
  background: var(--main-accent);
  color: #000000;
  border: none;
  padding: 10px 16px;
  border-radius: 8px;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 0 12px var(--main-accent);
  transition: background 0.3s ease, box-shadow 0.3s ease, transform 0.15s ease;
}

#sidebar-toggle:hover {
  transform: scale(1.05);
}

#sidebar-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  background: rgba(0, 0, 0, 0.6);
  z-index: 1001;
  display: none;
  backdrop-filter: blur(2px);
}
#sidebar-overlay.active { display: block; }

.sidebar {
  position: fixed;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100vh;
  background: #121215;
  color: #fff;
  z-index: 1002;
  transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  padding: 20px;
  box-sizing: border-box;
  overflow-y: auto;
}

@media (min-width: 600px) {
  .sidebar {
    width: 33.33vw;
    min-width: 300px;
    left: -33.33vw;
    border-right: 2px solid var(--card-border);
  }
}

.sidebar.open { left: 0; }

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--card-border);
  padding-bottom: 10px;
  margin-bottom: 20px;
}

.close-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.8rem;
  cursor: pointer;
  transition: color 0.2s ease, transform 0.2s ease;
}

.close-btn:hover {
  color: var(--main-accent);
  transform: rotate(90deg);
}

/* LAYER DISPLAY FIXES */
.sidebar-layer { 
  display: none; 
}

.sidebar-layer.active { 
  display: block !important; 
  animation: fadeIn 0.2s ease-in-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.sidebar-btn {
  width: 100%;
  background: #18181b;
  color: var(--main-accent);
  border: 1px solid var(--card-border);
  padding: 12px;
  margin-bottom: 10px;
  border-radius: 6px;
  text-align: left;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s, transform 0.15s ease;
}

.sidebar-btn:hover, .sidebar-btn.active {
  background: #27272a;
  border-color: var(--main-accent);
  transform: translateX(3px);
}

.back-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 15px;
  transition: color 0.2s ease;
}

.back-btn:hover {
  color: var(--main-accent);
}

.layer-desc {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 10px;
}

.stat-badge {
  background: #18181b;
  padding: 10px;
  margin-bottom: 8px;
  border-radius: 6px;
  border-left: 4px solid var(--main-accent);
  transition: border-color 0.3s ease;
}

/* MAIN CONTENT PUSH EFFECT */
#main-content {
  width: 100%;
  min-height: 100vh;
  padding: 20px;
  background: transparent;
  box-sizing: border-box;
  transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (min-width: 600px) {
  body.sidebar-active #main-content {
    margin-left: 33.33vw;
    width: 66.67vw;
  }
}

@media (max-width: 599px) {
  body.sidebar-active #main-content {
    width: 100%;
    margin-left: 0;
  }
}
/* ==========================================
   7. THEME MODAL & INLINE SVG HEXAGON PALETTE
   ========================================== */
.theme-modal {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  background: rgba(0, 0, 0, 0.85);
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.hex-swatch {
  cursor: pointer;
  pointer-events: visiblePainted !important;
  transition: transform 0.2s ease, filter 0.2s ease;
}

.hex-swatch:hover {
  transform: scale(1.15);
  filter: brightness(1.25);
}

/* ==========================================
   8. FOOTER
   ========================================== */
.site-footer {
  text-align: center;
  padding: 2rem 1.5rem 3rem;
  color: var(--text-dim);
  font-size: 0.85rem;
}
