/* Drawer: the native <dialog> in its modal form, held against the right edge at the full height
   of the window. The element carries no padding and no border — every pixel of it is the frame
   inside or the backdrop outside, which is what lets a click beside it close it. The backdrop is
   clear: the page stays in sight beside it, and the drawer's own shadow is what sets it apart. */
.drawer {
  position: fixed;
  inset: 0 0 0 auto;
  margin: 0;
  width: min(var(--drawer-width), 100vw);
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  padding: 0;
  border: none;
  background: none;
  color: var(--color-ink);
  box-shadow: var(--shadow-drawer);
  overflow: visible;
}

.drawer::backdrop {
  background: transparent;
}

.drawer-frame {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--color-surface);
  border-left: var(--hairline) solid var(--color-line);
}

/* The one line in ink across the top: what to know before touching anything inside. */
.drawer-banner {
  padding: var(--space-3) var(--space-6);
  background: var(--color-ink);
  color: var(--color-bg);
  font-size: var(--text-quiet);
  line-height: var(--leading-body);
}

.drawer-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-6) 0;
}

/* The section size of the display face, as the snapshot titles a block. */
.drawer-title {
  margin: 0;
  font-size: var(--text-display-5);
  font-weight: var(--weight-regular);
  line-height: var(--leading-section);
  letter-spacing: var(--tracking-section);
}

.drawer-close {
  flex: none;
  padding: 0;
  border: 0;
  background: none;
  color: var(--color-muted);
  font: inherit;
  font-size: var(--text-sm);
  white-space: nowrap;
  cursor: pointer;
}

.drawer-close:hover {
  color: var(--color-ink);
}

.drawer-close:focus-visible {
  outline: var(--focus-width) solid var(--color-accent);
  outline-offset: var(--focus-offset);
}

.drawer-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: var(--space-4) var(--space-6);
}

.drawer-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-6) var(--space-5);
  border-top: var(--hairline) solid var(--color-line);
}

/* While a drawer is open the page behind it does not scroll, as with a dialog. */
html.drawer-open {
  overflow: hidden;
}

/* **On a phone the drawer is the screen.** Under 36rem it takes the full width, as a sheet does:
   no page is left beside it to keep in sight, so there is no edge, no shadow cast over nothing, and
   the insets come in to the phone's gutter. */
@media (max-width: 36rem) {
  .drawer {
    width: 100vw;
    box-shadow: none;
  }

  .drawer-frame {
    border-left: none;
  }

  .drawer-banner,
  .drawer-body {
    padding-inline: var(--space-4);
  }

  .drawer-head {
    padding-inline: var(--space-4);
  }

  .drawer-footer {
    padding-inline: var(--space-4);
  }
}
