/* ---------------------------------------------------------------------------
   Slide-in side menu (B1.church style).

   Replaces the old .admin-menu gear dropdown in the topbar. The drawer is a
   left-anchored panel that slides in over a dimmed backdrop. It must sit above
   the fixed bottom tab bar (z-index 100) and the install banner (90), hence
   z-index 150/151.

   Everything is expressed with the app's CSS variables so /theme.css restyling
   keeps working.
   --------------------------------------------------------------------------- */

.drawer-toggle {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.35rem;
  line-height: 1;
  padding: 6px 8px;
  margin-right: -4px;
  cursor: pointer;
  border-radius: 8px;
}
.drawer-toggle:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 150;
  background: rgba(13, 36, 71, 0.45);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.22s ease, visibility 0s linear 0.22s;
}

.drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 151;
  width: 84vw;
  max-width: 320px;
  background: var(--card, #fff);
  color: var(--text);
  border-right: 1px solid var(--border);
  box-shadow: 2px 0 16px rgba(13, 36, 71, 0.18);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  /* keep the last row clear of the iPhone home indicator */
  padding-bottom: calc(var(--safe-b, 0px) + 12px);
  transform: translateX(-100%);
  /* transform + opacity only: compositor-friendly, no layout thrash on mobile */
  transition: transform 0.24s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
  visibility: hidden;
}

body.drawer-open .drawer-backdrop {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.22s ease;
}
body.drawer-open .drawer {
  transform: translateX(0);
  visibility: visible;
}

/* Body scroll lock while the drawer is open. */
body.drawer-open {
  overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
  .drawer,
  .drawer-backdrop { transition: none; }
}

/* --- identity header ------------------------------------------------------ */

.drawer-id {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 16px;
  padding-top: calc(env(safe-area-inset-top, 0px) + 18px);
  background: linear-gradient(135deg, #0d2440 0%, #16467f 60%, #1d5eb4 100%);
  color: #fff;
}
.drawer-id .avatar {
  background: rgba(255, 255, 255, 0.9);
  color: var(--amber-700);
}
.drawer-id-text { min-width: 0; }
.drawer-id-name {
  font-weight: 700;
  font-size: 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.drawer-id-sub {
  font-size: 0.8rem;
  color: #bfd7f2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.drawer-chip {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

/* --- sections ------------------------------------------------------------- */

.drawer-section {
  padding: 8px 0;
  border-top: 1px solid var(--border);
}
.drawer-section:first-of-type { border-top: none; }

.drawer-heading {
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--text-muted);
  padding: 8px 16px 4px;
  margin: 0;
}

.drawer-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.95rem;
  border-left: 3px solid transparent;
}
.drawer-link:hover,
.drawer-link:focus {
  background: var(--amber-100, var(--border));
  text-decoration: none;
}
.drawer-link:focus-visible {
  outline: 2px solid var(--amber-700);
  outline-offset: -2px;
}
.drawer-link.active {
  color: var(--amber-700);
  font-weight: 700;
  border-left-color: var(--amber-700);
  background: var(--amber-100, var(--border));
}
.drawer-link-icon {
  width: 22px;
  text-align: center;
  flex-shrink: 0;
  font-size: 1.05rem;
}
.drawer-link-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- logout --------------------------------------------------------------- */

.drawer-foot {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding: 8px 0 4px;
}
.drawer-logout { margin: 0; }
.drawer-logout button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: none;
  border: none;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.95rem;
  text-align: left;
  cursor: pointer;
}
.drawer-logout button:hover { background: var(--amber-100, var(--border)); }
