/* ═══════════════════════════════════════════════
   PRESENCE MODAL (overlay, periodic human check-in)
   Independent from wellness — same visual language,
   distinct accent colors per challenge level.
   ═══════════════════════════════════════════════ */

#presence-modal-container:empty { display: none; }

/* ── Overlay & backdrop ── */

.presence-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease;
}

.presence-modal-overlay.presence-modal-visible {
  opacity: 1;
  pointer-events: auto;
}

.presence-modal-overlay.presence-modal-out {
  opacity: 0;
  transition: opacity 0.22s ease;
}

.presence-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 8, 20, 0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

/* ── Card ── */

.presence-modal-card {
  --pm-accent: #10b981;
  --pm-accent-soft: rgba(16, 185, 129, 0.10);
  --pm-accent-glow: rgba(16, 185, 129, 0.25);

  position: relative;
  z-index: 9302;
  background: #ffffff;
  border-radius: 20px;
  max-width: 440px;
  width: 100%;
  overflow: hidden;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.06),
    0 20px 60px rgba(0, 0, 0, 0.18),
    0 4px 16px rgba(0, 0, 0, 0.08);
  transform: scale(0.86) translateY(20px);
  opacity: 0;
  transition:
    transform 0.44s cubic-bezier(0.34, 1.56, 0.64, 1),
    opacity   0.28s ease;
}

.presence-modal-card--easy {
  --pm-accent: #10b981;
  --pm-accent-soft: rgba(16, 185, 129, 0.10);
  --pm-accent-glow: rgba(16, 185, 129, 0.25);
}

.presence-modal-card--medium {
  --pm-accent: #f59e0b;
  --pm-accent-soft: rgba(245, 158, 11, 0.10);
  --pm-accent-glow: rgba(245, 158, 11, 0.25);
}

.presence-modal-card--hard {
  --pm-accent: #6366f1;
  --pm-accent-soft: rgba(99, 102, 241, 0.10);
  --pm-accent-glow: rgba(99, 102, 241, 0.25);
}

.presence-modal-card.presence-modal-card-in {
  transform: scale(1) translateY(0);
  opacity: 1;
}

.presence-modal-card.presence-modal-card-out {
  transform: scale(0.9) translateY(10px);
  opacity: 0;
  transition: transform 0.22s ease, opacity 0.22s ease;
}

/* ── Close button (top-right) ── */

.presence-modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  color: #9ca3af;
  cursor: pointer;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
  z-index: 10;
}

.presence-modal-close:hover {
  background: rgba(0, 0, 0, 0.05);
  color: #111827;
}

[data-theme="dark"] .presence-modal-close {
  color: #6b7280;
}

[data-theme="dark"] .presence-modal-close:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #f9fafb;
}

/* ── Support link (WhatsApp) ── */

.presence-modal-support-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  align-self: center;
  font-size: 0.75rem;
  color: #25D366;
  text-decoration: none;
  font-weight: 500;
  padding: 0.45rem 0.9rem;
  border: 1px solid rgba(37, 211, 102, 0.3);
  border-radius: 999px;
  background: rgba(37, 211, 102, 0.05);
  transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
  margin-bottom: 0.4rem;
}

.presence-modal-support-link:hover {
  background: rgba(37, 211, 102, 0.12);
  border-color: rgba(37, 211, 102, 0.55);
}

[data-theme="dark"] .presence-modal-support-link {
  background: rgba(37, 211, 102, 0.08);
  border-color: rgba(37, 211, 102, 0.35);
}

/* ── "Gerar novo desafio" secondary button ── */

.presence-modal-reissue {
  align-self: center;
  margin-top: 0.25rem;
  background: transparent;
  border: 1px solid #e5e7eb;
  color: #6b7280;
  padding: 0.42rem 0.95rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.02em;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.presence-modal-reissue:hover {
  border-color: var(--pm-accent);
  color: var(--pm-accent);
  background: var(--pm-accent-soft);
}

.presence-modal-reissue:disabled {
  opacity: 0.55;
  cursor: default;
}

[data-theme="dark"] .presence-modal-reissue {
  border-color: #374151;
  color: #9ca3af;
}

/* ── Identity zone ── */

.presence-modal-identity {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 2rem 1.75rem 1.5rem;
  background: var(--pm-accent-soft);
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  position: relative;
}

.presence-modal-identity::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--pm-accent);
  border-radius: 0 0 3px 3px;
}

.presence-modal-icon-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--pm-accent);
  color: #ffffff;
  margin-bottom: 1rem;
  box-shadow: 0 4px 16px var(--pm-accent-glow);
}

.presence-modal-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 800;
  color: #111827;
  margin: 0 0 0.45rem;
  letter-spacing: -0.01em;
}

.presence-modal-desc {
  font-size: 0.85rem;
  color: #6b7280;
  line-height: 1.65;
  margin: 0;
  max-width: 320px;
}

.presence-modal-level-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.9rem;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--pm-accent);
  background: #ffffff;
  border: 1px solid var(--pm-accent-glow);
  letter-spacing: 0.06em;
}

/* ── Action zone ── */

.presence-modal-action {
  padding: 1.5rem 1.75rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.presence-modal-flash {
  border-radius: 8px;
  padding: 0.6rem 0.85rem;
  font-size: 0.78rem;
  line-height: 1.5;
}

.presence-modal-flash--error {
  background: #fff5f5;
  color: #c53030;
  border: 1px solid #fed7d7;
}

.presence-modal-flash--success {
  background: #f0fff4;
  color: #276749;
  border: 1px solid #c6f6d5;
}

/* ── Hold-to-Play (Easy) ── */

.presence-modal-hold {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.55rem;
}

.presence-modal-hold-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  width: 100%;
  padding: 1rem 1.5rem;
  background: #f3f4f6;
  color: var(--pm-accent);
  border: 2px solid var(--pm-accent);
  border-radius: 14px;
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  overflow: hidden;
  letter-spacing: 0.02em;
  transition: transform 0.1s ease;
}

.presence-modal-hold-btn:active {
  transform: scale(0.98);
}

.presence-modal-hold-btn::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--pm-accent);
  transform-origin: left center;
  transform: scaleX(var(--pm-hold-progress, 0));
  pointer-events: none;
  z-index: 0;
  transition: transform 0.06s linear;
}

.presence-modal-hold-btn[data-armed="true"] {
  color: #ffffff;
}

.presence-modal-hold-btn span {
  position: relative;
  z-index: 1;
  mix-blend-mode: difference;
  color: #ffffff;
}

.presence-modal-hold-hint {
  font-size: 0.72rem;
  color: #6b7280;
  text-align: center;
  margin: 0;
}

/* ── Word distorted SVG (Medium) ── */

.presence-modal-word {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.presence-modal-word-canvas {
  background: #fafafa;
  border: 2px dashed #e5e7eb;
  border-radius: 14px;
  padding: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 110px;
}

.presence-modal-word-canvas svg {
  max-width: 100%;
  height: auto;
}

.presence-modal-word-row {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}

.presence-modal-word-input {
  flex: 1;
  min-width: 0;
  text-align: center;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  padding: 0.68rem 0.6rem;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  background: #fafafa;
  color: #111827;
  outline: none;
  text-transform: lowercase;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.presence-modal-word-input:focus {
  border-color: var(--pm-accent);
  box-shadow: 0 0 0 3px var(--pm-accent-glow);
  background: #ffffff;
}

/* ── Sequence memory (Hard) ── */

.presence-modal-sequence {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  align-items: center;
}

.presence-modal-sequence-turnstile {
  display: flex;
  justify-content: center;
  min-height: 65px;
}

.presence-modal-sequence-canvas {
  display: block;
  width: 100%;
  max-width: 320px;
  height: auto;
  aspect-ratio: 1 / 1;
  border-radius: 14px;
  background: #0f172a;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}

.presence-modal-sequence-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.55rem;
  width: 100%;
  max-width: 280px;
  aspect-ratio: 1 / 1;
}

.presence-modal-sequence-cell {
  background: #f3f4f6;
  border: 2px solid #e5e7eb;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.4rem;
  color: transparent;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.18s ease, border-color 0.18s ease;
  user-select: none;
}

.presence-modal-sequence-cell.is-flashing {
  background: var(--pm-accent);
  border-color: var(--pm-accent);
  color: #ffffff;
  transform: scale(1.04);
}

.presence-modal-sequence-cell.is-tapped {
  background: var(--pm-accent-soft);
  border-color: var(--pm-accent);
  color: var(--pm-accent);
}

.presence-modal-sequence-cell:active {
  transform: scale(0.97);
}

.presence-modal-sequence-status {
  font-size: 0.75rem;
  color: #6b7280;
  text-align: center;
  margin: 0;
  font-weight: 600;
}

/* ── Common button ── */

.presence-modal-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  width: 100%;
  padding: 0.78rem 1.5rem;
  background: var(--pm-accent);
  color: #ffffff;
  border: none;
  border-radius: 12px;
  font-family: var(--font-display);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.1s ease;
  letter-spacing: 0.01em;
}

.presence-modal-btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
.presence-modal-btn:active { transform: scale(0.98); }
.presence-modal-btn:disabled { opacity: 0.55; cursor: default; transform: none; }

/* ── Dark mode ── */

[data-theme="dark"] .presence-modal-card {
  background: #17202e;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.06),
    0 20px 60px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .presence-modal-identity {
  border-bottom-color: rgba(255, 255, 255, 0.07);
}

[data-theme="dark"] .presence-modal-title { color: #f9fafb; }
[data-theme="dark"] .presence-modal-desc  { color: #9ca3af; }

[data-theme="dark"] .presence-modal-hold-btn {
  background: rgba(255, 255, 255, 0.04);
}

[data-theme="dark"] .presence-modal-word-canvas {
  background: rgba(255, 255, 255, 0.04);
  border-color: #374151;
}

[data-theme="dark"] .presence-modal-word-input {
  background: #1f2937;
  border-color: #374151;
  color: #f9fafb;
}

[data-theme="dark"] .presence-modal-sequence-cell {
  background: rgba(255, 255, 255, 0.05);
  border-color: #374151;
}

[data-theme="dark"] .presence-modal-level-badge {
  background: rgba(255, 255, 255, 0.06);
}
