/* ======================================================================
   Header — Stage 4 cleanup
   Scope:
   - logo/menu/search
   - global stats strip
   - mobile burger/menu
   ====================================================================== */

header[role="banner"] {
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--as-border-soft);
}

header[role="banner"] .site-header {
  max-width: 1024px;
  margin: 0 auto;
  padding: 12px 16px 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 18px;
  position: relative;
}

header[role="banner"] .site-logo {
  order: 1;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  line-height: 1;
  text-decoration: none;
}

header[role="banner"] .site-logo img {
  display: block;
  height: 42px;
  width: auto;
  opacity: .95;
  transition: filter .18s ease, transform .18s ease;
}

header[role="banner"] .site-logo:hover img,
header[role="banner"] .site-logo:focus-visible img {
  filter:
    brightness(1.10)
    drop-shadow(0 0 6px rgba(var(--as-accent-rgb), .24))
    drop-shadow(0 0 14px rgba(var(--as-accent-rgb), .12));
}

header[role="banner"] .site-name {
  display: none;
}

header[role="banner"] .site-header__search {
  order: 2;
  flex: 1 1 auto;
  min-width: 0;
}

header[role="banner"] .header-flex-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  width: 100%;
}

header[role="banner"] .header-flex-container nav {
  min-width: 0;
}

/* Compact language switcher. Keep full link text in the HTML for accessibility. */
header[role="banner"] .language-switcher-language-url {
  margin: 0;
}

header[role="banner"] .language-switcher-language-url ul.links {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

header[role="banner"] .language-switcher-language-url li {
  margin: 0;
  padding: 0;
}

header[role="banner"] .language-switcher-language-url .language-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  min-height: 40px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: var(--as-radius-xs);
  color: var(--as-text-muted);
  font-size: 0;
  font-weight: 800;
  line-height: 1;
  text-decoration: none;
}

header[role="banner"] .language-switcher-language-url .language-link[hreflang="en"]::before {
  content: "EN";
}

header[role="banner"] .language-switcher-language-url .language-link[hreflang="ru"]::before {
  content: "RU";
}

header[role="banner"] .language-switcher-language-url .language-link::before {
  font-size: 12px;
}

header[role="banner"] .language-switcher-language-url .language-link:hover,
header[role="banner"] .language-switcher-language-url .language-link:focus-visible,
header[role="banner"] .language-switcher-language-url .language-link.is-active {
  border-color: var(--as-border);
  background: var(--as-surface-2);
  color: var(--as-accent-hover);
}

/* Main navigation. */
header[role="banner"] #block-crypto-theme-osnovnayanavigaciya {
  margin: 0 !important;
}

header[role="banner"] #block-crypto-theme-osnovnayanavigaciya > h2 {
  display: none !important;
}

header[role="banner"] #block-crypto-theme-osnovnayanavigaciya ul.menu {
  display: flex !important;
  flex-flow: row nowrap !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 18px !important;
  margin: 0 !important;
  padding: 0 !important;
  list-style: none !important;
}

header[role="banner"] #block-crypto-theme-osnovnayanavigaciya ul.menu > li {
  margin: 0 !important;
  padding: 0 !important;
  list-style: none !important;
}

header[role="banner"] #block-crypto-theme-osnovnayanavigaciya a {
  display: inline-flex !important;
  align-items: center !important;
  height: 34px !important;
  padding: 0 10px !important;
  color: var(--as-text);
  font-size: 14px !important;
  font-weight: 700 !important;
  white-space: nowrap !important;
  text-decoration: none !important;
}

header[role="banner"] #block-crypto-theme-osnovnayanavigaciya a:hover,
header[role="banner"] #block-crypto-theme-osnovnayanavigaciya a.is-active {
  color: var(--as-accent-hover);
}

/* Search. */
header[role="banner"] #block-crypto-theme-formapoiska {
  max-width: 260px;
  margin: 0 !important;
  position: relative !important;
}

header[role="banner"] #block-crypto-theme-formapoiska > h2,
header[role="banner"] #block-crypto-theme-formapoiska label,
header[role="banner"] #block-crypto-theme-formapoiska .form-actions,
header[role="banner"] #block-crypto-theme-formapoiska input[type="submit"],
header[role="banner"] #block-crypto-theme-formapoiska .button,
header[role="banner"] #block-crypto-theme-formapoiska #edit-submit {
  display: none !important;
}

header[role="banner"] #block-crypto-theme-formapoiska form,
header[role="banner"] #block-crypto-theme-formapoiska .content,
header[role="banner"] #block-crypto-theme-formapoiska .search-block-form {
  display: block !important;
  width: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
}

header[role="banner"] #block-crypto-theme-formapoiska .form-item,
header[role="banner"] #block-crypto-theme-formapoiska .js-form-item,
header[role="banner"] #block-crypto-theme-formapoiska .js-form-type-search {
  margin: 0 !important;
}

header[role="banner"] #block-crypto-theme-formapoiska::before {
  content: "";
  position: absolute;
  left: 13px;
  top: 50%;
  width: 14px;
  height: 14px;
  transform: translateY(-50%);
  pointer-events: none;
  opacity: .5;
  z-index: 2;
  background-repeat: no-repeat;
  background-size: 14px 14px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23c8ced8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E");
}

header[role="banner"] #block-crypto-theme-formapoiska .form-search {
  width: 100% !important;
  min-width: 100% !important;
  height: 32px !important;
  padding: 0 13px 0 38px !important;
  border: 1px solid var(--as-border) !important;
  border-radius: var(--as-radius-xs) !important;
  background:
    radial-gradient(
      120% 140% at 0% 0%,
      rgba(var(--as-accent-rgb), .06),
      var(--as-surface-0) 55%,
      rgba(0, 0, 0, 0) 100%
    ),
    linear-gradient(180deg, var(--as-surface-1), rgba(255, 255, 255, .012)) !important;
  color: var(--as-text-strong) !important;
  font-size: 13px !important;
  outline: none !important;
  appearance: none !important;
  -webkit-appearance: none !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .025),
    0 6px 18px rgba(0, 0, 0, .22) !important;
}

/* Global stats. */
header[role="banner"] .site-header__stats {
  order: 3;
  flex: 0 0 100%;
  width: 100%;
  margin: 0;
  padding-top: 8px;
  justify-content: center;
  position: relative;
}

header[role="banner"] .site-header__stats::before {
  content: "";
  position: absolute;
  top: 0;
  left: 16px;
  right: 16px;
  height: 1px;
  opacity: .65;
  background: linear-gradient(
    90deg,
    var(--as-border-soft),
    rgba(var(--as-accent-rgb), .14),
    var(--as-border-soft)
  );
}

header[role="banner"] .global-stats-inline {
  display: flex !important;
  align-items: center !important;
  justify-content: center;
  gap: 20px !important;
  width: 100%;
  white-space: nowrap !important;
  font-size: 13px;
}

header[role="banner"] .stats-item {
  position: relative;
  display: inline-flex !important;
  align-items: center !important;
  gap: 4px;
  cursor: help;
}

.stats-item:not(:last-child)::after {
  content: "|";
  opacity: .25;
  margin: 0 10px;
}

header[role="banner"] .stats-label--short {
  opacity: .65;
  margin-right: 4px;
}

header[role="banner"] .stats-label--long {
  display: none;
}

header[role="banner"] .stats-value {
  color: var(--as-text);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: .02em;
}

header[role="banner"] .stats-item[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  top: calc(100% + 10px);
  transform: translateX(-50%);
  min-width: 180px;
  max-width: 260px;
  padding: 8px 10px;
  border: 1px solid var(--as-border-strong);
  border-radius: var(--as-radius-sm);
  background: rgba(8, 8, 8, .96);
  box-shadow: 0 10px 28px rgba(0, 0, 0, .45);
  color: var(--as-text-strong);
  font-size: 12px;
  line-height: 1.35;
  text-align: center;
  white-space: normal;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  z-index: 1000;
  transition: opacity .16s ease, visibility .16s ease, transform .16s ease;
}

header[role="banner"] .stats-item[data-tip]::before {
  content: "";
  position: absolute;
  left: 50%;
  top: calc(100% + 4px);
  transform: translateX(-50%);
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 6px solid rgba(8, 8, 8, .96);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  z-index: 1001;
  transition: opacity .16s ease, visibility .16s ease, transform .16s ease;
}

header[role="banner"] .stats-item[data-tip]:hover::after,
header[role="banner"] .stats-item[data-tip]:hover::before,
header[role="banner"] .stats-item[data-tip]:focus-visible::after,
header[role="banner"] .stats-item[data-tip]:focus-visible::before {
  opacity: 1;
  visibility: visible;
}

header[role="banner"] .stats-item[data-tip]:hover::after,
header[role="banner"] .stats-item[data-tip]:focus-visible::after {
  transform: translateX(-50%) translateY(2px);
}

.header-burger {
  display: none;
}

/* Live flash used by global/live blocks. */
tbody.is-live-updated tr {
  animation: liveRowFlash 1.2s ease;
}

@keyframes liveRowFlash {
  0% { background-color: rgba(var(--as-accent-rgb), .16); }
  100% { background-color: transparent; }
}

@media (max-width: 860px) {
  header[role="banner"] .site-header {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 10px 12px;
    text-align: center;
  }

  header[role="banner"] .site-logo {
    order: 1;
    flex: 0 0 auto;
    justify-content: center;
  }

  .header-burger {
    order: 2;
    flex: 0 0 auto;
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 42px;
    height: 42px;
    padding: 0;
    margin-left: 6px;
    border: 1px solid var(--as-border-strong);
    border-radius: var(--as-radius-xs);
    background: transparent;
    cursor: pointer;
  }

  .header-burger span {
    display: block;
    width: 18px;
    height: 2px;
    margin: 0 auto;
    background: var(--as-text-strong);
  }

  header[role="banner"] .site-header__search {
    order: 3;
    flex: 0 0 auto;
    width: auto;
    min-width: 0;
    display: block;
  }

  header[role="banner"] .header-flex-container {
    width: auto;
    display: block;
  }

  header[role="banner"] .language-switcher-language-url ul.links {
    justify-content: center;
  }

  header[role="banner"] .header-flex-container nav {
    flex: 0 0 auto;
    width: 100%;
    min-width: 0;
  }

  header[role="banner"] #block-crypto-theme-osnovnayanavigaciya {
    display: none !important;
    width: 100%;
    flex: 0 0 100%;
    margin-top: 10px !important;
  }

  header[role="banner"] #block-crypto-theme-osnovnayanavigaciya.is-open {
    display: block !important;
  }

  header[role="banner"] #block-crypto-theme-osnovnayanavigaciya ul.menu {
    flex-direction: column !important;
    gap: 12px !important;
  }

  header[role="banner"] #block-crypto-theme-formapoiska {
    width: 170px;
    min-width: 170px;
    max-width: 170px;
    margin: 0 !important;
  }

  header[role="banner"] #block-crypto-theme-formapoiska::before {
    display: none !important;
  }

  header[role="banner"] #block-crypto-theme-formapoiska .form-search {
    height: 40px !important;
    padding-left: 38px !important;
    background:
      url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23c8ced8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat 13px 50% / 14px 14px,
      radial-gradient(120% 140% at 0% 0%, rgba(var(--as-accent-rgb), .06), var(--as-surface-0) 55%, rgba(0, 0, 0, 0) 100%),
      linear-gradient(180deg, var(--as-surface-1), rgba(255, 255, 255, .012)) !important;
  }

  header[role="banner"] .site-header__stats {
    order: 4;
    flex: 0 0 100%;
    width: 100%;
    min-width: 0;
    padding-top: 4px;
  }

  header[role="banner"] .global-stats-inline {
    justify-content: flex-start;
    gap: 18px !important;
    width: 100% !important;
    padding: 4px 0;
    overflow-x: auto !important;
    scrollbar-width: none;
    white-space: nowrap !important;
  }

  header[role="banner"] .global-stats-inline::-webkit-scrollbar {
    display: none;
  }

  header[role="banner"] .stats-item {
    flex: 0 0 auto;
    gap: 4px;
    width: auto;
    padding: 6px 0;
    cursor: default !important;
  }

  .stats-item:not(:last-child)::after {
    content: none;
  }

  header[role="banner"] .stats-label--short {
    display: inline !important;
  }

  header[role="banner"] .stats-label--long {
    display: none !important;
  }

  header[role="banner"] .stats-value {
    min-width: 0;
    font-size: 13px;
  }

  header[role="banner"] .stats-item::before,
  header[role="banner"] .stats-item::after {
    content: none !important;
  }
}
