/* ========================================================================
   Shared top-bar — used on every .ofself page (index + all narratives).
   Pair with topbar.js, which injects the markup and sets the active state.
   All colours/fonts come from tokens.css — link tokens.css BEFORE this.
   ========================================================================
*/

.top-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 200;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  background: var(--topbar-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  /* No border-bottom — when the submenu opens, topbar + submenu read
     as one continuous panel. The submenu carries its own bottom rule. */
}

.top-bar-word {
  font-family: var(--f-mono);
  font-size: 9.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(var(--cream-rgb), 0.35);
  text-decoration: none;
  border: none;
  transition: color 0.15s ease;
}
.top-bar-word:hover { color: rgba(var(--cream-rgb), 0.7); }

.top-bar-nav {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  gap: 4px;
  align-items: center;
}

.top-bar-link {
  font-family: 'Menlo', 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10.5px;
  font-weight: 400;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(var(--cream-rgb), 0.72);
  text-decoration: none;
  border: none;
  padding: 6px 12px;
  border-radius: 3px;
  transition: color 0.15s ease, background 0.15s ease;
  line-height: 1;
}
.top-bar-link:hover {
  color: rgba(var(--cream-rgb), 0.98);
  background: rgba(var(--cream-rgb), 0.08);
}
/* Active page — slightly lifted bg + full-bright text. Underline
   removed for cleaner read; the bg lift alone marks the active state. */
.top-bar-link.active {
  color: rgba(var(--cream-rgb), 1);
  background: rgba(var(--cream-rgb), 0.08);
}

/* Parent items (Apps, Philosophy) are pure submenu triggers — they
   render as <span> with no navigation. Cursor stays "default" so it
   doesn't read as a clickable link, but hover highlight still confirms
   it's interactive (it opens the dropdown). */
.top-bar-link--parent {
  cursor: default;
  user-select: none;
}

/* Login CTA — terra-lt accent (matches the .of italic in the wordmark
   and other terra accents across the site). Both text and border carry
   the colour; hover fills the rectangle with terra and inverts to dark. */
.top-bar-cta {
  font-family: var(--f-mono);
  font-size: 9.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--terra-lt);
  text-decoration: none;
  border: 1px solid var(--terra-lt);
  padding: 5px 12px;
  border-radius: 3px;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
/* External-link indicator — small NE arrow signals that login opens
   in a new tab to nucleus.ofself.ai. Pseudo-element so the textContent
   stays clean for screen readers. */
.top-bar-cta::after {
  content: ' ↗';
  display: inline-block;
  margin-left: 4px;
  font-size: 11px;
  letter-spacing: 0;
  transition: transform 0.18s ease;
}
.top-bar-cta:hover {
  color: var(--dark);
  background: var(--terra-lt);
  border-color: var(--terra-lt);
}
.top-bar-cta:hover::after {
  transform: translate(1px, -1px);
}

/* Right group — login + hamburger live together at the bar's right edge.
   Login hides at the mobile breakpoint and the hamburger takes over. */
.top-bar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* Hamburger — two long thin lines, 24px wide, hairlines at 1px.
   On open, both lines converge to center and rotate into an X.
   Hidden by default; revealed at ≤900px in place of the login button. */
.top-bar-hamb {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 36px;
  height: 30px;
  padding: 0;
  background: transparent;
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.top-bar-hamb span {
  display: block;
  width: 24px;
  height: 1px;
  background: rgba(var(--cream-rgb), 0.72);
  transform-origin: center;
  transition: transform 0.32s cubic-bezier(0.6, 0.05, 0.28, 1),
              background 0.2s ease;
}
.top-bar-hamb:hover span { background: rgba(var(--cream-rgb), 1); }
.top-bar-hamb.open span:nth-child(1) {
  transform: translateY(4.5px) rotate(45deg);
}
.top-bar-hamb.open span:nth-child(2) {
  transform: translateY(-4.5px) rotate(-45deg);
}

/* Drawer — full-bleed slide-down panel with all nav + login. Starts
   below the 40px top-bar so the bar (and its X-toggle) stay accessible. */
.top-bar-drawer {
  position: fixed;
  top: 40px;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 199;
  background: rgba(8, 8, 7, 0.96);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.28s ease, visibility 0.28s ease;
  pointer-events: none;
}
.top-bar-drawer.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
.top-bar-drawer-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 40px 24px 60px;
  gap: 14px;
  text-align: center;
}
.top-bar-drawer-link {
  font-family: var(--f-display);
  font-size: 36px;
  font-weight: 300;
  letter-spacing: -0.01em;
  color: rgba(var(--cream-rgb), 0.78);
  text-decoration: none;
  padding: 6px 0;
  transition: color 0.18s ease;
}
.top-bar-drawer-link:hover {
  color: rgba(var(--cream-rgb), 1);
}
.top-bar-drawer-link.active {
  color: var(--terra-lt);
}
.top-bar-drawer-cta {
  margin-top: 32px;
  align-self: center;
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--terra-lt);
  text-decoration: none;
  padding: 12px 24px;
  border: 1px solid var(--terra-lt);
  border-radius: 4px;
  transition: color 0.15s ease, background 0.15s ease;
}
.top-bar-drawer-cta::after {
  content: ' ↗';
  display: inline-block;
  margin-left: 6px;
  font-size: 13px;
  letter-spacing: 0;
}
.top-bar-drawer-cta:hover {
  color: var(--dark);
  background: var(--terra-lt);
}

/* Hover submenu — full-bleed panel pinned under the topbar. The outer
   container spans the viewport (dark bg + faint bottom rule). Content
   sits in a max-width inner column. Hidden by default; .open fades
   + slides it down. Sits at z:198 so the bar (z:200) overlays cleanly. */
.top-bar-submenu {
  position: fixed;
  top: 40px;
  left: 0;
  right: 0;
  z-index: 198;
  background: rgba(8, 8, 7, 0.96);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid rgba(var(--cream-rgb), 0.06);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-6px);
  transition: opacity 0.18s ease,
              transform 0.22s cubic-bezier(0.22, 1.12, 0.32, 1),
              visibility 0.18s ease;
}
.top-bar-submenu.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}
.top-bar-submenu-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 40px 36px;
  display: flex;
  gap: 64px;
  /* Left-anchor content — every submenu starts from the same x edge
     regardless of how many items it has (Company has 3, Apps has 13).
     Without this they'd all center-align and the narrow ones would
     appear to "drift" to a different position than the wide ones. */
  justify-content: flex-start;
}
.top-bar-submenu-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 150px;
}
/* Flat variant — one ungrouped list, flowed as 2 newspaper columns.
   Used by Apps where category labels would just add chrome. */
.top-bar-submenu-group--flat {
  display: block;
  column-count: 2;
  column-gap: 56px;
  min-width: 320px;
}
.top-bar-submenu-group--flat .top-bar-submenu-item {
  display: block;
  break-inside: avoid;
}
.top-bar-submenu-label {
  font-family: var(--f-mono);
  font-size: 9px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(var(--cream-rgb), 0.4);
  margin-bottom: 10px;
}
.top-bar-submenu-item {
  font-family: 'Menlo', 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(var(--cream-rgb), 0.72);
  text-decoration: none;
  padding: 7px 0;
  line-height: 1;
  transition: color 0.15s ease, transform 0.15s ease;
}
.top-bar-submenu-item:hover {
  color: var(--terra-lt);
  transform: translateX(2px);
}

/* Temporarily hidden — only the wordmark and Login button show in the
   topbar. Restore by replacing this block with the @media (max-width:
   900px) rule below. */
.top-bar-nav { display: none !important; }
.top-bar-hamb { display: none !important; }
.top-bar-submenu { display: none !important; }
.top-bar-drawer { display: none !important; }
/*
@media (max-width: 900px) {
  .top-bar-nav { display: none; }
  .top-bar-cta { display: none; }
  .top-bar-hamb { display: flex; }
  .top-bar-submenu { display: none; }
}
*/
@media (max-width: 720px) {
  .top-bar { padding: 0 18px; }
}
