/* =============================================================================
   vault-legal-acceptance
   -----------------------------------------------------------------------------
   Compact checkbox row used at signup to record the user's acceptance of the
   Terms (AGB) and Privacy Policy (Datenschutz), plus a self-contained modal
   overlay that previews each legal document inline (iframe). Designed to fit
   the dark auth card in the side panel, PWA, and 320 px extension popup.

   - The row sits between the password input and the Sign-up button.
   - The modal floats above everything (z-index very high) and is fully
     keyboard accessible (close on backdrop click, ESC, X button).
   - Visual language matches the existing auth card: slate-800/600/400 tones,
     emerald accent on focus, small font sizes for compactness.
   ========================================================================= */

.vault-legal-accept {
  /* The auth card behind us is white (.vault-form-box has background:#fff),
     so the row uses no fill of its own — just a hairline border on hover/
     focus/error so it never reads as a separate "dark panel". Padding and
     gap stay so the checkbox and label keep a comfortable tap target. */
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.25rem 0;
  background: transparent;
  border: 0;
  border-radius: 0.375rem;
  font-size: 0.75rem;
  line-height: 1.4;
  /* Use the global muted-text variable so we stay readable on light AND dark
     themes (the sidepanel reuses the same component). Falls back to slate-600
     for the public auth pages that don't load styles.css. */
  color: var(--vault-text-muted, #475569);
  cursor: pointer;
  transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

.vault-legal-accept.is-error {
  /* Red emphasis when the user tries to submit without ticking. Uses a soft
     tint + ring so the alert reads clearly on the white card without
     reintroducing the heavy dark panel look. */
  background: rgba(239, 68, 68, 0.06); /* red-500/6 */
  box-shadow: inset 0 0 0 1px rgb(239, 68, 68); /* red-500 ring */
  padding: 0.4rem 0.5rem;
}

.vault-legal-accept__checkbox {
  /* Slightly larger tap target, custom emerald accent on check. */
  flex-shrink: 0;
  margin-top: 0.125rem;
  width: 1rem;
  height: 1rem;
  accent-color: rgb(16, 185, 129); /* emerald-500 */
  cursor: pointer;
}

.vault-legal-accept__text {
  flex: 1 1 auto;
  user-select: none;
}

.vault-legal-accept__link {
  /* The two inline links inside the label. Use the brand primary so they're
     obviously interactive without competing with the Sign-up button. */
  color: var(--vault-primary, #10b981);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.vault-legal-accept__link:hover,
.vault-legal-accept__link:focus-visible {
  color: var(--vault-primary-hover, #059669);
  outline: none;
}

.vault-legal-accept__link:focus-visible {
  /* Visible keyboard focus ring — required for accessibility. */
  outline: 2px solid var(--vault-primary, #10b981);
  outline-offset: 2px;
  border-radius: 2px;
}

.vault-legal-accept__error {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.7rem;
  line-height: 1.3;
  color: rgb(220, 38, 38); /* red-600 — readable on the white card */
}


/* ─── Modal overlay (iframe preview of legal page) ────────────────────────── */

.vault-legal-modal__overlay {
  /* Full-screen scrim. Stays above every other UI surface, including the
     existing vault-modal-overlay (which uses z-index ≤ 50), drawers, etc. */
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: vault-legal-fade-in 0.15s ease;
}

@keyframes vault-legal-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.vault-legal-modal {
  width: 100%;
  max-width: 56rem;
  /* Use full available viewport height so long legal text scrolls inside the
     iframe rather than overflowing the modal. */
  height: 90vh;
  max-height: 90vh;
  background: rgb(255, 255, 255);
  border-radius: 0.5rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.vault-legal-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.625rem 1rem;
  border-bottom: 1px solid rgb(226, 232, 240); /* slate-200 */
  background: rgb(248, 250, 252); /* slate-50 */
  flex-shrink: 0;
}

.vault-legal-modal__title {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  color: rgb(15, 23, 42); /* slate-900 */
}

.vault-legal-modal__close {
  appearance: none;
  background: transparent;
  border: 0;
  width: 1.75rem;
  height: 1.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.25rem;
  color: rgb(71, 85, 105); /* slate-600 */
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.vault-legal-modal__close:hover,
.vault-legal-modal__close:focus-visible {
  background: rgb(226, 232, 240); /* slate-200 */
  color: rgb(15, 23, 42);
  outline: none;
}

.vault-legal-modal__close:focus-visible {
  box-shadow: 0 0 0 2px rgb(16, 185, 129);
}

.vault-legal-modal__body {
  flex: 1 1 auto;
  overflow: hidden;
  background: rgb(255, 255, 255);
}

.vault-legal-modal__iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

/* Phone breakpoint — give the modal the full viewport so legal text remains
   readable on narrow screens (PWA opened on a phone). */
@media (max-width: 540px) {
  .vault-legal-modal__overlay {
    padding: 0;
  }
  .vault-legal-modal {
    width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
  }
}
