/* Единый публичный хедер ДивёрсИИ.
   Используется на главной, /news и всех страницах статей.
   Личный кабинет имеет собственный хедер и здесь не переопределяется. */

.public-header .header-inner {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  column-gap: 32px;
}

.public-header .brand {
  grid-column: 1;
  justify-self: start;
}

.public-header .header-nav {
  grid-column: 2;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 34px;
}

.public-header .header-nav .nav-link {
  color: rgba(255, 255, 255, 0.72);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: color 0.2s ease;
}

.public-header .header-nav .nav-link:hover {
  color: var(--white);
}

/* Визуальный стиль (скругление, фон, hover) наследуется из единого CTA-блока /styles.css.
   Здесь — только компактные размеры для Header. */
.public-header .account-link {
  min-height: 44px;
  padding: 0 18px;
  gap: 10px;
  font-size: 13px;
}

[hidden] { display: none !important; }
.public-header .header-user-area { position: relative; display: flex; align-items: center; gap: 8px; }
.header-wallet-link, .header-profile-trigger { min-height: 42px; border: 1px solid rgba(255,255,255,.13); background: #101010; color: #fff; text-decoration: none; }
.header-wallet-link { display: inline-flex; align-items: center; gap: 9px; padding: 0 13px 0 9px; border-radius: 8px; color: rgba(255,255,255,.78); font-size: 13px; font-weight: 600; white-space: nowrap; }
.header-credit-icon { display: block; width: 18px; height: 18px; flex: 0 0 18px; object-fit: contain; }
.header-profile-trigger { display: inline-flex; align-items: center; gap: 9px; padding: 5px 7px 5px 12px; border-radius: 8px; font: inherit; cursor: pointer; }
.header-nickname { max-width: 150px; overflow: hidden; font-size: 13px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.header-avatar { display: grid; width: 34px; height: 34px; flex: 0 0 34px; place-items: center; overflow: hidden; border-radius: 50%; background: #ff692a; color: #fff; font-size: 14px; font-weight: 700; }
.header-profile-trigger .header-avatar { width: 30px; height: 30px; flex-basis: 30px; font-size: 13px; }
.header-avatar > * { grid-area: 1 / 1; }
.header-avatar img { width: 100%; height: 100%; object-fit: cover; }
.header-wallet-link:hover, .header-profile-trigger:hover,
.header-wallet-link:focus-visible, .header-profile-trigger:focus-visible { border-color: rgba(255,105,42,.7); background: #17120f; }
.header-user-menu { position: absolute; z-index: 50; top: calc(100% + 10px); right: 0; width: 240px; padding: 8px; border: 1px solid rgba(255,255,255,.14); border-radius: 8px; background: #0d0d0d; box-shadow: 0 18px 50px rgba(0,0,0,.45); }
.header-user-summary { display: grid; gap: 4px; margin-bottom: 6px; padding: 10px; border-bottom: 1px solid rgba(255,255,255,.1); }
.header-user-summary strong { font-size: 14px; }
.header-user-summary span { overflow: hidden; color: rgba(255,255,255,.5); font-size: 12px; text-overflow: ellipsis; }
.header-user-menu a, .header-user-menu button { display: flex; width: 100%; min-height: 38px; align-items: center; padding: 0 10px; border: 0; border-radius: 6px; background: transparent; color: rgba(255,255,255,.78); font: inherit; font-size: 13px; text-align: left; text-decoration: none; cursor: pointer; }
.header-user-menu a:hover, .header-user-menu button:hover, .header-user-menu a:focus-visible, .header-user-menu button:focus-visible { background: rgba(255,255,255,.07); color: #fff; }

/* Кнопка-гамбургер скрыта на desktop */
.public-header .menu-toggle {
  display: none;
}

/* Мобильное меню (оверлей) */
.mobile-menu {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(3, 3, 3, 0.97);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.28s ease, visibility 0s linear 0.28s;
}

.mobile-menu.is-open {
  opacity: 1;
  visibility: visible;
  transition-delay: 0s;
}

.mobile-menu-inner {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 96px 24px 40px;
  transform: translateY(-12px);
  transition: transform 0.28s ease;
}

.mobile-menu.is-open .mobile-menu-inner {
  transform: translateY(0);
}

.mobile-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 54px;
  margin-bottom: 18px;
  border-radius: 10px;
  background: linear-gradient(115deg, var(--orange), #f43e22);
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  text-decoration: none;
}

.mobile-nav {
  display: grid;
  gap: 4px;
}

.mobile-nav a {
  padding: 15px 14px;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 18px;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.2s ease, color 0.2s ease;
}

.mobile-nav a:hover {
  background: #141414;
  color: #fff;
}

.mobile-user-panel { margin-bottom: 12px; padding-bottom: 16px; border-bottom: 1px solid rgba(255,255,255,.1); }
.mobile-user-summary { display: flex; align-items: center; gap: 12px; padding: 10px 14px 14px; }
.mobile-user-summary > span:last-child { display: grid; min-width: 0; gap: 4px; }
.mobile-user-summary strong { overflow: hidden; color: #fff; font-size: 16px; text-overflow: ellipsis; white-space: nowrap; }
.mobile-user-summary small { color: rgba(255,255,255,.48); font-size: 12px; }
.mobile-account-nav { display: grid; gap: 4px; }
.mobile-account-nav a, .mobile-account-nav button { display: flex; min-height: 44px; align-items: center; padding: 0 14px; border: 0; border-radius: 8px; background: transparent; color: rgba(255,255,255,.82); font: inherit; font-size: 16px; text-align: left; text-decoration: none; cursor: pointer; }
.mobile-account-nav a:hover, .mobile-account-nav button:hover,
.mobile-account-nav a:focus-visible, .mobile-account-nav button:focus-visible { background: #141414; color: #fff; }

/* Блокировка прокрутки при открытом меню */
body.menu-locked {
  overflow: hidden;
}

/* Mobile */
@media (max-width: 720px) {
  .site-header {
    position: fixed;
    z-index: 40;
    inset: 0 0 auto;
    padding: 10px 0;
    pointer-events: none;
  }

  .public-header .header-inner {
    grid-template-columns: minmax(0, 1fr) auto auto;
    column-gap: 8px;
    pointer-events: none;
  }

  .public-header .brand,
  .public-header .menu-toggle,
  .public-header .header-account-actions,
  .public-header .header-nav a {
    pointer-events: auto;
  }

  .public-header .brand {
    grid-column: 1;
  }

  .public-header .header-nav,
  .public-header .header-login-link {
    display: none;
  }

  .public-header .header-account-actions { grid-column: 2; display: flex; }
  .public-header .header-user-area { gap: 6px; }
  .public-header .header-profile-trigger,
  .public-header .header-user-menu { display: none; }
  .public-header .header-wallet-link { min-height: 40px; padding: 0 10px 0 7px; }
  .public-header .header-credit-icon { width: 18px; height: 18px; flex-basis: 18px; }

  .public-header .menu-toggle {
    grid-column: 3;
    justify-self: end;
    display: grid;
    place-content: center;
    gap: 5px;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid #343434;
    border-radius: 6px;
    background: #111;
    cursor: pointer;
  }

  .public-header .menu-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    border-radius: 2px;
    background: #fff;
    transition: transform 0.2s ease, opacity 0.2s ease;
  }

  .public-header .menu-toggle.is-open {
    border-color: var(--orange);
    background: var(--orange);
  }

  .public-header .menu-toggle.is-open span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
  }

  .public-header .menu-toggle.is-open span:nth-child(2) {
    opacity: 0;
  }

  .public-header .menu-toggle.is-open span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
  }
}

.public-header .header-account-actions {
  grid-column: 3;
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 14px;
}

.header-wallet-balance {
  color: rgba(255, 255, 255, 0.62);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}

.header-wallet-balance[hidden],
.mobile-account-link [data-header-wallet][hidden] { display: none; }
.mobile-account-link [data-header-wallet] { color: rgba(255, 255, 255, 0.52); font-size: 14px; }

@media (max-width: 720px) {
  .public-header .header-account-actions { grid-column: 2; }
  .public-header .menu-toggle { grid-column: 3; }
}

.site-legal-block {
  width: min(1120px, calc(100% - 40px));
  margin: 28px auto 0;
  padding: 22px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
}

.site-legal-block--news {
  margin-top: 36px;
}

.site-legal-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 24px;
}

.site-legal-links a:not(:last-child)::after {
  content: "·";
  margin-left: 24px;
  color: rgba(255, 255, 255, 0.28);
  pointer-events: none;
}

.site-legal-links a {
  color: rgba(255, 255, 255, 0.58);
  font-size: 13px;
  text-decoration: none;
}

.site-legal-links a:hover { color: #fff; }
.site-legal-meta {
  display: contents;
  color: rgba(255, 255, 255, 0.42);
  font-size: 12px;
}
.site-legal-meta > :first-child { grid-column: 1; grid-row: 1; justify-self: start; }
.site-legal-links { grid-column: 2; grid-row: 1; }
.site-legal-meta > :last-child { grid-column: 3; grid-row: 1; justify-self: end; }
.site-legal-meta a { color: inherit; text-decoration: none; }
.site-legal-meta a:hover { color: rgba(255, 255, 255, 0.72); }
.site-legal-fallback { border-top: 1px solid rgba(255, 255, 255, 0.1); background: #050505; }
.site-legal-fallback--news { border-top: 0; background: #000; }

@media (max-width: 760px) {
  .site-legal-block { display: flex; flex-direction: column; padding: 24px 0; }
  .site-legal-links { align-items: center; flex-direction: column; text-align: center; }
  .site-legal-links a:not(:last-child)::after { content: none; }
  .site-legal-meta { display: flex; align-items: center; flex-direction: column; gap: 8px; text-align: center; }
}
