/* Ladeanimationen: dünne Leiste oben, Overlay für lange Aktionen, Fortschrittsbalken für Hintergrund-Läufe.
   Farben kommen aus den Variablen in theme.css (hell/dunkel). */

/* --- Leiste oben bei Seitenwechseln --- */
#sa-topbar {
  position: fixed; inset: 0 0 auto 0; height: 3px; z-index: 2000; pointer-events: none;
  opacity: 0; transition: opacity .2s;
}
#sa-topbar::before {
  content: ""; display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--brand-accent), var(--brand-strong), var(--brand-accent));
  background-size: 200% 100%; box-shadow: 0 0 8px var(--brand-accent);
  border-radius: 0 2px 2px 0;
}
#sa-topbar.is-active { opacity: 1; }
#sa-topbar.is-active::before { animation: sa-topbar-grow 12s cubic-bezier(.1, .6, .2, 1) forwards, sa-shimmer 1.2s linear infinite; }

/* --- Overlay für lange Aktionen --- */
#sa-loader {
  position: fixed; inset: 0; z-index: 1900; display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  opacity: 0; visibility: hidden; transition: opacity .25s, visibility .25s;
}
#sa-loader.is-active { opacity: 1; visibility: visible; }
.sa-loader-card {
  display: flex; flex-direction: column; align-items: center; gap: 18px; text-align: center;
  padding: 34px 44px; max-width: 420px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 12px 40px rgba(24, 24, 27, .18);
}
.sa-orb { position: relative; width: 84px; height: 84px; display: grid; place-items: center; }
.sa-orb img { width: 38px; height: 38px; position: relative; z-index: 2; animation: sa-breathe 1.8s ease-in-out infinite; }
.sa-orb::before, .sa-orb::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid var(--brand-accent); opacity: 0; animation: sa-ripple 2.2s ease-out infinite;
}
.sa-orb::after { animation-delay: 1.1s; }
.sa-orb .sa-arc {
  position: absolute; inset: 6px; border-radius: 50%;
  border: 3px solid transparent; border-top-color: var(--brand-accent); border-right-color: var(--brand-accent);
  animation: sa-spin 1.1s linear infinite;
}
.sa-loader-title { font-size: 16px; font-weight: 600; color: var(--text); margin: 0; }
.sa-loader-sub { font-size: 13px; color: var(--text-muted); margin: 0; min-height: 1.3em; }
.sa-dots span { display: inline-block; animation: sa-dot 1.2s infinite both; }
.sa-dots span:nth-child(2) { animation-delay: .2s; }
.sa-dots span:nth-child(3) { animation-delay: .4s; }

/* --- Fortschritt eines Hintergrund-Laufs --- */
.sa-progress {
  margin: 14px 0 20px; padding: 16px 18px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); max-width: 640px;
}
.sa-progress-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 10px; }
.sa-progress-title { font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 10px; }
.sa-progress-title .sa-pulse {
  width: 10px; height: 10px; border-radius: 50%; background: var(--brand-accent);
  box-shadow: 0 0 0 0 var(--brand-accent); animation: sa-pulse 1.6s infinite;
}
.sa-progress.is-finished .sa-pulse { animation: none; background: var(--ok); }
.sa-progress-count { font-variant-numeric: tabular-nums; color: var(--text-muted); font-size: 13px; }
.sa-progress-track { height: 12px; border-radius: 999px; background: var(--neutral-soft); overflow: hidden; }
.sa-progress-fill {
  height: 100%; width: 0; border-radius: 999px; transition: width .6s ease;
  background: repeating-linear-gradient(135deg, var(--brand-accent) 0 12px, var(--brand) 12px 24px);
  background-size: 34px 34px; animation: sa-stripes 1s linear infinite;
}
.sa-progress.is-finished .sa-progress-fill { animation: none; background: var(--ok); }
.sa-progress-detail { margin-top: 8px; font-size: 13px; color: var(--text-muted); min-height: 1.3em; }
.sa-progress-actions { margin-top: 10px; }

@keyframes sa-topbar-grow { 0% { width: 0; } 30% { width: 55%; } 100% { width: 92%; } }
@keyframes sa-shimmer { to { background-position: -200% 0; } }
@keyframes sa-spin { to { transform: rotate(360deg); } }
@keyframes sa-breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.14); } }
@keyframes sa-ripple { 0% { transform: scale(.55); opacity: .7; } 100% { transform: scale(1.25); opacity: 0; } }
@keyframes sa-dot { 0%, 80%, 100% { opacity: .2; } 40% { opacity: 1; } }
@keyframes sa-pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--brand-accent) 60%, transparent); } 70% { box-shadow: 0 0 0 9px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
@keyframes sa-stripes { to { background-position: 34px 0; } }

@media (prefers-reduced-motion: reduce) {
  #sa-topbar.is-active::before { animation: none; width: 70%; }
  .sa-orb img, .sa-orb::before, .sa-orb::after, .sa-orb .sa-arc, .sa-progress-fill,
  .sa-progress-title .sa-pulse, .sa-dots span { animation: none; }
  .sa-orb .sa-arc { border-color: var(--brand-accent); }
}

/* Laufende Aufgaben auf der Übersicht: ganze Karte ist ein Link zur Detailseite */
.sa-jobs { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 20px; }
.sa-jobs .sa-progress { margin: 0; min-width: 320px; }
.sa-job-link { display: block; flex: 1 1 360px; max-width: 640px; color: inherit; text-decoration: none; border-radius: 12px; }
.sa-job-link:hover { text-decoration: none; }
.sa-job-link:hover .sa-progress, .sa-job-link:focus-visible .sa-progress { border-color: var(--brand); }
.sa-job-link .sa-progress-title::after { content: "Öffnen →"; margin-left: 8px; font-size: 12px; font-weight: 500; color: var(--brand); }

/* Erklär-Kasten und Kampagnen-Übersicht (Teilnahmen) */
.sa-explain {
  margin: 0 0 20px; padding: 16px 20px; background: var(--surface); border: 1px solid var(--line);
  border-left: 4px solid var(--brand-accent); border-radius: 10px; box-shadow: var(--shadow); max-width: 820px;
}
.sa-explain h2 { margin: 0 0 8px; font-size: 15px; color: var(--text); }
.sa-explain p, .sa-explain li { color: var(--text-muted); line-height: 1.5; }
.sa-explain ul { margin: 6px 0 8px 18px; padding: 0; }
.sa-muted { color: var(--text-muted); }
.sa-chip {
  display: inline-block; padding: 2px 9px; margin: 1px 2px 1px 0; border-radius: 999px; font-size: 12px;
  background: var(--neutral-soft); color: var(--neutral); font-variant-numeric: tabular-nums;
}
.sa-chip.is-on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
