/* ===========================================
   Unified Header & Hamburger Styles
   =========================================== */

header {
  position: sticky;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 2000;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
  display: flex;
  align-items: center;
  /* Ensure proper stacking context */
  isolation: isolate;
  justify-content: space-between;
  padding: 0 var(--space-md);
  height: 80px;
  transition: background 0.3s, box-shadow 0.3s;
}

/* Desktop header title centered */
.header-title-link {
  position: absolute;
  left: 50%; /* Center horizontally */
  top: 50%; /* Vertical center */
  transform: translate(-50%, -50%); /* Center both horizontally and vertically */
  text-decoration: none;
  color: var(--primary);
  font-size: 2.1rem;
  letter-spacing: 5px; /* Desktop letter spacing */
  white-space: nowrap; /* Prevent wrapping */
  z-index: 1; /* Ensure proper stacking order */
}

/* Ensure header title uses Creepster font with specific selector and proper vertical alignment */
header .header-title,
.header-title-link .header-title,
.header-title.creepster-font {
  font-family: 'Creepster', cursive;
  margin: 0; /* Remove default margins to help with centering */
  line-height: 1.3; /* Adjust line height for better vertical position */
}

.header-title-link:hover,
.header-title-link:focus {
  color: var(--primary-light);
}

.logo-pumpkin {
  width: 44px;
  height: 44px;
  margin-right: var(--space-sm);
  vertical-align: middle;
}

.header-links {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  position: relative;
  z-index: 2; /* Higher than header title */
  margin-left: auto; /* Push to right side */
}

.header-links a {
  display: flex;
  align-items: center;
  color: var(--light-gray); /* Gray color instead of white */
  font-family: var(--font-primary);
  font-size: 1.1rem;
  padding: 0.1em 0.1em;
  text-decoration: none;
  font-weight: normal; /* Ensure all links are normal weight by default */
  transition: color 0.18s;
  background: none; /* No background */
  border: none;
}

/* Active link - bold and orange */
.header-links a.active {
  color: var(--primary); /* Orange color */
  font-weight: bold;
  background: none; /* No background */
}

/* Keep hover and focus a subtler effect - just color change, no background */
.header-links a:hover,
.header-links a:focus {
  color: var(--primary-light);
  background: none; /* No background */
}

.header-links i {
  margin-right: 0.35em; /* Reduced by half from 0.7em */
  min-width: 1.3em;
  text-align: center;
}

.header-link-logout {
  color: var(--danger);
  font-weight: 700;
}
.header-link-logout:hover,
.header-link-logout:focus {
  color: #ff3c3c;
}

.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 44px;
  height: 44px;
  background: transparent; /* Transparent background */
  border: none;
  cursor: pointer;
  z-index: 9999; /* Extremely high z-index to ensure it's above everything */
  position: relative; /* Establish stacking context */
  margin-right: -1px; 
  margin-top: -6px; 
}
.hamburger:focus {
  outline: none;
}
.hamburger-bar {
  width: 28px;
  height: 4px;
  background: #272727;
  margin: 4px 0;
  border-radius: 2px;
  transition: all 0.3s cubic-bezier(.7,.3,.2,1);
}

/* Transform hamburger into X when active */
.hamburger.active .hamburger-bar:nth-child(1) {
  transform: translateY(8px) rotate(45deg);
}

.hamburger.active .hamburger-bar:nth-child(2) {
  opacity: 0;
}

.hamburger.active .hamburger-bar:nth-child(3) {
  transform: translateY(-8px) rotate(-45deg);
}

/* ========== MOBILE ========== */
@media (max-width: 767px) {
  /* Ensure consistent header height with structural approach */
  header,
  html body header,
  html body.calendar-page header,
  html body:not(.calendar-page) header,
  .calendar-container.loaded ~ header,
  body.calendar-page .calendar-container.loaded ~ header {
    padding: 0 var(--space-sm);
    min-height: 70px;
    max-height: 70px;
    text-align: center;
    justify-content: center;
  }
  
  /* Left-justify the header title in mobile */
  .header-title-link {
    position: absolute;
    left: calc(var(--space-sm) * 2.1); /* Increased right spacing */
    top: 50%; /* Position at vertical center */
    transform: translateY(-50%); /* Center vertically only */
    justify-content: flex-start;
    white-space: nowrap; /* Prevent wrapping */
    letter-spacing: 5px; /* Mobile letter spacing */
    font-size: 1.8rem; /* Slightly smaller font size for mobile */
    height: auto; /* Override the desktop height setting */
  }
  
  /* Keep hamburger menu on the right */
  .hamburger {
    display: flex;
    position: absolute;
    right: var(--space-sm);
    top: 20px; /* Position lower in the header */
    background: transparent;
    z-index: 1500;
  }
  
  /* Mobile header links */
  .header-links {
    display: none;
    flex-direction: column;
    background: rgba(0, 0, 0, 0.94);
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: 50vw;
    max-width: 350px;
    margin: 0;
    padding: 7rem 0.5rem 1.5rem 0.5rem; /* Increased top padding to push links down */
    border-radius: 0 0 0 12px;
    box-shadow: -6px 0 24px rgba(0,0,0,0.25);
    z-index: 1002;
    opacity: 1;
    pointer-events: none;
    transform: translateX(100%);
    transition: transform 0.35s cubic-bezier(.7,.3,.2,1), box-shadow 0.25s;
  }
  
  .header-links.active {
    display: flex;
    pointer-events: auto;
    transform: translateX(0);
    box-shadow: -12px 0 32px rgba(0,0,0,0.45);
  }
  
  /* Mobile user dropdown */
  .header-links .user-dropdown {
    width: 100%;
    display: block;
  }
  
  /* Make dropdown toggle look like other mobile menu items */
  .header-links .dropdown-toggle {
    display: block;
    width: 100%;
    text-align: left;
    padding: 1.1rem 1.2rem;
    border: none;
    border-bottom: 2px solid var(--primary);
    background: none;
    margin: 0;
    border-radius: 0;
    font-size: 1.1em;
    color: var(--primary);
    font-weight: bold;
  }
  
  /* Override dropdown menu positioning for mobile */
  .header-links .dropdown-menu {
    position: relative;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    background: transparent;
    box-shadow: none;
    border-radius: 0;
    margin-top: 0;
    display: block; /* Always show dropdown contents on mobile */
    padding-left: 1.5rem; /* Indent the menu items for hierarchy */
  }
  
  /* Style dropdown items in mobile menu */
  .header-links .dropdown-menu a {
    padding: 1.1rem 1.2rem;
    border-bottom: 1px solid rgba(255,102,0,0.2);
  }
  
  .header-links .dropdown-menu a:last-child {
    border-bottom: none;
  }
  
  /* Hide dropdown caret on mobile since menu is always expanded */
  .header-links .dropdown-toggle .fa-caret-down {
    display: none;
  }
  
  .header-links i {
    margin-right: 0.35em;
    min-width: 1.3em;
    text-align: center;
  }
  
  /* Specific fix for profile page - position the hamburger properly */
  .header-wrapper .hamburger {
    position: relative;
    z-index: 2500;
    transform: translateZ(0);
  }
  
  /* Ensure no background color on hover/active states */
  .hamburger:hover,
  .hamburger:active,
  .hamburger.active {
    background: transparent;
  }
}

/* ========== DESKTOP/TABLET ========== */
@media (min-width: 768px) {
  .header-links {
    display: flex;
    position: static;
    flex-direction: row;
    background: none;
    height: auto;
    width: auto;
    box-shadow: none;
    border-radius: 0;
    padding: 0;
  }
  .hamburger {
    display: none;
  }
}

/* User Dropdown Styles */
.user-dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-toggle {
  cursor: pointer;
}

.dropdown-toggle .fa-caret-down {
  margin-left: 5px;
  transition: transform 0.2s;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  background: rgba(0,0,0,0.9);
  backdrop-filter: blur(8px);
  min-width: 180px;
  border-radius: 5px;
  box-shadow: 0 3px 15px rgba(0,0,0,0.3);
  overflow: hidden;
  display: none;
  z-index: 1010;
}

.dropdown-menu a {
  display: block;
  padding: 12px 16px;
  width: 100%;
  text-align: left;
  border-bottom: 1px solid rgba(255,102,0,0.2);
}

.dropdown-menu a:last-child {
  border-bottom: none;
}

.user-dropdown.active .dropdown-menu {
  display: block;
}

.user-dropdown.active .dropdown-toggle .fa-caret-down {
  transform: rotate(180deg);
}

/* Logo Animation */
@keyframes pumpkin-pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

.logo-pumpkin {
  animation: pumpkin-pulse 2s infinite ease-in-out;
}