/* Header with Language Selector */
header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  /* Make header readable on bright hero background */
  background: var(--surface-elevated);
  backdrop-filter: blur(50px);
  -webkit-backdrop-filter: blur(50px);
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow);
  z-index: 1000;
  width: 100%;
  margin: 0;
  padding: 15px 0;
  /* Transition only for transform and other properties, NOT opacity during scroll */
  transition: padding 1.4s ease, max-height 1.4s ease, transform 0.5s ease, background 0.5s ease, border-bottom-color 0.5s ease, color 0.5s ease, backdrop-filter 0.5s ease;
  max-height: 1000px;
  overflow: visible;
  /* Hidden by default on page load - only show after scroll */
  opacity: 1;
  transform: translateY(-100%);
  pointer-events: none;
}

/* Header color variants - только для фото-секции */
header.section-photo {
  background: rgba(0, 0, 0, 0.1) !important;
  backdrop-filter: blur(50px);
  -webkit-backdrop-filter: blur(50px);
  border-bottom-color: rgba(255, 255, 255, 0.15);
  color: #ffffff;
}

/* Brand section - similar header mode switch */
header.section-brand {
  background: rgba(0, 0, 0, 0.16) !important;
  backdrop-filter: blur(50px);
  -webkit-backdrop-filter: blur(50px);
  border-bottom-color: rgba(255, 255, 255, 0.18);
  color: #ffffff;
}

header.section-photo .header-social-link {
  background: rgba(255, 255, 255, 0.1) !important;
}

header.section-photo .language-selector {
  background: rgba(255, 255, 255, 0.1) !important;
}

header.hidden {
  transform: translateY(-100%);
  pointer-events: none;
  /* Reset animation when hidden */
  animation: none;
  /* Smooth animation for hiding - only transform, opacity stays from initial fade-in */
  transition: transform 0.5s ease, padding 1.4s ease, max-height 1.4s ease, background 0.5s ease, border-bottom-color 0.5s ease, color 0.5s ease, backdrop-filter 0.5s ease;
}

/* Show header after scroll - only transform, opacity stays from initial fade-in animation */
header:not(.hidden) {
  /* Opacity is not changed here - it's already set by initial headerFadeIn animation */
  transform: translateY(0);
  pointer-events: auto;
  /* Smooth animation for showing - only transform, no opacity change */
  transition: transform 0.5s ease, padding 1.4s ease, max-height 1.4s ease, background 0.5s ease, border-bottom-color 0.5s ease, color 0.5s ease, backdrop-filter 0.5s ease;
}

header:hover {
  padding: 15px 0;
  max-height: 1000px;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 30px;
  transition: opacity 1.4s ease, transform 1.4s ease;
  opacity: 1;
  transform: scale(1);
  transform-origin: center;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0;
  flex: 1;
}

.header-left > * {
  pointer-events: auto;
}

.header-left::before,
.header-left::after {
  display: none !important;
  content: none !important;
}

.header-palm-logo {
  margin-right: 20px;
}

.header-nav {
  margin-left: 0;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 20px;
  transition: opacity 1.4s ease 0.2s, transform 1.4s ease 0.2s;
  opacity: 1;
  transform: translateY(0) scale(1);
}

.header-nav {
  display: flex;
  gap: 39px; /* +30% */
  align-items: center;
  transition: opacity 1.4s ease 0.1s, transform 1.4s ease 0.1s;
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* Убираем все возможные псевдоэлементы у навигации */
.header-nav::before,
.header-nav::after {
  display: none !important;
  content: none !important;
}

.nav-link {
  color: var(--text-primary);
  text-decoration: none;
  font-size: 20px; /* +30% */
  font-weight: 400;
  transition: all 0.3s ease;
  position: relative;
  padding: 7px 0; /* +30% */
  list-style: none;
}

header.section-photo .nav-link {
  color: #ffffff;
}
header.section-brand .nav-link {
  color: #ffffff;
}

.nav-link::before,
.nav-link::after {
  display: none !important;
  content: none !important;
}

.nav-link:hover {
  color: var(--primary-color);
}

header.section-photo .nav-link:hover {
  color: #ffffff;
  opacity: 0.8;
}

.burger-menu-btn {
  display: none;
  position: relative;
  width: 44px;
  height: 44px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  z-index: 1001;
}

.burger-menu-btn span {
  position: absolute;
  left: 50%;
  width: 24px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
  transform: translateX(-50%);
  transition: transform 0.25s ease, opacity 0.2s ease, background 0.3s ease;
}

header.section-photo .burger-menu-btn span {
  background: #ffffff;
}
header.section-brand .burger-menu-btn span {
  background: #ffffff;
}

.burger-menu-btn span:nth-child(1) {
  top: 14px;
}

.burger-menu-btn span:nth-child(2) {
  top: 21px;
}

.burger-menu-btn span:nth-child(3) {
  top: 28px;
}

.burger-menu-btn.active span:nth-child(1) {
  top: 21px;
  transform: translateX(-50%) rotate(45deg);
}

.burger-menu-btn.active span:nth-child(2) {
  opacity: 0;
}

.burger-menu-btn.active span:nth-child(3) {
  top: 21px;
  transform: translateX(-50%) rotate(-45deg);
}


.header-palm-logo {
  height: 60px;
  width: auto;
  object-fit: contain;
  animation: rainbow-palm 30s ease-in-out infinite;
  position: relative;
  filter: drop-shadow(0 0 20px rgba(255, 200, 0, 0.6)) drop-shadow(0 0 40px rgba(255, 150, 0, 0.4)) drop-shadow(0 0 60px rgba(255, 100, 0, 0.3));
}



@keyframes rainbow-palm {
  0% {
    filter: sepia(0.8) hue-rotate(0deg) saturate(1.3) brightness(0.8) drop-shadow(0 0 20px rgba(255, 200, 0, 0.6)) drop-shadow(0 0 40px rgba(255, 150, 0, 0.4)) drop-shadow(0 0 60px rgba(255, 100, 0, 0.3));
  }
  20% {
    filter: sepia(0.2) hue-rotate(0deg) saturate(0.9) brightness(0.85) drop-shadow(0 0 20px rgba(255, 180, 50, 0.6)) drop-shadow(0 0 40px rgba(255, 130, 30, 0.4)) drop-shadow(0 0 60px rgba(255, 80, 20, 0.3));
  }
  50% {
    filter: sepia(0.9) hue-rotate(220deg) saturate(1.4) brightness(0.7) drop-shadow(0 0 20px rgba(200, 150, 255, 0.6)) drop-shadow(0 0 40px rgba(150, 100, 255, 0.4)) drop-shadow(0 0 60px rgba(100, 50, 255, 0.3));
  }
  75% {
    filter: sepia(0.2) hue-rotate(0deg) saturate(0.9) brightness(0.85) drop-shadow(0 0 20px rgba(255, 180, 50, 0.6)) drop-shadow(0 0 40px rgba(255, 130, 30, 0.4)) drop-shadow(0 0 60px rgba(255, 80, 20, 0.3));
  }
  100% {
    filter: sepia(0.8) hue-rotate(0deg) saturate(1.3) brightness(0.8) drop-shadow(0 0 20px rgba(255, 200, 0, 0.6)) drop-shadow(0 0 40px rgba(255, 150, 0, 0.4)) drop-shadow(0 0 60px rgba(255, 100, 0, 0.3));
  }
}

.header-social-links {
  display: flex;
  gap: 12px;
  align-items: center;
}

.header-social-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0);
  text-decoration: none;
  transition: all 0.3s ease;
  overflow: hidden;
}

/* Social buttons: always transparent background (all modes/sections) */
header.section-photo .header-social-link,
header.section-brand .header-social-link {
  background: transparent !important;
}

.header-social-link img {
  width: 32px;
  height: 32px;
  object-fit: contain;
  transition: transform 0.3s ease;
}

.header-social-link:hover {
  transform: translateY(-2px) scale(1.1);
  box-shadow: 0 4px 12px rgba(107, 114, 128, 0.2);
}

.header-social-link:hover img {
  transform: scale(1.1);
}

.header-social-link:nth-child(1):hover {
  background: #1877F2;
}

.header-social-link:nth-child(2):hover {
  background: #E4405F;
}

.header-social-link:nth-child(3):hover {
  background: #25D366;
}

.header-social-link:nth-child(4):hover {
  background: #00C300;
}

@media (max-width: 768px) {
  header {
    width: 100% !important;
    border-radius: 0 !important;
  }

  .header-content {
    flex-wrap: nowrap;
    justify-content: space-between;
  }

  .header-left {
    gap: 15px;
  }

  .header-nav {
    position: fixed;
    top: calc(var(--header-height, 80px) + 20px);
    right: -100%;
    width: auto;
    min-width: max-content;
    max-width: min(90vw, 576px);
    height: calc(100vh - var(--header-height, 80px) - 40px);
    /* Делаем фон реально полупрозрачным, иначе blur визуально “пропадает” */
    background: var(--surface-elevated);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    flex-direction: column;
    align-items: flex-start;
    padding: 30px;
    gap: 20px;
    border-radius: 20px;
    transition: right 0.3s ease, background 0.3s ease, backdrop-filter 0.3s ease;
    z-index: 999;
    overflow-y: auto;
    opacity: 1;
    pointer-events: auto;
    -webkit-overflow-scrolling: touch;
    /* Нужно для псевдо-слоя с blur */
    position: fixed;
    isolation: isolate;
  }

  .header-nav.active {
    right: 20px;
  }

  /* Стабильный blur-слой: работает заметнее, чем blur на “залитом” фоне */
  .header-nav::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: rgba(255, 255, 255, 0.26);
    backdrop-filter: blur(120px) saturate(200%);
    -webkit-backdrop-filter: blur(120px) saturate(200%);
    pointer-events: none;
    z-index: 0;
  }

  .header-nav > * {
    position: relative;
    z-index: 1;
  }

  header.section-photo .header-nav {
    background: rgba(0, 0, 0, 0.26);
    border-color: rgba(255, 255, 255, 0.18);
  }

  header.section-photo .header-nav::before {
    background: rgba(0, 0, 0, 0.26);
  }

  .nav-link {
    width: 100%;
    padding: 12px 0;
    font-size: 21px; /* +30% */
    border-bottom: 1px solid var(--border-color);
  }

  .nav-link::after {
    display: none;
  }

  .burger-menu-btn {
    display: flex;
    order: 3;
  }

  .header-social-links {
    display: none;
  }

  .language-selector-wrapper {
    order: 2;
  }
  
  .theme-toggle-btn {
    order: 1;
  }

  .header-logo {
    height: 35px;
  }
}

/* Старые стили language-selector удалены - теперь используется language-slider.css */

/* Header improvements */
header.scrolled {
  box-shadow: var(--shadow-hover);
  background: var(--surface-elevated);
}
