/* ═══════════════════════════════════════════════════════════
   Navigation + motion — JUSTART-inspired editorial UX
   ═══════════════════════════════════════════════════════════ */

:root {
  --nm-ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --nm-ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --nm-dur: 0.55s;
  --nm-line: rgba(255, 255, 255, 0.1);
  --nm-fg: rgba(255, 255, 255, 0.92);
  --nm-muted: rgba(255, 255, 255, 0.52);
  --nm-accent: #3b82f6;
  --nm-mono: "JetBrains Mono", ui-monospace, monospace;
  --nm-display: "Cabinet Grotesk", "Satoshi", system-ui, sans-serif;
}

/* Hide broken React hamburger — we drive the menu ourselves */
header button[aria-label="Menu"] {
  display: none !important;
}

/* Our toggle — fixed outside React tree (JUSTART ≡ style) */
#nm-menu-toggle {
  display: none;
  position: fixed;
  top: 18px;
  right: 16px;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(10, 12, 16, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--nm-fg);
  cursor: pointer;
  z-index: 270;
  transition: background 0.25s var(--nm-ease), border-color 0.25s var(--nm-ease), transform 0.2s var(--nm-ease);
}

#nm-menu-toggle:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.22);
}

#nm-menu-toggle:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 2px;
}

#nm-menu-toggle .nm-bars {
  width: 18px;
  height: 12px;
  position: relative;
  display: block;
}

#nm-menu-toggle .nm-bars span {
  position: absolute;
  left: 0;
  right: 0;
  height: 1.5px;
  background: currentColor;
  border-radius: 2px;
  transition: transform 0.35s var(--nm-ease), opacity 0.25s ease, top 0.35s var(--nm-ease);
}

#nm-menu-toggle .nm-bars span:nth-child(1) { top: 0; }
#nm-menu-toggle .nm-bars span:nth-child(2) { top: 5px; }
#nm-menu-toggle .nm-bars span:nth-child(3) { top: 10px; }

body.nm-nav-open #nm-menu-toggle .nm-bars span:nth-child(1) {
  top: 5px;
  transform: rotate(45deg);
}
body.nm-nav-open #nm-menu-toggle .nm-bars span:nth-child(2) {
  opacity: 0;
  transform: scaleX(0.4);
}
body.nm-nav-open #nm-menu-toggle .nm-bars span:nth-child(3) {
  top: 5px;
  transform: rotate(-45deg);
}

@media (max-width: 1023px) {
  #nm-menu-toggle { display: inline-flex; }
}

/* Global language switch — compact, in-flow on desktop, beside menu on mobile */
.site-lang-native-hide { display: none !important; }
#site-lang {
  position: relative !important;
  top: auto !important;
  right: auto !important;
  inset: auto !important;
  z-index: 6;
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 1px;
  height: 32px;
  margin: 0 8px 0 4px;
  padding: 2px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(8, 10, 14, 0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: none;
  transform: none !important;
  vertical-align: middle;
  align-self: center;
}
#site-lang.is-floating {
  position: fixed !important;
  top: 22px !important;
  right: 68px !important;
  left: auto !important;
  z-index: 240;
  margin: 0;
  height: 36px;
}
@media (max-width: 1023px) {
  #site-lang {
    position: fixed !important;
    top: 22px !important;
    right: 68px !important;
    left: auto !important;
    z-index: 240;
    margin: 0;
    height: 36px;
  }
}
#site-lang button {
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.55);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 9px;
  letter-spacing: 0.06em;
  padding: 5px 8px;
  min-width: 28px;
  border-radius: 999px;
  cursor: pointer;
  line-height: 1;
  outline: none;
  box-shadow: none;
}
#site-lang button:focus,
#site-lang button:focus-visible {
  outline: none;
  box-shadow: none;
}
#site-lang button.is-active {
  background: #fff;
  color: #0a0c10;
  box-shadow: none;
}

/* Full-screen editorial menu panel */
#nm-overlay {
  position: fixed;
  inset: 0;
  z-index: 250;
  pointer-events: none;
  visibility: hidden;
}

#nm-overlay.is-open {
  pointer-events: auto;
  visibility: visible;
}

#nm-overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 6, 10, 0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0;
  transition: opacity 0.35s var(--nm-ease);
}

#nm-overlay.is-open #nm-overlay-backdrop { opacity: 1; }

#nm-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(440px, 100%);
  height: 100%;
  background:
    linear-gradient(180deg, rgba(16, 19, 26, 0.98), rgba(8, 10, 14, 0.99));
  border-left: 1px solid var(--nm-line);
  box-shadow: -24px 0 80px rgba(0, 0, 0, 0.45);
  transform: translateX(104%);
  transition: transform 0.5s var(--nm-ease-out);
  display: flex;
  flex-direction: column;
  padding: 88px 28px 28px;
  overflow: auto;
}

#nm-overlay.is-open #nm-panel {
  transform: translateX(0);
}

#nm-panel-kicker {
  font-family: var(--nm-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(147, 197, 253, 0.8);
  margin-bottom: 18px;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.4s var(--nm-ease), transform 0.4s var(--nm-ease);
  transition-delay: 0.08s;
}

#nm-overlay.is-open #nm-panel-kicker {
  opacity: 1;
  transform: none;
}

#nm-nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  border-top: 1px solid var(--nm-line);
}

#nm-nav-list a {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  align-items: baseline;
  gap: 12px;
  padding: 16px 0;
  border-bottom: 1px solid var(--nm-line);
  color: var(--nm-fg);
  text-decoration: none;
  font-family: var(--nm-display);
  font-size: clamp(22px, 6vw, 28px);
  font-weight: 700;
  letter-spacing: -0.03em;
  opacity: 0;
  transform: translateY(18px);
  transition:
    opacity 0.45s var(--nm-ease),
    transform 0.45s var(--nm-ease),
    color 0.2s ease,
    padding-left 0.25s var(--nm-ease);
}

#nm-overlay.is-open #nm-nav-list a {
  opacity: 1;
  transform: none;
}

#nm-overlay.is-open #nm-nav-list li:nth-child(1) a { transition-delay: 0.10s; }
#nm-overlay.is-open #nm-nav-list li:nth-child(2) a { transition-delay: 0.14s; }
#nm-overlay.is-open #nm-nav-list li:nth-child(3) a { transition-delay: 0.18s; }
#nm-overlay.is-open #nm-nav-list li:nth-child(4) a { transition-delay: 0.22s; }
#nm-overlay.is-open #nm-nav-list li:nth-child(5) a { transition-delay: 0.26s; }
#nm-overlay.is-open #nm-nav-list li:nth-child(6) a { transition-delay: 0.30s; }
#nm-overlay.is-open #nm-nav-list li:nth-child(7) a { transition-delay: 0.34s; }
#nm-overlay.is-open #nm-nav-list li:nth-child(8) a { transition-delay: 0.38s; }
#nm-overlay.is-open #nm-nav-list li:nth-child(9) a { transition-delay: 0.42s; }
#nm-overlay.is-open #nm-nav-list li:nth-child(10) a { transition-delay: 0.46s; }

#nm-nav-list a:hover,
#nm-nav-list a.is-active {
  color: #fff;
  padding-left: 6px;
}

#nm-nav-list .nm-num {
  font-family: var(--nm-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--nm-accent);
  font-weight: 500;
}

#nm-nav-list .nm-arrow {
  font-family: var(--nm-mono);
  font-size: 14px;
  color: var(--nm-muted);
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity 0.25s ease, transform 0.25s var(--nm-ease);
}

#nm-nav-list a:hover .nm-arrow,
#nm-nav-list a.is-active .nm-arrow {
  opacity: 1;
  transform: none;
  color: var(--nm-accent);
}

#nm-panel-footer {
  margin-top: auto;
  padding-top: 28px;
  display: grid;
  gap: 14px;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.45s var(--nm-ease), transform 0.45s var(--nm-ease);
  transition-delay: 0.28s;
}

#nm-overlay.is-open #nm-panel-footer {
  opacity: 1;
  transform: none;
}

#nm-lang {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--nm-line);
  border-radius: 999px;
  width: fit-content;
  background: rgba(255, 255, 255, 0.03);
}

#nm-lang button {
  border: 0;
  background: transparent;
  color: var(--nm-muted);
  font-family: var(--nm-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  padding: 8px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

#nm-lang button.is-active {
  background: #fff;
  color: #0a0c10;
}

#nm-panel-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 18px;
  border-radius: 999px;
  background: var(--nm-accent);
  color: #fff;
  text-decoration: none;
  font-weight: 650;
  font-size: 14px;
  transition: background 0.2s ease, transform 0.2s var(--nm-ease);
}

#nm-panel-cta:hover {
  background: #2563eb;
  transform: translateY(-1px);
}

#nm-panel-meta {
  font-family: var(--nm-mono);
  font-size: 11px;
  color: var(--nm-muted);
  letter-spacing: 0.04em;
}

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

/* Desktop nav polish */
@media (min-width: 1024px) {
  header nav a {
    position: relative;
    transition: color 0.25s var(--nm-ease) !important;
  }
  header nav a::after {
    content: "";
    position: absolute;
    left: 14px;
    right: 14px;
    bottom: 4px;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--nm-accent), transparent);
    transform: scaleX(0);
    transform-origin: center;
    transition: transform 0.3s var(--nm-ease);
    opacity: 0.9;
  }
  header nav a:hover::after,
  header nav a[aria-current="page"]::after {
    transform: scaleX(1);
  }
}

/* ── Site-wide reveal motion (JUSTART-like) ── */
.js-nm .nm-reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.7s var(--nm-ease), transform 0.7s var(--nm-ease);
  will-change: opacity, transform;
}

.js-nm .nm-reveal.is-in {
  opacity: 1;
  transform: none;
}

.js-nm .nm-stagger > .nm-reveal:nth-child(1) { transition-delay: 0.04s; }
.js-nm .nm-stagger > .nm-reveal:nth-child(2) { transition-delay: 0.1s; }
.js-nm .nm-stagger > .nm-reveal:nth-child(3) { transition-delay: 0.16s; }
.js-nm .nm-stagger > .nm-reveal:nth-child(4) { transition-delay: 0.22s; }
.js-nm .nm-stagger > .nm-reveal:nth-child(5) { transition-delay: 0.28s; }
.js-nm .nm-stagger > .nm-reveal:nth-child(6) { transition-delay: 0.34s; }

/* Soft hover lift for interactive surfaces */
main a.glass-card,
main .glass-card,
main button.group,
.rd-card,
.rd-btn {
  transition:
    transform 0.35s var(--nm-ease),
    border-color 0.25s ease,
    background 0.25s ease,
    box-shadow 0.35s var(--nm-ease) !important;
}

@media (hover: hover) {
  .rd-card:hover,
  main a.glass-card:hover,
  main .glass-card:hover {
    transform: translateY(-3px);
  }
}

/* Page fade on hash route change */
#root.nm-route-fade {
  animation: nmRouteIn 0.45s var(--nm-ease);
}

@keyframes nmRouteIn {
  from { opacity: 0.55; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@keyframes nmFadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  #nm-panel,
  #nm-overlay-backdrop,
  #nm-nav-list a,
  #nm-panel-kicker,
  #nm-panel-footer,
  .js-nm .nm-reveal,
  #root.nm-route-fade {
    transition: none !important;
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
  #nm-menu-toggle .nm-bars span { transition: none !important; }
}
