﻿/**
 * هدر سایت — BEM: .header, .header__*
 */

.header {
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 0 var(--space-4) var(--space-3);
  direction: rtl;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

/* باز بودن منو: بدون تأخیر ترنسفورم تا پنل fixed دقیقاً زیر شِل قفل شود */
.header.header--nav-open {
  transition: none;
}

.header.header--hidden {
  transform: translateY(calc(-100% - 8px));
  opacity: 0;
}

.header__shell {
  max-width: 1200px;
  margin-inline: auto;
  padding: var(--space-2) var(--space-4);
  background-color: var(--color-glass-bg);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  border: 2px solid var(--color-glass-stroke);
  box-shadow: 0 10px 40px rgba(15, 23, 42, 0.06);
  position: relative;
  overflow: visible;
  transition: background-color 0.2s ease, backdrop-filter 0.2s ease, -webkit-backdrop-filter 0.2s ease;
}

/* پس از اسکرول یا باز بودن منوی موبایل: پس‌زمینهٔ مات تا محتوای زیر از شیشه دیده نشود */
.header.header--surface-solid .header__shell,
.header.header--nav-open .header__shell {
  background-color: #fff;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.header__inner {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--header-bar-height);
}

.header__logo {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  text-decoration: none;
  line-height: 0;
}

.header__logo-img {
  display: block;
  width: auto;
  height: 36px;
}

.header__toggle {
  display: none;
  position: relative;
  flex-direction: column;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  margin-inline-start: auto;
  padding: 0;
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--color-text-heading);
  cursor: pointer;
}

.header__toggle-bars {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.header__toggle-bar {
  display: block;
  width: 20px;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
  transition: opacity 0.2s ease;
}

.header__toggle-close {
  position: absolute;
  display: none;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
}

.header__toggle-close-line {
  position: absolute;
  width: 20px;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
}

.header__toggle-close-line:first-child {
  transform: rotate(45deg);
}

.header__toggle-close-line:last-child {
  transform: rotate(-45deg);
}

.header__toggle[aria-expanded="true"] .header__toggle-bars {
  display: none;
}

.header__toggle[aria-expanded="true"] .header__toggle-close {
  display: inline-flex;
}

.header__panel {
  display: flex;
  flex: 1;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}

.header__nav {
  flex: 1;
  display: flex;
  justify-content: center;
  min-width: 0;
}

.header__menu {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--space-2) 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.header__menu-item {
  position: relative;
  margin: 0;
  padding: 0;
}

.header__menu-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  font-size: 15px;
  color: var(--color-text-body);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: background-color 0.15s ease, color 0.15s ease;
}

.header__menu-link:hover,
.header__menu-link:focus-visible {
  outline: none;
}

.header__menu-link-text {
  display: inline-flex;
  align-items: center;
}

.header__menu-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 12px;
  height: 7px;
}

.header__menu-arrow-svg {
  display: block;
  width: 12px;
  height: 7px;
  transition: transform 0.15s ease;
}

.header__menu-arrow-svg path {
  stroke: var(--color-text-secondary);
  transition: stroke 0.15s ease;
}

.header__menu-item--current:not(.header__menu-item--has-children) > .header__menu-link {
  color: var(--color-primary);
  background-color: rgba(43, 99, 235, 0.1);
}

.header__menu-item--has-children > .header__menu-link {
  gap: 10px;
  padding-inline-end: var(--space-3);
}

.header__menu-item--has-children:hover > .header__menu-link,
.header__menu-item--has-children:focus-within > .header__menu-link,
.header__menu-item--open > .header__menu-link {
  color: var(--color-primary);
  background-color: rgba(43, 99, 235, 0.1);
}

.header__menu-item--has-children:hover .header__menu-arrow-svg,
.header__menu-item--has-children:focus-within .header__menu-arrow-svg,
.header__menu-item--open .header__menu-arrow-svg {
  transform: rotate(180deg);
}

.header__menu-item--has-children:hover .header__menu-arrow-svg path,
.header__menu-item--has-children:focus-within .header__menu-arrow-svg path,
.header__menu-item--open .header__menu-arrow-svg path {
  stroke: var(--color-primary);
}

.header__menu-item--has-children:not(:hover):not(:focus-within):not(.header__menu-item--open) .header__menu-arrow-svg path {
  stroke: var(--color-text-secondary);
}

.header__submenu {
  position: absolute;
  inset-inline-start: 0;
  top: calc(100% + 12px);
  z-index: 55;
  display: none;
  min-width: 220px;
  margin: 0;
  padding: var(--space-2) 0;
  list-style: none;
  background: #fff;
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.08);
}

.header__menu-item:hover > .header__submenu,
.header__menu-item:focus-within > .header__submenu,
.header__menu-item--open > .header__submenu {
  display: block;
}

.header__submenu .header__menu-link {
  display: block;
  width: 100%;
  padding: var(--space-2) var(--space-4);
  font-size: 14px;
}

.header__submenu .header__submenu {
  inset-inline-start: 100%;
  top: 0;
}

.header__cta {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  padding: var(--space-3) var(--space-4);
  font-size: 14px;
  color: #fff;
  text-decoration: none;
  text-align: center;
  white-space: nowrap;
  background-color: var(--color-primary);
  border-radius: var(--radius-md);
  transition: background-color 0.15s ease, transform 0.15s ease;
}

.header__cta:hover,
.header__cta:focus-visible {
  outline: none;
  background-color: #2457d4;
}

.header__cta:focus-visible {
  box-shadow: 0 0 0 3px rgba(43, 99, 235, 0.35);
}

/* پل نامرئی بین لینک والد و زیرمنو — حفظ :hover هنگام حرکت موس به پایین (دسکتاپ) */
@media (min-width: 1024px) {
  .header__submenu {
    inset-inline-start: 50%;
    min-width: 200px;
    padding: 6px 0;
    transform: translateX(-50%);
  }

  .header__submenu .header__menu-link {
    padding: 8px 14px;
    font-size: 13px;
    line-height: 1.45;
  }

  .header__menu-item--has-children::after {
    content: "";
    position: absolute;
    inset-inline: 0;
    top: 100%;
    height: 12px;
    z-index: 45;
  }
}

/* موبایل */
@media (max-width: 1023px) {
  .header {
    isolation: isolate;
  }

  .header__toggle {
    display: inline-flex;
  }

  .header__panel {
    position: fixed;
    inset-inline: var(--space-4);
    top: var(--netron-mobile-panel-top, 88px);
    bottom: auto;
    width: auto;
    max-width: none;
    z-index: 500;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    align-self: stretch;
    padding: var(--space-4);
    max-height: calc(100dvh - var(--netron-mobile-panel-top, 88px) - var(--space-4));
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background-color: #fff;
    border: 1px solid var(--color-divider);
    border-radius: var(--radius-md);
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.14);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease, visibility 0.2s ease;
  }

  .header--nav-open .header__panel {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  .header__nav {
    flex: 0 1 auto;
    justify-content: stretch;
  }

  .header__menu {
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    width: 100%;
    gap: var(--space-3);
  }

  .header__menu-item {
    width: 100%;
  }

  .header__menu-item--open {
    margin-block-end: var(--space-3);
  }

  .header__menu-link {
    width: 100%;
    justify-content: space-between;
  }

  .header__submenu {
    position: static;
    display: none;
    width: 100%;
    margin-block-start: var(--space-3);
    padding: 0;
    border: 0;
    border-radius: var(--radius-sm);
    box-shadow: none;
    background: rgba(43, 99, 235, 0.06);
  }

  .header__menu-item--open > .header__submenu {
    display: block;
  }

  .header__cta {
    width: 100%;
    margin-block-start: var(--space-4);
    white-space: normal;
  }

  .header__menu-item--has-children::after {
    display: none;
  }
}

