/* Navigation drawer
 *
 * A <dialog> slid in from the left. Browser handles focus, Esc and the
 * backdrop; this file only positions and animates it.
 *
 * See design-documents/header-and-menu.md.
 */

.menubtn,
.menubtn-spacer {
  flex: none;
  width: 44px;
  height: 44px;
}

/* The spacer is what centres the brand: without it the brand would centre in
   the space left over beside the button, which is not the middle of the row. */
.menubtn-spacer { display: block; }

.menubtn {
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink-soft);
  cursor: pointer;
  padding: 0;
}
.menubtn:hover { color: var(--ink); border-color: var(--accent); }
.menubtn svg { width: 21px; height: 21px; stroke: currentColor; }

/* ---------- the drawer ---------- */

.navdrawer {
  /* The dialog is the full viewport; the panel inside it is the drawer. That
     is what makes a click on the dialog element itself mean "outside". */
  margin: 0;
  padding: 0;
  width: 100vw;
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  border: none;
  background: transparent;
  overflow: hidden;
}
.navdrawer::backdrop { background: rgba(0, 0, 0, .45); }

.navdrawer-inner {
  width: min(310px, 84vw);
  height: 100%;
  box-sizing: border-box;
  background: var(--surface);
  border-right: 1px solid var(--line);
  box-shadow: 0 0 40px -10px rgba(0, 0, 0, .4);
  display: flex;
  flex-direction: column;
  /* Clear of the status bar and the home indicator in an installed PWA. */
  padding: calc(18px + env(safe-area-inset-top, 0px)) 0
           calc(18px + env(safe-area-inset-bottom, 0px))
           calc(0px + env(safe-area-inset-left, 0px));
}

@media (prefers-reduced-motion: no-preference) {
  .navdrawer[open] .navdrawer-inner { animation: navdrawer-in .22s cubic-bezier(.22, 1, .36, 1); }
  .navdrawer[data-closing] .navdrawer-inner { animation: navdrawer-out .18s ease-in forwards; }
  .navdrawer[open]::backdrop { animation: navdrawer-fade .22s ease-out; }
}
@keyframes navdrawer-in  { from { transform: translateX(-100%); } to { transform: translateX(0); } }
@keyframes navdrawer-out { from { transform: translateX(0); } to { transform: translateX(-100%); } }
@keyframes navdrawer-fade { from { opacity: 0; } to { opacity: 1; } }

.navdrawer-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px 16px;
  border-bottom: 1px solid var(--line);
}
.navdrawer-head .brand-mark { width: 30px; height: 30px; flex: none; }
.navdrawer-title { font-size: 16px; font-weight: 700; color: var(--ink); flex: 1; min-width: 0; }
.navdrawer-close {
  flex: none; width: 36px; height: 36px; border-radius: 50%;
  border: none; background: var(--surface-2); color: var(--ink-soft);
  font-size: 14px; cursor: pointer; font-family: inherit;
  display: flex; align-items: center; justify-content: center;
}

/* ---------- the list ---------- */

.navlist { display: flex; flex-direction: column; padding: 10px 0; overflow-y: auto; }

.navitem {
  display: flex;
  align-items: center;
  gap: 14px;
  /* 52px, comfortably past the 44px minimum tap target. */
  min-height: 52px;
  padding: 0 16px;
  border: none;
  background: none;
  color: var(--ink);
  font-family: inherit;
  font-size: 15.5px;
  font-weight: 600;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  width: 100%;
  box-sizing: border-box;
}
.navitem:hover { background: var(--surface-2); }
.navitem svg { flex: none; width: 21px; height: 21px; stroke: currentColor; color: var(--accent-ink); }
.navitem-state { color: var(--ink-faint); font-weight: 500; }

.navlist-rule { height: 1px; background: var(--line); margin: 10px 16px; }
