/* ══════════════════════════════════════════════════════════════════
   nav.css  —  Shared Global Navigation Bar
   Edit this ONE file; all pages pick it up automatically.
   ══════════════════════════════════════════════════════════════════ */

/* ── Global cursor rules ────────────────────────────────────────── */
a, button, [role="button"], label[for] { cursor: pointer; }

/* ── Buttons — single canonical definition ───────────────────────── */
.btn-primary {
  display: inline-flex; align-items: center; gap: 8px;
  height: 48px; padding: 0 24px;
  background: var(--buidl-blue); color: #ffffff;
  border: none; border-radius: 8px; cursor: pointer;
  font-family: inherit; font-variation-settings: "wght" 600;
  font-size: 16px; letter-spacing: 0; white-space: nowrap;
  text-decoration: none;
  transition: background 0.2s;
}
.btn-primary:hover { background: #3a67f5; }
.btn-secondary {
  display: inline-flex; align-items: center; gap: 8px;
  height: 48px; padding: 0 24px;
  background: transparent; color: var(--ink);
  border: 1px solid var(--hairline-dark); border-radius: 8px; cursor: pointer;
  font-family: inherit; font-variation-settings: "wght" 600;
  font-size: 16px; letter-spacing: 0; white-space: nowrap;
  text-decoration: none;
  transition: background 0.2s, border-color 0.2s;
}
.btn-secondary:hover { background: rgba(255,255,255,0.06); border-color: var(--ink-faint); }

/* Hero variants — pill shape, on-dark colours */
.hero .btn-primary { border-radius: 9999px; }
.hero .btn-primary:hover { background: #3a67f5; }
.hero .btn-secondary {
  color: var(--on-primary);
  border: 1px solid rgba(255,255,255,0.24);
  border-radius: 9999px;
}
.hero .btn-secondary:hover { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.4); }

/* ── Hero edge fades — right, top, bottom only ──────────────────── */
/* Left side is already handled by ::before text-readability gradient */
/* Right fade: image dissolves before hitting card boundary           */
.hero::after,
.cm-hero::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to left,   black 0%, transparent 30%),
    linear-gradient(to bottom, black 0%, transparent 16%),
    linear-gradient(to top,    black 0%, transparent 16%);
  z-index: 0;
  pointer-events: none;
}

/* ── Hero container: aligned with section container at all widths ── */
/* Mirrors .container (max-width:1080px, padding:0 32px) so hero text */
/* starts at exactly the same x-offset as the sections below.         */
.hero .container,
.cm-hero .container {
  max-width: 100%;
  margin: 0;
  padding-left:  max(32px, calc((100vw - 1080px) / 2 + 32px));
  padding-right: max(32px, calc((100vw - 1080px) / 2 + 32px));
}
/* Match .container responsive padding — same specificity, after base rule */
@media (max-width: 768px) {
  .hero .container,
  .cm-hero .container { padding-left: 20px; padding-right: 20px; }
}
@media (max-width: 480px) {
  .hero .container,
  .cm-hero .container { padding-left: 16px; padding-right: 16px; }
}

/* ── Floating glass bar ─────────────────────────────────────────── */
nav {
  position: fixed;
  top: 12px;
  left: 50%; transform: translateX(-50%);
  width: calc(100% - 24px); max-width: 1280px;
  z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 20px;
  background: hsla(0, 0%, 60%, .15);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  border-radius: 0;
  color: var(--on-primary);
  border: 1px solid rgba(255, 255, 255, 0.13);
  box-shadow:
    0 -1px 0 0 rgba(255,255,255,0.04) inset,
    0 8px 32px rgba(0, 0, 0, 0.55),
    0 1px 2px rgba(0, 0, 0, 0.7);
}

/* ── Logo ───────────────────────────────────────────────────────── */
.nav-logo {
  display: inline-flex; align-items: center;
  flex-shrink: 0; line-height: 0;
}
.nav-logo-full { height: 20px; width: auto; }
.nav-logo-mark, .footer-logo-mark { display: none; }

/* ── Link list ──────────────────────────────────────────────────── */
.nav-links { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }

.nav-item {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 6px 12px; border-radius: 8px;
  min-height: 36px; min-width: 56px;
  text-decoration: none;
  opacity: 0.6;
  transition: background 0.18s, opacity 0.18s;
  /* Prevent hover-trail paint artifacts caused by parent nav's
     backdrop-filter, while keeping text on the CPU layer to avoid
     sub-pixel font doubling during opacity/height transitions. */
  isolation: isolate;
}
.nav-item:hover { background: rgba(255,255,255,0.06); opacity: 1; }

.nav-verb {
  font-family: inherit; font-variation-settings: "wght" 540;
  font-size: 13px; color: var(--on-dark-mute);
  letter-spacing: 0;
  transition: color 0.18s;
  white-space: nowrap; line-height: 1.2;
}
.nav-item:hover .nav-verb { color: var(--on-primary); }
.nav-item.active .nav-verb { color: var(--on-primary); }
.nav-item.active { opacity: 1; }

.nav-expand {
  font-family: inherit; font-variation-settings: "wght" 460;
  font-size: 10px; color: var(--on-dark-faint);
  letter-spacing: 0; white-space: nowrap;
  opacity: 0; max-height: 0; overflow: hidden;
  transition: opacity 0.18s ease, max-height 0.18s ease;
  text-align: center; line-height: 1.4;
  /* Prevent sub-pixel font doubling during opacity/height transitions */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.nav-item:hover .nav-expand { opacity: 1; max-height: 16px; margin-top: 2px; }
.nav-item .nav-expand:empty { display: none; }

/* ── CTA pill (hidden by default; visible on home via JS) ───────── */
.nav-cta { display: none !important; }
.nav-cta:hover { background: #3a67f5 !important; }
.nav-cta .nav-verb { color: #ffffff !important; font-variation-settings: "wght" 600; font-size: 13px; letter-spacing: 0; }
.nav-cta .nav-expand { display: none !important; }

/* ── External link icon ─────────────────────────────────────────── */
.ext-icon {
  font-size: 9px; color: var(--on-dark-faint);
  margin-left: 3px; vertical-align: 1px;
  font-family: inherit;
}
.nav-item:hover .ext-icon { color: var(--on-primary); }

/* ── Apps dropdown ──────────────────────────────────────────────── */
.nav-dropdown-trigger {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 36px; min-width: 56px; text-decoration: none;
}
.nav-dropdown-trigger .nav-verb { color: var(--on-dark-mute); transition: color 0.18s; }
.nav-dropdown:hover .nav-dropdown-trigger .nav-verb,
.nav-dropdown:focus-within .nav-dropdown-trigger .nav-verb { color: var(--on-primary); }
.nav-dropdown.active .nav-dropdown-trigger .nav-verb { color: var(--on-primary); }

.nav-dropdown { position: relative; cursor: pointer; }
.dropdown-menu {
  display: none;
  position: absolute; top: calc(100% + 8px); right: 0;
  background: var(--canvas-soft);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  min-width: 160px; padding: 8px; z-index: 200;
  box-shadow: 0 8px 32px rgba(0,0,0,0.55);
}
.dropdown-menu::before {
  content: ''; position: absolute; top: -8px; left: 0; right: 0; height: 8px; background: transparent;
}
.nav-dropdown:hover .dropdown-menu,
.nav-dropdown:focus .dropdown-menu,
.nav-dropdown:focus-within .dropdown-menu { display: flex; flex-direction: column; }
.dropdown-item {
  display: flex; align-items: center; justify-content: flex-start;
  padding: 10px 14px; border-radius: 8px;
  font-family: inherit; font-variation-settings: "wght" 540;
  font-size: 13px; color: var(--on-dark-mute);
  letter-spacing: 0;
  transition: background 0.15s, color 0.15s;
  text-decoration: none; gap: 2px;
}
.dropdown-item .ext-icon { color: var(--on-dark-faint); font-size: 11px; transition: color 0.15s; }
.dropdown-item:hover .ext-icon { color: var(--violet-soft); }
.dropdown-item:hover { background: rgba(255,255,255,0.06); color: var(--on-primary); }

/* ── Hamburger button ───────────────────────────────────────────── */
.nav-burger {
  display: none;
  flex-direction: column; justify-content: center; align-items: center;
  gap: 5px; width: 36px; height: 36px;
  background: none; border: none; cursor: pointer;
  border-radius: 8px; padding: 0;
  transition: background 0.18s;
}
.nav-burger:hover { background: rgba(255,255,255,0.14); }
.nav-burger span {
  display: block; width: 18px; height: 1.5px;
  background: var(--on-primary);
  border-radius: 2px;
  transition: transform 0.22s, opacity 0.22s, width 0.22s;
  transform-origin: center;
}
.nav-burger.open span:nth-child(1) { transform: translateY(6.5px) rotate(45deg); }
.nav-burger.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.nav-burger.open span:nth-child(3) { transform: translateY(-6.5px) rotate(-45deg); }

/* ── Mobile full-screen overlay menu ───────────────────────────── */
.nav-mobile-menu {
  display: flex;                              /* always in flow; hidden via opacity */
  position: fixed; inset: 0;
  z-index: 99;
  flex-direction: column; align-items: flex-start; justify-content: flex-start;
  padding: 88px 28px max(48px, env(safe-area-inset-bottom, 48px));
  background: rgba(8, 10, 13, 0.98);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  overflow-y: auto;
  /* Hidden state */
  opacity: 0;
  pointer-events: none;
  transform: translateY(-10px);
  transition: opacity 0.22s ease, transform 0.22s ease;
}
.nav-mobile-menu.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.nav-mobile-link {
  display: flex; align-items: center; justify-content: space-between;
  font-family: inherit; font-variation-settings: "wght" 600;
  font-size: 16px; color: rgba(255,255,255,0.5);
  letter-spacing: -0.2px; line-height: 1.25;
  text-decoration: none;
  padding: 14px 0;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  width: 100%;
  transition: color 0.15s;
}
.nav-mobile-link:last-child { border-bottom: none; }
.nav-mobile-link:hover, .nav-mobile-link:active { color: var(--on-primary); }
.nav-mobile-link.active {
  color: var(--on-primary);
  font-variation-settings: "wght" 700;
}
/* Chevron for internal links */
.nav-mobile-link:not([target="_blank"])::after {
  content: '›';
  font-size: 24px; font-variation-settings: "wght" 300;
  color: rgba(255,255,255,0.15);
  flex-shrink: 0;
  transition: transform 0.15s, color 0.15s;
}
.nav-mobile-link:hover:not([target="_blank"])::after { transform: translateX(4px); color: rgba(255,255,255,0.4); }
.nav-mobile-link.active::after { color: rgba(255,255,255,0.4); }
/* External icon injected inline via JS — no ::after needed */

/* ── Floating CTA pill (mobile, home page only) ─────────────────── */
.floating-cta {
  display: none;           /* hidden by default; shown on mobile via media query */
  position: fixed;
  bottom: 28px; left: 50%;
  transform: translateX(-50%);
  z-index: 98;
  background: rgba(18, 20, 24, 0.72);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow:
    0 1px 0 0 rgba(255,255,255,0.18) inset,
    0 8px 32px rgba(0,0,0,0.55),
    0 2px 8px rgba(0,0,0,0.3);
  color: rgba(255,255,255,0.92);
  padding: 14px 32px;
  border-radius: 9999px;
  font-family: inherit; font-variation-settings: "wght" 600;
  font-size: 15px; white-space: nowrap;
  transition: background 0.2s, border-color 0.2s, opacity 0.22s, transform 0.22s;
}
.floating-cta:hover {
  background: rgba(30, 34, 42, 0.82);
  border-color: rgba(255,255,255,0.28);
}
.floating-cta.hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(64px);
  pointer-events: none;
}

/* ── Mobile overrides ───────────────────────────────────────────── */
@media (max-width: 1060px) {
  nav {
    top: 8px; left: 8px; right: 8px;
    width: auto;
    transform: none;
    padding: 10px 16px;
    border-radius: 12px;              /* restore floating pill look */
  }
  .nav-links { display: none; }
  .nav-burger { display: flex !important; }
  .nav-logo-full, .footer-logo-full { display: none; }
  .nav-logo-mark, .footer-logo-mark { display: inline-block; height: 24px; width: auto; }
  .floating-cta { display: inline-flex !important; align-items: center; gap: 8px; padding: 12px 22px; font-size: 14px; }
}

/* ── Apps section (always expanded) ─────────────────────────────── */
.nav-mobile-section { width: 100%; }
.nav-mobile-section.active .nav-mobile-section-label { color: var(--on-primary); font-variation-settings: "wght" 700; }

/* ── Mobile sub-items (Apps dropdown children) ──────────────────── */
.nav-mobile-sub {
  display: flex; align-items: center; justify-content: space-between;
  font-family: inherit; font-variation-settings: "wght" 500;
  font-size: 14px; color: rgba(255,255,255,0.32);
  letter-spacing: -0.1px; line-height: 1.25;
  text-decoration: none;
  padding: 11px 0 11px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  width: 100%;
  transition: color 0.15s;
}
.nav-mobile-sub:hover, .nav-mobile-sub:active { color: rgba(255,255,255,0.75); }

/* ── Footer active link ─────────────────────────────────────────── */
.footer-link-active { color: #ffffff !important; font-variation-settings: "wght" 600 !important; }

/* ── Global section typography spacing ──────────────────────────── */
/* Overrides per-page inline styles — gives sections more breathing room */
.section-label { margin-bottom: 24px !important; }
.section-title { margin-bottom: 32px !important; }
.section-sub   { margin-bottom: 0; }

/* Mobile: tighter typography — avoids excess whitespace on small screens */
@media (max-width: 768px) {
  .section-label { margin-bottom: 14px !important; }
  .section-title { margin-bottom: 20px !important; }
}

/* ── Footer brand: hide entirely below 1024px (more room for menus) */
@media (max-width: 1024px) {
  .footer-brand { display: none !important; }
  .footer-grid { grid-template-columns: repeat(3, 1fr) !important; }
}


/* ── Footer Apps sub-group ──────────────────────────────────────── */
.footer-sub-label {
  list-style: none;
  font-variation-settings: "wght" 540;
  font-size: 12px; color: rgba(255,255,255,0.25);
  letter-spacing: 0.06em; text-transform: uppercase;
  margin-top: 12px; margin-bottom: 2px;
  padding-left: 0;
}
.footer-sub-label a { color: inherit; text-decoration: none; transition: color 0.15s; }
.footer-sub-label a:hover { color: rgba(255,255,255,0.6); }
.footer-sub-item { padding-left: 10px; }

/* ── Respect reduced-motion system preference ───────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
