/* Site menu — the only route between pages below 940px.

   .navlinks is display:none under that width, and until this button existed
   nothing replaced it: every shell page carried a brand and nothing else on
   a phone. The tools, the cases and the manifesto were reachable only by
   the browser's back button, which is to say not reachable at all to anyone
   arriving from a search result or a shared link.

   Hidden above the breakpoint, where the full nav row is already on screen.
   The manifesto opts out of that with .site-menu--always: its nav is five
   essay anchors at every width, so it needs this menu on desktop too. */

.site-menu { position: relative; display: none; }
.site-menu--always { display: block; }

.site-menu-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
}

.site-menu-caret { font-size: 11px; color: var(--muted); transition: transform .22s; }
.site-menu-btn[aria-expanded="true"] .site-menu-caret { transform: rotate(180deg); }

/* Three bars drawn in CSS rather than an icon font or an inline SVG per
   page: the header is in every generated file, so a glyph here would be
   copied a dozen times and would have to be re-generated to change. */
.site-menu-bars { display: none; position: relative; width: 18px; height: 12px; }
.site-menu-bars i {
  position: absolute;
  left: 0;
  width: 100%;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  transition: transform .22s, opacity .22s;
}
.site-menu-bars i:nth-child(1) { top: 0; }
.site-menu-bars i:nth-child(2) { top: 5px; }
.site-menu-bars i:nth-child(3) { top: 10px; }

/* Open folds the bars into a cross, so the same control visibly closes the
   panel it opened. */
.site-menu-btn[aria-expanded="true"] .site-menu-bars i:nth-child(1) { transform: translateY(5px) rotate(45deg); }
.site-menu-btn[aria-expanded="true"] .site-menu-bars i:nth-child(2) { opacity: 0; }
.site-menu-btn[aria-expanded="true"] .site-menu-bars i:nth-child(3) { transform: translateY(-5px) rotate(-45deg); }

.site-menu-panel {
  position: absolute;
  right: 0;
  top: 100%;
  z-index: 40;
  display: grid;
  gap: 2px;
  min-width: 212px;
  max-height: calc(100vh - 92px);
  overflow-y: auto;
  padding: 8px;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #0e131e;
  box-shadow: var(--shadow);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: opacity .2s, transform .2s, visibility .2s;
}

.site-menu-panel.is-open { opacity: 1; visibility: visible; transform: none; }

/* Hover-to-open only where a real pointer exists. On a touch screen the
   first tap would otherwise both trigger the hover state and fire the
   click, opening and closing the panel in one go. */
@media (hover: hover) and (pointer: fine) {
  .site-menu:hover .site-menu-panel { opacity: 1; visibility: visible; transform: none; }
  .site-menu:hover .site-menu-caret { transform: rotate(180deg); }
}

.site-menu-panel a {
  padding: 9px 13px;
  border-radius: 11px;
  color: var(--muted);
  font-size: 14px;
  transition: .18s;
}

.site-menu-panel a:hover,
.site-menu-panel a:focus-visible { background: rgba(255, 255, 255, .08); color: var(--text); }
.site-menu-panel a[aria-current="page"] { color: var(--text); }

@media (max-width: 940px) {
  .site-menu { display: block; }
  .site-menu-label, .site-menu-caret { display: none; }
  .site-menu-bars { display: block; }
  .site-menu-btn { padding: 11px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .site-menu-panel, .site-menu-caret, .site-menu-bars i { transition: none; }
}
