/*
  Shared background decor + animated visuals ("Lottie-like", built in CSS/SVG:
  no animation library, no third-party request). Used by index, bewerbung,
  anfrage, danke, followup-report, followup-training and the legal pages.
  (followup-kurs and followup-kurs-zugang carry their own inline version.)

  1. DECOR — <div class="sh-decor [is-dark|is-page]" aria-hidden="true"> as the
     first child of a section (or of <body> with .is-page), holding <i> motifs:
       .d-grid  hairline grid, faded out by a radial mask (--gx/--gy = centre)
       .d-dots  dot grid in a soft circle
       .d-glow  warm light (accent at low alpha; --d-glow = r,g,b)
       .d-grain film grain (light sections only)
     Position modifiers: .tl .tr .bl .br .cl .cr .c
     The host gets position:relative + isolation:isolate (via :has), so the
     decor's z-index:-1 sits above the host's background and below its content.

  2. VISUALS — elements with [data-fx]. Their markup shows the final state, so
     with JS off or prefers-reduced-motion nothing is hidden. /js/sh-fx.js sets
     html.sh-motion (only when motion is allowed) and toggles .is-live while a
     visual is on screen; every animation below needs both. Opacity/transform
     only.
*/

/* ---------- 1. Decor ---------- */
:is(section, main, header, footer, body):has(> .sh-decor) { position: relative; isolation: isolate; }
.sh-decor {
  position: absolute; inset: 0; z-index: -1; overflow: hidden; pointer-events: none;
  --d-line: rgba(6,8,12,0.085);
  --d-dot: rgba(6,8,12,0.26);
  --d-glow: 255,122,89;
  --d-glow-a: 0.26;
}
.sh-decor.is-dark { --d-line: rgba(255,255,255,0.06); --d-dot: rgba(255,255,255,0.2); --d-glow-a: 0.34; }
.sh-decor.is-page { inset: 0 0 auto 0; height: min(1100px, 100%); }
.sh-decor > i { position: absolute; display: block; }
.sh-decor .d-grid {
  inset: 0;
  background-image:
    linear-gradient(to right, var(--d-line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--d-line) 1px, transparent 1px);
  background-size: 72px 72px; background-position: center top;
  -webkit-mask-image: radial-gradient(ellipse 65% 60% at var(--gx, 50%) var(--gy, 0%), #000 15%, transparent 72%);
  mask-image: radial-gradient(ellipse 65% 60% at var(--gx, 50%) var(--gy, 0%), #000 15%, transparent 72%);
}
.sh-decor .d-dots {
  width: min(560px, 130vw); aspect-ratio: 1;
  background-image: radial-gradient(var(--d-dot) 1.2px, transparent 1.7px);
  background-size: 20px 20px;
  -webkit-mask-image: radial-gradient(circle at center, #000 0%, transparent 66%);
  mask-image: radial-gradient(circle at center, #000 0%, transparent 66%);
}
.sh-decor .d-glow {
  width: min(780px, 170vw); aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(var(--d-glow), var(--d-glow-a)), rgba(var(--d-glow), calc(var(--d-glow-a) * 0.3)) 55%, rgba(var(--d-glow), 0));
}
.sh-decor .d-glow.is-soft { --d-glow-a: 0.17; }
.sh-decor.is-dark .d-glow.is-soft { --d-glow-a: 0.24; }
.sh-decor .d-grain {
  inset: 0; opacity: 0.85; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.sh-decor .d-glow.tl, .sh-decor .d-dots.tl { left: -18%; top: -38%; }
.sh-decor .d-glow.tr, .sh-decor .d-dots.tr { right: -18%; top: -38%; }
.sh-decor .d-glow.bl, .sh-decor .d-dots.bl { left: -18%; bottom: -42%; }
.sh-decor .d-glow.br, .sh-decor .d-dots.br { right: -18%; bottom: -42%; }
.sh-decor .d-glow.cl, .sh-decor .d-dots.cl { left: -24%; top: 50%; transform: translateY(-50%); }
.sh-decor .d-glow.cr, .sh-decor .d-dots.cr { right: -24%; top: 50%; transform: translateY(-50%); }
.sh-decor .d-glow.c { left: 50%; top: 50%; transform: translate(-50%, -50%); }
.sh-decor .d-dots.tl, .sh-decor .d-dots.tr { top: -14%; }
.sh-decor .d-dots.bl, .sh-decor .d-dots.br { bottom: -18%; }
.sh-decor .d-dots.tl, .sh-decor .d-dots.bl { left: -8%; }
.sh-decor .d-dots.tr, .sh-decor .d-dots.br { right: -8%; }

@keyframes shfx-breathe { 0%, 100% { opacity: 0.75; } 50% { opacity: 1; } }
.sh-motion .sh-decor .d-glow { animation: shfx-breathe 11s ease-in-out infinite; }

/* ---------- 2. Visuals ---------- */
.fx { --fx-ink: #06080C; --fx-accent: #FF7A59; --fx-muted: #5F6672; --fx-soft: #E9ECF1; --fx-bg: #FFFFFF; position: relative; }
.fx.is-dark { --fx-ink: #F8F9FA; --fx-muted: #A3A3A3; --fx-soft: rgba(255,255,255,0.10); --fx-bg: #0E1116; }
.fx-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; line-height: 1.3; color: var(--fx-muted); margin-bottom: 10px; }
.fx-legend span { display: inline-flex; align-items: center; gap: 7px; }
.fx-legend span::before { content: ''; width: 10px; height: 10px; border-radius: 3px; background: var(--fx-soft); }
.fx-legend .k-ink::before { background: var(--fx-ink); }
.fx-legend .k-accent::before { background: var(--fx-accent); }

/* A — line chart revealed left to right (a cover scales away: transform only) */
.fx-chart { margin-top: 22px; padding: 16px 16px 12px; border-radius: 14px; background: var(--fx-bg); border: 1px solid rgba(6,8,12,0.06); }
.fx-chart .plot { position: relative; height: 92px; }
.fx-chart svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.fx-chart .l-a { fill: none; stroke: var(--fx-ink); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.fx-chart .l-b { fill: none; stroke: var(--fx-accent); stroke-width: 2.5; stroke-dasharray: 6 5; stroke-linecap: round; }
.fx-chart .base { stroke: var(--fx-soft); stroke-width: 1; }
.fx-chart .cover { position: absolute; top: -6px; bottom: -6px; left: 0; right: -6px; background: var(--fx-bg); transform-origin: right; transform: scaleX(0); }
@keyframes shfx-wipe { from { transform: scaleX(1); } to { transform: scaleX(0); } }
.sh-motion .fx.is-live .cover { animation: shfx-wipe 2.4s cubic-bezier(0.45, 0, 0.2, 1) both; }

/* B — split bar: realised vs. left lying */
.fx-split { margin-top: 22px; padding: 16px; border-radius: 14px; background: var(--fx-bg); border: 1px solid rgba(6,8,12,0.06); }
.fx-split .bar { display: flex; gap: 4px; height: 26px; }
.fx-split .won { flex: 0 0 60%; border-radius: 7px; background: var(--fx-ink); transform-origin: left; }
.fx-split .lost { flex: 1; border-radius: 7px; border: 1.5px dashed var(--fx-accent);
  background: repeating-linear-gradient(135deg, rgba(255,122,89,0.22) 0 6px, rgba(255,122,89,0.06) 6px 12px); }
.fx-split .labels { display: flex; justify-content: space-between; gap: 12px; margin-top: 10px; font-size: 13px; color: var(--fx-muted); }
.fx-split .labels b { color: var(--fx-accent); font-weight: 700; }
@keyframes shfx-grow-x { from { transform: scaleX(0.04); } to { transform: scaleX(1); } }
@keyframes shfx-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
.sh-motion .fx.is-live .won { animation: shfx-grow-x 1.6s cubic-bezier(0.22, 1, 0.36, 1) both; }
.sh-motion .fx.is-live .lost { animation: shfx-pulse 1.8s ease-in-out 1.4s infinite; }

/* C — pipeline: a deal walks through four stages */
.fx-pipe { margin: 4px 0 26px; padding: 16px; border-radius: 16px; background: var(--fx-bg); border: 1px solid rgba(255,255,255,0.07); }
.fx-pipe .cols { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; font-size: 12px; font-weight: 600; color: var(--fx-muted); margin-bottom: 8px; }
.fx-pipe .cols span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fx-pipe .lanes { position: relative; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.fx-pipe .lane { height: 74px; border-radius: 10px; background: var(--fx-soft); }
.fx-pipe .lane i { display: block; height: 16px; margin: 10px 8px 0; border-radius: 5px; background: rgba(255,255,255,0.08); }
.fx-pipe .deal { position: absolute; left: 0; top: 0; width: calc((100% - 24px) / 4); height: 74px; padding: 8px; }
.fx-pipe .deal span { display: flex; align-items: center; height: 100%; padding: 0 10px; border-radius: 9px;
  background: var(--fx-accent); color: #FFFFFF; font-size: 12px; font-weight: 700; box-shadow: 0 8px 22px rgba(255,122,89,0.35); }
.fx-pipe .deal { transform: translateX(calc(300% + 24px)); }
@keyframes shfx-walk {
  0%, 14%   { transform: translateX(0); }
  24%, 38%  { transform: translateX(calc(100% + 8px)); }
  48%, 62%  { transform: translateX(calc(200% + 16px)); }
  72%, 92%  { transform: translateX(calc(300% + 24px)); }
  100%      { transform: translateX(calc(300% + 24px)); opacity: 0; }
}
.sh-motion .fx.is-live .deal { animation: shfx-walk 7s cubic-bezier(0.65, 0, 0.35, 1) infinite; }

/* D — stacked bars: the follow-up share grows month by month */
.fx-stack { margin: 4px 0 26px; padding: 16px; border-radius: 16px; background: var(--fx-bg); border: 1px solid rgba(255,255,255,0.07); }
.fx-stack .bars { display: flex; align-items: flex-end; gap: 10px; height: 120px; }
.fx-stack .bars > span { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; gap: 3px; height: 100%; }
.fx-stack .top { border-radius: 6px 6px 2px 2px; background: var(--fx-accent); transform-origin: bottom; }
.fx-stack .bottom { border-radius: 2px; background: var(--fx-soft); }
@keyframes shfx-grow-y { from { transform: scaleY(0.05); } to { transform: scaleY(1); } }
.sh-motion .fx.is-live .top { animation: shfx-grow-y 1.2s cubic-bezier(0.22, 1, 0.36, 1) both; }
.sh-motion .fx.is-live .bars > span:nth-child(2) .top { animation-delay: 0.1s; }
.sh-motion .fx.is-live .bars > span:nth-child(3) .top { animation-delay: 0.2s; }
.sh-motion .fx.is-live .bars > span:nth-child(4) .top { animation-delay: 0.3s; }
.sh-motion .fx.is-live .bars > span:nth-child(5) .top { animation-delay: 0.4s; }
.sh-motion .fx.is-live .bars > span:nth-child(6) .top { animation-delay: 0.5s; }

/* E — small animated icons (offer) */
.fx-icon { width: 64px; height: 64px; border-radius: 16px; background: #FFFFFF; border: 1px solid rgba(6,8,12,0.06);
  box-shadow: 0 1px 2px rgba(6,8,12,0.04), 0 8px 20px rgba(6,8,12,0.06); display: grid; place-items: center; margin-bottom: 18px; }
.fx-icon svg { width: 40px; height: 40px; overflow: visible; }
.fx-icon .ink { fill: none; stroke: var(--fx-ink); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.fx-icon .acc { fill: var(--fx-accent); }
.fx-icon .acc-line { fill: none; stroke: var(--fx-accent); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.fx-icon .spin, .fx-icon .spin-r, .fx-icon .bar, .fx-icon .runner, .fx-icon .ping { transform-box: fill-box; transform-origin: center; }
.fx-icon .bar { transform-origin: bottom; }
@keyframes shfx-spin { to { transform: rotate(360deg); } }
@keyframes shfx-spin-r { to { transform: rotate(-360deg); } }
@keyframes shfx-bounce { 0%, 100% { transform: scaleY(1); } 50% { transform: scaleY(0.45); } }
@keyframes shfx-run { 0% { transform: translateX(0); opacity: 0; } 10% { opacity: 1; } 90% { opacity: 1; } 100% { transform: translateX(28px); opacity: 0; } }
@keyframes shfx-ping { 0% { transform: scale(0.6); opacity: 0.9; } 100% { transform: scale(2.2); opacity: 0; } }
.sh-motion .fx.is-live .spin { animation: shfx-spin 6s linear infinite; }
.sh-motion .fx.is-live .spin-r { animation: shfx-spin-r 4s linear infinite; }
.sh-motion .fx.is-live .bar { animation: shfx-bounce 1.6s ease-in-out infinite; }
.sh-motion .fx.is-live .bar:nth-of-type(2) { animation-delay: 0.25s; }
.sh-motion .fx.is-live .bar:nth-of-type(3) { animation-delay: 0.5s; }
.sh-motion .fx.is-live .runner { animation: shfx-run 2.2s ease-in-out infinite; }
.sh-motion .fx.is-live .ping { animation: shfx-ping 1.8s ease-out infinite; }
.fx-icon .runner { opacity: 1; }
.fx-icon .ping { opacity: 0; }

/* F — play pulse ring (video previews on the follow-up pages) */
@keyframes shfx-ring { 0% { transform: scale(1); opacity: 0.55; } 100% { transform: scale(1.9); opacity: 0; } }
.sh-motion .fx-ring { position: relative; isolation: isolate; }
.sh-motion .fx-ring::after { content: ''; position: absolute; inset: 0; border-radius: inherit; background: currentColor; opacity: 0;
  animation: shfx-ring 2.2s ease-out infinite; pointer-events: none; z-index: -1; }
.sh-motion .fx-ring::after { background: var(--ring, currentColor); }

@media (prefers-reduced-motion: reduce) {
  .sh-motion *, .sh-motion *::before, .sh-motion *::after { animation: none !important; }
}
