/* Shared top bar, language menu and the live status pill. */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  margin: 0 calc(var(--page-gutter) * -1);
  padding: 0 var(--page-gutter);
  background: rgba(9, 12, 16, 0.72);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  backdrop-filter: blur(16px) saturate(140%);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s, background-color 0.2s;
}

.topbar.is-scrolled,
.topbar.menu-open {
  border-bottom-color: var(--line);
  background: rgba(9, 12, 16, 0.9);
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 24px;
  max-width: var(--page-max);
  height: 64px;
  margin: 0 auto;
}

.topbar-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.125rem;
  letter-spacing: -0.01em;
  text-decoration: none;
  flex-shrink: 0;
}

.topbar-brand img {
  border-radius: 8px;
}

.topbar-links {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.topbar-links a {
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.9375rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.15s, background-color 0.15s;
}

.topbar-links a:hover,
.topbar-links a[aria-current="page"] {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  max-width: 240px;
  padding: 0 14px 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}

.status-pill:hover {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.06);
}

.status-pill-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-dot {
  position: relative;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--state-unknown);
  flex-shrink: 0;
}

.status-pill[data-state="up"] .status-dot { background: var(--state-up); }
.status-pill[data-state="degraded"] .status-dot { background: var(--state-degraded); }
.status-pill[data-state="down"] .status-dot { background: var(--state-down); }

.status-pill[data-state="up"] .status-dot::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 1px solid var(--state-up);
  opacity: 0;
  animation: status-ping 2.4s ease-out infinite;
}

@keyframes status-ping {
  0% { transform: scale(0.5); opacity: 0.8; }
  100% { transform: scale(1.4); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .status-pill[data-state="up"] .status-dot::after { animation: none; }
}

.lang-menu {
  position: relative;
}

/* The flag of the current language and its code. The bottom padding lifts
   them a pixel: small capitals next to a flag otherwise read low. */
.lang-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 10px 2px;
  line-height: 1;
  border: 1px solid transparent;
  border-radius: 8px;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
}

.lang-toggle:hover,
.lang-menu.is-open .lang-toggle {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.lang-flag {
  display: block;
  flex-shrink: 0;
  width: 18px;
  height: 12px;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.14);
}

/* Centred by its box, the flag sits 0.35-0.75px below the middle of the "RU"
   capitals, measured by pixels in Chromium and WebKit from 1x to 3x. Half a
   pixel up centres it within 0.3px. A 1x screen takes a whole pixel instead:
   half of one would soften the stripes. A transform, since Chromium rounds a
   half pixel offset of top to a whole one. */
.lang-toggle .lang-flag {
  transform: translateY(-1px);
}

@media (min-resolution: 1.2dppx), (-webkit-min-device-pixel-ratio: 1.2) {
  .lang-toggle .lang-flag {
    transform: translateY(-0.5px);
  }
}

.lang-list {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  display: none;
  min-width: 140px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-raised);
  box-shadow: var(--shadow-pop);
}

.lang-menu.is-open .lang-list {
  display: block;
}

.lang-list button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.875rem;
  text-align: left;
  cursor: pointer;
}

.lang-list button:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.lang-list button[aria-pressed="true"] {
  color: var(--accent-text);
}

.topbar-cta {
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 16px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: border-color 0.15s, background-color 0.15s;
}

.topbar-cta:hover {
  border-color: rgba(255, 255, 255, 0.26);
  background: rgba(255, 255, 255, 0.05);
}

.menu-toggle {
  display: none;
  position: relative;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 8px;
  background: none;
  cursor: pointer;
}

.menu-toggle span {
  position: absolute;
  left: 11px;
  right: 11px;
  height: 2px;
  border-radius: 2px;
  background: var(--text);
  transition: transform 0.2s;
}

.menu-toggle span:first-child { top: 15px; }
.menu-toggle span:last-child { top: 23px; }
.menu-toggle[aria-expanded="true"] span:first-child { transform: translateY(4px) rotate(45deg); }
.menu-toggle[aria-expanded="true"] span:last-child { transform: translateY(-4px) rotate(-45deg); }

.mobile-menu {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 8px 0 20px;
}

.mobile-menu nav {
  display: grid;
}

.mobile-menu nav a {
  padding: 14px 4px;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  font-size: 1.0625rem;
  font-weight: 500;
  text-decoration: none;
}

.mobile-lang {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-top: 16px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.mobile-lang button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
}

.mobile-lang button[aria-pressed="true"] {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.mobile-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 52px;
  margin-top: 16px;
  border-radius: 14px;
  background: var(--accent);
  color: #08110a;
  font-weight: 600;
  text-decoration: none;
}

@media (max-width: 1080px) {
  .topbar-links a:nth-child(n+4) { display: none; }
}

@media (max-width: 860px) {
  .topbar-inner { gap: 12px; height: 56px; }
  .topbar-links,
  .lang-menu,
  .topbar-cta { display: none; }
  .menu-toggle { display: block; }
  .status-pill { height: 34px; max-width: 46vw; padding: 0 12px 0 10px; font-size: 0.8125rem; }
}

@media (min-width: 861px) {
  .mobile-menu { display: none !important; }
}
