/* ==========================================================
   neur0doku-modals.css

   Generic modal SHELL — the fixed-position overlay, backdrop,
   panel, header, and close button shared by every neur0doku
   modal (Settings, Profile, Legal, and any added later). This
   file owns the BOX a modal sits inside.

   What actually goes INSIDE a modal's .nd-modal-body (toggle
   cards, the avatar grid, profile name field, etc.) is content
   specific to which modal it is, not shell — that lives in
   neur0doku-pages.css's HOME section, scoped per-modal where two
   modals share a class name (see #profile-modal .nd-tab-btn
   there, to avoid colliding with Quests' unrelated .nd-tab-btn).

   Colors come from neur0doku-theme.css (--nd-*) exclusively.
   LOAD ORDER: after neur0doku-theme.css and
   neur0doku-components.css, before neur0doku-pages.css, on any
   page that opens a modal.
   ========================================================== */

.nd-modal[hidden] { display: none !important; }
.nd-modal {
  position: fixed;
  inset: 0;
  /* Was 200 — the site's own header apparently stacks above that,
     which is exactly the "modal renders under the navbar" bug.
     9999 is deliberately high: a modal should always be the
     topmost thing on screen regardless of what z-index any other
     component (header, banner, future widget) happens to use. */
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}
.nd-modal-backdrop {
  position: absolute;
  inset: 0;
  background: var(--nd-overlay);
}
body.nd-modal-open { overflow: hidden; }

.nd-modal-panel {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 380px;
  max-height: calc(100vh - 2.5rem);
  overflow-y: auto;
  background: var(--nd-surface);
  border: 1px solid var(--nd-border);
  border-radius: 1.25rem;
  box-shadow: 0 20px 50px var(--nd-shadow);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, Roboto, sans-serif;
  color: var(--nd-text);
  animation: nd-modal-rise 0.18s ease-out;
}
.nd-modal-panel--small { max-width: 320px; }

@keyframes nd-modal-rise {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .nd-modal-panel { animation: none; }
}

.nd-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.4rem 1.25rem 1rem;
}
.nd-modal-header h2 {
  margin: 0;
  font-family: ui-rounded, 'SF Pro Rounded', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--nd-accent);
  flex: 1;
  text-align: center;
}
.nd-modal-close {
  background: none;
  border: none;
  font-size: 1.35rem;
  line-height: 1;
  color: var(--nd-text-soft);
  cursor: pointer;
  padding: 0.25rem 0.4rem;
  border-radius: 0.5rem;
}
.nd-modal-close:hover { background: var(--nd-surface-soft); }
.nd-modal-close:focus-visible { outline: 2px solid var(--nd-focus); outline-offset: 2px; }
/* Balances the close button so the title stays visually centered. */
.nd-modal-header::before { content: ''; width: 1.35rem; }

.nd-modal-body { padding: 0.25rem 1.375rem 1.5rem; }

/* Generic tab-panel visibility for any modal that switches panels
   via [hidden] (Profile's Avatar/Frame/Faces/Theme panels today).
   Native [hidden] already does this, but a low-specificity rule
   elsewhere winning that race is exactly what caused this bug in
   the first place — this makes it explicit rather than relying on
   the browser default going uncontested. */
.nd-tab-panel[hidden] { display: none; }

/* Generic "primary action" button for a modal's footer — currently
   only Profile's Confirm button, but not modal-specific itself. */
.nd-confirm-btn {
  display: block;
  width: 100%;
  background: var(--nd-button-bg);
  border: 1px solid var(--nd-button-border);
  color: var(--nd-button-ink);
  font-family: ui-rounded, 'SF Pro Rounded', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  padding: 0.8rem 1rem;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 4px 10px var(--nd-shadow);
}
.nd-confirm-btn:hover { background: var(--nd-button-bg-hover); }
.nd-confirm-btn:focus-visible { outline: 2px solid var(--nd-focus); outline-offset: 2px; }