/* Field Brief site chrome: one dark topbar with foldered navigation, shared by every public page.
   Markup is generated by tools/site_nav.mjs; behaviour lives in assets/site-nav.js (progressive: the nav
   works as a plain link list without it). Spec: research/site-nav-spec.md */
.site-topbar {
  --site-nav-bg: #101828;
  --site-nav-fg: #e8edf4;
  --site-nav-muted: #b7c2d0;
  --site-nav-accent: #e87324;
  --site-nav-panel: #16213a;
  --site-nav-line: rgba(255, 255, 255, 0.1);
  --site-nav-hover: rgba(255, 255, 255, 0.07);
  position: relative;
  z-index: 40;
  background: var(--site-nav-bg);
  color: var(--site-nav-fg);
  font-family: var(--sans, var(--display, system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif));
  line-height: 1.2;
}
.site-topbar-inner {
  width: min(var(--site-nav-width, 1180px), calc(100% - 40px));
  min-height: 58px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.site-brand {
  color: var(--site-nav-fg);
  text-decoration: none;
  font-family: var(--mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  white-space: nowrap;
}
.site-brand span { color: var(--site-nav-accent); }
.site-brand:hover, .site-brand:focus-visible { color: #fff; }

.site-nav { display: flex; align-items: center; gap: 4px; }
.site-nav > a,
.site-nav-folder-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  padding: 9px 10px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--site-nav-muted);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.site-nav > a:hover,
.site-nav-folder-button:hover,
.site-nav-folder-button[aria-expanded="true"] { color: #fff; background: var(--site-nav-hover); }
.site-nav > a[aria-current="page"],
.site-nav-folder[data-active="true"] > .site-nav-folder-button {
  color: #fff;
  box-shadow: inset 0 -2px 0 var(--site-nav-accent);
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}
.site-nav-folder-button::after {
  content: "";
  width: 6px;
  height: 6px;
  margin-top: -3px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.15s ease;
}
.site-nav-folder-button[aria-expanded="true"]::after { transform: translateY(3px) rotate(225deg); }

.site-nav-folder { position: relative; }
.site-nav-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 232px;
  padding: 6px;
  flex-direction: column;
  gap: 2px;
  background: var(--site-nav-panel);
  border: 1px solid var(--site-nav-line);
  border-radius: 10px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.35);
}
/* The last folder (and any panel the script finds running past the viewport) hangs from the button's right edge. */
.site-nav-folder:last-child > .site-nav-menu,
.site-nav-folder[data-align="right"] > .site-nav-menu { left: auto; right: 0; }
/* Invisible bridge over the 6px gap so a pointer moving from the button into the panel never leaves the folder's hover area. */
.site-nav-menu::before { content: ""; position: absolute; left: 0; right: 0; bottom: 100%; height: 8px; }
.site-nav-folder[data-open="true"] > .site-nav-menu { display: flex; }
.site-nav-menu a {
  display: block;
  padding: 9px 12px;
  border-radius: 6px;
  color: var(--site-nav-muted);
  font-size: 0.86rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.site-nav-menu a:hover { color: #fff; background: var(--site-nav-hover); }
.site-nav-menu a[aria-current="page"] {
  color: #fff;
  background: rgba(232, 115, 36, 0.16);
  box-shadow: inset 3px 0 0 var(--site-nav-accent);
}

.site-nav-toggle {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid var(--site-nav-line);
  border-radius: 6px;
  background: none;
  color: var(--site-nav-fg);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}
.site-nav-toggle::before {
  content: "";
  width: 16px;
  height: 2px;
  background: currentColor;
  box-shadow: 0 -5px 0 currentColor, 0 5px 0 currentColor;
}
.site-nav-toggle[aria-expanded="true"] { background: var(--site-nav-hover); }

.site-brand:focus-visible,
.site-nav > a:focus-visible,
.site-nav-folder-button:focus-visible,
.site-nav-menu a:focus-visible,
.site-nav-toggle:focus-visible { outline: 2px solid var(--site-nav-accent); outline-offset: 2px; }

/* Without the script the folders still open on hover and keyboard focus. */
.site-topbar:not(.site-nav-js) .site-nav-folder:hover > .site-nav-menu,
.site-topbar:not(.site-nav-js) .site-nav-folder:focus-within > .site-nav-menu { display: flex; }

@media (max-width: 860px) {
  .site-topbar-inner { flex-wrap: wrap; gap: 12px 20px; }
  .site-nav-toggle { display: inline-flex; }
  .site-nav {
    display: none;
    flex: 1 0 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding: 6px 0 12px;
    border-top: 1px solid var(--site-nav-line);
  }
  .site-topbar[data-open="true"] .site-nav { display: flex; }
  .site-nav > a,
  .site-nav-folder-button {
    width: 100%;
    justify-content: space-between;
    padding: 12px 10px;
    font-size: 0.95rem;
  }
  .site-nav > a[aria-current="page"],
  .site-nav-folder[data-active="true"] > .site-nav-folder-button {
    box-shadow: inset 3px 0 0 var(--site-nav-accent);
    border-radius: 6px;
  }
  .site-nav-menu {
    position: static;
    min-width: 0;
    margin: 0 0 6px 10px;
    padding: 4px 0 4px 10px;
    border: 0;
    border-left: 2px solid var(--site-nav-line);
    border-radius: 0;
    background: none;
    box-shadow: none;
  }
  .site-nav-menu::before { display: none; }
  .site-nav-menu a { font-size: 0.92rem; padding: 11px 12px; }
  /* A pinned bar taller than a short viewport scrolls inside itself while the menu is open; without the script the
     full list is ordinary page flow instead of a pinned wall. */
  .site-topbar[data-sticky][data-open="true"] { max-height: 100vh; max-height: 100dvh; overflow-y: auto; }
  .site-topbar[data-sticky]:not(.site-nav-js) { position: relative; }
  /* Without the script: no toggle, everything listed. */
  .site-topbar:not(.site-nav-js) .site-nav-toggle { display: none; }
  .site-topbar:not(.site-nav-js) .site-nav,
  .site-topbar:not(.site-nav-js) .site-nav-menu { display: flex; }
}

.site-topbar[data-sticky] { position: sticky; top: 0; }

@media print { .site-topbar { display: none; } }
