/**
 * The site drawer: a sheet off the right edge, over a scrim.
 *
 * What this replaces was a column inside the layout's flex row that pushed the page sideways as it
 * opened — so opening the menu reflowed everything under it, and on a narrow screen there was not
 * enough width left for either. A sheet takes the page's width from nobody.
 *
 * Both halves are `position: fixed` and are not in flow at all, which is why the element itself is
 * laid out as nothing: it can stay exactly where it is in `site-layout`'s markup.
 */
site-sidebar {
  display: contents;
}

/* ---------------- SCRIM ---------------- */

.site-scrim {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: light-dark(rgb(19 19 21 / 28%), rgb(0 0 0 / 55%));
  opacity: 0;
  pointer-events: none;
  transition: opacity 260ms linear;
}

.site-viewport.sidebar-open .site-scrim {
  opacity: 1;
  pointer-events: auto;
}

/* ---------------- SHEET ---------------- */

.site-sidebar {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  width: min(360px, 86vw);
  display: flex;
  flex-direction: column;
  background: var(--background);
  border-left: 1px solid var(--text);
  text-align: left;
  transform: translateX(101%);
  transition: transform 340ms cubic-bezier(0.32, 0.72, 0, 1);
}

/* 101% rather than 100%: the left border is outside the box, and at exactly 100% it stays on
   screen as a hairline down the edge of every page. */
.site-viewport.sidebar-open .site-sidebar {
  transform: translateX(0);
}

/* The sheet slides rather than fades, and a visitor who asked for neither gets it immediately. */
@media (prefers-reduced-motion: reduce) {
  .site-sidebar,
  .site-scrim {
    transition-duration: 1ms;
  }
}

.site-sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--light);
  flex: 0 0 auto;
}

.site-sidebar-wordmark {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.site-sidebar-close {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--light2);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
  transition: border-color 180ms linear;
}

.site-sidebar-close:hover {
  border-color: var(--text);
}

.site-sidebar-close:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 1px;
}

/* ---------------- ROWS ---------------- */

.site-sidebar-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 8px 24px 24px;
  display: flex;
  flex-direction: column;
}

.site-sidebar-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 18px 0;
  border-bottom: 1px solid var(--light);
  color: var(--text);
  text-decoration: none;
  transition: opacity 160ms linear;
}

.site-sidebar-row:hover {
  opacity: 0.62;
}

.site-sidebar-row:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

.site-sidebar-row-label {
  font-family: var(--font-mono);
  font-size: 14px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.site-sidebar-row-note {
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.03em;
  color: var(--text2);
}

/* ---------------- FOOT ---------------- */

.site-sidebar-foot {
  flex: 0 0 auto;
  padding: 20px 24px 24px;
  border-top: 1px solid var(--light);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.site-sidebar-foot[hidden] {
  display: none;
}

.site-sidebar-identity {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.site-sidebar-initials {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--text);
  color: var(--background);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
}

.site-sidebar-identity-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.site-sidebar-identity-name {
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.site-sidebar-identity-alias {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.site-sidebar-identity-alias[hidden] {
  display: none;
}

.site-sidebar-signout {
  width: 100%;
  padding: 13px 16px;
  background: transparent;
  border: 1px solid var(--text);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text);
  text-align: center;
  text-decoration: none;
  transition: background-color 160ms linear, color 160ms linear;
}

.site-sidebar-signout:hover {
  background: var(--text);
  color: var(--background);
}
