/* ═══════════════════════════════════════════════════════════════════════════
   site-switch — глобальный виджет «Другие разделы сайта».
   Общий компонент: статичная иконка (мгновенный рендер), панель + поведение
   инжектит /site-switch.js. Подключается на всех контентных страницах домена.
   Токены берутся из design-system (есть и в root, и в /olt/). Шапки везде тёмные
   → кнопка var(--text-light) видима на всех группах.
   ═══════════════════════════════════════════════════════════════════════════ */

.topnav-switch { position: relative; flex-shrink: 0; }

/* --tsw-fg / --tsw-bd: цвет иконки под тему шапки. Дефолт — светлый (тёмные шапки).
   На светлой шапке (напр. лендинг /olt/) страница переопределяет их на тёмные. */
.topnav-switch__btn {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  background: transparent;
  border: 1px solid var(--tsw-bd, rgba(245, 241, 236, 0.3));
  border-radius: var(--radius-sm);
  color: var(--tsw-fg, var(--text-light));
  cursor: pointer;
  transition: border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.topnav-switch__btn:hover,
.topnav-switch[data-open="true"] .topnav-switch__btn { border-color: var(--accent); color: var(--accent); }
.topnav-switch__btn svg { width: 18px; height: 18px; }

.topnav-switch__pop {
  position: absolute;
  top: calc(100% + 12px); right: 0;
  width: 340px; max-width: calc(100vw - 32px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 24px 60px -12px rgba(20, 16, 12, 0.4), 0 8px 20px rgba(20, 16, 12, 0.12);
  padding: 0 8px 8px;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
  opacity: 0; visibility: hidden;
  transform: translateY(-6px);
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease), visibility 0.2s;
  z-index: 200;
}
.topnav-switch[data-open="true"] .topnav-switch__pop { opacity: 1; visibility: visible; transform: translateY(0); }

/* ─── Sticky-шапка панели с крестиком (не уезжает при скролле длинного списка) ─── */
.topnav-switch__pop .tsw-bar {
  position: sticky; top: 0; z-index: 3;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin: 0 -8px 4px;
  padding: 12px 12px 10px;
  background: var(--surface);
  border-radius: 12px 12px 0 0;
}
.topnav-switch__pop .tsw-bar .tsw-head { padding: 0; }
.topnav-switch__pop .tsw-close {
  flex-shrink: 0;
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border: none; border-radius: var(--radius-sm);
  background: var(--bg-cream); color: var(--text-muted);
  cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.topnav-switch__pop .tsw-close:hover { background: var(--border); color: var(--text-dark); }
.topnav-switch__pop .tsw-close svg { width: 16px; height: 16px; }

.topnav-switch__pop .tsw-head {
  display: block;
  padding: 8px 12px 10px;
  font: 600 10.5px/1.2 var(--font-body);
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--text-muted);
}
.topnav-switch__pop .tsw-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 11px 12px;
  border-radius: 8px;
  text-decoration: none;
  transition: background var(--dur) var(--ease);
}
.topnav-switch__pop .tsw-item:hover { background: var(--bg-cream); text-decoration: none; }
.topnav-switch__pop .tsw-ico {
  flex-shrink: 0;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 8px;
  background: var(--bg-cream);
  color: var(--text-dark);
}
.topnav-switch__pop .tsw-ico svg { width: 18px; height: 18px; }
.topnav-switch__pop .tsw-ico--accent { background: rgba(200, 121, 42, 0.12); color: var(--accent); }
.topnav-switch__pop .tsw-item--here .tsw-ico { background: rgba(200, 121, 42, 0.12); color: var(--accent); }
.topnav-switch__pop .tsw-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.topnav-switch__pop .tsw-name {
  font: 500 14px/1.25 var(--font-body);
  color: var(--text-dark);
  letter-spacing: 0.1px;
  display: flex; align-items: center; gap: 7px;
}
.topnav-switch__pop .tsw-desc { font: 400 12px/1.35 var(--font-body); color: var(--text-muted); text-wrap: pretty; }
.topnav-switch__pop .tsw-ext { color: var(--accent); font-size: 12px; }
.topnav-switch__pop .tsw-badge {
  font: 600 9px/1 var(--font-body);
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--accent);
  background: rgba(200, 121, 42, 0.12);
  padding: 3px 7px; border-radius: 999px;
}
.topnav-switch__pop .tsw-item--here { cursor: default; }
.topnav-switch__pop .tsw-item--here:hover { background: transparent; }
.topnav-switch__pop .tsw-sep { display: block; height: 1px; background: var(--border); margin: 8px 6px; }

/* На телефоне поповер прикреплён к вьюпорту (иначе right:0 при 340px уезжает за левый край) */
@media (max-width: 480px) {
  .topnav-switch__pop {
    position: fixed;
    top: 72px; left: 16px; right: 16px;
    width: auto; max-width: none;
    max-height: calc(100vh - 88px);
    overflow-y: auto;
  }
}

/* Иконка уходит в правый кластер, когда основное меню сворачивается в бургер */
@media (max-width: 1240px) {
  .topnav-switch { margin-left: auto; }
}
