/* Nav micro-animations: sliding active pill, eased anchor scroll arrival,
   animated mobile menu + hamburger morph. Colours/radii from styles.css tokens. */

/* ---- Sliding pill ---- */
.nav.has-pill a.link.active { background: transparent; color: var(--line); }
.nav.has-pill a.link { position: relative; z-index: 1; transition: color .25s ease-out, transform .15s ease-out; }
.nav.has-pill a.link.pill-on { color: var(--ink); }
.nav.has-pill a.link:active { transform: scale(.94); }
.nav-pill {
  position: absolute; top: 0; left: 0; height: 0; width: 0; z-index: 0; pointer-events: none;
  background: #fff; border-radius: var(--radius-lg);
  box-shadow: 0 2px 8px rgba(15, 23, 42, .18);
  opacity: 0;
  transition: transform .45s cubic-bezier(.22, 1, .36, 1), width .45s cubic-bezier(.22, 1, .36, 1), height .3s ease-out, opacity .25s ease-out;
}
.nav-pill.show { opacity: 1; }
.nav-pill.bump { animation: pill-bump .35s ease-out; }
@keyframes pill-bump { 40% { box-shadow: 0 0 0 4px rgba(20, 184, 166, .35); } }

/* ---- Arrival highlight on the target section ---- */
.arrived .eyebrow { animation: eyebrow-pop .7s cubic-bezier(.22, 1, .36, 1); }
.arrived .eyebrow .dot { animation: dot-spin .7s cubic-bezier(.22, 1, .36, 1); }
.arrived .section-head h2 { position: relative; }
.arrived .section-head h2::after {
  content: ""; position: absolute; left: 50%; bottom: -10px; height: 3px; width: 72px; translate: -50% 0;
  background: var(--teal-bright); border-radius: 99px; transform-origin: left center;
  animation: underline-sweep 1.3s cubic-bezier(.22, 1, .36, 1) forwards;
}
.faq .arrived-host .section-head h2::after, .faq.arrived .section-head h2::after { left: 0; translate: 0 0; }
@keyframes eyebrow-pop { 0% { transform: scale(.9); } 50% { transform: scale(1.06); box-shadow: 0 0 0 6px rgba(20, 184, 166, .15); } 100% { transform: none; } }
@keyframes dot-spin { from { transform: rotate(-120deg) scale(.6); } }
@keyframes underline-sweep { 0% { transform: scaleX(0); opacity: 1; } 55% { transform: scaleX(1); opacity: 1; } 100% { transform: scaleX(1); opacity: 0; } }

/* ---- Hamburger → X ---- */
.nav-toggle.burger { width: 44px; height: 44px; position: relative; }
.nav-toggle.burger span {
  position: absolute; left: 12px; right: 12px; height: 2px; background: currentColor; border-radius: 2px;
  transition: transform .35s cubic-bezier(.22, 1, .36, 1), opacity .2s ease-out, top .35s cubic-bezier(.22, 1, .36, 1);
}
.nav-toggle.burger span:nth-child(1) { top: 15px; }
.nav-toggle.burger span:nth-child(2) { top: 21px; }
.nav-toggle.burger span:nth-child(3) { top: 27px; }
.nav-toggle.burger[aria-expanded="true"] span:nth-child(1) { top: 21px; transform: rotate(45deg); }
.nav-toggle.burger[aria-expanded="true"] span:nth-child(2) { opacity: 0; transform: scaleX(.2); }
.nav-toggle.burger[aria-expanded="true"] span:nth-child(3) { top: 21px; transform: rotate(-45deg); }

/* ---- Animated mobile menu ---- */
.mobile-menu {
  display: block; visibility: hidden; opacity: 0; pointer-events: none;
  transform: translateY(-10px) scale(.97); transform-origin: top center;
  transition: opacity .25s ease-out, transform .35s cubic-bezier(.22, 1, .36, 1), visibility 0s linear .35s;
}
.mobile-menu.open {
  visibility: visible; opacity: 1; pointer-events: auto; transform: none;
  transition: opacity .25s ease-out, transform .35s cubic-bezier(.22, 1, .36, 1), visibility 0s;
}
.mobile-menu a { opacity: 0; transform: translateX(-12px); transition: opacity .3s ease-out, transform .35s cubic-bezier(.22, 1, .36, 1), background .2s; }
.mobile-menu.open a { opacity: 1; transform: none; transition-delay: calc(var(--mi, 0) * 45ms + 60ms), calc(var(--mi, 0) * 45ms + 60ms), 0s; }
.mobile-menu a:active { transform: scale(.98); }
@media (min-width: 721px) { .mobile-menu { display: none; } }

@media (prefers-reduced-motion: reduce) {
  .nav-pill, .mobile-menu, .mobile-menu a, .nav-toggle.burger span { transition: none !important; }
  .arrived .eyebrow, .arrived .eyebrow .dot, .arrived .section-head h2::after { animation: none !important; }
}

/* ---- Log in (web portal) ---- */
.nav { width: min(900px, calc(100% - 32px)); }
.nav-login {
  display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 14px;
  color: #fff; font-size: 14px; font-weight: 500; border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, .18); transition: background .2s, border-color .2s, transform .15s ease-out;
}
.nav-login .icon { width: 15px; height: 15px; transition: transform .3s cubic-bezier(.22, 1, .36, 1); }
/* Hover matches the "How it works" link: white background, dark label and lock icon (#44).
   Only colours change, so the 1px border keeps the button's size and position stable. */
.nav-login { transition: background .2s, border-color .2s, color .2s, transform .15s ease-out; }
.nav-login:hover { background: #fff; border-color: #fff; color: var(--ink); }
.nav-login:hover .icon { transform: translateY(-1px) rotate(-8deg); }
.nav-login:active { transform: scale(.95); }
.mobile-menu a.mm-login { display: flex; align-items: center; gap: 8px; margin-top: 6px; border: 1px solid rgba(255, 255, 255, .14); }
.mobile-menu a.mm-login .icon { width: 16px; height: 16px; }
@media (max-width: 720px) { .nav-login { display: none; } }

/* ---- Even inner spacing: 8px on every side ---- */
.nav { padding: 8px; }
.nav .brand { height: 40px; }

/* ---- Equal gaps between Pricing, Log in and Get started ---- */
.nav-side.right { gap: 8px; }

/* ---------- Dropdowns: Resources / Company ---------- */
.nav .dd { position: relative; }
.dd-trigger {
  display: inline-flex; align-items: center; gap: 4px; height: 40px; padding: 0 12px; border: 0; background: none;
  color: var(--line); font-size: 14px; border-radius: var(--radius-lg); transition: color .2s, background .2s;
}
.dd-trigger:hover, .dd.open .dd-trigger { color: #fff; background: rgba(255, 255, 255, .08); }
.dd-trigger .chev { width: 14px; height: 14px; transition: transform .3s cubic-bezier(.22, 1, .36, 1); }
.dd.open .dd-trigger .chev { transform: rotate(180deg); }
.dd-panel {
  position: absolute; top: calc(100% + 14px); left: 50%; min-width: 290px; padding: 8px; z-index: 60;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  opacity: 0; visibility: hidden; transform: translate(-50%, -6px) scale(.97); transform-origin: top center;
  transition: opacity .2s ease-out, transform .3s cubic-bezier(.22, 1, .36, 1), visibility 0s linear .3s;
}
.dd-panel::before { /* hover bridge so the panel doesn't close crossing the gap */
  content: ""; position: absolute; left: 0; right: 0; top: -16px; height: 16px;
}
.dd.open .dd-panel { opacity: 1; visibility: visible; transform: translate(-50%, 0) scale(1); transition-delay: 0s; }
.dd-item {
  display: flex; gap: 12px; align-items: flex-start; padding: 10px; border-radius: var(--radius); color: var(--ink);
  opacity: 0; transform: translateY(-4px); transition: background .2s, opacity .25s ease-out, transform .3s cubic-bezier(.22, 1, .36, 1);
}
.dd.open .dd-item { opacity: 1; transform: none; }
.dd.open .dd-item:nth-child(2) { transition-delay: 0s, 40ms, 40ms; }
.dd.open .dd-item:nth-child(3) { transition-delay: 0s, 80ms, 80ms; }
.dd-item:hover, .dd-item:focus-visible { background: var(--surface); }
.dd-item b { display: block; font-size: 14px; font-weight: 600; }
.dd-item small { display: block; font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.dd-ic { width: 34px; height: 34px; flex: none; border-radius: var(--radius); display: grid; place-items: center; background: var(--ok-bg); color: var(--ok-text); transition: transform .3s cubic-bezier(.22, 1, .36, 1); }
.dd-ic .icon { width: 17px; height: 17px; }
.dd-item:hover .dd-ic { transform: scale(1.08) rotate(-4deg); }
.mobile-menu .mm-group { display: block; padding: 14px 14px 4px; font-size: 11.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--mint); opacity: .85; }
@media (max-width: 720px) { .nav .dd { display: none; } }
@media (prefers-reduced-motion: reduce) { .dd-panel, .dd-item, .dd-trigger .chev { transition: none !important; } }

/* Integrations dropdown: brand logos in the icon tile; left-side panel aligns left */
.dd-ic.dd-logo { background: var(--bg-soft); border: 1px solid var(--line); }
.dd-ic.dd-logo img { width: 22px; height: 22px; object-fit: contain; }
.nav-side:not(.right) .dd-panel { left: 0; transform: translate(0, -6px) scale(.97); transform-origin: top left; }
.nav-side:not(.right) .dd.open .dd-panel { transform: none; }
.nav { width: min(980px, calc(100% - 32px)); }
.nav-side { gap: 2px; }
@media (max-width: 1000px) { .dd-trigger, .nav a.link { padding-left: 9px; padding-right: 9px; } .nav-login { padding: 0 10px; } }
@media (max-width: 860px) { .nav-login { display: none; } }
.dd-item.is-current { background: var(--ok-bg); }
.dd-sep { display: block; height: 1px; background: var(--line); margin: 6px 10px; }
.dd.open .dd-item:nth-child(n+4) { transition-delay: 0s, 120ms, 120ms; }

/* Integrations dropdown: grouped, two-column on wide screens */
.dd-group { display: block; padding: 8px 10px 4px; font-size: 11px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.dd-panel.dd-wide { min-width: 340px; max-height: calc(100vh - 110px); overflow-y: auto; }
.dd-ic.dd-abr { font-size: 10.5px; font-weight: 800; letter-spacing: .02em; color: var(--teal); }
.dd-ic.dd-logo svg { width: 18px; height: 18px; }
.dd.open .dd-item:nth-child(n+6) { transition-delay: 0s, 160ms, 160ms; }

/* ---- Balanced layout: logo dead-centre, each side spread evenly across its half ---- */
@media (min-width: 721px) {
  .nav { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; column-gap: 20px; }
  .nav .brand { margin: 0; }
  .nav-side { flex: none; justify-content: space-between; gap: 2px; min-width: 0; }
  .nav-side.right { justify-content: space-between; }
}
@media (min-width: 1061px) {
  .nav { width: min(1040px, calc(100% - 32px)); }
  .nav-side:not(.right) a.link, .nav-side:not(.right) .dd-trigger { padding-left: 17px; padding-right: 17px; }
}

/* ---- Mobile: logo dead-centre, menu button right; the empty left column mirrors it ---- */
@media (max-width: 720px) {
  .nav { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; }
  .nav-side { flex: none; min-width: 0; }
  .nav-side.right { justify-content: flex-end; }
  .nav .brand { margin: 0; }
}

/* ---- Tablet (≤1080px): the full menu no longer fits, so use the ☰ menu with a centred logo ---- */
.nav a.link, .dd-trigger, .nav-login, .nav .btn { white-space: nowrap; }
@media (max-width: 1080px) {
  .nav { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; width: min(560px, calc(100% - 32px)); }
  .nav-side { flex: none; min-width: 0; justify-content: flex-start; }
  .nav-side.right { justify-content: flex-end; }
  .nav .brand { margin: 0; }
  .nav-side .link, .nav-side .btn, .nav .dd, .nav-login { display: none !important; }
  .nav-toggle { display: block; }
  .mobile-menu { display: block; left: max(16px, calc(50% - 280px)); right: max(16px, calc(50% - 280px)); }
}

/* ---- Mobile menu scrolls on its own inside the visible viewport (#45) ----
   The panel never extends past the bottom of the screen (dvh tracks Safari's
   toolbars), so every item can be reached by swiping inside it. The nav bar with
   the close button sits above it and stays put; nav.js locks the page behind. */
.mobile-menu {
  max-height: calc(100vh - 84px - 16px);
  max-height: calc(100dvh - 84px - 16px);
  overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
}
@media (max-height: 480px) {
  .mobile-menu a { padding-top: 10px; padding-bottom: 10px; }
  .mobile-menu .mm-group { padding-top: 10px; }
}
html.menu-locked, html.menu-locked body { overscroll-behavior: none; }

/* Dropdown panels never run off short (e.g. landscape) viewports; long subtitles wrap */
.dd-panel { max-height: calc(100vh - 110px); max-height: calc(100dvh - 110px); overflow-y: auto; overscroll-behavior: contain; max-width: min(360px, calc(100vw - 32px)); }
.dd-panel.dd-wide { max-width: min(380px, calc(100vw - 32px)); }
.dd-item > span:last-child { min-width: 0; }
