/* ============================================
   Sticky Header & Navigation
   ============================================ */

.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: var(--z-sticky);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid transparent;
  transition: all var(--transition-base);
  height: var(--header-height);
}

.header.nav-open {
  background: rgba(255, 255, 255, 0.85) !important;
  backdrop-filter: blur(20px) !important;
  -webkit-backdrop-filter: blur(20px) !important;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05) !important;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05) !important;
}

/* Swap website logo to mark_icon.svg when nav is open */
.header.nav-open .header__logo img,
.header.nav-open .header__logo-text {
  opacity: 0;
  visibility: hidden;
}

.header.nav-open .header__logo::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 75px;
  height: 75px;
  
  /* Use mask to perfectly colorize the icon with exact golden hex colors */
  -webkit-mask-image: url('../images/mark_icon.svg');
  -webkit-mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-image: url('../images/mark_icon.svg');
  mask-size: contain;
  mask-repeat: no-repeat;
  mask-position: center;
  
  /* The exact golden color matching the uploaded icon */
  background: linear-gradient(135deg, #D5A32B 0%, #A67B1E 100%);
  
  z-index: 5;
  animation: logoPhysicsPop 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  
  /* Make image sharp and crispy */
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  
  /* Subtle drop shadow matching the gold */
  filter: drop-shadow(0 4px 10px rgba(166, 123, 30, 0.4));
}

@keyframes logoPhysicsPop {
  0% {
    opacity: 0;
    transform: translate(-50%, -20%) scale(0.2) rotate(-90deg);
  }
  40% {
    opacity: 1;
    transform: translate(-50%, -60%) scale(1.15) rotate(10deg);
  }
  70% {
    transform: translate(-50%, -45%) scale(0.95) rotate(-5deg);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1) rotate(0deg);
  }
}

/* Hide donate button when mobile nav is open so it goes behind/disappears */
.header.nav-open .header__donate-btn {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: scale(0.9);
}

.header.scrolled {
  height: var(--header-height-scrolled);
  background: rgba(255, 255, 255, 0.98);
  border-bottom-color: var(--color-border);
  box-shadow: var(--shadow-sm);
}

.header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  max-width: var(--container-wide);
  margin: 0 auto;
  padding: 0 var(--space-6);
}

/* ---- Logo ---- */
.header__logo {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 0;
  text-decoration: none;
  flex-shrink: 0;
}

.header__logo img {
  height: 65px;
  width: 65px;
  object-fit: contain;
  border-radius: var(--radius-full);
  transform: translateX(0);
  transition: transform 0.4s ease, all var(--transition-base);
}

.header.scrolled .header__logo img {
  transform: translateX(-10px);
}

.header__logo-text {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  overflow: hidden;
  max-width: 0;
  opacity: 0;
  margin-left: 0;
  transition: max-width 0.4s ease, opacity 0.4s ease, margin-left 0.4s ease;
}

.header.scrolled .header__logo-text {
  max-width: 150px;
  opacity: 1;
  margin-left: var(--space-2);
}

.header__logo-name {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: var(--fw-bold);
  color: var(--color-primary);
  line-height: 1.1;
  text-align: left;
}

.header__logo-tagline {
  font-size: 0.65rem;
  color: var(--color-text-muted);
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  font-weight: var(--fw-medium);
}

/* ---- Navigation ---- */
.nav {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.nav__link {
  display: inline-flex;
  align-items: center;
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-heading);
  font-size: var(--fs-body-sm);
  font-weight: var(--fw-medium);
  color: var(--color-text-light);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  white-space: nowrap;
  position: relative;
}

.nav__link::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%) scaleX(0);
  width: 20px;
  height: 2px;
  background: var(--color-secondary);
  border-radius: var(--radius-full);
  transition: transform var(--transition-base);
}

.nav__link:hover,
.nav__link.active {
  color: var(--color-primary);
}

.nav__link:hover::after,
.nav__link.active::after {
  transform: translateX(-50%) scaleX(1);
}

/* ---- Header Actions ---- */
.header__actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.header__search-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--color-text-light);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.header__search-btn:hover {
  color: var(--color-primary);
  background: var(--color-primary-50);
}

.header__search-btn svg {
  width: 20px;
  height: 20px;
}

.header__donate-btn {
  padding: var(--space-2) var(--space-5);
  font-family: var(--font-heading);
  font-size: var(--fs-body-sm);
  font-weight: var(--fw-semibold);
  background: var(--color-secondary);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.3), var(--shadow-sm);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-base);
  white-space: nowrap;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  position: relative;
}

.header__donate-btn::after {
  content: "💸";
  position: absolute;
  left: 20px;
  top: -25px;
  font-size: 16px;
  opacity: 0;
  pointer-events: none;
  animation: moneyFall 3s infinite;
  z-index: 10;
}

@keyframes moneyFall {
  0% {
    transform: translateY(0);
    opacity: 0;
  }
  15% {
    opacity: 1;
  }
  30% {
    transform: translateY(34px);
    opacity: 1;
  }
  35%, 100% {
    transform: translateY(34px);
    opacity: 0;
  }
}

.header__donate-btn:hover {
  background: var(--color-secondary-dark);
  transform: translateY(-1px);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.4), var(--shadow-md), 0 4px 14px rgba(46, 204, 113, 0.3);
}

.header__donate-btn svg {
  width: 16px;
  height: 16px;
  transform-origin: center;
  animation: heartBeatRed 3s infinite;
}

@keyframes heartBeatRed {
  0%, 25% {
    fill: none;
    stroke: currentColor;
    transform: scale(1);
  }
  30%, 35% {
    fill: #ff4757;
    stroke: #ff4757;
    transform: scale(1.3);
  }
  40%, 100% {
    fill: none;
    stroke: currentColor;
    transform: scale(1);
  }
}

/* ---- Mobile Menu ---- */
.hamburger {
  display: none;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  flex-direction: column;
  gap: 5px;
}

.hamburger__line {
  display: block;
  width: 26px;
  height: 3px;
  background: var(--color-text);
  border-radius: var(--radius-full);
  transition: all var(--transition-base);
}

.hamburger.active .hamburger__line:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.hamburger.active .hamburger__line:nth-child(2) {
  opacity: 0;
}

.hamburger.active .hamburger__line:nth-child(3) {
  transform: rotate(-45deg) translate(5px, -5px);
}

/* ---- Mobile Nav Overlay ---- */
.mobile-nav {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  height: 100vh;
  background: rgba(255, 255, 255, 0.65);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  z-index: 199; /* Below header which is 200 */
  padding: calc(var(--header-height) + var(--space-6)) var(--space-6) var(--space-8);
  overflow-y: auto;
  overscroll-behavior: none;
  animation: slideUpNav 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.mobile-nav.active {
  display: block;
}

@keyframes slideUpNav {
  from {
    opacity: 0;
    transform: translateY(100%);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.mobile-nav__link {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-3);
  font-family: var(--font-heading);
  font-size: var(--fs-body);
  font-weight: var(--fw-bold);
  color: var(--color-text);
  background: rgba(255, 255, 255, 0.5);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.9);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.8),
              inset 0 -2px 0 rgba(0, 0, 0, 0.05),
              0 4px 10px rgba(0, 0, 0, 0.08);
  transition: all 0.3s ease;
}

.mobile-nav__link:hover,
.mobile-nav__link.active {
  color: white;
  background: var(--gradient-primary);
  border-color: transparent;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.3),
              0 6px 12px rgba(0, 0, 0, 0.15);
  transform: translateY(-2px);
}

.mobile-nav__donate {
  display: none;
}

@media (max-width: 1024px) {
  .nav {
    display: none;
  }

  .hamburger {
    display: flex;
    order: -1;
  }

  /* Keep donate button visible on tablets */
  .header__donate-btn {
    padding: var(--space-2) var(--space-4);
    font-size: 0.8rem;
  }

  .header__inner {
    position: relative;
    justify-content: space-between;
  }

  .header__actions {
    width: 100%;
    justify-content: space-between;
  }

  .header__logo {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    transition: all 0.4s ease;
  }

  .header.scrolled .header__logo {
    /* Slide the whole block slightly left so the text fits without hitting the right edge */
    transform: translateX(calc(-50% - 15px));
  }
}

@media (max-width: 768px) {
  .header__logo img {
    height: 75px !important;
    width: 75px !important;
  }

  .header__logo-name {
    font-size: 0.65rem;
  }

  .header.scrolled .header__logo-text {
    max-width: 100px;
    margin-left: 4px;
  }

  .header__logo-tagline {
    display: none;
  }

  /* Keep donate button visible - compact version */
  .header__donate-btn {
    padding: 6px 12px;
    font-size: 0.75rem;
    gap: 4px;
  }

  .header__donate-btn::after {
    left: 10px; /* Adjust money drop position for smaller padding */
  }

  .header__donate-btn svg {
    width: 14px;
    height: 14px;
  }

  .header__search-btn {
    display: none;
  }
}


@media (max-width: 480px) {
  .header__inner {
    padding: 0 var(--space-3);
  }


  /* Keep donate button visible and very compact on small mobile */
  .header__donate-btn {
    padding: 4px 8px;
    font-size: 0.7rem;
    gap: 4px;
    border-width: 1px;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3);
  }

  .header__donate-btn svg {
    width: 12px;
    height: 12px;
  }

  .header__donate-btn::after {
    left: 8px;
  }

  .header__actions {
    gap: var(--space-2);
  }
}

