/* ────────────────────────────────────────────────────────────────────
 * Spartan CRM — Email reminders top bar (WIP-V2.1-EMAIL-INTAKE-01)
 * Companion to modules/38-email-reminders-bar.js
 *
 * Pulse escalates by day-count:
 *   Day 0-1  → .er-pulse-normal   (2.4s red pulse, normal banner)
 *   Day 2    → .er-pulse-super    (1.4s super-red pulse, thicker border)
 *   Day 3+   → .er-pulse-fullscreen / .er-pulse-extreme
 *               full-screen red overlay + 1.0s pulse on the banner
 *               body.er-fullscreen-active locks the screen until the
 *               user resolves, snoozes, or dismisses the overlay
 *
 * All gated by prefers-reduced-motion: reduce.
 * ──────────────────────────────────────────────────────────────────── */

#email-reminders-root {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9000; /* above the topbar (56px @ z 100-200) but below modals */
  pointer-events: none;
}
#email-reminders-root .er-banner {
  pointer-events: auto;
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 10px 18px;
  background: linear-gradient(180deg, rgba(220,38,38,.95) 0%, rgba(196,18,48,.95) 100%);
  color: #fff;
  font-family: 'Archivo', system-ui, sans-serif;
  font-size: 13px;
  border-bottom: 2px solid rgba(255,255,255,.18);
  box-shadow: 0 6px 20px -2px rgba(220,38,38,.55);
}

.er-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(255,255,255,.18);
  border: 1px solid rgba(255,255,255,.35);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}
.er-icon svg { width: 18px; height: 18px; }

.er-body { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.er-h {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: 'Archivo Narrow', sans-serif;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: rgba(255,255,255,.92);
}
.er-sep { opacity: .5; }
.er-age { color: #fff; }
.er-priority { padding: 2px 6px; border-radius: 4px; background: rgba(255,255,255,.18); }
.er-priority-critical { background: #fff; color: #991B1B; }
.er-ai-tag {
  background: rgba(124,58,237,.45);
  border: 1px solid rgba(124,58,237,.6);
  color: #fff;
  padding: 2px 6px;
  border-radius: 4px;
}

.er-title {
  font-size: 14px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -.005em;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: calc(100vw - 480px);
}
.er-text {
  font-size: 12px;
  color: rgba(255,255,255,.88);
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: calc(100vw - 480px);
}

.er-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.er-more,
.er-action {
  padding: 7px 11px;
  border-radius: 7px;
  font-family: 'Archivo Narrow', sans-serif;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  cursor: pointer;
  border: 1px solid rgba(255,255,255,.35);
  background: rgba(255,255,255,.12);
  color: #fff;
  transition: background 150ms ease, transform 150ms ease;
}
.er-more:hover,
.er-action:hover { background: rgba(255,255,255,.22); transform: translateY(-1px); }
.er-action.er-resolve {
  background: #fff;
  color: #991B1B;
  border-color: #fff;
}
.er-action.er-resolve:hover { background: #FECACA; }

/* Body padding adjustment when banner is present — push the app down */
body:has(#email-reminders-root .er-banner) main,
body:has(#email-reminders-root .er-banner) .tb,
body:has(#email-reminders-root .er-banner) .mod {
  margin-top: 0;
}

/* ── Pulse keyframes — escalating ─────────────────────────────────── */
@keyframes er-pulse-normal {
  0%, 100% { box-shadow: 0 6px 20px -2px rgba(220,38,38,.55), 0 0 0 0 rgba(220,38,38,.45); }
  50%      { box-shadow: 0 6px 20px -2px rgba(220,38,38,.55), 0 0 0 6px rgba(220,38,38,0); }
}
@keyframes er-pulse-super {
  0%, 100% { box-shadow: 0 6px 20px -2px rgba(220,38,38,.7), inset 0 0 0 2px rgba(255,255,255,.4), 0 0 0 0 rgba(220,38,38,.7); }
  50%      { box-shadow: 0 6px 20px -2px rgba(220,38,38,.9), inset 0 0 0 3px rgba(255,255,255,.7), 0 0 0 10px rgba(220,38,38,0); }
}
@keyframes er-pulse-fullscreen-banner {
  0%, 100% { box-shadow: 0 8px 30px -2px rgba(220,38,38,.95), inset 0 0 0 3px rgba(255,255,255,.8); transform: translateY(0); }
  50%      { box-shadow: 0 8px 40px -2px rgba(220,38,38,1),   inset 0 0 0 5px rgba(255,255,255,1);   transform: translateY(-1px); }
}
@keyframes er-fullscreen-flash {
  0%, 100% { background: rgba(220,38,38,.12); }
  50%      { background: rgba(220,38,38,.32); }
}

.er-banner.er-pulse-normal     { animation: er-pulse-normal 2.4s ease-in-out infinite; }
.er-banner.er-pulse-super      { animation: er-pulse-super 1.4s ease-in-out infinite; }
.er-banner.er-pulse-fullscreen { animation: er-pulse-fullscreen-banner 1.0s ease-in-out infinite; }
.er-banner.er-pulse-extreme    { animation: er-pulse-fullscreen-banner 0.8s ease-in-out infinite; background: linear-gradient(180deg, #991B1B 0%, #7F1D1D 100%); }

/* ── Full-screen overlay (day 3+) ─────────────────────────────────── */
.er-fullscreen-overlay {
  position: fixed;
  inset: 0;
  z-index: 8900; /* below banner, above app */
  background: rgba(220,38,38,.18);
  animation: er-fullscreen-flash 1.0s ease-in-out infinite;
  pointer-events: auto;
  cursor: pointer; /* click to dismiss the overlay (banner stays) */
}

/* When fullscreen-active body class is set, also tint the entire app
   subtly so the user knows something is demanding their attention. */
body.er-fullscreen-active main {
  filter: saturate(0.85) brightness(0.96);
  transition: filter 300ms ease;
}

@media (prefers-reduced-motion: reduce) {
  .er-banner,
  .er-banner.er-pulse-normal,
  .er-banner.er-pulse-super,
  .er-banner.er-pulse-fullscreen,
  .er-banner.er-pulse-extreme,
  .er-fullscreen-overlay {
    animation: none !important;
  }
  .er-banner.er-pulse-super,
  .er-banner.er-pulse-fullscreen,
  .er-banner.er-pulse-extreme {
    box-shadow: 0 8px 28px -2px rgba(220,38,38,.7), inset 0 0 0 2.5px #fff;
  }
}

/* Narrower screens — stack actions + truncate title */
@media (max-width: 900px) {
  #email-reminders-root .er-banner {
    grid-template-columns: 36px 1fr;
    gap: 10px;
    padding: 10px 14px;
  }
  #email-reminders-root .er-actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
    flex-wrap: wrap;
  }
  .er-title,
  .er-text { max-width: 100%; }
}
