/* ==========================================================================
   THE PRIVACY GUARD'S SHEET (js/privacy-guard.js, 2026-09-28)

   "That looks like a card number." with Remove it, Edit, Keep it. The module
   links this file the first time a sheet is needed, so it costs nothing
   until then.

   Full Stop's rules (docs/full-stop.md): the tokens are css/fullstop.css's
   --fs-* in all three lights (Studio, Night, Day); the fallbacks after each
   comma are Studio's and Day's, for a page that does not load Full Stop.
   One gold button (Remove it, the thing to do). Glass only because a sheet
   floats: blur 28px, tint 94%, an edge of light, solid under more contrast.
   Type on the scale (22/28 title, 17/22 body and buttons). Targets 48px.
   Motion under 300ms, none under Reduce Motion. A bottom sheet on a phone,
   a centred dialog from 601px.
   ========================================================================== */

.pg-overlay {
  --pg-surface: var(--fs-s2, #2c1e16);
  --pg-t1: var(--fs-t1, #f6ebdd);
  --pg-t2: var(--fs-t2, #d5cabd);
  --pg-line: var(--fs-line, #3c2e25);
  --pg-hover: var(--fs-s3, #36281e);
  --pg-firm: var(--fs-firm, #d8bd8e);
  --pg-on-firm: var(--fs-on-firm, #21130c);
  --pg-firm-hover: var(--fs-firm-hover, #e4c999);
  --pg-focus: var(--fs-kept, #4e8fb2);
  --pg-scrim: var(--fs-scrim, rgba(12, 6, 3, 0.62));
  --pg-shadow: var(--fs-e3, 0 24px 64px -16px rgba(0, 0, 0, 0.7));
  --pg-edge: var(--fs-glass-edge, inset 0 1px 0 rgba(255, 244, 222, 0.09));
  --pg-ease: var(--fs-ease, cubic-bezier(0.23, 1, 0.32, 1));
  --pg-sheet: var(--fs-sheet, cubic-bezier(0.32, 0.72, 0, 1));

  position: fixed;
  inset: 0;
  z-index: 420; /* over every sheet (the add-task sheet is 220, the scan card 300), under the 9000 toast */
  display: flex;
  align-items: flex-end;
  justify-content: center;
  box-sizing: border-box;
  background: transparent;
  font-family: var(--fs-font, "Mona Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif);
  font-optical-sizing: auto;
  font-variant-numeric: proportional-nums;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: contain;
}
/* Day: the sheet is paper, like every Day sheet. */
:root[data-theme="light"] .pg-overlay {
  --pg-surface: var(--fs-s1, #fffcf8);
  --pg-t1: var(--fs-t1, #21130c);
  --pg-t2: var(--fs-t2, #5b4c42);
  --pg-line: var(--fs-line, #e3dbd1);
  --pg-hover: var(--fs-s2, #f4efe5);
  --pg-firm: var(--fs-firm, #21130c);
  --pg-on-firm: var(--fs-on-firm, #fbf6ee);
  --pg-firm-hover: var(--fs-firm-hover, #000000);
  --pg-focus: var(--fs-kept, #1a5f80);
  --pg-scrim: var(--fs-scrim, rgba(33, 19, 12, 0.3));
  --pg-shadow: var(--fs-e3, 0 0 0 1px rgba(28, 23, 18, 0.06), 0 24px 64px -16px rgba(28, 23, 18, 0.3));
  --pg-edge: var(--fs-glass-edge, inset 0 1px 0 rgba(255, 255, 255, 0.7));
}

/* The veil is its own layer behind the sheet, so the sheet's blur reaches the
   page (an ancestor with its own background or fade stops a backdrop blur). */
.pg-overlay::before {
  content: "";
  position: fixed;
  inset: 0;
  background: var(--pg-scrim);
  animation: pg-veil 200ms var(--pg-ease);
}

.pg-card {
  position: relative;
  z-index: 1;
  box-sizing: border-box;
  width: 100%;
  max-width: 480px;
  max-height: calc(100vh - 24px);
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
  margin: 0;
  padding: 24px 20px max(20px, env(safe-area-inset-bottom));
  border: 0;
  border-radius: 20px 20px 0 0;
  background: var(--pg-surface);
  box-shadow: var(--pg-shadow), inset 0 0 0 1px var(--pg-line);
  color: var(--pg-t1);
  text-align: left;
  animation: pg-rise 240ms var(--pg-sheet);
}
@media (min-width: 601px) {
  .pg-overlay { align-items: center; padding: 24px; }
  .pg-card { max-width: 440px; padding: 24px; border-radius: 20px; }
}

/* Glass, because it floats. The selector outranks Full Stop's global
   "no backdrop-filter" rule; the tint is 94%, over the 80% floor. */
@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) and (background: color-mix(in srgb, red 50%, transparent)) {
  :root .pg-overlay > .pg-card {
    background: color-mix(in srgb, var(--pg-surface) 94%, transparent);
    -webkit-backdrop-filter: blur(28px) saturate(150%) !important;
    backdrop-filter: blur(28px) saturate(150%) !important;
    box-shadow: var(--pg-shadow), inset 0 0 0 1px var(--pg-line), var(--pg-edge);
  }
}
@media (prefers-contrast: more) {
  :root .pg-overlay > .pg-card {
    background: var(--pg-surface);
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
  }
}

.pg-title {
  margin: 0 0 8px;
  font-size: 22px;
  line-height: 28px;
  font-weight: 700;
  font-style: normal;
  letter-spacing: -0.017em;
  text-transform: none;
  color: var(--pg-t1);
  text-wrap: balance;
}
.pg-body {
  margin: 0;
  font-size: 17px;
  line-height: 22px;
  font-weight: 400;
  font-style: normal;
  letter-spacing: -0.011em;
  color: var(--pg-t2);
  text-wrap: pretty;
}

/* Remove it across the top; Edit and Keep it side by side under it. */
.pg-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;   /* 8 left a 4px sliver once the 2px focus ring (2px out) drew on Remove it */
  margin-top: 20px;
}
.pg-btn {
  box-sizing: border-box;
  min-width: 0;
  min-height: 48px;
  margin: 0;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 12px;
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--pg-line);
  color: var(--pg-t1);
  font: inherit;
  font-size: 17px;
  line-height: 22px;
  font-weight: 620;
  letter-spacing: -0.011em;
  text-transform: none;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 120ms var(--pg-ease), background-color 120ms var(--pg-ease), color 120ms var(--pg-ease);
}
.pg-btn-primary {
  grid-column: 1 / -1;
  background: var(--pg-firm);
  color: var(--pg-on-firm);
  box-shadow: none;
}
.pg-btn:active { transform: scale(0.97); }
.pg-btn:focus { outline: none; }
.pg-btn:focus-visible {
  outline: 2px solid var(--pg-focus) !important;
  outline-offset: 2px !important;
}
@media (hover: hover) and (pointer: fine) {
  .pg-btn:hover { background: var(--pg-hover); }
  .pg-btn-primary:hover { background: var(--pg-firm-hover); }
}

/* Windows Contrast themes drop backgrounds and shadows: keep the edges. */
@media (forced-colors: active) {
  .pg-card { border: 1px solid CanvasText; }
  .pg-btn { border: 1px solid ButtonText; }
  .pg-btn:focus-visible { outline-color: Highlight !important; }
}

@keyframes pg-veil { from { opacity: 0; } }
@keyframes pg-rise { from { opacity: 0; transform: translateY(16px); } }
@media (prefers-reduced-motion: reduce) {
  .pg-overlay::before,
  .pg-card { animation: none; }
  .pg-btn { transition: none; }
  .pg-btn:active { transform: none; }
}
