/* Primary navigation — layout, dropdowns, overflow fixes */

#nav {
  display: grid;
  grid-template-columns: minmax(100px, auto) minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px 20px;
}

/* Desktop: menu button hidden (drawer only on small screens) */
.nav-toggle {
  display: none;
}

.nav-logo {
  justify-self: start;
  min-width: 0;
}

.nav-logo img {
  width: auto;
  height: auto;
  max-height: 48px;
  max-width: min(200px, 40vw);
  object-fit: contain;
}

.nav-center {
  position: static;
  left: auto;
  transform: none;
  justify-self: center;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: nowrap;
  gap: 2px;
  min-width: 0;
  max-width: 100%;
  overflow: visible;
}

.nav-item {
  position: relative;
  flex-shrink: 0;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 11px;
  white-space: nowrap;
}

.nav-chevron {
  flex-shrink: 0;
  opacity: 0.55;
  transition: transform 0.2s ease;
}

.nav-item.has-dropdown:hover .nav-chevron,
.nav-item.has-dropdown:focus-within .nav-chevron {
  transform: rotate(180deg);
  opacity: 0.9;
}

.nav-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  z-index: 1001;
  min-width: 220px;
  padding: 8px;
  margin: 0;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(12, 26, 46, 0.1);
  box-shadow: 0 16px 48px rgba(12, 26, 46, 0.14);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateX(-50%) translateY(6px);
  transition:
    opacity 0.2s ease,
    visibility 0.2s ease,
    transform 0.2s ease;
}

.nav-dropdown::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: -8px;
  height: 8px;
}

.nav-item.has-dropdown:hover .nav-dropdown,
.nav-item.has-dropdown:focus-within .nav-dropdown {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.nav-dropdown-link {
  display: block;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: none;
  color: #5a6b82;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-dropdown-link:hover {
  background: rgba(13, 110, 253, 0.08);
  color: #0c1a2e;
}

.nav-right {
  justify-self: end;
  flex-shrink: 0;
  gap: 10px;
  min-width: 0;
}

.lang-switch {
  flex-shrink: 0;
  margin-right: 0;
  padding: 3px;
}

.lang-switch a {
  padding: 5px 9px;
  font-size: 10px;
  letter-spacing: 0.08em;
}

.nav-locations {
  flex-shrink: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-locations span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-btn {
  flex-shrink: 0;
  padding: 10px 16px;
  white-space: nowrap;
}

.nav-drawer-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 0 12px 16px;
  border-left: 2px solid rgba(13, 110, 253, 0.2);
  margin: -4px 0 8px 8px;
}

.nav-drawer-sub {
  font-size: 14px !important;
  font-weight: 500 !important;
  letter-spacing: 0 !important;
  text-transform: none !important;
  color: var(--c-slate) !important;
  padding: 8px 12px !important;
}

body.site-light .nav-drawer-sub {
  color: var(--sl-muted) !important;
}

body.site-light .nav-drawer-sub:hover {
  color: var(--sl-blue) !important;
}

body.site-light .nav-dropdown {
  background: #fff;
  border-color: rgba(12, 26, 46, 0.1);
}

body.site-light .nav-dropdown-link {
  color: var(--sl-muted);
}

body.site-light .nav-dropdown-link:hover {
  color: var(--sl-text);
  background: var(--sl-blue-soft);
}

@media (max-width: 1280px) {
  .nav-locations {
    display: none;
  }

  .nav-link {
    padding: 8px 9px;
    font-size: 11px;
    letter-spacing: 1px;
  }

  .nav-logo img {
    height: 44px;
  }
}

@media (max-width: 1100px) {
  #nav {
    gap: 8px 12px;
    padding-left: 24px;
    padding-right: 24px;
  }

  .nav-btn {
    padding: 9px 14px;
    font-size: 11px;
  }
}

@media (max-width: 768px) {
  #nav {
    display: flex !important;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    z-index: 1002;
  }

  .nav-logo {
    flex: 1;
    min-width: 0;
  }

  .nav-center,
  .nav-right {
    display: none !important;
  }

  .nav-toggle {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-shrink: 0;
    order: 2;
    margin-left: auto;
    min-width: 88px;
    height: 44px;
    padding: 0 16px;
    border-radius: 10px;
    border: 2px solid #0d6efd;
    background: #0d6efd;
    color: #fff;
    cursor: pointer;
    position: relative;
    z-index: 1003;
    box-shadow: 0 4px 16px rgba(13, 110, 253, 0.35);
  }

  .nav-toggle-bars {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 18px;
    height: 14px;
  }

  .nav-toggle-bars span {
    display: block;
    width: 18px;
    height: 2px;
    border-radius: 1px;
    background: #fff;
    transition: transform 0.3s ease, opacity 0.3s ease;
  }

  .nav-toggle-label {
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    line-height: 1;
    color: #fff;
  }

  .nav-toggle.open .nav-toggle-label {
    font-size: 0;
    width: 0;
    overflow: hidden;
  }

  .nav-toggle.open .nav-toggle-bars span:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
  }

  .nav-toggle.open .nav-toggle-bars span:nth-child(2) {
    opacity: 0;
  }

  .nav-toggle.open .nav-toggle-bars span:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
  }
}

/* Mobile drawer — above page content; header stays on top to close menu */
.nav-drawer {
  z-index: 1001;
  padding: 100px 24px 48px;
  justify-content: flex-start;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.nav-drawer.open {
  z-index: 1001;
}

@media (max-width: 768px) {
  .nav-drawer a {
    font-size: clamp(28px, 8vw, 42px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .nav-dropdown,
  .nav-chevron {
    transition: none;
  }
}
