/* ============================================================
   styles.css
   Complete stylesheet for GamesDexter site
   - Default block layout for pages
   - Flex only for .container.with-sidebar
   - Accessibility & overflow fixes
   - Compact mobile navbar + right-slide drawer (mobile)
   - Compact game-card on small/medium screens (title + play only)
   - Desktop: nav contents aligned to the right
   ============================================================ */

/* ================== ROOT THEME ================== */
:root {
  --bg: #ffffff;
  --fg: #111827;
  --muted: #6b7280;
  --accent: #ff9800; /* Orange Accent */
  --card: #f8fafc;
  --header-grad: linear-gradient(90deg, #0f172a, #1f2937);
  --radius: 12px;
  --page-max-width: 1200px;
  --gutter: 24px;

  /* Mobile header height used for fixed header spacing */
  --mobile-header-h: 64px;
  --mobile-pills-h: 48px;
}

/* ================== GLOBAL RESET ================== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

/* ================== BASE ================== */
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
}

/* Accessible helper to hide text visually while keeping it available to screen readers */
.visually-hidden {
  position: absolute !important;
  height: 1px;
  width: 1px;
  overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px);
  white-space: nowrap;
  border: 0;
  padding: 0;
  margin: -1px;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:focus {
  outline: 3px solid rgba(255,152,0,0.15);
}

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

/* ================== HEADER + NAVBAR ================== */
/* Desktop default: grid layout with brand left, nav content right */
.header {
  background: var(--header-grad);
  color: #fff;
  padding: 12px var(--gutter);
  display: grid;
  grid-template-columns: auto 1fr auto; /* brand | spacer | nav cluster */
  align-items: center;
  gap: 20px;
  position: sticky;
  top: 0;
  z-index: 10070; /* raised so header/hamburger sits above drawer */
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  transition: background .15s;
}

/* Logo Section */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 20px;
  color: #fff;
  min-width: 0;
  grid-column: 1; /* explicitly left */
}

.nav-logo {
  height: 38px;
  width: auto;
  border-radius: 6px;
  object-fit: contain;
}

/* Navigation: place entire nav cluster in right column */
.nav {
  grid-column: 3;              /* RIGHT side cluster */
  display: flex;
  align-items: center;
  gap: 18px;
  justify-content: flex-end;   /* push items to far right inside cluster */
  min-width: 0;
  position: relative;          /* default desktop behaviour */
}

/* nav-links sits inside nav cluster and is horizontally laid out */
.nav-links {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: nowrap;
}

.nav-links a {
  position: relative;
  font-weight: 500;
  font-size: 15px;
  color: #e2e8f0;
  transition: color .18s;
  padding: 6px 8px;
  border-radius: 8px;
}
.nav-links a:hover,
.nav-links a:focus {
  color: #fff;
}

/* Underline effect */
.nav-links a::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -6px;
  width: 0;
  height: 2px;
  background: var(--accent);
  transition: width .18s ease-out;
}
.nav-links a:hover::after,
.nav-links a:focus::after {
  width: 100%;
}

/* Search + Theme inside the same right cluster */
.nav-search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
}
.nav-search-input {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid #374151;
  background: #1e293b;
  color: #fff;
  font-size: 14px;
  width: 220px;
  transition: border-color .18s, box-shadow .18s, opacity .18s, width .18s;
}
.nav-search-input::placeholder { color: rgba(255,255,255,0.5); }
.nav-search-input:focus {
  outline: 3px solid rgba(255,152,0,0.12);
  border-color: var(--accent);
  box-shadow: 0 4px 18px rgba(0,0,0,.12);
}

/* Small search icon button (for mobile) — hidden on desktop */
.nav-search-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.06);
  background: rgba(255,255,255,0.02);
  color: #fff;
  cursor: pointer;
}

/* Floating search panel (desktop) */
#navSearchPanel {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  width: 360px;
  max-width: calc(100vw - 40px);
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.04);
  box-shadow: 0 12px 36px rgba(2,6,23,0.5);
  padding: 10px;
  display: none;
  z-index: 1200;
  backdrop-filter: blur(6px);
}
#navSearchPanel.open { display: block; }

#navSearchResults {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 44vh;
  overflow: auto;
  padding-right: 6px;
}
#navSearchResults a { color: #e6edf3; text-decoration: none; padding: 8px 10px; border-radius: 8px; }
#navSearchResults a:hover, #navSearchResults a:focus { background: rgba(255,255,255,0.03); color:#fff; outline:none; }

/* Theme Toggle Button */
.theme-toggle {
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid #374151;
  background: transparent;
  color: #cbd5e1;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.theme-toggle:focus {
  outline: 3px solid rgba(255,152,0,0.12);
}

/* Hamburger button (hidden on desktop) */
.hamburger {
  display: none;
  background: transparent;
  border: none;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  padding: 8px;
  border-radius: 8px;
  z-index: 10080; /* ensure above header background if needed */
}

/* ================== MAIN CONTENT LAYOUT ================== */
/* DEFAULT: normal block layout for pages without sidebar */
.container {
  max-width: var(--page-max-width);
  width: 100%;
  margin: 0 auto; /* center page — change to `margin: 0;` if you want flush left */
  padding: 32px var(--gutter);
  display: block;   /* NOT flex by default — prevents columnized text on category pages */
  clear: both;
}

/* ONLY use flex when a sidebar is present */
.container.with-sidebar {
  display: flex;
  gap: 30px;
  align-items: flex-start;
}

.content-area {
  flex: 1;
  min-width: 0; /* critical to allow flex children to shrink without overflow */
}

.sidebar {
  width: 300px;
  flex-shrink: 0;
}

/* Page header area inside content */
.page-header {
  display: flex;
  align-items: flex-start;
  gap: 28px;
}
.page-title {
  font-size: 40px;
  font-weight: 800;
  margin: 8px 0 24px 0;
  color: var(--fg);
  line-height: 1;
}

/* ================== GAMES CARDS & GRIDS ================== */
/* 1. STANDARD GAME CARDS (Vertical / Grid List) */
.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 40px;
}

.game-card {
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.06);
  transition: transform .16s, box-shadow .16s;
  border: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
}
.game-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 10px 22px rgba(0,0,0,0.08);
}

.game-thumb {
  position: relative;
  display: block;
  width: 100%;
  overflow: hidden;
}
.game-thumb img {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  display: block;
  height: auto;
  max-height: 240px;
}

/* Play badge overlay (desktop + mobile) */
.game-play-overlay {
  position: absolute;
  right: 10px;
  bottom: 10px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  padding: 8px 10px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 13px;
  text-decoration: none;
  backdrop-filter: blur(2px);
}

/* Card body */
.game-card-body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1 1 auto;
}

.game-title {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
  white-space: nowrap; /* single-line truncation for small cards */
  overflow: hidden;
  text-overflow: ellipsis;
}

.game-desc {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.4em;
}

.game-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.badge {
  background: #eef2ff;
  color: #374151;
  font-size: 12px;
  padding: 6px 8px;
  border-radius: 999px;
  border: 1px solid #e6e9f2;
}

/* Play button (desktop) */
.game-play-btn {
  display: inline-block;
  text-align: center;
  background: #eff6ff;
  color: #2563eb;
  font-weight: 600;
  padding: 8px;
  border-radius: 6px;
  font-size: 13px;
  text-decoration: none;
  width: 100%;
}

/* 2. COMPACT MINI GRID (Forces 4 Icons in a row) */
.games-mini-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 20px 0 40px 0;
}

.mini-game-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
}

.mini-game-icon {
  width: 100%;
  aspect-ratio: 1/1;
  border-radius: 14px;
  object-fit: cover;
  box-shadow: 0 2px 5px rgba(0,0,0,0.06);
}

.mini-game-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--fg);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}

/* ================== GENERAL UI ELEMENTS ================== */
.meta {
  color: var(--muted);
  font-size: 0.95rem;
  margin-bottom: 1rem;
}

.post-item {
  border-bottom: 1px solid #e5e7eb;
  padding-bottom: 16px;
  margin-bottom: 16px;
}

.post-item h3 {
  margin: 0 0 8px 0;
}

.trending-box {
  background: #f1f5f9;
  padding: 16px;
  border-radius: 8px;
}

/* ================== FOOTER ================== */
.footer {
  text-align: center;
  padding: 40px 20px;
  border-top: 1px solid #e2e8f0;
  color: var(--muted);
  font-size: 14px;
  margin-top: 40px;
}

/* ================== DARK MODE ================== */
body.dark-mode {
  --bg: #020617;
  --fg: #f1f5f9;
  --card: #0f172a;
  --muted: #94a3b8;
}

body.dark-mode .game-card {
  background: var(--card);
  border-color: #1e293b;
}

body.dark-mode .nav-search-input {
  background: #0f172a;
  border-color: #1e293b;
}

body.dark-mode .game-play-btn {
  background: #1e293b;
  color: #60a5fa;
}

body.dark-mode .trending-box {
  background: #1e293b;
}

/* ================== RESPONSIVE FIXES (MOBILE & SMALL/MEDIUM) ================== */

/* ================== MOBILE: right-slide classic drawer ================== */
/* ================== MOBILE RIGHT-SLIDE DRAWER FIX ================== */
/* ========= FIXED MOBILE DRAWER PATCH =========
   Use this to replace only the mobile-drawer related rules.
   - preserves original gaps/spacing
   - hamburger only visible on <=1100px
   - desktop nav restored on larger screens (no persistent hamburger)
   - keeps theme-toggle available in drawer and on desktop
   ============================================== */

/* Ensure hamburger is hidden by default (desktop-first) */
.hamburger {
  display: none !important;
}

/* MOBILE / TABLET: enable hamburger + right-drawer */
@media (max-width: 1100px) {
  /* Header (fixed) */
  .header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--mobile-header-h);
    padding: 8px 12px;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    background: var(--header-grad);
    z-index: 11100;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  }

  /* keep original body top padding so content doesn't jump */
  body {
    padding-top: var(--mobile-header-h);
  }

  /* Show hamburger on mobile only */
  .hamburger {
    display: inline-flex !important;
    grid-column: 3 !important;
    justify-self: end !important;
    width: 48px !important;
    height: 48px !important;
    padding: 8px !important;
    border-radius: 8px !important;
    cursor: pointer !important;
    border: 1px solid rgba(255,255,255,0.12) !important;
    background: rgba(255,255,255,0.06) !important;
    color: #fff !important;
    font-size: 22px !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 11200 !important;
  }
  .hamburger, .hamburger * { pointer-events: auto !important; }

  /* Backdrop */
  .nav-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.28);
    opacity: 0;
    pointer-events: none;
    transition: opacity .22s ease;
    z-index: 11050;
  }
  body.nav-open .nav-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  /* Right-side drawer panel (preserve the original gap values) */
  .nav {
    position: fixed;
    top: var(--mobile-header-h);
    right: 0;
    bottom: 0;
    width: 300px;           /* keep as provided */
    max-width: 92%;
    background: var(--header-grad);
    color: #e6edf3;
    padding: 22px 20px;
    box-shadow: -10px 0 32px rgba(2,6,23,0.55);
    border-left: 1px solid rgba(255,255,255,0.1);
    transform: translateX(110%);
    transition: transform .28s cubic-bezier(.22,.9,.28,1), visibility .22s;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 18px;              /* preserve original gap: 18px */
    z-index: 11100;
    will-change: transform;
    -webkit-overflow-scrolling: touch;
    min-width: 0;
  }
  body.nav-open .nav {
    transform: translateX(0);
    visibility: visible;
  }

  /* Drawer header */
  .nav .drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
  }
  .drawer-title { font-size: 18px; font-weight: 700; }
  .drawer-close {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    padding: 6px;
    line-height: 1;
  }
  .drawer-close:focus { outline: 3px solid rgba(255,152,0,0.12); border-radius: 6px; }

  /* Menu links: keep the same larger pill padding from your original mobile rules */
  .nav-links {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;            /* original gap preserved */
    padding-top: 10px;
  }
  .nav-links a {
    width: 100%;
    padding: 16px 20px;   /* keep your original bigger vertical + horizontal padding */
    border-radius: 18px;  /* same as original */
    background: rgba(255,255,255,0.08); /* slightly stronger contrast as original */
    border: 1px solid rgba(255,255,255,0.15);
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    text-decoration: none;
    text-align: left;
    transition: background .15s, transform .15s;
    display: inline-block;
  }
  .nav-links a:hover,
  .nav-links a:focus {
    background: rgba(255,255,255,0.12);
    transform: translateX(4px);
    outline: none;
  }
  .nav-links a:focus { outline: 3px solid rgba(255,152,0,0.12); border-radius: 18px; }

  /* Search inside drawer: preserve size and styles */
  .drawer-search { margin-top: 10px; width: 100%; }
  .drawer-search .nav-search-input {
    width: 100%;
    height: 46px;
    font-size: 14px;
    border-radius: 14px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15);
    color: #fff;
    padding: 10px 14px;
  }
  .drawer-search .nav-search-input::placeholder { color: rgba(255,255,255,0.6); }
  .drawer-search .nav-search-input:focus { outline: 3px solid rgba(255,152,0,0.12); }

  /* Drawer footer retains theme-toggle appearance */
  .drawer-footer {
    margin-top: auto;
    display: flex;
    gap: 12px;
    align-items: center;
    padding-top: 10px;
  }
  .drawer-footer .theme-toggle {
    padding: 10px 16px;
    border-radius: 12px;
    font-size: 14px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.12);
    width: auto;
    color: #fff;
    font-weight: 600;
    cursor: pointer;
  }
  .drawer-footer .theme-toggle:focus { outline: 3px solid rgba(255,152,0,0.12); }

  /* keep small-screen adjustments unchanged */
  @media (max-width: 360px) {
    .games-grid { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
    .nav { width: 92%; right: 0; }
    .nav-search-input { font-size: 13px; padding: 8px 10px; }
    .page-title { font-size: 24px; }
  }
}

/* DESKTOP: explicitly restore desktop nav behavior (override mobile rules when >=1101px)
   This prevents the hamburger from appearing and ensures .nav is the normal navbar. */
@media (min-width: 1101px) {
  /* ensure hamburger is never visible on desktop */
  .hamburger { display: none !important; }

  /* Make sure .nav behaves like the original desktop cluster (not a fixed drawer) */
  .nav {
    position: relative !important;
    top: auto !important;
    right: auto !important;
    bottom: auto !important;
    width: auto !important;
    max-width: none !important;
    transform: none !important;
    transition: none !important;
    background: transparent !important;
    color: inherit !important;
    padding: 0 !important;
    box-shadow: none !important;
    border-left: none !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 18px !important; /* preserve original desktop gap */
    overflow: visible !important;
    z-index: auto !important;
  }

  /* hide the mobile-only backdrop on desktop */
  .nav-backdrop { display: none !important; pointer-events: none !important; }

  /* ensure nav-links revert to horizontal layout on desktop */
  .nav-links {
    display: flex !important;
    flex-direction: row !important;
    gap: 20px !important;
    align-items: center !important;
    padding-top: 0 !important;
  }
  .nav-links a {
    padding: 6px 8px !important;
    border-radius: 8px !important;
    background: transparent !important;
    border: none !important;
    color: #e2e8f0 !important;
    font-size: 15px !important;
    font-weight: 500 !important;
    transition: color .18s !important;
  }
  .nav-links a:hover, .nav-links a:focus {
    color: #fff !important;
    background: transparent !important;
    transform: none !important;
  }

  /* keep theme-toggle visible on desktop cluster (matches original) */
  .theme-toggle {
    display: inline-flex !important;
  }
}

/* final safety: ensure we didn't accidentally duplicate utility rules with different values */
.u-center { text-align: center; }
.u-muted { color: var(--muted); }
.card { background: var(--card); border-radius: 12px; padding: 16px; border: 1px solid #e5e7eb; }

/* Ensure essential elements never cause horizontal overflow */
.game-card,
.games-grid,
.mini-game-item {
  box-sizing: border-box;
  min-width: 0;
}


/* ================== UTILITIES ================== */
.u-center { text-align:center; }
.u-muted { color: var(--muted); }
.card { background: var(--card); border-radius:12px; padding:16px; border:1px solid #e5e7eb; }

/* Ensure elements don't cause horizontal scroll */
* { -webkit-tap-highlight-color: transparent; }
.game-card, .games-grid, .mini-game-item { box-sizing: border-box; min-width: 0; }

/* ================== UTILITIES ================== */
.u-center { text-align: center; }
.u-muted { color: var(--muted); }
.card { background: var(--card); border-radius: 12px; padding: 16px; border: 1px solid #e5e7eb; }

/* Ensure essential elements never cause a horizontal overflow */
.game-card,
.games-grid,
.mini-game-item {
  box-sizing: border-box;
  min-width: 0;
}

/* End of file */
