/* ============================
   Верхняя тонкая шапка (topbar)
   ============================ */

.topbar {
    height: var(--topbar-height);
    background-color: var(--bg-topbar);
    color: #ffffff;
    font-size: 13px;
}

.topbar .container {
    height: 100%;
}

.topbar-inner {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.topbar-left,
.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-link {
    opacity: 0.85;
    transition: opacity 0.15s ease;
    white-space: nowrap;
}

.topbar-link:hover {
    opacity: 1;
}

.topbar-divider {
    width: 1px;
    height: 16px;
    background-color: rgba(255, 255, 255, 0.25);
}

.topbar-phone {
    font-weight: 600;
    white-space: nowrap;
}

.topbar-btn {
    border-radius: 999px;
    padding: 4px 12px;
    font-size: 12px;
    border: 1px solid rgba(255, 255, 255, 0.6);
    background: transparent;
    color: #ffffff;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    white-space: nowrap;
}

.topbar-btn:hover {
    background-color: #ffffff;
    color: var(--bg-topbar);
}

/* ============================
   Основная шапка (main-header)
   ============================ */

.main-header {
    background-color: var(--bg-header);
    border-bottom: 1px solid var(--border-soft);
    box-shadow: 0 4px 10px rgba(15, 35, 52, 0.04);
    position: sticky;
    top: 0;
    z-index: 20;
    backdrop-filter: saturate(120%) blur(2px);
}

.main-header-inner {
    /* было height: var(--header-height); из-за этого текст вылезал */
    min-height: var(--header-height);
    height: auto;

    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 32px;

    /* чтобы при росте высоты выглядело нормально */
    padding: 10px 0;
    min-width: 0;

    /* важно для корректного ужатия */
    flex-wrap: nowrap;
}

/* Бренд: логотип + текст */

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;

    /* бренд НЕ должен растягиваться на всю ширину хедера */
    flex: 0 1 auto;
}

.brand-logo {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: radial-gradient(circle at 30% 30%, #ffffff, var(--primary));
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.brand-logo img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.brand-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;

    /* чтобы бренд не захватывал весь хедер и всегда был слева */
    flex: 0 1 auto;
    max-width: min(320px, 52vw);
}

.brand-title {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.01em;
    max-width: min(220px, 52vw);

    /* перенос в несколько строк + аккуратное ограничение по высоте */
    white-space: normal;
    overflow: hidden;
    overflow-wrap: anywhere;
    word-break: normal;
    hyphens: auto;
    text-overflow: ellipsis;

    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3; /* можно 2, если надо ниже */
    line-height: 1.15;
}

.brand-subtitle {
    font-size: 12px;
    color: var(--text-muted);
    max-width: 260px;

    /* subtitle можно переносить, он не критичен */
    overflow-wrap: anywhere;
}

/* Навигация справа */

.nav {
    display: flex;
    align-items: center;
    gap: 24px;

    /* правая часть не должна схлопываться/вытесняться брендом */
    flex: 0 0 auto;
    justify-content: flex-end;
    min-width: 0;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 18px;
    font-size: 14px;
}

.nav-link {
    position: relative;
    padding: 6px 0;
    white-space: nowrap;
    transition: color 0.15s ease;
}

.nav-link::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: -4px;
    width: 0;
    height: 2px;
    background-color: var(--primary);
    border-radius: 999px;
    transition: width 0.18s ease;
}

.nav-link:hover::after {
    width: 100%;
}

.nav-link--active,
.nav-link.nav-link--active {
    color: var(--primary);
    font-weight: 600;
}

.nav-link--active::after,
.nav-link.nav-link--active::after {
    width: 100%;
}

/* CTA блок справа */

.nav-cta {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-cta-btn {
    border-radius: 999px;
    border: none;
    padding: 8px 18px;
    font-size: 14px;
    font-weight: 500;
    background: var(--primary);
    color: #ffffff;
    cursor: pointer;
    box-shadow: 0 8px 16px rgba(0, 132, 255, 0.2);
    transition: background-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
    white-space: nowrap;
    align-items: center;
    justify-content: center;
    gap: 8px;
    display: inline-flex;
}

.nav-cta-btn img {
    display: block;
}

.nav-cta-btn:hover {
    background-color: var(--primary-dark);
    box-shadow: 0 10px 20px rgba(0, 100, 194, 0.25);
    transform: translateY(-1px);
}

.nav-cta-secondary {
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
}

.nav-cta-secondary a {
    color: var(--primary);
    font-weight: 500;
}

/* Бургер на мобилке */

.nav-toggle {
    display: none;
    border: none;
    background: transparent;
    cursor: pointer;
    width: 32px;
    height: 32px;
    padding: 0;
}

.nav-toggle span {
    display: block;
    height: 2px;
    width: 100%;
    margin: 6px 0;
    background-color: var(--text-main);
    transition: transform 0.2s ease, opacity 0.2s ease;
}

/* ============================
   Футер
   ============================ */

.site-footer {
    background-color: var(--bg-footer);
    color: #ffffff;
    padding: 18px 0;
    font-size: 13px;
    margin-top: auto;
}

.site-footer-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

@media (max-width: 600px) {
  .site-footer-inner {
    flex-direction: column;
    gap: 8px;
    text-align: center;
  }
}

.site-footer a {
    color: #d0e2ff;
}

.site-footer a:hover {
    text-decoration: underline;
}

/* ============================
   Адаптив
   ============================ */

/* ВАЖНО: на этом размере меню пропадает полностью и остаётся только бренд слева */
@media (max-width: 900px) {
    .brand-subtitle {
        display: none;
    }

    .main-header-inner {
        min-height: 70px;
        height: auto;

        /* когда справа ничего нет — не раздвигать space-between */
        justify-content: flex-start;
    }

    /* пункты меню и CTA исчезают */
    .nav {
        display: none;
    }
}

@media (max-width: 600px) {
    .topbar-inner {
        justify-content: space-between;
    }

    .topbar-left {
        display: none;
    }

    .main-header-inner {
        gap: 16px;
    }
}

/* === Кастомизация под широкое лого === */

.main-header-inner {
    gap: 40px;
}

.brand {
    gap: 16px;
}

.brand-logo {
    width: auto;
    height: 64px;
    border-radius: 0;
    background: none;
    padding: 0;
}

.brand-logo img {
    height: 100%;
    width: auto;
    object-fit: contain;
}

/* оставляем как было, но без "жёстких" max-width: none и flex:1,
   чтобы бренд не растягивался на всю ширину */
.brand-text {
    max-width: min(620px, 52vw);
}

/* Старые классы (site-header-inner/site-logo...) оставляю, чтобы ничего не сломать,
   если где-то в проекте они используются. */
.site-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.site-logo,
.site-logo-text,
.header-logo {
  min-width: 0;
  flex-shrink: 1;
}

.site-logo-text {
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.2;
}

@media (max-width: 600px) {
  .site-header-inner {
    flex-wrap: wrap;
  }

  .site-logo-text {
    font-size: 14px;
  }
}

/* === Блок пользователя: иконка в сером кружке === */

.nav-user{
  display: inline-flex;
  align-items: center;
  gap: 8px;
  line-height: 1;
  min-width: 0;
}

.nav-user-avatar{
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #e9edf3;
  border: 1px solid var(--border-soft);

  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 28px;
}

.nav-user-icon{
  width: 16px;
  height: 16px;
  display: block;
  opacity: 0.7;
}

.nav-user-name{
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 0;
}

/* === Переменные масштаба (оставляем, они не ломают поведение) === */

:root{
  --brand-logo-h: clamp(34px, 4.2vw, 64px);
  --brand-title-fs: clamp(12px, 1.15vw + 6px, 18px);
}

/* масштабируем лого (не трогаем меню) */
.brand-logo{
  height: var(--brand-logo-h);
  width: auto;
  flex: 0 0 auto;
}

/* адаптивный размер заголовка (переносы сохраняются) */
.brand-title{
  font-size: var(--brand-title-fs);
}

/* на очень узких экранах чуть уменьшим зазор */
@media (max-width: 600px){
  .brand{ gap: 10px; }
}
