/*
================================================================================
SILVERPAUL FORUM - HEADER MODULE
================================================================================

This module contains all header and navigation styling including:
- Header container and logo
- Navigation bars (.nav_mid, .nav_first, .nav_last) 
- Mobile hamburger menu and dropdown functionality

IMPORTANT: This module depends on JavaScript for mobile navigation functionality.
Make sure to test hamburger menu toggle and dropdown behavior on mobile devices.

Dependencies:
- CSS Custom Properties from variables.css (must be loaded first)
- JavaScript hamburger menu functionality in base.html

Last Updated: July 24, 2025
================================================================================
*/

/* ==========================================================================
   HEADER AND NAVIGATION
   ========================================================================== */

header {
  height: auto;
  /* Let CSS Grid handle width - removed explicit width: 100% */
  position: relative;
  z-index: 1000;
}
.header-container {
  max-width: 100%;
  margin: 0 auto;
  padding: var(--space-2-5) var(--space-5);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo {
  height: var(--space-37);
  max-width: 100%;
  /* Prevent logo from causing horizontal overflow */
  object-fit: contain;
}
.mobile-controls {
  display: none;
}
/* Floating Mobile Menu Trigger */
.mobile-menu-trigger {
  position: fixed;
  left: 10px;
  top: 50vh; /* Use viewport height for true centering */
  transform: translateY(-50%);
  z-index: 1001;
  cursor: pointer;
  transition: all 0.3s ease;
  display: none; /* Hidden by default, shown on mobile */
  /* Ensure it stays fixed regardless of parent containers */
  width: auto;
  height: auto;
}

.menu-trigger-icon {
  width: 30px;
  height: 30px;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  transition: all 0.3s ease;
}

/* Attention-grabbing animation on page load */
.menu-trigger-icon.pulse {
  animation: pulseAttention 0.6s ease-out;
}

@keyframes pulseAttention {
  0% { transform: scale(1); }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

/* Icon moves with menu */
.mobile-menu-trigger.menu-open {
  left: calc(70vw - 30px); /* Stick to right edge of 70% viewport width menu */
}

/* Left-Sliding Menu */
.slide-menu {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw; /* Use viewport width */
  height: 100vh; /* Use viewport height */
  z-index: 1000;
  pointer-events: none;
  transition: all 0.333s ease;
  display: none; /* Hidden by default, shown on mobile */
  /* Ensure it covers everything */
  overflow: hidden;
}

.slide-menu.show {
  pointer-events: auto;
}

.slide-menu-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 0.333s ease;
  z-index: 999; /* Below the panel but above everything else */
}

.slide-menu.show .slide-menu-backdrop {
  opacity: 1;
}

.slide-menu-panel {
  position: fixed;
  top: 0;
  left: 0;
  width: 70vw; /* Use viewport width */
  height: 100vh; /* Use viewport height */
  background: var(--bg-light);
  transform: translateX(-100%);
  transition: transform 0.333s ease;
  overflow-y: auto;
  box-shadow: 2px 0 10px rgba(0,0,0,0.3);
  z-index: 1001; /* Above backdrop and trigger */
}

.slide-menu.show .slide-menu-panel {
  transform: translateX(0);
}

/* Two-Column Grid Layout */
.menu-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: repeat(8, 1fr); /* Exactly 8 equal rows */
  gap: var(--space-1); /* Match desktop spacing */
  padding: 0; /* Remove padding to use full percentage height */
  margin-top: 10%;
  margin-bottom: 10%;
  height: 80vh; /* Set explicit height for percentage calculations */
  box-sizing: border-box;
}

.menu-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px; /* Small fixed padding for visual spacing */
  text-decoration: none;
  border-radius: var(--radius-md);
  background: #F0F2F4; /* Subtle button background */
  transition: all 0.2s ease;
  min-height: 44px; /* Touch target minimum */
  height: 100%; /* Fill the grid cell completely */
  width: 60%;
  margin: auto;
  justify-content: center;
  box-sizing: border-box;
}

.menu-item:hover {
  background: var(--bg-lighter);
  transform: scale(1.05);
}

.menu-icon {
  font-size: 32px; /* Larger since no text */
  margin-bottom: 0; /* Remove margin since no text below */
}

/* Special styling for donate button */
.menu-item-donate {
  grid-column: 1 / -1; /* Full width */
  width: 81%; /* Slightly narrower to prevent border clipping */
  margin: var(--space-2) auto 0 auto; /* Center it horizontally */
  border: 2px solid var(--primary-red);
}

/* ==========================================================================
   DESKTOP LEFT NAVIGATION SYSTEM
   ========================================================================== */

/* Desktop Left Navigation Container */
.desktop-left-nav {
  position: fixed;
  top: 0;
  left: 0;
  width: 12.5%;
  height: 100vh;
  min-width: 200px; /* Prevent emoji overlap */
  background: var(--bg-light);
  z-index: 100;
  display: none; /* Hidden on mobile */
  overflow-y: auto; /* Enable vertical scrolling */
  direction: rtl; /* Place scrollbar on left side */
}

/* Desktop Banner Styling */
.desktop-banner {
  background: var(--sidebar-card-bg);
  border-radius: var(--radius-lg); /* Match sidebar cards */
  box-shadow: 0 var(--space-0-5) var(--space-2) var(--sidebar-card-shadow);
  padding: var(--space-4);
  margin: var(--space-3-5) var(--space-3-5) var(--space-5) var(--space-3-5); /* Match sidebar spacing */
  transition: box-shadow 0.3s ease;
  direction: ltr; /* Reset direction for content */
}

.desktop-logo {
  width: 120px;
  height: auto;
  display: block;
  margin: 0 auto; /* Center the image */
}

/* Desktop Menu Grid Container */
.desktop-menu-container {
  background: var(--sidebar-card-bg);
  border-radius: var(--radius-lg); /* Match sidebar cards */
  box-shadow: 0 var(--space-0-5) var(--space-2) var(--sidebar-card-shadow);
  margin: 0 var(--space-3-5) var(--space-3-5) var(--space-3-5); /* Match sidebar spacing */
  padding: var(--space-2);
  transition: box-shadow 0.3s ease;
  direction: ltr; /* Reset direction for content */
}

.desktop-menu-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: repeat(8, auto); /* Use auto sizing for better fit */
  gap: var(--space-1);
  padding: var(--space-2);
  box-sizing: border-box;
  min-height: 100%; /* Take at least full height */
}

.desktop-menu-item {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-1-5); /* Slightly less padding for compact fit */
  border-radius: var(--radius-md);
  background: #F0F2F4; /* Subtle button background */
  text-decoration: none;
  transition: all 0.2s ease;
  max-height: 46px; /* Slightly smaller minimum height */
  height: auto; /* Let content determine height */
  box-sizing: border-box;
}

.desktop-menu-item:hover {
  background: var(--bg-lighter);
  transform: scale(1.05);
}

.desktop-menu-icon {
  font-size: 28px; /* Slightly smaller for desktop */
}

/* Desktop donate button styling */
.desktop-menu-item.desktop-donate {
  grid-column: 1 / -1;
  width: 98%;
  margin: 0 auto;
  border: 2px solid var(--primary-red);
}

/* Mobile-first: navbar hidden by default */
.navbar {
  display: none;
}
#nav_ul {
  background-color: var(--primary-blue);
  list-style-type: none;
  padding: var(--space-0);
  margin: var(--space-0);
  overflow: hidden;
  width: 100%;
  border-radius: var(--space-1-5);
}
.nav_a {
  color: var(--header-white);
  text-decoration: none;
  font-family: var(--font-family-navigation);
  padding: var(--space-2-5);
  display: block;
  text-align: center;
}
.nav_a:hover {
  color: var(--silver);
}
.nav_mid {
  float: left;
  border-right: var(--space-px) solid var(--header-white);
  border-left: var(--space-px) solid var(--header-white);
}
.nav_first {
  float: left;
  border-right: var(--space-px) solid var(--header-white);
}
.nav_last {
  float: left;
  border-left: var(--space-px) solid var(--header-white);
}
a.dev {
  cursor: not-allowed;
}

/* ==========================================================================
   DESKTOP STYLES
   ========================================================================== */

/* ==========================================================================
   DESKTOP LAYOUT (>1000px)
   ========================================================================== */

@media (min-width: 1001px) {
  /* Show desktop left navigation */
  .desktop-left-nav {
    display: block;
  }
  
  /* Hide mobile navigation elements */
  .mobile-menu-trigger,
  .slide-menu,
  .mobile-controls {
    display: none !important;
  }
  
  /* Hide original header and navbar on desktop */
  .header {
    display: none;
  }
  
  /* Desktop grid layout - override existing grid */
  .app-layout {
    display: grid;
    grid-template-columns: minmax(200px, 12.5%) 1% 53% 2% 19% 12.5%; /* Smaller gap between nav and main content */
    grid-template-rows: 1fr auto; /* content, footer */
    grid-template-areas: 
      "left-nav gap1 main gap2 sidebar right-space"
      "left-nav gap1 footer footer footer right-space";
    min-height: 100vh;
    max-width: none; /* Override existing max-width */
    margin: 0; /* Override existing centering */
    padding: 0; /* Override existing padding */
    gap: 0; /* Override existing gap for precise control */
    width: 100vw; /* Full viewport width */
    min-width: 1200px; /* Minimum total width to prevent nav overlap */
  }
  
  /* Content fills header space and accounts for fixed left nav */
  .main-content {
    grid-area: main;
    padding-top: var(--space-4); /* Some top padding for content */
    margin-left: 0; /* Grid handles positioning */
  }
  
  .sidebar {
    /* Maintains existing proportions but positioned in grid */
    grid-area: sidebar;
    padding-top: var(--space-4); /* Match main content */
  }
  
  /* Right space placeholder */
  .right-space {
    grid-area: right-space;
    background: transparent; /* Empty for future features */
  }
  
  /* Footer spans main content and sidebar areas */
  .footer {
    grid-area: footer;
    border-radius: 20px 20px 0 0; /* Rounded top corners */
  }
}

/* ==========================================================================
   MOBILE RESPONSIVE HEADER STYLES
   ========================================================================== */

@media (max-width: 1000px) {
  /* Mobile-only: hide desktop navigation */
  .desktop-left-nav {
    display: none !important;
  }
  
  /* Mobile-only: show header and mobile controls */
  .header {
    display: block !important;
  }
  
  .header-container {
    padding: var(--space-2) var(--space-3-5); /* 8px 14px - closest to original 8px 15px */
    flex-wrap: wrap;
  }
  
  .logo {
    height: var(--space-29);
    max-width: 100%;
    margin-bottom: var(--space-1-5);
    /* Ensure logo scales properly on mobile */
    object-fit: contain;
  }
  
  .mobile-controls {
    display: flex;
    align-items: center;
    gap: var(--space-2);
  }
  
  .mobile-menu-trigger {
    display: block;
  }
  
  .slide-menu {
    display: block;
  }
  
  /* navbar is hidden by default (mobile-first) */
}

/* Additional mobile breakpoint for smaller devices */
@media (max-width: 480px) {
  .logo {
    height: var(--space-29);
    max-width: 90%;
    object-fit: contain;
  }
  
  .header-container {
    padding: var(--space-1-5) var(--space-2-5);
  }
}
