/* ==========================================================================
   navbar.css — shared header component: two visual states, language
   control, mobile drawer. See plans/landing.MD §7.
   ========================================================================== */

.site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  width: 100%;
  background: transparent;
  transition: background-color var(--dur-base) var(--ease-out),
              box-shadow var(--dur-base) var(--ease-out),
              border-color var(--dur-base) var(--ease-out);
}

/* Sentinel pinned to the hero's top edge (which sits at document y:0,
   since .hero is pulled up under the sticky header — see .hero below),
   spanning the first 24px of the page. nav.js observes it against the
   default viewport root: while any part of it is still in view the page
   hasn't scrolled past the 24px threshold yet, so the navbar stays
   transparent; once it scrolls fully out of view, .is-solid is added.
   No scroll listener needed. */
.nav-sentinel {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 24px;
  pointer-events: none;
}

.site-nav__inner {
  display: flex;
  align-items: center;
  gap: var(--space-8);
  height: var(--nav-h);
  transition: height var(--dur-base) var(--ease-out);
}

.site-nav__brand {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-inline-end: auto;
  min-width: 0;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.brand__name {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -0.01em;
  line-height: 1.2;
  color: #fff;
  transition: color var(--dur-base) var(--ease-out);
  white-space: nowrap;
}
.brand__name--short { display: none; }
.brand__sub {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1.2;
  color: rgba(255,255,255,.72);
  transition: color var(--dur-base) var(--ease-out);
  white-space: nowrap;
}

.brand__rule {
  width: 1px;
  height: 26px;
  background: rgba(255,255,255,.28);
  flex-shrink: 0;
  transition: background-color var(--dur-base) var(--ease-out);
}

.brand__kit img {
  display: block;
  height: 34px;
  width: auto;
  max-width: 118px;
  object-fit: contain;
}

/* -- Nav links -- */
.site-nav__nav { display: flex; }
.nav-list {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}
.nav-list a {
  position: relative;
  display: inline-block;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: var(--fs-nav);
  letter-spacing: 0.005em;
  color: rgba(255,255,255,.90);
  padding: 10px var(--space-5);
  border-radius: var(--radius-pill);
  transition: color var(--dur-base) var(--ease-out),
              background-color var(--dur-base) var(--ease-out);
}
.nav-list a::after {
  content: "";
  position: absolute;
  left: var(--space-5);
  right: var(--space-5);
  bottom: 4px;
  height: 2px;
  border-radius: 2px;
  background: var(--green-300);
  transform: scaleX(0);
  transform-origin: right;
  transition: transform var(--dur-base) var(--ease-out);
}
@media (hover: hover) {
  .nav-list a:hover {
    color: #fff;
    background: rgba(255,255,255,.12);
  }
  .nav-list a:hover::after {
    transform: scaleX(1);
    transform-origin: left;
  }
}
.nav-list a:focus-visible::after {
  transform: scaleX(1);
  transform-origin: left;
}
.nav-list a[aria-current="page"] {
  color: #fff;
  font-weight: 600;
}
.nav-list a[aria-current="page"]::after {
  background: var(--green-300);
  transform: scaleX(1);
}

/* -- Language control (§7.6) -- */
.site-nav__lang {
  display: flex;
  align-items: center;
  margin-inline-start: var(--space-5);
}

.lang { position: relative; }
.lang__btn {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 7px 10px 7px 8px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(255,255,255,.34);
  background: rgba(255,255,255,.10);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  transition: border-color var(--dur-base) var(--ease-out),
              background-color var(--dur-base) var(--ease-out);
}
.lang__flag {
  width: 20px;
  height: 14px;
  border-radius: var(--radius-xs);
  object-fit: cover;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.10);
}
.lang__code {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.04em;
  color: #fff;
  transition: color var(--dur-base) var(--ease-out);
}
.lang__caret {
  width: 8px;
  height: 8px;
  color: #fff;
  transition: transform var(--dur-fast) var(--ease-out), color var(--dur-base) var(--ease-out);
}
.lang[data-open="true"] .lang__caret { transform: rotate(180deg); }

@media (hover: hover) {
  .lang__btn:hover {
    border-color: var(--green-300);
    background: rgba(255,255,255,.18);
  }
}

.lang__menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 168px;
  background: #fff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: var(--space-2);
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-out);
}
.lang[data-open="true"] .lang__menu {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.lang__menu li {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-small);
  color: var(--text-primary);
  cursor: pointer;
}
.lang__menu li img { width: 20px; height: 14px; border-radius: var(--radius-xs); box-shadow: inset 0 0 0 1px rgba(0,0,0,.10); }
.lang__menu li span {
  margin-left: auto;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
}
@media (hover: hover) {
  .lang__menu li:hover { background: var(--green-50); }
}
.lang__menu li[aria-selected="true"] { background: var(--green-100); }
.lang__menu li.is-unavailable {
  opacity: .5;
  cursor: not-allowed;
}
.lang__menu li.is-unavailable:hover { background: transparent; }
.lang__note {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-left: var(--space-1);
}

/* -- Hamburger toggle -- */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 6px;
  width: 44px;
  height: 44px;
  margin-inline-start: var(--space-2);
}
.nav-toggle__bar {
  width: 20px;
  height: 2px;
  background: #fff;
  border-radius: 1px;
  transition: transform var(--dur-base) var(--ease-out), opacity var(--dur-base) var(--ease-out);
}
.nav-toggle[aria-expanded="true"] .nav-toggle__bar:first-child {
  transform: translateY(4px) rotate(45deg);
}
.nav-toggle[aria-expanded="true"] .nav-toggle__bar:last-child {
  transform: translateY(-4px) rotate(-45deg);
}

/* -- Scroll-progress hairline (§7.8) -- */
.nav-progress {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 2px;
  width: 100%;
  background: var(--grad-accent-rule);
  transform: scaleX(0);
  transform-origin: left;
  opacity: 0;
  transition: opacity var(--dur-base) var(--ease-out);
}

/* ==========================================================================
   Solid state
   ========================================================================== */
.site-nav.is-solid {
  background: rgba(255,255,255,.86);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  backdrop-filter: saturate(160%) blur(14px);
  box-shadow: var(--shadow-nav);
  border-bottom: 1px solid var(--border-subtle);
}
.site-nav.is-solid .site-nav__inner { height: var(--nav-h-solid); }

.site-nav.is-solid .brand__name { color: var(--ink-700); }
.site-nav.is-solid .brand__sub { color: var(--ink-500); }
.site-nav.is-solid .brand__rule { background: var(--border-subtle); }

.site-nav.is-solid .nav-list a { color: var(--ink-700); }
.site-nav.is-solid .nav-list a::after { background: var(--kit-green); }
@media (hover: hover) {
  .site-nav.is-solid .nav-list a:hover {
    color: var(--green-700);
    background: var(--green-50);
  }
}
.site-nav.is-solid .nav-list a[aria-current="page"] {
  color: var(--green-700);
}
.site-nav.is-solid .nav-list a[aria-current="page"]::after {
  background: var(--green-600);
}

.site-nav.is-solid .lang__btn {
  border-color: var(--border-subtle);
  background: #fff;
}
.site-nav.is-solid .lang__code { color: var(--ink-700); }
.site-nav.is-solid .lang__caret { color: var(--ink-700); }
@media (hover: hover) {
  .site-nav.is-solid .lang__btn:hover {
    border-color: var(--green-300);
    background: var(--green-50);
  }
}

.site-nav.is-solid .nav-toggle__bar { background: var(--ink-700); }

.site-nav.is-solid .nav-progress { opacity: 1; }

/* focus ring inverts on dark/transparent state (§7.7) — restricted to the
   transparent-over-hero state only; .site-nav--static must keep the default
   green ring (plans/team.MD §4.3 defect 1) */
.site-nav:not(.is-solid):not(.site-nav--static) :focus-visible {
  outline-color: #fff;
}

/* -- Non-hero (inner) pages start solid permanently -- */
.site-nav--static {
  background: rgba(255,255,255,.86);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  backdrop-filter: saturate(160%) blur(14px);
  box-shadow: var(--shadow-nav);
  border-bottom: 1px solid var(--border-subtle);
}
.site-nav--static .site-nav__inner { height: var(--nav-h-solid); }
.site-nav--static .brand__name { color: var(--ink-700); }
.site-nav--static .brand__sub { color: var(--ink-500); }
.site-nav--static .brand__rule { background: var(--border-subtle); }
.site-nav--static .nav-list a { color: var(--ink-700); }
.site-nav--static .lang__btn { border-color: var(--border-subtle); background: #fff; }
.site-nav--static .lang__code,
.site-nav--static .lang__caret { color: var(--ink-700); }
.site-nav--static .nav-toggle__bar { background: var(--ink-700); }

/* -- Static-state link/language states (plans/team.MD §4.3 defects 2-5) --
   .site-nav--static mirrored only the base link colour, not the active/hover
   states .is-solid defines above; the Team page is the first to expose the
   gap. No new values: all lifted from the .is-solid rules above. */
.site-nav--static .nav-list a::after                      { background: var(--kit-green); }
.site-nav--static .nav-list a[aria-current="page"]        { color: var(--green-700); }
.site-nav--static .nav-list a[aria-current="page"]::after { background: var(--green-600); }
@media (hover: hover) {
  .site-nav--static .nav-list a:hover { color: var(--green-700); background: var(--green-50); }
  .site-nav--static .lang__btn:hover  { border-color: var(--green-300); background: var(--green-50); }
}

/* ==========================================================================
   Mobile drawer (§7.10)
   ========================================================================== */
.nav-drawer {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(255,255,255,.98);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  display: flex;
  flex-direction: column;
  padding: var(--space-16) var(--container-gutter) var(--space-8);
  overflow-y: auto;
}
.nav-drawer[hidden] { display: none; }

.nav-drawer__close {
  position: absolute;
  top: var(--space-5);
  right: var(--container-gutter);
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.nav-drawer__close svg { width: 22px; height: 22px; color: var(--ink-700); }

.nav-drawer__list {
  display: flex;
  flex-direction: column;
  margin-top: var(--space-12);
}
.nav-drawer__list li {
  border-bottom: 1px solid var(--ink-100);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity var(--dur-slow) var(--ease-out), transform var(--dur-slow) var(--ease-out);
  transition-delay: calc(var(--i, 0) * 40ms);
}
.nav-drawer.is-open .nav-drawer__list li {
  opacity: 1;
  transform: translateY(0);
}
.nav-drawer__list a {
  display: block;
  padding-block: var(--space-5);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 32px;
  color: var(--ink-700);
}
.nav-drawer__list a[aria-current="page"] { color: var(--green-700); }

.nav-drawer__footer {
  margin-top: auto;
  padding-top: var(--space-8);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
/* the drawer is always a light surface, so its language control always
   uses the solid-state (light) look, regardless of the header's state */
.nav-drawer__footer .lang__btn {
  border-color: var(--border-subtle);
  background: #fff;
}
.nav-drawer__footer .lang__code,
.nav-drawer__footer .lang__caret {
  color: var(--ink-700);
}
@media (hover: hover) {
  .nav-drawer__footer .lang__btn:hover {
    border-color: var(--green-300);
    background: var(--green-50);
  }
}
.nav-drawer__email {
  font-size: var(--fs-small);
  color: var(--text-muted);
}

/* ==========================================================================
   Responsive (§7.3, §7.10, §12)
   ========================================================================== */
@media (max-width: 1100px) {
  .brand__sub { display: none; }
  .nav-list a { padding-inline: var(--space-4); }
}

/* Mobile top bar: logo left, hamburger centred on the whole bar, language
   control right — not a flex row with the brand pushing things right, since
   that can't centre the hamburger independent of the brand/lang widths.
   A 3-column grid with equal outer tracks guarantees true centring. The
   group name is dropped entirely (KIT logo alone identifies the site at
   this width); markup order was changed to put the toggle before the
   language control so visual order and keyboard tab order still match. */
@media (max-width: 900px) {
  .site-nav__nav { display: none; }
  .site-nav__inner {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: var(--space-3);
  }
  .site-nav__brand { margin-inline-end: 0; justify-self: start; }
  .brand__name,
  .brand__rule { display: none; }
  .nav-toggle {
    display: flex;
    justify-self: center;
    flex-shrink: 0;
    margin-inline-start: 0;
    width: 48px;
    height: 48px;
    gap: 7px;
  }
  .nav-toggle__bar { width: 22px; }
  .site-nav__lang { margin-inline-start: 0; flex-shrink: 0; justify-self: end; }
}

@media (max-width: 420px) {
  .lang__flag { display: none; }
  .brand__kit img { height: 28px; }
}

/* -- Touch targets: bump toward 44x44px minimum on touch input (§12) -- */
@media (hover: none) {
  .nav-list a { padding-block: 12px; }
  .lang__btn { padding-block: 11px; }
  .nav-drawer__list a { padding-block: var(--space-5); }
}
