/* ========================================================================= */
/* ======================= ШАПКА САЙТА - HEADER.CSS ====================== */
/* ========================================================================= */

/* ОСНОВНАЯ ШАПКА САЙТА */
.site-header {
	position: sticky;
	top: 0;
	left: 0;
	right: 0;
	background: var(--glassmorphism);
	backdrop-filter: var(--blur-backdrop);
	-webkit-backdrop-filter: var(--blur-backdrop);
	border-bottom: 1px solid var(--border-light);
	z-index: var(--z-top-header);
	transition: all 0.3s ease;
	display: flex;
	justify-content: center;
	width: 100%;
}

.header-content {
	/* central config: header max width used by positioning calc() below */
	--header-max-width: 1200px;
	max-width: var(--header-max-width);
	width: 100%;
	margin: 0 auto;
	padding: 0.75rem 2rem;
	display: grid;
	grid-template-columns: 1fr auto 1fr;
	align-items: center;
	position: relative;
	height: 72px;
	gap: 1rem;
	min-width: 0;
}

/* Grid layout автоматически обеспечивает стабильность, ::before не требуется */

/* ========================================================================= */
/* ================ ✅ ИСПРАВЛЕННЫЙ ЛОГОТИП - СИММЕТРИЧНЫЙ ================= */
/* ========================================================================= */

/* ЛОГОТИП - БАЗОВЫЕ СТИЛИ (Consolidated from lines 41-52, 419-424, 447-459, 563-567) */
.header-logo {
	font-weight: 600;
	font-size: 1.1rem;
	color: var(--text-primary);
	/* ✅ СКРЫТ ПО УМОЛЧАНИЮ - УПРОЩЕННЫЙ СТИЛЬ */
	opacity: 0;
	pointer-events: none;
	transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
	position: relative;
	z-index: 1400;
	/* Улучшенная типографика для логотипа */
	font-feature-settings: 'kern' 1, 'liga' 1;
	text-rendering: optimizeLegibility;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	/* Предотвращение layout shift */
	min-width: 60px;
	max-width: 250px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	/* Grid positioning - левая колонка */
	grid-column: 1;
	justify-self: start;
	/* Принудительное использование GPU */
	will-change: transform, opacity;
	backface-visibility: hidden;
	perspective: 1000px;
}

/* Клон фиксированного логотипа — используется для плавного появления без перепозиционирования оригинального DOM */
.header-logo-fixed {
	position: fixed;
	/* top будет устанавливаться скриптом для точной вертикальной центровки */
	left: calc((100vw - var(--header-max-width, 1200px)) / 2 + 2rem);
	z-index: 1001;
	opacity: 0;
	pointer-events: none;
	/* Копируем стили основного логотипа */
	font-family: inherit;
	font-size: inherit;
	font-weight: inherit;
	color: inherit;
	user-select: none;
	transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
	will-change: transform, opacity;
	backface-visibility: hidden;
	perspective: 1000px;
}

.header-logo-fixed.visible {
	opacity: 1;
}

/* ✅ ВИДИМЫЙ ЛОГОТИП - FIXED ПОЗИЦИОНИРОВАНИЕ СИММЕТРИЧНО БУРГЕРУ */
/* Видимость лого управляется анимациями anim-in / anim-out */
.header-logo.visible {
	opacity: 1;
	pointer-events: all;
	transform: translateY(0) scale(1);
}

/* Ensure explicit hidden state to avoid conflicts with animations or other classes */
.header-logo.hidden {
	opacity: 0;
	pointer-events: none;
	visibility: hidden;
	transform: translateY(-6px);
}

/* Анимация появления сверху вниз - UPDATED TO USE logoFadeIn */
.header-logo.anim-in {
	animation: logoFadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
	position: fixed;
	z-index: 1400;
	/* По умолчанию позиционируем логотип симметрично отступам .header-content */
	left: calc((100vw - var(--header-max-width)) / 2 + 2rem);
}

/* Анимация скрытия вверх - UPDATED TO USE logoFadeOut */
.header-logo.anim-out {
	animation: logoFadeOut 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
	position: fixed;
	z-index: 1400;
	left: calc((100vw - var(--header-max-width)) / 2 + 2rem);
}

/* Отключаем will-change когда анимация не нужна */
.header-logo:not(.anim-in):not(.anim-out) {
	will-change: auto;
}

/* ✅ СОКРАЩЕННАЯ ВЕРСИЯ */
.header-logo.shortened {
	font-weight: 700;
	font-size: 1.3rem;
	letter-spacing: 0.1em;
	color: var(--text-primary);
}

/* ========================================================================= */
/* ================= ✅ УЛУЧШЕННЫЕ АНИМАЦИИ ЛОГОТИПА ====================== */
/* ========================================================================= */

/* ПЛАВНАЯ АНИМАЦИЯ ПОЯВЛЕНИЯ - SINGLE KEYFRAME SET (from lines 502-529) */
@keyframes logoFadeIn {
	0% {
		opacity: 0;
		transform: translateY(-8px) scale(0.95);
	}

	50% {
		opacity: 0.7;
		transform: translateY(-2px) scale(0.98);
	}

	100% {
		opacity: 1;
		transform: translateY(0) scale(1);
	}
}

/* ПЛАВНАЯ АНИМАЦИЯ СКРЫТИЯ - SINGLE KEYFRAME SET (from lines 502-529) */
@keyframes logoFadeOut {
	0% {
		opacity: 1;
		transform: translateY(0) scale(1);
	}

	100% {
		opacity: 0;
		transform: translateY(-8px) scale(0.95);
	}
}

/* ========================================================================= */
/* ============== ✅ АДАПТИВНОЕ ПОЗИЦИОНИРОВАНИЕ ЛОГОТИПА ================== */
/* ========================================================================= */

/* СУПЕР ШИРОКИЕ ЭКРАНЫ (от 1301px) */
@media screen and (min-width: 1301px) {
	.header-logo.anim-in,
	.header-logo.anim-out,
	.header-logo.visible {
		left: calc((100vw - var(--header-max-width)) / 2 + 2rem);
	}
}

/* ШИРОКИЕ ЭКРАНЫ (901px - 1300px) */
@media screen and (min-width: 901px) and (max-width: 1300px) {
	.header-logo.anim-in,
	.header-logo.anim-out,
	.header-logo.visible {
		left: 2rem;
	}
}

/* СРЕДНИЕ ЭКРАНЫ (до 900px) */
@media screen and (max-width: 900px) {
	.header-content {
		padding: 0.75rem 1.5rem;
		height: 60px;
	}

	.header-logo.anim-in,
	.header-logo.anim-out,
	.header-logo.visible {
		left: 1rem;
	}
}

/* ПЛАНШЕТЫ */
@media (max-width: 768px) {
	.header-logo.visible {
		left: 1rem;
		font-size: 1rem;
		max-width: 180px;
	}

	.header-support {
		min-width: 100px;
		font-size: 0.85rem;
	}
}

/* МОБИЛЬНЫЕ */
@media (max-width: 640px) {
	.header-content {
		padding: 0.5rem 1rem;
		height: 56px;
	}

	.header-logo.visible {
		left: 1rem;
		font-size: 0.95rem;
	}
}

@media (max-width: 480px) {
	.header-content {
		padding: 0.5rem 0.75rem;
		height: 52px;
	}

	.header-logo.visible {
		left: 0.75rem;
		font-size: 0.9rem;
	}
}

/* ========================================================================= */
/* ================ ✅ КОЛЛИЗИИ С АКТИВНЫМИ МЕНЮ ========================== */
/* ========================================================================= */

/* Сокращение логотипа при активном меню на мобильных - НЕ ВЛИЯЕТ НА ВИДИМОСТЬ */
@media (max-width: 900px) {
	.header-nav:has(.nav-menu.active) .header-logo.visible,
	.header-nav:has(.nav-lang.active) .header-logo.visible {
		font-size: 0.9rem;
		/* НЕ меняем opacity и visibility - только размер */
	}
}

@media (max-width: 640px) {
	.header-nav:has(.nav-menu.active) .header-logo.visible {
		font-size: 0.85rem;
		font-weight: 700;
		letter-spacing: 0.1em;
	}

	.header-nav:has(.nav-menu.active) .header-logo.visible[data-short="true"] {
		font-size: 0.9rem;
		letter-spacing: 0.15em;
	}
}

/* Дополнительное сокращение на экстремально узких экранах */
@media (max-width: 480px) {
	.header-nav:has(.nav-menu.active) .header-logo.visible,
	.header-nav:has(.nav-lang.active) .header-logo.visible {
		font-size: 0.8rem;
		font-weight: 700;
		letter-spacing: 0.1em;
	}
}

/* ========================================================================= */
/* ====================== ЦЕНТРАЛЬНЫЙ БЛОК - ПОДДЕРЖКА ==================== */
/* ========================================================================= */

.header-center {
	position: absolute;
	left: 50%;
	transform: translateX(-50%);
}

/* By default header-support participates in the normal flow (grid-based layout, центральная колонка).
   Absolute centering is available via the modifier class .header-support.is-fixed
   (useful for fixed/overlay states). This keeps layout stable by default. */
.header-support {
	display: flex;
	align-items: center;
	justify-content: center;
	opacity: 1;
	transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
	position: relative;
	transform: none;
	min-width: 120px;
	grid-column: 2;
	will-change: transform, opacity;
	backface-visibility: hidden;
	perspective: 1000px;
}

.header-support.is-fixed {
	position: absolute;
	left: 50%;
	top: 50%;
	transform: translate(-50%, -50%);
}

.header-support.hidden {
	opacity: 0;
	transform: translateX(20px) scale(0.95);
	pointer-events: none;
}

.header-support:not(.hidden) {
	will-change: auto;
}

.header-support-icon {
	width: 110px;
	height: auto;
	filter: brightness(0.2) contrast(1.2);
	transition: all 0.3s ease;
	will-change: filter, transform;
}

:root[data-theme="dark"] .header-support-icon {
	filter: brightness(1.1);
}

:root[data-theme="dark"] .header-support a {
	background: rgba(255, 255, 255, 0.12);
	border-radius: 8px;
	padding: 6px 8px;
	transition: all 0.3s ease;
}

.header-support a:hover .header-support-icon {
	filter: brightness(0.4) contrast(1.2);
}

.header-support a:hover {
	transform: translateY(-2px);
}

:root[data-theme="dark"] .header-support a:hover .header-support-icon {
	filter: brightness(1.3);
}

:root[data-theme="dark"] .header-support a:hover {
	background: rgba(255, 255, 255, 0.18);
	transform: translateY(-2px);
}

/* ========================================================================= */
/* ==================== КНОПКА МАГАЗИНА В HEADER =========================== */
/* Живёт внутри .header-support, не добавляет grid-колонку.                */
/* Скрыта по умолчанию. Появляется через body.nav-active (CSS only).       */
/* ========================================================================= */

.header-shop-btn {
	position: absolute !important;
	top: 50% !important;
	left: 50% !important;
	transform: translate(-50%, -50%) scale(0.5) !important;
	visibility: hidden !important;
	pointer-events: none !important;
	transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), visibility 0s 0.4s, box-shadow 0.3s, color 0.3s, border-color 0.3s !important;

	display: flex !important;
	align-items: center !important;
	justify-content: center !important;
	width: 48px !important;
	height: 48px !important;
	border-radius: 100px !important;
	background: var(--gradient-light) !important;
	border: 1px solid var(--glassmorphism-border) !important;
	box-shadow: var(--shadow-inset-light) !important;
	color: var(--text-primary) !important;
	text-decoration: none !important;
	font-size: 1.2rem !important;
	backdrop-filter: var(--blur-backdrop) !important;
	-webkit-backdrop-filter: var(--blur-backdrop) !important;
	z-index: 10 !important;
}

body.nav-active .header-shop-btn {
	visibility: visible !important;
	transform: translate(-50%, -50%) scale(1) !important;
	pointer-events: auto !important;
	transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), visibility 0s 0s, box-shadow 0.3s, color 0.3s, border-color 0.3s !important;
}

body.nav-active .header-shop-btn:hover {
	color: var(--color-primary) !important;
	border-color: var(--color-primary) !important;
	box-shadow: var(--shadow-md) !important;
	transform: translate(-50%, -50%) scale(1.08) !important;
}

body.nav-active .header-shop-btn:active {
	transform: translate(-50%, -50%) scale(0.95) !important;
	box-shadow: var(--shadow-inset-pressed) !important;
}

:root[data-theme="dark"] .header-shop-btn {
	box-shadow: var(--shadow-inset-light) !important;
}

/* На мобильных десктопная кнопка не нужна — есть пункт меню */
@media screen and (max-width: 768px) {
	.header-shop-btn { display: none !important; }
}

/* ========================================================================= */
/* ======================= НАВИГАЦИЯ В HEADER ============================= */
/* ========================================================================= */

.header-nav {
	display: flex;
	align-items: center;
	position: relative;
	pointer-events: auto;
	grid-column: 3;
	justify-self: end;
}

/* ✅ ПРЕДОТВРАЩЕНИЕ LAYOUT SHIFT В НАВИГАЦИИ */
.nav-menu,
.nav-lang {
	min-width: fit-content;
	flex-shrink: 0;
	transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========================================================================= */
/* ====================== ТЕМНАЯ ТЕМА ===================================== */
/* ========================================================================= */

:root[data-theme="dark"] .site-header {
	border-bottom-color: var(--border-light);
}

@media (prefers-color-scheme: dark) {
	.header-logo,
	.header-logo-fixed {
		color: #f8fafc;
	}
}

/* ========================================================================= */
/* ====================== ACCESSIBILITY =================================== */
/* ========================================================================= */

@media (prefers-reduced-motion: reduce) {
	.header-logo,
	.header-support,
	.header-support-icon,
	.header-logo-fixed {
		transition: none;
		animation: none;
	}

	.header-logo.anim-in,
	.header-logo.anim-out {
		animation: none;
		opacity: 1;
		transform: none;
	}
}

/* HIGH CONTRAST MODE */
@media (prefers-contrast: high) {
	.site-header {
		background: var(--bg-primary);
		border-bottom: 2px solid var(--border-dark);
		box-shadow: none;
	}
}

/* FOCUS STYLES */
.header-support a:focus-visible {
	outline: 2px solid var(--color-primary);
	outline-offset: 2px;
	border-radius: var(--radius-small);
}

/* ✅ ВЫСОКИЕ DPI ЭКРАНЫ */
@media (-webkit-min-device-pixel-ratio: 2),
(min-resolution: 192dpi) {
	.header-logo,
	.header-support {
		-webkit-font-smoothing: antialiased;
		-moz-osx-font-smoothing: grayscale;
	}
}

/* ========================================================================= */
/* ========================= ПЕЧАТЬ ======================================= */
/* ========================================================================= */

@media print {
	.site-header {
		position: static;
		background: transparent;
		border-bottom: 1px solid var(--border-dark);
		box-shadow: none;
	}

	.header-support {
		display: none;
	}

	.header-logo.visible {
		opacity: 1;
		position: static;
		transform: none;
		animation: none;
	}

	.header-content {
		padding: 0.5rem 1rem;
	}
}

/* ========================================================================= */
/* ==================== ДОПОЛНИТЕЛЬНЫЕ УТИЛИТЫ ============================ */
/* ========================================================================= */

/* ✅ ОТЛАДОЧНЫЕ СТИЛИ (для development) */
.debug-screen-state .header-logo {
	box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.5);
}

.debug-screen-state .header-support {
	box-shadow: 0 0 0 1px rgba(16, 185, 129, 0.5);
}
