/**
 * Responsive Header Styles for MyFanClub.ru
 * Overrides enterprise template header for modern responsive layout
 */

/* ===== Fluid wrapper overrides ===== */
.wrapper {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 0 15px;
  box-sizing: border-box;
}
.container {
  min-width: auto;
  width: 100%;
}
#page_content {
  width: 100%;
  min-width: auto;
}

/* ===== Base header restructure ===== */
#header {
  position: relative;
  z-index: 10;
  padding-bottom: 0;
}

/* Header top area (toolbar + logo + rupor) */
/* Use element+class selector to override legacy layout.css rules
   (div.header-1 has higher specificity than class alone) */
div.header-1 {
  background: linear-gradient(180deg, #f5f9ff 0%, #e8f0fe 100%);
  padding: 4px 15px;
  overflow: visible;
}

.header-b3 {
  background: var(--c-stihi-grad-h);
  height: 4px;
  padding: 0;
}

/* ===== Toolbar ===== */
#toolbar {
  height: auto;
  overflow: visible;
  line-height: 1.4;
  font-size: 11px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px 0;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  margin-bottom: 0;
}
#toolbar .left,
#toolbar .right {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}
#toolbar ul.menu {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
}
#toolbar .menu li {
  display: inline-flex;
}
#toolbar .menu li a {
  padding: 2px 8px;
  background: none;
  border-radius: 4px;
  transition: background 0.2s;
}
#toolbar .menu li a:hover {
  background: rgba(0,0,0,0.05);
}
#toolbar .menu a.first {
  padding-left: 0;
}

/* ===== Logo area ===== */
#headerbar {
  min-height: auto;
  padding: 0;
  display: none; /* hide old headerbar spacer */
}

#logo {
  position: relative;
  top: auto;
  left: auto;
  display: inline-block;
  vertical-align: middle;
}
#logo a.logo-icon {
  width: 200px;
  height: 72px;
  background-size: contain !important;
}

/* ===== Rupor / top_message ===== */
#top_message {
  position: relative;
  top: auto;
  left: auto;
  padding: 0;
  width: auto;
  height: auto;
  /* Take all the free horizontal space between the logo and the menu
     so the leader avatars don't wrap onto a second row when the
     viewport is narrow. min-width: 0 lets it shrink past its content
     size if absolutely necessary. */
  flex: 1 1 auto;
  min-width: 0;
  overflow: visible;
  align-self: center;
}
/* Rupor itself is a fixed-height horizontal strip — never let its
   children (avatars) break onto multiple lines. */
#top_message > div { white-space: nowrap; }
#top_message #rupor-faces { display: inline-block; }
#top_message + .popover,
#top_message .popover {
  pointer-events: none;
}

/* ===== Menu background (replaces header-b1 image) ===== */
#menu {
  background: var(--c-stihi-grad);
  padding: 0 15px;
}
#menu a.level1 span.bg,
#menu span.level1 span.bg {
  color: #fff;
}
#menu li.level1:hover,
#menu li.level1.remain {
  background: rgba(255,255,255,0.15);
}
#menu li:hover .level1 span.bg,
#menu li.remain .level1 span.bg {
  color: #fff;
}
#menu li.active .level1 span.bg {
  color: #fff;
  font-weight: 700;
}
#menu li.active:hover .level1 span.bg,
#menu li.active.remain .level1 span.bg {
  color: #fff;
}

/* ===== Main navigation ===== */
#menu {
  position: relative;
  bottom: auto;
  left: auto;
  z-index: 11;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  flex: 1;
}
#menu ul.menu {
  float: none;
  display: flex;
  flex-wrap: wrap;
}
#menu li.level1 {
  float: none;
  margin-left: 0;
  background: none;
  display: flex;
}
#menu a.level1,
#menu span.level1 {
  float: none;
  padding: 0 14px;
  display: flex;
  align-items: center;
  height: 42px;
}
#menu a.level1 span.bg,
#menu span.level1 span.bg {
  height: auto;
  float: none;
  line-height: 1.3;
  font-size: 13px;
  color: #fff;
}
#menu li.level1:hover,
#menu li.level1.remain {
  background: rgba(255,255,255,0.15);
  border-radius: 6px;
}
#menu li:hover .level1 span.bg,
#menu li.remain .level1 span.bg {
  color: #fff;
  text-shadow: none;
}
#menu li.parent a.level1,
#menu li.parent span.level1 {
  background: none;
  padding-left: 14px;
}
#menu li.parent:hover a.level1,
#menu li.parent.remain a.level1 {
  background: none;
}
#menu li.active .level1 span.bg {
  color: #fff;
  font-weight: 700;
}
#menu li.active:hover .level1 span.bg,
#menu li.active.remain .level1 span.bg {
  color: #fff;
}

/* Dropdown modernize */
#menu .dropdown {
  top: 100%;
  left: -999em;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  border: 1px solid rgba(0,0,0,0.08);
  padding: 8px 0;
  min-width: 220px;
}
#menu li:hover .dropdown,
#menu li.remain .dropdown {
  left: 0;
}
#menu .dropdown-t1,
#menu .dropdown-t2,
#menu .dropdown-t3,
#menu .dropdown-b1,
#menu .dropdown-b2,
#menu .dropdown-b3 {
  background: none;
  height: auto;
  padding: 0;
  border: none;
}
#menu .dropdown-1,
#menu .dropdown-2,
#menu .dropdown-3 {
  background: none;
  padding: 0;
}
#menu ul.level2 {
  background: none;
}
#menu li.level2 {
  margin: 0;
  padding: 0;
  background: none;
}
#menu a.level2 {
  padding: 6px 14px;
  display: block;
}
#menu a.level2:hover {
  background: rgba(66,165,245,0.06);
}
#menu a.level2 span.bg {
  padding: 0;
  line-height: 1.4;
  text-shadow: none;
}
#menu a.level2:hover span.bg {
  color: #1a6fc4;
}

/* Remove white text-shadow from menu items (enterprise template adds it) */
#menu a.level1 span.bg,
#menu span.level1 span.bg,
#menu a.level2 span.bg {
  text-shadow: none !important;
}
#menu a.level2 span.icon {
  min-height: auto;
  padding-left: 40px;
  line-height: 1.4;
  background-position: 0 50%;
  background-size: 24px;
  background-repeat: no-repeat;
}
#menu a.level2 span.icon span.title,
#menu span.level2 span.icon span.title {
  display: block;
  line-height: 1.3;
}
#menu a.level2 span.icon span.subtitle,
#menu span.level2 span.icon span.subtitle {
  display: block;
  line-height: 1.3;
  margin-top: 2px;
  font-size: 11px;
  color: rgba(0,0,0,0.5);
}

/* Remove deep nested decorative boxes */
#menu .group-box1,
#menu .group-box2,
#menu .group-box3,
#menu .group-box4,
#menu .group-box5,
#menu .hover-box1,
#menu .hover-box2,
#menu .hover-box3,
#menu .hover-box4 {
  background: none;
  padding: 0;
  margin: 0;
}

/* ===== Header main row: logo + nav ===== */
.header-main-row {
  display: flex;
  align-items: center;
  gap: 40px;
  flex-wrap: wrap;
  padding: 8px 15px;
}

/* ===== Mobile toggle button ===== */
.header-mobile-toggle {
  display: none;
  width: 40px;
  height: 40px;
  border: none;
  background: var(--c-stihi-grad);
  color: #fff;
  font-size: 20px;
  border-radius: 8px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(30,136,229,0.25);
  transition: box-shadow 0.2s, transform 0.2s;
  flex-shrink: 0;
  position: relative;
  overflow: visible;
}
.header-mobile-toggle:hover {
  box-shadow: 0 4px 12px rgba(30,136,229,0.35);
}
.header-mobile-toggle:active {
  transform: scale(0.96);
}
.header-mobile-toggle:focus-visible {
  outline: 2px solid #1a6fc4;
  outline-offset: 2px;
  box-shadow: 0 4px 12px rgba(30,136,229,0.35);
}

/* Burger wave ripple animation on first show */
@keyframes burger-wave-ripple {
  0% {
    box-shadow: 0 0 0 0 rgba(66, 165, 245, 0.5);
  }
  70% {
    box-shadow: 0 0 0 18px rgba(66, 165, 245, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(66, 165, 245, 0);
  }
}
.burger-wave::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  animation: burger-wave-ripple 1.2s ease-out 2;
  pointer-events: none;
}

/* ===== Responsive breakpoints ===== */

/* Tablet (768px - 1023px) */
@media (max-width: 1023px) {
  .wrapper {
    padding: 0 12px;
  }
  #logo a.logo-icon {
    width: 160px;
    height: 58px;
  }
  #menu a.level1 span.bg,
  #menu span.level1 span.bg {
    font-size: 12px;
  }
  #top_message {
    display: none;
  }
}

/* Mobile (< 768px) */
@media (max-width: 767px) {
  #header {
    padding-bottom: 0;
    overflow-x: hidden;
  }
  div.header-1 {
    padding: 6px 12px;
    overflow-x: hidden;
  }
  .header-main-row {
    flex-wrap: nowrap;
    justify-content: space-between;
    align-items: center;
    gap: 0;
    padding: 8px 12px;
  }
  #logo {
    align-self: center;
  }
  #logo a.logo-icon {
    width: 140px;
    height: 50px;
  }

  /* Show mobile toggle */
  .header-mobile-toggle {
    display: flex;
    align-self: center;
  }

  /* Collapse menu into vertical panel */
  #menu {
    display: none;
    width: 100%;
    order: 3;
    margin-top: 8px;
  }
  #menu.active {
    display: block;
  }
  #menu ul.menu {
    flex-direction: column;
    width: 100%;
    float: none;
  }
  #menu li.level1 {
    width: 100%;
    border-bottom: 1px solid rgba(0,0,0,0.06);
    float: none;
    margin-left: 0;
    display: block;
  }
  #menu li.level1:last-child {
    border-bottom: none;
  }
  #menu a.level1,
  #menu span.level1 {
    height: auto;
    padding: 10px 12px;
    width: 100%;
    box-sizing: border-box;
    float: none;
  }
  #menu a.level1 span.bg,
  #menu span.level1 span.bg {
    float: none;
  }

  /* Dropdowns on mobile: always expanded inline */
  #menu .dropdown {
    position: static;
    left: auto;
    display: none;
    box-shadow: none;
    border: none;
    border-radius: 0;
    padding: 0 0 0 16px;
    background: rgba(0,0,0,0.02);
    min-width: auto;
    width: 100%;
    box-sizing: border-box;
  }
  #menu li.level1.open .dropdown {
    display: block;
  }
  #menu a.level2 {
    padding: 8px 12px;
  }

  /* Toolbar: force wrap and prevent overflow */
  #toolbar {
    font-size: 10px;
    gap: 2px;
    flex-wrap: wrap;
  }
  #toolbar .left,
  #toolbar .right {
    flex-wrap: wrap;
    max-width: 100%;
  }
  #toolbar ul.menu {
    flex-wrap: wrap;
    max-width: 100%;
  }
  #toolbar .menu li a {
    padding: 2px 4px;
  }

  /* Hide rupor */
  #top_message {
    display: none;
  }

  /* Decorative bar */
  .header-b3 {
    height: 3px;
  }
}

/* Small mobile (< 480px) */
@media (max-width: 480px) {
  .wrapper {
    padding: 0 8px;
  }
  #logo a.logo-icon {
    width: 120px;
    height: 44px;
  }
  .header-mobile-toggle {
    width: 36px;
    height: 36px;
    font-size: 18px;
    border-radius: 6px;
  }
  #toolbar .right {
    display: none; /* hide language selector on tiny screens */
  }
}

/* ===== Miniheader icon-only on narrow viewports ===== */
@media (max-width: 1023px) {
  #miniheader .btn-group .miniheader-label {
    display: none;
  }
  #miniheader .btn-group .btn {
    padding-left: 8px;
    padding-right: 8px;
  }
}
