/**
 * Wordoorio Unified Header Styles v3.0
 * 
 * Features:
 * - Smart hide behavior (hides on scroll down, shows on scroll up)
 * - Desktop navigation with logo + nav items + auth
 * - Mobile: username dropdown menu
 * - Consistent across all pages
 */

/* ===== CSS VARIABLES (fallbacks if tokens.css not loaded) ===== */
:root {
  --teal: #1B7A94;
  --teal-light: #39A0B3;
  --teal-dark: #145f73;
  --teal-bg: #edf7fa;
  --teal-border: rgba(27,122,148,0.18);
  --bg: #f4f7f9;
  --bg-card: #ffffff;
  --border: #e2e8f0;
  --text-1: #0f172a;
  --text-2: #4a5568;
  --text-3: #94a3b8;
  --header-height: 68px;
  --header-height-mobile: 60px;
}

/* ===== SMART HIDE HEADER ===== */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: var(--header-height);
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(0,0,0,0.04), 0 4px 20px rgba(0,0,0,0.06);
  transform: translateY(0);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.header-inner {
  max-width: var(--W, 1200px);
  margin: 0 auto;
  padding: 0 32px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Gradient line at top */
.site-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--teal-dark) 0%, var(--teal-light) 60%, #6dd5ed 100%);
}

/* Hidden state for smart hide */
.site-header.is-hidden {
  transform: translateY(calc(-100% - 10px));
}

/* ===== HEADER LEFT: LOGO + NAV ===== */
.header-left {
  display: flex;
  align-items: center;
  gap: 32px;
}

/* Logo */
.logo-link {
  display: flex;
  align-items: center;
  text-decoration: none;
  flex-shrink: 0;
  transition: opacity 0.15s;
  margin-top: 3px;
}

.logo-link:hover { opacity: 0.75; }

.logo-img {
  height: 30px;
  width: auto;
}

/* Desktop Navigation */
.site-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 3px;
}

.nav-item {
  color: var(--text-2);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 8px;
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
}

.nav-item:hover,
.nav-item.is-active {
  color: var(--teal);
  background: var(--teal-bg);
}

/* ===== HEADER RIGHT: AUTH ===== */
.auth-section {
  position: relative;
  margin-top: 3px;
}

/* Login button for non-authenticated */
.login-btn {
  display: inline-block;
  padding: 10px 22px;
  background: var(--teal);
  color: #ffffff;
  text-decoration: none;
  border-radius: 9px;
  font-weight: 700;
  font-size: 0.875rem;
  transition: background 0.15s, transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 2px 10px rgba(27,122,148,0.35);
}

.login-btn:hover {
  background: var(--teal-light);
  transform: translateY(-1px);
  box-shadow: 0 4px 18px rgba(27,122,148,0.45);
  color: #ffffff;
}

/* User dropdown trigger for authenticated */
.user-trigger {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--teal-bg);
  border: 1px solid var(--teal-border);
  border-radius: 9px;
  color: var(--text-1);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}

.user-trigger:hover { background: #d8f1f7; }

.user-trigger .dropdown-arrow {
  width: 14px;
  height: 14px;
  color: var(--text-3);
  transition: transform 0.2s ease;
}

.auth-section.open .user-trigger .dropdown-arrow {
  transform: rotate(180deg);
}

/* User dropdown menu */
.user-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.1);
  min-width: 200px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: all 0.15s ease;
  z-index: 200;
  overflow: hidden;
  padding: 8px 0;
}

.auth-section.open .user-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.user-menu-item {
  display: block;
  padding: 12px 16px;
  color: var(--text-1);
  text-decoration: none;
  font-size: 0.9375rem;
  font-weight: 500;
  transition: background 0.12s;
  border-bottom: none;
}

.user-menu-item:hover {
  background: #f4f7f9;
}

.user-menu-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* Hide mobile-only items on desktop */
@media (min-width: 769px) {
  .mobile-only {
    display: none !important;
  }
}

/* Hide desktop-only items on mobile */
@media (max-width: 768px) {
  .desktop-only {
    display: none !important;
  }
}

/* ===== MOBILE HEADER ADJUSTMENTS ===== */
@media (max-width: 768px) {
  .site-header {
    height: var(--header-height-mobile);
  }

  .header-inner {
    padding: 0 16px;
  }
  
  .header-left {
    gap: 16px;
  }
  
  .logo-img {
    height: 26px;
  }
  
  .site-nav {
    display: none;
  }
}

/* ===== PAGE CONTENT OFFSET ===== */
body.has-fixed-header {
  padding-top: var(--header-height);
}

@media (max-width: 768px) {
  body.has-fixed-header {
    padding-top: var(--header-height-mobile);
  }
}

/* ===== UTILITY CLASSES ===== */
.header-spacer {
  height: var(--header-height);
}

@media (max-width: 768px) {
  .header-spacer {
    height: var(--header-height-mobile);
  }
}

/* ===== PAPER THEME — светлая шапка страниц редизайна 02.11.2026 (разбор; фон страницы #eef3f4) =====
   Включается опцией initUnifiedHeader(id, { theme: 'paper' }): класс site-header--paper на <header>
   и has-paper-header на <body> (высота 84 / 64 вместо 68 / 60). Остальное поведение шапки — общее. */
body.has-paper-header { --header-height: 84px; --header-height-mobile: 64px; }
.site-header--paper { background: rgba(238, 243, 244, 0.94); border-bottom: 0; box-shadow: none; }
.site-header--paper::before { display: none; }
.site-header--paper .header-inner { box-sizing: content-box; max-width: 1320px; padding: 0 clamp(16px, 4vw, 48px); }
.site-header--paper .logo-link, .site-header--paper .site-nav, .site-header--paper .auth-section { margin-top: 0; }
.site-header--paper .nav-item { color: #3d5560; }
.site-header--paper .nav-item:hover, .site-header--paper .nav-item.is-active { color: #071e2a; background: rgba(7, 30, 42, 0.06); }
.site-header--paper .paper-link {
  display: inline-flex; align-items: center; height: 44px; padding: 0 16px; font-size: 15px; color: #3d5560; text-decoration: none;
}
.site-header--paper .paper-login {
  display: inline-flex; align-items: center; height: 44px; padding: 0 20px; border-radius: 999px; border: 1px solid #071e2a;
  font-size: 15px; font-weight: 500; color: #071e2a; text-decoration: none;
}
.site-header--paper .auth-section--guest { display: flex; align-items: center; gap: 8px; }
.site-header--paper .user-trigger {
  height: 44px; padding: 0 18px; border-radius: 999px; background: transparent; border: 1px solid #071e2a; color: #071e2a;
}
.site-header--paper .user-trigger:hover { background: rgba(7, 30, 42, 0.06); }
@media (max-width: 768px) {
  .site-header--paper .logo-img { height: 24px; }
  .site-header--paper .paper-link { display: none; }
  .site-header--paper .paper-login { padding: 0 18px; }
}
