/* The site menu at the right end of every page's top bar (.bar). Tokens come from base.css. */

.site-menu {
  position: relative;
}

.site-menu summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 7px 14px 7px 12px;
  border: 1px solid var(--border-2);
  border-radius: 999px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.3;
  cursor: pointer;
  list-style: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background-color .15s, border-color .15s;
}

.site-menu summary::-webkit-details-marker {
  display: none;
}

.site-menu summary:hover,
.site-menu[open] summary {
  background: var(--bg-2);
}

.site-menu[open] summary {
  border-color: var(--text-3);
}

.site-menu summary:focus-visible,
.site-menu-link:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

.site-menu-icon {
  flex: none;
}

.site-menu-panel {
  position: absolute;
  z-index: 1100; /* above Leaflet map controls (1000) */
  top: calc(100% + 8px);
  right: 0;
  width: min(calc(100vw - 24px), 240px);
  padding: 6px;
  border-radius: var(--r-md);
  background: var(--bg);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .14), 0 2px 6px rgba(0, 0, 0, .06), 0 0 0 1px var(--border);
  transform-origin: top right;
  animation: site-menu-in .14s ease-out;
}

@keyframes site-menu-in {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(.98);
  }
}

@media (prefers-reduced-motion: reduce) {
  .site-menu-panel {
    animation: none;
  }
}

.site-menu-panel ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-menu-panel form {
  margin: 0;
}

.site-menu-account {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
}

.site-menu-user {
  overflow: hidden;
  padding: 4px 10px 6px;
  color: var(--text-3);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.site-menu-user strong {
  color: var(--text-2);
  font-weight: 500;
}

/* Also styles the sign-out button, overriding base.css's page-wide button style. */
.site-menu-link {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--r-sm);
  background: none;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  text-align: left;
  text-decoration: none;
}

/* Beats base.css's grey `.bar nav a` links. */
.bar .site-menu-link {
  color: var(--text);
}

.site-menu-link:hover {
  background: var(--bg-2);
}

.site-menu-link[aria-current="page"] {
  background: var(--bg-2);
  font-weight: 600;
}

/* A dot marks the current page. */
.site-menu-link[aria-current="page"]::after {
  width: 6px;
  height: 6px;
  margin-left: auto;
  border-radius: 50%;
  background: var(--text);
  content: "";
}

@media (max-width: 480px) {
  .site-menu summary {
    padding-inline: 10px;
  }

  .site-menu-label {
    display: none;
  }
}
