/*
 * Privacy Shield (public/js/privacy-shield.js). GWiZ(TM); the same file in every
 * app that carries the shield. An app tints it through the --privacy-shield-*
 * properties rather than by editing this file.
 *
 * The overlay is a modal <dialog>: the top layer puts it above every z-index and
 * any modal already open, while a dialog opened after it (the re-authentication
 * prompt) still stacks above it. So nothing here needs a z-index war.
 *
 * Blur is backdrop-filter, with the -webkit- prefix Safari still wants. Where it
 * is unsupported, or the person asked for less transparency, the overlay is opaque
 * instead -- a translucent tint with no blur would leave every figure legible.
 */

.privacy-shield {
  --privacy-shield-tint: rgba(15, 23, 42, 0.45);
  --privacy-shield-solid: #0f172a;
  --privacy-shield-card-bg: #ffffff;
  --privacy-shield-card-fg: #0f172a;
  --privacy-shield-muted: #475569;
  --privacy-shield-accent: #2563eb;
  --privacy-shield-accent-fg: #ffffff;

  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 16px;
  border: 0;
  box-sizing: border-box;
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--privacy-shield-tint);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  color: var(--privacy-shield-card-fg);
  overflow: auto;
}

.privacy-shield[open] {
  display: flex;
}

/* The dialog itself covers the viewport; its ::backdrop adds nothing. */
.privacy-shield::backdrop {
  background: transparent;
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .privacy-shield {
    background: var(--privacy-shield-solid);
  }
}

@media (prefers-reduced-transparency: reduce) {
  .privacy-shield {
    background: var(--privacy-shield-solid);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}

.privacy-shield__card {
  width: 100%;
  max-width: 420px;
  padding: 28px 24px;
  border-radius: 16px;
  background: var(--privacy-shield-card-bg);
  color: var(--privacy-shield-card-fg);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  text-align: center;
  box-sizing: border-box;
}

.privacy-shield__title {
  margin: 0 0 8px;
  font-size: 1.25rem;
  line-height: 1.3;
  color: inherit;
}

.privacy-shield__text {
  margin: 0 0 20px;
  color: var(--privacy-shield-muted);
  line-height: 1.5;
}

.privacy-shield__slot:empty {
  display: none;
}

.privacy-shield__slot {
  display: flex;
  justify-content: center;
  margin: 0 0 16px;
}

.privacy-shield__actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.privacy-shield__button {
  min-width: 180px;
  min-height: 44px;
  padding: 10px 20px;
  border: 0;
  border-radius: 10px;
  background: var(--privacy-shield-accent);
  color: var(--privacy-shield-accent-fg);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.privacy-shield__link,
.privacy-shield__extra {
  min-height: 44px;
  padding: 8px 12px;
  border: 0;
  background: transparent;
  color: var(--privacy-shield-accent);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.privacy-shield__button:disabled {
  opacity: 0.6;
  cursor: progress;
}

/* While an adapter's own sign-in control is in the slot (STRUCTiO's Google
   button), that control is the way forward; a greyed-out Unlock beside it is
   only noise. */
.privacy-shield__slot:not(:empty) + .privacy-shield__actions .privacy-shield__button:disabled {
  display: none;
}

.privacy-shield [hidden] {
  display: none !important;
}

.privacy-shield button:focus-visible {
  outline: 3px solid var(--privacy-shield-accent);
  outline-offset: 3px;
}

@media (prefers-color-scheme: dark) {
  .privacy-shield {
    --privacy-shield-card-bg: #1e293b;
    --privacy-shield-card-fg: #f1f5f9;
    --privacy-shield-muted: #cbd5e1;
    --privacy-shield-accent: #60a5fa;
    --privacy-shield-accent-fg: #0f172a;
  }
}

/* A printout of a page left behind the shield shows the shield, not the data. */
@media print {
  .privacy-shield-engaged body > *:not(.privacy-shield) {
    visibility: hidden;
  }
}
