/* ============================================================================
   HEADER — шапка сайту.
   Перенесено з inline <style> у d1/header.php (там CSS жив просто в шаблоні).
   Змінено: іконки Font Awesome → inline-SVG, тому .hd2-top a вирівнюється
   по svg, а не по <i>.
   ========================================================================== */

/* ------------------- верхня смуга: контакти + мови ---------------------- */
.hd2-top {
  background: var(--c-topbar);
  color: #cfe0ef;
  font-size: 13px;
}
.hd2-top-in {
  max-width: var(--w-page);
  margin: 0 auto;
  padding: 7px var(--wrap-pad);
  display: flex;
  align-items: center;
  gap: 10px 26px;
  flex-wrap: wrap;
}
.hd2-top a {
  color: #cfe0ef;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.hd2-top a:hover { color: #fff; text-decoration: none; }
.hd2-top .sp { flex: 1 1 auto; }

/* ------------- сегментований перемикач мов + кнопка теми ---------------- */
.hd2-switch { display: inline-flex; align-items: center; gap: 8px; }

.hd2-lang {
  display: inline-flex;
  background: rgba(255, 255, 255, .13);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
  border: 1px solid rgba(255, 255, 255, .16);
}
.hd2-lang a {
  padding: 5px 15px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: .04em;
  color: rgba(255, 255, 255, .72);
  line-height: 1.2;
  transition: background .18s, color .18s;
}
.hd2-lang a:hover { color: #fff; background: rgba(255, 255, 255, .12); }
.hd2-lang a.on {
  background: #fff;
  color: var(--c-brand-dark, #00619a);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .18);
}
.hd2-lang a.on:hover { background: #fff; }

/* мова без перекладу поточної сторінки — неактивна «кнопка» (span, не лінк) */
.hd2-lang .off {
  padding: 5px 15px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: .04em;
  color: rgba(255, 255, 255, .72);
  line-height: 1.2;
  opacity: .42;
  cursor: not-allowed;
}

.hd2-theme {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .16);
  background: rgba(255, 255, 255, .13);
  color: rgba(255, 255, 255, .85);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  transition: background .18s, color .18s;
  font-family: inherit;
  padding: 0;
}
.hd2-theme:hover { background: rgba(255, 255, 255, .22); color: #fff; }
.hd2-theme svg { display: block; }
.hd2-theme:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
/* Іконка показує, що ввімкнеться: у світлій темі - місяць, у темній - сонце. */
.hd2-theme .iep-i--sun { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .hd2-theme .iep-i--sun { display: block; }
  :root:not([data-theme="light"]) .hd2-theme .iep-i--moon { display: none; }
}
:root[data-theme="dark"] .hd2-theme .iep-i--sun { display: block; }
:root[data-theme="dark"] .hd2-theme .iep-i--moon { display: none; }

/* Логотипи - растрові картинки на білому тлі: у темній темі даємо їм
   світлу підкладку, інакше це білі прямокутники з рваним краєм. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .hd2-logos img { background: #fff; border-radius: 6px; padding: 3px; }
}
:root[data-theme="dark"] .hd2-logos img { background: #fff; border-radius: 6px; padding: 3px; }
.hd2-top a:focus-visible,
.hd2-lang a:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* ------------------ логотипи + назва інституту + пошук ------------------ */
.hd2-main {
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-line);
}
.hd2-main-in {
  max-width: var(--w-page);
  margin: 0 auto;
  padding: 14px var(--wrap-pad);
  display: flex;
  align-items: center;
  gap: 22px;
}

.hd2-logos { display: flex; align-items: center; gap: 16px; flex: none; }
.hd2-logos img { height: 64px; width: auto; display: block; }

.hd2-name {
  flex: 1 1 auto;
  min-width: 0;
  text-decoration: none;
  border-left: 1px solid var(--c-line);
  padding-left: 22px;
}
.hd2-name:hover { text-decoration: none; }
.hd2-name .t1 {
  font-size: clamp(14px, 1.15vw, 17px);
  font-weight: 700;
  color: var(--c-heading);
  line-height: 1.28;
  display: block;
  letter-spacing: -.1px;
}
.hd2-name .t2 {
  font-size: 12.5px;
  color: var(--c-muted);
  margin-top: 3px;
  display: block;
  letter-spacing: .02em;
}
.hd2-name:hover .t1 { color: var(--c-brand-text); }

.hd2-search { flex: none; position: relative; }
.hd2-search input {
  width: 210px;
  padding: 9px 38px 9px 14px;
  border: 1px solid var(--c-line-strong);
  border-radius: 22px;
  font-size: 13.5px;
  color: var(--c-ink);
  background: var(--c-surface-2);
  font-family: inherit;
  transition: border-color .18s, width .2s;
}
.hd2-search input:focus {
  outline: none;
  border-color: var(--c-brand);
  background: var(--c-surface);
  width: 250px;
}
.hd2-search button {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  border: none;
  background: none;
  color: var(--c-faint);
  cursor: pointer;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.hd2-search button:hover { color: var(--c-brand-text); background: var(--c-surface-3); }

/* -------------------------------- Адаптив -------------------------------- */
@media (max-width: 1100px) {
  .hd2-search input { width: 160px; }
  .hd2-search input:focus { width: 190px; }
}

@media (max-width: 900px) {
  .hd2-main-in { flex-wrap: wrap; gap: 14px; padding: 12px var(--wrap-pad-sm); }
  .hd2-logos img { height: 52px; }
  .hd2-name { border-left: none; padding-left: 0; flex: 1 1 100%; order: 3; }
  .hd2-search { order: 2; margin-left: auto; }
  .hd2-top-in { padding: 7px var(--wrap-pad-sm); font-size: 12.5px; gap: 8px 16px; }
  .hd2-top .hd2-hide-sm { display: none; }
}

@media (max-width: 560px) {
  .hd2-search { flex: 1 1 100%; order: 4; }
  .hd2-search input,
  .hd2-search input:focus { width: 100%; }
}
