/* ============================================================
   Global navbar component
   Pairs with templates/core/_navbar.html and js/navbar.js.
   Self-contained (own tokens) so it can load on any page,
   regardless of whether style.css or base.css is present.
   Variants: .nav (black bar, inner pages) / .nav--overlay (home hero).
   ============================================================ */

/* The topbar is the top row of the page shell (css/page-transitions.css),
   so pages need no clearance for it. */
.topbar {
  position: relative;
  z-index: 1000;
}

/* Home: #swup spans the header row too, so its vertical scrollbar runs the
   full window height and the bar would be drawn over it. Keep the bar clear of
   the scrollbar (--scrollbar-w is measured in js/navbar.js; 0 for overlay
   scrollbars). Other pages scroll below the bar, so nothing overlaps. */
.topbar:has(.nav--overlay) {
  margin-inline-end: var(--scrollbar-w, 0px);
}

/* Figma Components / Navbar: "Light" is the black bar on inner pages,
   "Overlay" the transparent one over the home hero (.nav--overlay; it turns
   solid once the hero has scrolled away — .nav--solid, js/navbar.js). */
.nav {
  --nav-primary: #005ca7;
  --nav-ink: #414752;
  --nav-font: "Inter", system-ui, sans-serif;
  position: relative;
  z-index: 3;  /* above the megamenu's page overlay (.mega-overlay) */
  width: 100%;
  background: #0f0f0f;
  color: #f8f8f8;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: background-color .3s ease;
}

.nav:lang(fa) { --nav-font: var(--font-sans); }  /* Vazirmatn, design-system.css */
.nav:lang(zh-hans) { --nav-font: var(--font-sans); }  /* + Noto Sans SC, design-system.css */
/* The language menu names Chinese in Chinese on every page, so its entry needs Noto too. */
.nav__lang-option:lang(zh-hans),
.nav-menu__lang-option:lang(zh-hans) { font-family: var(--nav-font), "Noto Sans SC", sans-serif; }

.nav--overlay { background: transparent; }
.nav--overlay.nav--solid,
.nav--overlay.nav--mega-open { background: #0f0f0f; }

.nav__inner {
  display: flex;
  align-items: center;
  gap: 72px;
  height: 86px;
  /* content is 1440 wide at most, never closer than 72px to the edge */
  padding: 0 max(72px, calc((100% - 1440px) / 2));
}

.nav__logo img { display: block; width: 62px; height: 51px; }

/* --- links --- */

.nav__links {
  display: flex;
  align-items: center;
  gap: 48px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav__link {
  display: block;
  font-family: var(--nav-font);
  font-size: 14px;
  font-weight: 700;
  line-height: 20px;
  letter-spacing: 0.7px;
  color: inherit;
  text-decoration: none;
  padding: 6px 0;
  border-bottom: 2px solid transparent;
  transition: border-color .15s ease, opacity .15s ease;
}

.nav__link:hover { opacity: 0.8; }
.nav__link--active { border-bottom-color: currentColor; }
.nav__link--active:hover { opacity: 1; }

/* --- catalogue megamenu (templates/core/_navbar.html, js/navbar.js) ---
   A full-width panel under the bar with three columns: supply line,
   category, subcategories. js/navbar.js opens it on hover/focus and animates
   it with GSAP (the panel unrolls, the page dims behind it); without GSAP the
   .is-open classes alone show and hide it. Desktop only: phones use the
   full-screen menu. */

.nav__item--menu > .nav__link::after {
  /* Chevron via ::after: page-transitions.js copies .nav__link's text on
     every navigation, which would wipe an icon element inside the link. */
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-inline-start: 7px;
  border-right: 2px solid currentColor;  /* physical: a down chevron, symmetric */
  border-bottom: 2px solid currentColor;
  transform: translateY(-3px) rotate(45deg);
  transition: transform .2s ease;
}
.nav__item--menu.is-open > .nav__link::after { transform: translateY(0) rotate(225deg); }

.mega {
  position: absolute;
  top: 100%;
  inset-inline: 0;
  z-index: 2;
  visibility: hidden;
}
.mega.is-open { visibility: visible; }

.mega__panel {
  background: var(--neutral-white, #f8f8f8);
  color: var(--neutral-black, #0f0f0f);
}

.mega__inner {
  display: grid;
  grid-template-columns: 220px 300px minmax(0, 1fr);
  min-height: 320px;
  padding: 0 max(72px, calc((100% - 1440px) / 2));
}

.mega__group { display: none; grid-column: 2 / 4; grid-template-columns: subgrid; }
.mega__group.is-active { display: grid; }

.mega__col {
  margin: 0;
  max-height: calc(100dvh - var(--header-h, 86px) - 96px);  /* long lists scroll in place */
  padding: 32px 24px 40px;
  list-style: none;
  overflow-y: auto;
  font-family: var(--font-sans, "Inter", system-ui, sans-serif);
}
.mega__col + .mega__col,
.mega__group > .mega__col:first-child { border-inline-start: 1px solid var(--neutral-100, #e0e3e1); }
.mega__col--l1 { padding-inline-start: 0; }
.mega__l1--all { color: var(--blue-600, #005ca7); }
.mega__l1--all::after { content: none; }

/* Levels 1 and 2: a list; the active item is the one whose contents show. */
.mega__l1,
.mega__l2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--neutral-black, #0f0f0f);
  text-decoration: none;
  transition: background-color .15s ease, color .15s ease;
}
.mega__l1 {
  font-family: var(--font-display-ds, "Plus Jakarta Sans", sans-serif);
  font-size: 16px;
  font-weight: 800;
  line-height: 24px;
}
.mega__l2 {
  font-size: 15px;
  font-weight: 600;
  line-height: 22px;
}
.mega__l1::after,
.mega__l2::after {
  content: "";
  flex: none;
  width: 6px;
  height: 6px;
  border-right: 2px solid currentColor;  /* physical: drawn as ">", turned in RTL */
  border-top: 2px solid currentColor;
  transform: rotate(45deg);
  opacity: 0;
  transition: opacity .15s ease;
}
.mega__l1:hover,
.mega__l2:hover { background: var(--neutral-50, #f1f4f2); }
.mega__l1.is-active,
.mega__l2.is-active {
  background: var(--blue-100, #dce8ff);
  color: var(--blue-600, #005ca7);
}
.mega__l1.is-active::after,
.mega__l2.is-active::after { opacity: 1; }
/* The chevron points along the reading direction: left in RTL. */
[dir="rtl"] .mega__l1::after,
[dir="rtl"] .mega__l2::after { transform: rotate(-135deg); }

/* Level 3: the active category's subcategories. */
.mega__subs { display: none; }
.mega__subs.is-active { display: block; }

.mega__heading {
  margin-block: 10px 16px;
  margin-inline: 12px 0;
  font-family: var(--font-display-ds, "Plus Jakarta Sans", sans-serif);
  font-size: 20px;
  font-weight: 700;
  line-height: 28px;
  color: var(--neutral-black, #0f0f0f);
}

.mega__sub-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 2px 16px;
  margin: 0 0 20px;
  padding: 0;
  list-style: none;
}

.mega__l3 {
  display: block;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  color: var(--neutral-black, #0f0f0f);
  text-decoration: none;
  transition: background-color .15s ease, color .15s ease;
}
.mega__l3:hover,
.mega__l3:focus-visible {
  background: var(--neutral-50, #f1f4f2);
  color: var(--blue-600, #005ca7);
}

.mega__all {
  display: inline-block;
  margin-inline-start: 12px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.14px;
  color: var(--blue-600, #005ca7);
  text-decoration: none;
}
.mega__all:hover { text-decoration: underline; }

.mega a:focus-visible {
  outline: 2px solid var(--blue-500, #007ee2);
  outline-offset: 2px;
}

/* The page behind the open menu goes dark. It sits in the header's stacking
   context under the bar (.nav) and the panel, over everything in #swup. */
.mega-overlay {
  position: fixed;
  inset: 0;
  z-index: 1;
  background: rgba(15, 15, 15, 0.72);
  opacity: 0;
  visibility: hidden;
}
.mega-overlay.is-open { opacity: 1; visibility: visible; }

/* --- search: on desktop always shown, filling the space between the links and the icons;
   on phones hidden until the search icon is tapped --- */

.nav__search {
  display: none;
  position: relative;
  flex: 1;
  min-width: 160px;
}

.nav--search-open .nav__search { display: block; }

.nav__search input {
  width: 100%;
  height: 38px;
  background: #fff;
  border: 1px solid rgba(197, 197, 216, 0.5);
  border-radius: 9999px;
  padding-block: 0;
  padding-inline: 33px 16px;
  font: 400 14px/1 var(--nav-font);
  color: #374151;
}
.nav__search input::placeholder { color: #6b7280; }

.nav__suggest {
  position: absolute;
  inset-inline: 0;
  top: calc(100% + 8px);
  z-index: 5;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}
.nav__suggest[hidden] { display: none; }
.nav__suggest a {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  color: #111827;
  font: 500 14px/1.3 var(--nav-font);
  text-decoration: none;
}
.nav__suggest a:hover,
.nav__suggest a:focus-visible,
.nav__suggest a[aria-selected="true"] { background: #f3f4f6; }
.nav__suggest-cas { flex-shrink: 0; color: #6b7280; font-size: 12px; font-weight: 400; }

.nav__search-icon {
  position: absolute;
  inset-inline-start: 12px;
  top: 50%;
  transform: translateY(-50%);
}

/* --- actions --- */

.nav__actions {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-inline-start: auto;
}

.nav__icon-btn svg { width: 24px; height: 24px; }

.nav__icon-btn {
  display: flex;
  padding: 8px;
  border: 0;
  background: none;
  cursor: pointer;
  color: inherit;
}

/* --- language dropdown --- */

.nav__lang {
  position: relative;
}

.nav__icon-btn--globe {
  align-items: center;
  gap: 4px;
}

.nav__lang-current {
  font-family: var(--nav-font);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.nav__lang-menu {
  position: absolute;
  top: calc(100% + 12px);
  inset-inline-end: 0;
  min-width: 160px;
  background: #fff;
  color: var(--nav-ink);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(15, 15, 15, 0.16);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity .15s ease, transform .15s ease, visibility .15s ease;
  z-index: 1200;
}

.nav__lang.is-open .nav__lang-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.nav__lang-option {
  display: flex;
  align-items: center;
  gap: 10px;
  box-sizing: border-box;
  width: 100%;
  text-decoration: none;
  text-align: start;
  padding: 10px 12px;
  border: 0;
  border-radius: 8px;
  background: none;
  cursor: pointer;
  font-family: var(--nav-font);
  font-size: 14px;
  font-weight: 500;
  color: inherit;
}

.nav__lang-option:hover { background: rgba(0, 92, 167, 0.08); }
.nav__lang-option--active {
  background: rgba(0, 92, 167, 0.1);
  color: var(--nav-primary);
  font-weight: 700;
}

.nav-menu__lang {
  display: none;
  flex-wrap: wrap;  /* seven languages don't fit one row on a phone */
  justify-content: center;
  gap: 10px;
  padding-inline: 20px;
}

.nav-menu__lang-option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  padding: 6px 18px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 9999px;
  background: none;
  color: rgba(255, 255, 255, 0.75);
  font-family: var(--nav-font);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  cursor: pointer;
}

/* Flags in the language menus (seo_tags.language_flag). */
.nav__lang-flag {
  flex: none;
  inline-size: 20px;
  block-size: 15px;
  border-radius: 2px;
  object-fit: cover;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12);
}

.nav-menu__lang-option--active {
  color: #0f1216;
  background: #fff;
  border-color: #fff;
}

.nav__cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 16px;
  background: #f8f8f8;
  color: var(--nav-primary);
  font-family: var(--nav-font);
  font-size: 14px;
  font-weight: 600;
  line-height: 20px;
  letter-spacing: 0.14px;
  border-radius: 999px;
  white-space: nowrap;
  text-decoration: none;
  transition: background-color .15s ease, color .15s ease;
}
.nav__cta:hover { background: #e0e3e1; }
.nav__cta:active { background: #d9d9d9; color: #00457c; }

/* --- full-screen mobile menu --- */
/* Lives inside .topbar (NOT .nav — its backdrop-filter would trap
   position:fixed descendants) so it inherits the component tokens. */

.nav__menu-btn { display: none; }

.nav-menu {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 48px;
  background: rgba(0, 0, 0, 0.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  visibility: hidden;
  transition: opacity .25s ease, visibility .25s ease;
}

.nav-menu.is-open {
  opacity: 1;
  visibility: visible;
}

body.nav-menu-open { overflow: hidden; }

.nav-menu__close {
  position: absolute;
  top: 20px;
  inset-inline-end: 20px;
  padding: 12px;
  border: 0;
  background: none;
  cursor: pointer;
  color: #fff;
}

.nav-menu__links {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
}

.nav-menu__link {
  font-family: var(--nav-font);
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 1.3px;
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
  padding-bottom: 8px;
  border-bottom: 2px solid transparent;
  transition: color .15s ease;
}

.nav-menu__link:hover { color: #9ec7e8; }
.nav-menu__link--active {
  color: #fff;
  border-bottom-color: #fff;
}

/* The overlay CTA can afford to be bigger than the bar one. */
.nav-menu > .nav__cta {
  font-size: 16px;
  padding: 12px 40px;
}

/* --- responsive --- */

@media (min-width: 769px) {
  .nav__search { display: block; }
  /* the bar's 72px gap is for the logo and links; the field sits 24px from its neighbours */
  .nav__search { margin-inline: -48px; }
  .nav-menu { display: none; }
}

@media (max-width: 1200px) {
  .nav__inner { gap: 28px; padding: 0 24px; }
  .nav__search { margin-inline: -8px; }
}

/* Five links (Home, Catalog, Periodic Table, News, About Us) on one line in
   every language: the gaps, then the type, tighten as the bar narrows. */
.nav__link { white-space: nowrap; }

@media (max-width: 1360px) {
  .nav__links { gap: 32px; }
}

@media (max-width: 1200px) {
  .nav__links { gap: 20px; }
}

@media (max-width: 1100px) {
  .nav__links { gap: 16px; }
  .nav__link { font-size: 13px; letter-spacing: 0.3px; }
}

@media (max-width: 1000px) {
  .nav__inner { gap: 14px; }
  .nav__links { gap: 12px; }
  .nav__lang-current { display: none; }
  .nav__cta { padding-inline: 12px; font-size: 13px; }
}

@media (max-width: 1200px) {
  .mega__inner { grid-template-columns: 200px 260px minmax(0, 1fr); padding: 0 24px; }
}

@media (max-width: 768px) {
  .mega,
  .mega-overlay { display: none; }
  .nav__inner { height: 64px; gap: 16px; padding: 0 20px; }
  .nav__links { display: none; }
  .nav__logo img { width: 40px; height: auto; }

  /* CTA moves into the full-screen menu; globe is hidden on mobile
     (its language options move into .nav-menu__lang instead) */
  .nav__lang,
  .nav > .nav__actions .nav__cta { display: none; }
  .nav__menu-btn { display: flex; }
  .nav-menu__lang { display: flex; }
}

/* Georgian words run long: tighter gaps and smaller type so the five links,
   the search field and the CTA still fit on one line. */
:lang(ka) .nav__inner { gap: 28px; }
:lang(ka) .nav__search { margin-inline: -8px; }
:lang(ka) .nav__links { gap: 20px; }
:lang(ka) .nav__link { font-size: 13px; letter-spacing: 0; }
:lang(ka) .nav__cta { padding-inline: 12px; font-size: 13px; letter-spacing: 0; }
@media (max-width: 1360px) {
  :lang(ka) .nav__inner { gap: 18px; padding: 0 24px; }
  :lang(ka) .nav__links { gap: 14px; }
  :lang(ka) .nav__link { font-size: 12px; }
  :lang(ka) .nav__lang-current { display: none; }
}
@media (max-width: 1150px) {
  :lang(ka) .nav__search { display: none; }
}
:lang(ka) .nav__logo { flex: none; }
@media (max-width: 1000px) {
  :lang(ka) .nav__links { gap: 10px; }
  :lang(ka) .nav__link { font-size: 11px; }
}
