/* Drawer UI framework — stacked right-side drawers with backdrop, hash routing, fullscreen mode. */

.drawer-host {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  /* No drawer open → invisible AND must not trap clicks. The previous
     `pointer-events: auto` here meant the page below stayed dead after the
     last drawer closed (only fix was a reload). */
  pointer-events: none;
  opacity: 0;
  transition: opacity 220ms ease-out;
}

.drawer-backdrop.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.drawer-layer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(960px, calc(100vw - 60px));
  background: var(--bg, #f3efe8);
  box-shadow: var(--shadow, 0 16px 40px rgba(23, 26, 31, 0.08));
  border-top-left-radius: var(--radius, 22px);
  border-bottom-left-radius: var(--radius, 22px);
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateX(100%);
  transition: transform 220ms ease-out, filter 220ms ease-out;
  will-change: transform;
}

.drawer-layer.is-open {
  transform: translateX(0);
}

.drawer-layer.is-closing {
  transform: translateX(100%);
}

/* Older drawers in the stack peek from the left so the user can click to bring them forward. */
.drawer-layer.is-peeking {
  filter: brightness(0.92);
  cursor: pointer;
}

.drawer-header {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line, rgba(22, 31, 45, 0.08));
  background: var(--panel, rgba(255, 255, 255, 0.92));
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  z-index: 1;
}

.drawer-title {
  flex: 1 1 auto;
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text, #18202b);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.drawer-newtab,
.drawer-close {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border: 1px solid var(--line, rgba(22, 31, 45, 0.08));
  border-radius: 12px;
  background: transparent;
  color: var(--text, #18202b);
  font-size: 13px;
  cursor: pointer;
  transition: background 160ms ease-out, color 160ms ease-out;
}

.drawer-newtab:hover {
  background: var(--accent, #bb4d00);
  color: #fff;
  border-color: transparent;
}

.drawer-close {
  width: 36px;
  height: 36px;
  padding: 0;
  justify-content: center;
  font-size: 20px;
  line-height: 1;
  color: var(--muted, #6e7784);
}

.drawer-close:hover {
  background: var(--line, rgba(22, 31, 45, 0.08));
  color: var(--text, #18202b);
}

.drawer-body {
  flex: 1 1 auto;
  overflow: auto;
  padding: 22px;
  color: var(--text, #18202b);
}

/* Direct-hash-load mode: single fullscreen drawer, no peek, hidden backdrop. */
.drawer-host.drawer-fullscreen .drawer-layer {
  width: 100vw;
  left: 0 !important;
  border-radius: 0;
}

.drawer-host.drawer-fullscreen .drawer-backdrop {
  display: none;
}

@media (max-width: 768px) {
  .drawer-layer {
    width: 100vw;
    left: 0 !important;
    border-radius: 0;
  }
  .drawer-layer.is-peeking {
    visibility: hidden;
  }
}
