/* ===== SIDEBAR.CSS =====
   Fixes: collapse/expand reflow, icon-only collapsed state,
   hover states, active indicator, scroll overflow, mobile drawer,
   keyboard focus, reduced-motion, and game-tab redesign.
   Does NOT change colours, fonts, or the overall palette.
================================================================ */

/* ── Layout tokens ───────────────────────────────────────────── */
:root {
  /* --sidebar-w holds dynamic width set by user dragging, or defaults */
  --sidebar-w: 300px;
  --sidebar-collapsed-w: 68px;

  --sidebar-transition:
    width 250ms cubic-bezier(0.4, 0, 0.2, 1),
    margin-left 220ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Sidebar base ─────────────────────────────────────────────── */
#sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  /* Solid theme background overlay to prevent content bleeding through underneath */
  background-color: var(--bg-alt) !important;
  /* Clear border and shadow separating sidebar from page content */
  border-right: 1px solid var(--line);
  box-shadow: 4px 0 16px rgba(0, 0, 0, 0.15);
  z-index: 1000 !important; /* Ensure desktop sidebar sits clearly above content */
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: var(--sidebar-transition);
  will-change: width;
}

/* Force-hide mobile header logo text overlap on desktop screens */
@media (min-width: 821px) {
  .mobile-header {
    display: none !important;
  }
}

/* ── Main content sync ────────────────────────────────────────── */
#main-content,
footer {
  margin-left: var(--sidebar-w);
  width: calc(100% - var(--sidebar-w));
  transition: var(--sidebar-transition);
}

/* ── Sidebar Header (Centered Toggle Button) ──────────────────── */
.sidebar-header {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
  height: 72px; /* Fixed height to match header rows */
  transition: padding 220ms ease;
}

body.sidebar-collapsed .sidebar-header {
  padding: 16px 8px; /* Reduces horizontal padding to prevent clipping */
}

#sidebar-collapse-btn {
  display: flex !important;
  align-items: center;
  justify-content: center;
  cursor: pointer !important;
  transition: all 220ms ease !important;
  color: var(--text-dim) !important;
  background-color: transparent !important;
  border: 1px solid var(--line) !important;
}

#sidebar-collapse-btn:hover {
  color: var(--text) !important;
  background-color: var(--bg-alt) !important;
  border-color: var(--cyan) !important;
  transform: scale(1.08);
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.25);
}

#sidebar-collapse-btn:active {
  transform: scale(0.95);
}
#sidebar-collapse-btn .collapse-icon {
  transition: transform 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Nav links: consistent spacing & states ───────────────────── */
.nav-links {
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  gap: 6px; /* Single consistent gap value */
  flex-grow: 1;
  overflow-y: auto;
  scrollbar-width: none;
}
.nav-links::-webkit-scrollbar {
  display: none;
}

.nav-links a {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: var(--text-dim);
  padding: 10px 12px;
  border-radius: 8px;
  font-weight: 500;
  text-decoration: none;
  border-left: 3px solid transparent;
  white-space: nowrap;
  transition:
    background 150ms ease,
    color 150ms ease,
    border-color 150ms ease,
    padding 200ms ease;
  position: relative;
  z-index: 1;
  min-height: 44px;
}

/* Icon sizing — consistent across all items */
.nav-links a svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  stroke-width: 1.75;
  opacity: 0.75;
  transition:
    opacity 150ms ease,
    color 150ms ease;
}

/* Hover state */
.nav-links a:hover {
  color: var(--text);
  background: var(--bg-alt);
  border-left-color: var(--cyan);
}
.nav-links a:hover svg {
  opacity: 1;
}

/* Active state — pill indicator + accent */
.nav-links a.active {
  color: var(--violet);
  background: var(--violet-soft);
  border-left-color: var(--violet);
  font-weight: 600;
}
.nav-links a.active svg {
  opacity: 1;
  color: var(--violet);
}

/* Focus-visible outline for keyboard navigation */
.nav-links a:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
  border-radius: 8px;
}

/* ── Profile section ──────────────────────────────────────────── */
.sidebar-profile {
  padding: 24px 20px;
  text-align: center;
  border-bottom: 1px solid var(--line);
  transition: padding 220ms ease;
  flex-shrink: 0;
}
.sidebar-profile img {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 12px;
  border: 2px solid var(--cyan);
  transition:
    width 220ms ease,
    height 220ms ease,
    margin-bottom 220ms ease;
  display: block;
  margin-left: auto;
  margin-right: auto;
}
.sidebar-profile h2 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 3px;
}
.sidebar-profile p {
  font-size: 12px;
  color: var(--text-dim);
}

/* ── Sidebar footer ───────────────────────────────────────────── */
.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  transition: padding 220ms ease;
}

/* ── Nav-pill (gliding background highlight) ──────────────────── */
/* Keep existing .nav-pill, just make sure z-index is behind links */
.nav-pill {
  z-index: 0;
}

/* ── Reduced-motion: disable all sidebar animations ──────────── */
@media (prefers-reduced-motion: reduce) {
  #sidebar,
  #main-content,
  footer,
  .nav-links a,
  .sidebar-profile img,
  #sidebar-collapse-btn svg,
  .sidebar-profile h2,
  .sidebar-profile p {
    transition: none !important;
    animation: none !important;
  }
}

/* =================================================================
   MOBILE (≤ 820px) — Sidebar becomes a slide-out drawer
================================================================== */
@media (max-width: 820px) {
  /* Sidebar overlays content — no margin push on mobile */
  #sidebar {
    width: 300px !important; /* always full-width; drawer logic overrides position */
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 250ms cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: none;
    z-index: 1100 !important; /* sits above mobile sticky header */
    background-color: var(--bg-alt) !important;
  }
  body.sidebar-open #sidebar {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.3);
  }
  /* Content fills full width on mobile */
  #main-content,
  footer {
    margin-left: 0 !important;
    width: 100% !important;
  }
  /* Hamburger tap target */
  .hamburger-btn {
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    border-radius: 8px;
  }
  .hamburger-btn:focus-visible {
    outline: 2px solid var(--cyan);
    outline-offset: 2px;
  }
  /* Drawer overlay backdrop */
  body.sidebar-open::before {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: calc(var(--z-nav) - 1);
    backdrop-filter: blur(2px);
  }
  /* No collapsed state on mobile */
  body.sidebar-collapsed #sidebar .sidebar-poster {
    display: none;
  }
  body.sidebar-collapsed {
    padding-left: var(--sidebar-collapsed-width);
  }
  body.sidebar-collapsed #sidebar {
    width: 300px !important;
  }
}

/* =================================================================
   GAME-TAB REDESIGN — replace vertical text panel with icon button
================================================================== */
#game-tab {
  position: fixed;
  right: 18px;
  bottom: 24px;
  top: auto; /* remove old top:50% positioning */
  transform: none !important; /* remove old translateY(-50%) */
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(11, 17, 32, 0.88);
  backdrop-filter: blur(10px);
  border: 1.5px solid rgba(0, 229, 255, 0.55);
  box-shadow:
    0 0 14px rgba(0, 229, 255, 0.22),
    0 4px 12px rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 100;
  padding: 0;
  transition:
    box-shadow 200ms ease,
    background 200ms ease,
    transform 200ms ease;
  animation: gameTabPulse 3s ease-in-out infinite;
}
#game-tab:hover {
  transform: scale(1.1) !important;
  background: rgba(0, 229, 255, 0.12);
  box-shadow:
    0 0 24px rgba(0, 229, 255, 0.45),
    0 6px 16px rgba(0, 0, 0, 0.35);
}
#game-tab:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
}
#game-tab:active {
  transform: scale(0.95) !important;
}

/* Icon inside */
#game-tab .tab-icon {
  width: 24px;
  height: 24px;
  color: #00e5ff;
  animation: pulseNeon 2.5s ease-in-out infinite alternate;
}

/* Hide the old vertical text completely */
#game-tab .tab-text {
  display: none;
}
/* Hide the scanline overlay */
#game-tab .scanline {
  display: none;
}

/* Tooltip label on hover */
#game-tab::before {
  content: "Launch Arcade";
  position: absolute;
  right: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 6px;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
  opacity: 0;
  pointer-events: none;
  transition: opacity 150ms ease;
}
#game-tab:hover::before {
  opacity: 1;
}

@keyframes gameTabPulse {
  0%,
  100% {
    box-shadow:
      0 0 14px rgba(0, 229, 255, 0.22),
      0 4px 12px rgba(0, 0, 0, 0.35);
  }
  50% {
    box-shadow:
      0 0 22px rgba(0, 229, 255, 0.4),
      0 4px 12px rgba(0, 0, 0, 0.35);
  }
}

/* Mobile: tuck into bottom-right, keep on screen */
@media (max-width: 820px) {
  #game-tab {
    right: 14px;
    bottom: 16px;
    width: 48px;
    height: 48px;
  }
  #game-tab .tab-icon {
    width: 22px;
    height: 22px;
  }
}

/* Remove old desktop game-tab hide rule — we show it everywhere now */
@media (max-width: 768px) {
  #game-tab {
    display: flex !important;
  }
}

/* ===== 12. SIDEBAR DRAG RESIZER STYLES ===== */
body.sidebar-dragging,
body.sidebar-dragging #sidebar,
body.sidebar-dragging #main-content,
body.sidebar-dragging footer {
  transition: none !important;
  cursor: col-resize !important;
  user-select: none !important;
  -webkit-user-select: none !important;
}

#sidebar-resizer:focus-visible {
  outline: 2px solid var(--cyan) !important;
  outline-offset: -2px;
}

@media (max-width: 820px) {
  #sidebar-collapse-btn {
    display: none !important;
  }
}
