/*!
 * Neonatology Academy — Global Navigation v1.0
 * Prefix: nnt- (neo nav topbar) — no collision with existing styles
 */

/* ── Design tokens ─────────────────────────────────────────────────────── */
:root {
  --nnt-h: 60px;
  --nnt-bg: #ffffff;
  --nnt-border: #e8edf2;
  --nnt-shadow: 0 1px 0 #e8edf2, 0 2px 12px rgba(15,23,42,.07);
  --nnt-brand: #0f766e;
  --nnt-brand-dark: #115e59;
  --nnt-navy: #0f172a;
  --nnt-text: #374151;
  --nnt-muted: #374151;
  --nnt-hover-bg: #f0fdf9;
  --nnt-hover-text: #0f766e;
  --nnt-dd-shadow: 0 4px 6px -1px rgba(0,0,0,.06), 0 12px 36px rgba(0,0,0,.12);
  --nnt-radius: 12px;
  --nnt-z: 9900;
}

/* ── Base header ────────────────────────────────────────────────────────── */
.neo-topnav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nnt-h);
  background: var(--nnt-bg);
  border-bottom: 1px solid var(--nnt-border);
  box-shadow: var(--nnt-shadow);
  z-index: var(--nnt-z);
  display: flex;
  align-items: center;
}

.nnt-inner {
  display: flex;
  align-items: center;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 1.5rem;
  gap: 0;
  height: 100%;
}

/* ── Logo ───────────────────────────────────────────────────────────────── */
.nnt-logo {
  display: flex;
  align-items: center;
  gap: .55rem;
  text-decoration: none;
  flex-shrink: 0;
  margin-right: 2rem;
  outline: none;
}

.nnt-logo:focus-visible .nnt-logo-icon {
  outline: 2px solid var(--nnt-brand);
  outline-offset: 2px;
  border-radius: 8px;
}

.nnt-logo-icon {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, #0f766e 0%, #0891b2 100%);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: .9rem;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(15,118,110,.35);
}

.nnt-logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.nnt-logo-name {
  font-size: .88rem;
  font-weight: 700;
  color: var(--nnt-navy);
  letter-spacing: -.02em;
  white-space: nowrap;
}

.nnt-logo-badge {
  font-size: .58rem;
  font-weight: 800;
  color: #ef4444;
  letter-spacing: .08em;
  text-transform: uppercase;
  line-height: 1.2;
}

/* ── Desktop nav ────────────────────────────────────────────────────────── */
.nnt-nav {
  display: flex;
  align-items: center;
  gap: .05rem;
  flex: 1;
  height: 100%;
}

.nnt-item {
  position: relative;
  height: 100%;
  display: flex;
  align-items: center;
}

.nnt-link {
  display: flex;
  align-items: center;
  gap: .32rem;
  padding: .38rem .6rem;
  border-radius: 7px;
  color: var(--nnt-text);
  font-size: .83rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: background .13s, color .13s;
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
  outline: none;
  position: relative;
}

.nnt-link:hover {
  color: var(--nnt-hover-text);
  background: var(--nnt-hover-bg);
}

.nnt-link:focus-visible {
  outline: 2px solid var(--nnt-brand);
  outline-offset: 2px;
}

.nnt-link-active {
  color: var(--nnt-brand) !important;
  font-weight: 600;
}

.nnt-link-active::after {
  content: '';
  position: absolute;
  bottom: -10px;
  left: .45rem; right: .45rem;
  height: 2px;
  background: var(--nnt-brand);
  border-radius: 99px;
}

.nnt-link i:first-child {
  font-size: .8rem;
  color: var(--nnt-muted);
  transition: color .13s;
}

.nnt-link:hover i:first-child,
.nnt-link-active i:first-child {
  color: var(--nnt-brand);
}

.nnt-arrow {
  font-size: .6rem;
  margin-left: .05rem;
  transition: transform .2s;
  color: var(--nnt-muted);
  flex-shrink: 0;
}

.nnt-item.open .nnt-arrow { transform: rotate(180deg); color: var(--nnt-brand); }
.nnt-item.open > .nnt-link { color: var(--nnt-brand); background: var(--nnt-hover-bg); }
.nnt-item.open > .nnt-link i:first-child { color: var(--nnt-brand); }

/* ── Dropdown ───────────────────────────────────────────────────────────── */
.nnt-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%) translateY(-6px) scale(.97);
  transform-origin: top center;
  min-width: 230px;
  background: #fff;
  border: 1px solid var(--nnt-border);
  border-radius: var(--nnt-radius);
  box-shadow: var(--nnt-dd-shadow);
  padding: .35rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity .16s cubic-bezier(.4,0,.2,1), transform .16s cubic-bezier(.4,0,.2,1);
  z-index: 100;
}

/* Keep within viewport on rightmost items */
.nnt-item:nth-last-child(-n+3) .nnt-dropdown {
  left: auto;
  right: 0;
  transform: translateY(-6px) scale(.97);
  transform-origin: top right;
}
.nnt-item:nth-last-child(-n+3).open .nnt-dropdown {
  transform: translateY(0) scale(1);
}

.nnt-item.open .nnt-dropdown {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0) scale(1);
}

.nnt-dd-item {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .42rem .65rem;
  border-radius: 6px;
  color: var(--nnt-text);
  font-size: .82rem;
  font-weight: 500;
  text-decoration: none;
  transition: background .11s, color .11s;
  white-space: nowrap;
  cursor: pointer;
  outline: none;
}

.nnt-dd-item:hover,
.nnt-dd-item:focus-visible {
  background: var(--nnt-hover-bg);
  color: var(--nnt-brand);
}

.nnt-dd-item:focus-visible {
  outline: 2px solid var(--nnt-brand);
  outline-offset: -2px;
}

.nnt-dd-icon {
  width: 15px;
  text-align: center;
  color: var(--nnt-muted);
  font-size: .78rem;
  flex-shrink: 0;
  transition: color .11s;
}

.nnt-dd-item:hover .nnt-dd-icon { color: var(--nnt-brand); }

.nnt-dd-divider {
  margin: .3rem .35rem .05rem;
  padding-top: .3rem;
  border-top: 1px solid var(--nnt-border);
}

.nnt-dd-divider-label {
  display: block;
  font-size: .66rem;
  font-weight: 700;
  color: var(--nnt-muted);
  text-transform: uppercase;
  letter-spacing: .07em;
  padding: .15rem .3rem;
}

.nnt-badge {
  display: inline-block;
  font-size: .59rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: .08rem .32rem;
  border-radius: 4px;
  margin-left: .25rem;
  flex-shrink: 0;
}
/* In dropdowns, push badge to right */
.nnt-dd-item .nnt-badge { margin-left: auto; }

.nnt-badge-new       { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.nnt-badge-private   { background: #ede9fe; color: #6d28d9; border: 1px solid #c4b5fd; }
.nnt-badge-unused    { background: #f1f5f9; color: #475569; border: 1px solid #cbd5e1; }
.nnt-badge-incorrect { background: #fee2e2; color: #b91c1c; border: 1px solid #fca5a5; }
.nnt-badge-marked    { background: #fef9c3; color: #854d0e; border: 1px solid #fde047; }

/* ── Actions (right side) ───────────────────────────────────────────────── */
.nnt-actions {
  display: flex;
  align-items: center;
  gap: .45rem;
  margin-left: auto;
  flex-shrink: 0;
}

.nnt-search-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  border: 1px solid var(--nnt-border);
  border-radius: 8px;
  background: transparent;
  color: var(--nnt-muted);
  font-size: .88rem;
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
  outline: none;
}

.nnt-search-btn:hover {
  background: var(--nnt-hover-bg);
  color: var(--nnt-brand);
  border-color: #a7f3d0;
}

.nnt-search-btn:focus-visible {
  outline: 2px solid var(--nnt-brand);
  outline-offset: 2px;
}

.nnt-cta-btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .42rem .88rem;
  background: var(--nnt-brand);
  color: #fff !important;
  border: none;
  border-radius: 8px;
  font-size: .81rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: background .13s, box-shadow .13s;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(15,118,110,.3);
  outline: none;
  line-height: 1;
}

.nnt-cta-btn:hover { background: var(--nnt-brand-dark); box-shadow: 0 2px 8px rgba(15,118,110,.35); }
.nnt-cta-btn:focus-visible { outline: 2px solid var(--nnt-brand); outline-offset: 2px; }

.nnt-btn-secondary {
  background: #f1f5f9;
  color: var(--nnt-text) !important;
  box-shadow: none;
  border: 1px solid var(--nnt-border);
}
.nnt-btn-secondary:hover { background: #e2e8f0; color: var(--nnt-navy) !important; box-shadow: none; }

.nnt-btn-icon {
  background: transparent;
  color: var(--nnt-muted) !important;
  border: 1px solid var(--nnt-border);
  padding: .42rem .65rem;
  box-shadow: none;
}
.nnt-btn-icon:hover { background: var(--nnt-hover-bg); color: var(--nnt-brand) !important; box-shadow: none; }

/* ── Hamburger ──────────────────────────────────────────────────────────── */
.nnt-hamburger {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 36px; height: 36px;
  background: transparent;
  border: 1px solid var(--nnt-border);
  border-radius: 8px;
  cursor: pointer;
  padding: 0;
  transition: background .12s;
  outline: none;
}

.nnt-hamburger span {
  display: block;
  width: 16px; height: 1.5px;
  background: var(--nnt-text);
  border-radius: 2px;
  transition: transform .22s cubic-bezier(.4,0,.2,1), opacity .22s;
  transform-origin: center;
}

.nnt-hamburger.open span:nth-child(1) { transform: translateY(5.5px) rotate(45deg); }
.nnt-hamburger.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.nnt-hamburger.open span:nth-child(3) { transform: translateY(-5.5px) rotate(-45deg); }

.nnt-hamburger:hover { background: #f1f5f9; }
.nnt-hamburger:focus-visible { outline: 2px solid var(--nnt-brand); outline-offset: 2px; }

/* ── Mobile menu ────────────────────────────────────────────────────────── */
.nnt-mob-menu {
  position: fixed;
  top: var(--nnt-h);
  left: 0; right: 0;
  background: #fff;
  border-bottom: 1px solid var(--nnt-border);
  box-shadow: 0 8px 32px rgba(0,0,0,.12);
  z-index: calc(var(--nnt-z) - 1);
  max-height: calc(100dvh - var(--nnt-h));
  overflow-y: auto;
  transform: translateY(-10px);
  opacity: 0;
  pointer-events: none;
  transition: transform .22s cubic-bezier(.4,0,.2,1), opacity .22s;
  -webkit-overflow-scrolling: touch;
}

.nnt-mob-menu.open {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.nnt-mob-inner {
  padding: .6rem .65rem 1.25rem;
}

.nnt-mob-item {
  border-radius: 9px;
  overflow: hidden;
  margin-bottom: 1px;
}

.nnt-mob-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .65rem .8rem;
  border-radius: 8px;
  color: var(--nnt-text);
  font-size: .9rem;
  font-weight: 500;
  text-decoration: none;
  transition: background .12s, color .12s;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.nnt-mob-link-left { display: flex; align-items: center; gap: .55rem; }
.nnt-mob-link-left i { font-size: .82rem; color: var(--nnt-muted); width: 16px; text-align: center; }

.nnt-mob-link:hover,
.nnt-mob-link:focus-visible { background: var(--nnt-hover-bg); color: var(--nnt-brand); }
.nnt-mob-link:hover i,
.nnt-mob-link:focus-visible i { color: var(--nnt-brand); }

.nnt-mob-arrow {
  font-size: .62rem;
  color: var(--nnt-muted);
  transition: transform .2s;
  flex-shrink: 0;
}

.nnt-mob-item.open .nnt-mob-arrow { transform: rotate(180deg); color: var(--nnt-brand); }
.nnt-mob-item.open > .nnt-mob-link { color: var(--nnt-brand); background: var(--nnt-hover-bg); }

.nnt-mob-sub {
  display: none;
  padding: .15rem .5rem .35rem 2.25rem;
  border-left: 2px solid #e2e8f0;
  margin-left: 1.4rem;
  margin-bottom: .2rem;
}

.nnt-mob-item.open > .nnt-mob-sub { display: block; }

.nnt-mob-sub-item {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .48rem .65rem;
  border-radius: 7px;
  color: var(--nnt-muted);
  font-size: .845rem;
  text-decoration: none;
  transition: background .11s, color .11s;
  -webkit-tap-highlight-color: transparent;
}
.nnt-mob-sub-item i { font-size: .75rem; width: 14px; text-align: center; }
.nnt-mob-sub-item:hover { background: var(--nnt-hover-bg); color: var(--nnt-brand); }

.nnt-mob-divider {
  height: 1px;
  background: var(--nnt-border);
  margin: .5rem .2rem;
}

.nnt-mob-footer {
  padding-top: .85rem;
  border-top: 1px solid var(--nnt-border);
  margin-top: .5rem;
  display: flex;
  flex-direction: column;
  gap: .45rem;
}

.nnt-mob-footer .nnt-cta-btn {
  width: 100%;
  justify-content: center;
  padding: .7rem 1rem;
  font-size: .88rem;
}

/* ── Mobile backdrop ───────────────────────────────────────────────────── */
.nnt-mob-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.3);
  z-index: calc(var(--nnt-z) - 2);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  cursor: pointer;
}

.nnt-mob-backdrop.open { display: block; }
body.nnt-mob-open { overflow: hidden; }

/* ── Search overlay ─────────────────────────────────────────────────────── */
.nnt-search-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.55);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  z-index: calc(var(--nnt-z) + 10);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 5rem 1rem 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s;
}

.nnt-search-overlay.open { opacity: 1; pointer-events: auto; }

.nnt-search-inner {
  width: 100%;
  max-width: 620px;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,.22), 0 4px 16px rgba(0,0,0,.1);
  overflow: hidden;
  transform: translateY(-20px);
  transition: transform .2s cubic-bezier(.4,0,.2,1);
}

.nnt-search-overlay.open .nnt-search-inner { transform: translateY(0); }

.nnt-search-bar {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .9rem 1.1rem;
  border-bottom: 1px solid var(--nnt-border);
}

.nnt-search-icon { color: #475569; font-size: .95rem; flex-shrink: 0; }

.nnt-search-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: .97rem;
  color: #0f172a;
  background: transparent;
  font-family: inherit;
}

.nnt-search-input::placeholder { color: #475569; }

.nnt-search-close {
  width: 28px; height: 28px;
  background: #f1f5f9;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  color: #334155;
  display: flex; align-items: center; justify-content: center;
  transition: background .12s;
  font-size: .82rem;
  flex-shrink: 0;
}
.nnt-search-close:hover { background: #e2e8f0; }

.nnt-search-results { padding: .35rem; max-height: 360px; overflow-y: auto; }

.nnt-result-item {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .55rem .75rem;
  border-radius: 8px;
  text-decoration: none;
  transition: background .1s;
  cursor: pointer;
  outline: none;
}
.nnt-result-item:hover,
.nnt-result-item:focus-visible { background: #f8fafc; }

.nnt-result-icon {
  width: 32px; height: 32px;
  background: var(--nnt-hover-bg);
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  color: var(--nnt-brand);
  font-size: .78rem;
  flex-shrink: 0;
}

.nnt-result-text { flex: 1; min-width: 0; }
.nnt-result-label { font-size: .84rem; font-weight: 500; color: #0f172a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nnt-result-sub { font-size: .73rem; color: #475569; margin-top: .1rem; }

.nnt-result-type {
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #475569;
  background: #f8fafc;
  padding: .13rem .38rem;
  border-radius: 4px;
  border: 1px solid var(--nnt-border);
  flex-shrink: 0;
  letter-spacing: .04em;
}

.nnt-no-results {
  padding: 1.75rem;
  text-align: center;
  color: #475569;
  font-size: .875rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
}
.nnt-no-results i { font-size: 1.5rem; opacity: .4; }

.nnt-search-tips {
  display: flex;
  gap: 1.25rem;
  padding: .55rem 1.1rem;
  border-top: 1px solid var(--nnt-border);
  background: #f8fafc;
}

.nnt-search-tips span { font-size: .72rem; color: #475569; }

.nnt-search-tips kbd {
  display: inline-block;
  padding: .08rem .28rem;
  background: #fff;
  border: 1px solid var(--nnt-border);
  border-bottom-width: 2px;
  border-radius: 4px;
  font-size: .68rem;
  color: #475569;
  font-family: monospace;
}

/* ── Responsive breakpoints ─────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .nnt-inner { padding: 0 1rem; }
  .nnt-logo { margin-right: 1.25rem; }
  .nnt-link { padding: .38rem .48rem; font-size: .8rem; }
}

@media (max-width: 880px) {
  .nnt-nav { display: none; }
  .nnt-hamburger { display: flex; }
}

@media (max-width: 600px) {
  .nnt-logo-name { font-size: .8rem; }
  .nnt-cta-btn.nnt-hide-mobile { display: none; }
  .nnt-search-overlay {
    padding: 0;
    align-items: flex-start;
  }
  .nnt-search-inner {
    border-radius: 0 0 14px 14px;
    max-width: 100%;
  }
}

/* ── Mobile horizontal-overflow fix ──────────────────────────────────────
   A flex item's default `min-width: auto` refuses to shrink below its
   intrinsic content width. The search <input> carries a browser-default
   intrinsic width (~432px), which inflated .nnt-search-bar →
   .nnt-search-inner → .nnt-search-overlay to 554px. Because the overlay is
   position:fixed and wider than the viewport, it dragged the whole
   document's scroll width with it: at a 375px viewport, body.scrollWidth
   measured 554px and every page scrolled sideways on a phone.

   Allowing these flex items to shrink is the actual fix; the 100vw caps
   are belt-and-braces so no future wide child can reintroduce it. */
.nnt-search-input,
.nnt-search-bar,
.nnt-search-inner,
.nnt-inner,
.nnt-mob-menu {
  min-width: 0;
}

.nnt-search-overlay,
.nnt-mob-menu,
.neo-topnav {
  max-width: 100vw;
}

.nnt-search-results {
  overflow-x: hidden;
}

/* Result-count line above search results — tells the learner how much exists
   on the topic across content types, not just what fits in the dropdown. */
.nnt-result-summary {
  padding: .5rem .9rem;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--nnt-brand, #0f766e);
  border-bottom: 1px solid var(--nnt-border, #e2e8f0);
  background: #f8fafc;
}
