/* ==========================================================================
   viz.css -- "Scroll-Visuals" in Blogartikeln und Projektseiten
   (HTML: Services/VizRenderer.cs, Animation: js/viz.js)
   Idee: Inhalte bauen sich beim Scrollen Schritt fuer Schritt auf und machen
   den Text greifbarer (Scrollytelling). Nur CSS-Transform/Opacity -> fluessig
   auch auf schwachen Geraeten. Ohne JavaScript ist alles sofort sichtbar.
   ========================================================================== */

.viz {
    --viz-accent: var(--accent, #b775ff);
    --viz-accent-soft: rgba(183, 117, 255, .14);
    --viz-surface: var(--surface, #17161b);
    --viz-border: var(--border, rgba(255, 255, 255, .08));
    --viz-text: var(--text, #f4f4f6);
    --viz-muted: var(--text-muted, #a1a1aa);
    margin: 2.25rem 0;
    padding: clamp(18px, 3vw, 28px);
    border: 1px solid var(--viz-border);
    border-radius: 18px;
    background:
        radial-gradient(120% 90% at 0% 0%, rgba(183, 117, 255, .10), transparent 60%),
        var(--viz-surface);
    color: var(--viz-text);
    position: relative;
    overflow: hidden;
    container: viz / inline-size;
}

.viz-title {
    font-weight: 700;
    font-size: 1.05rem;
    margin: 0 0 1.1rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}
.viz-title::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--viz-accent);
    box-shadow: 0 0 12px var(--viz-accent);
}

/* ---- Einblenden beim Scrollen (nur wenn viz.js aktiv ist) ---- */
.viz-js .viz .viz-item {
    opacity: 0;
    transform: translateY(18px);
    transition: opacity .6s cubic-bezier(.16, 1, .3, 1), transform .6s cubic-bezier(.16, 1, .3, 1);
    transition-delay: calc(var(--i, 1) * 110ms);
}
.viz-js .viz.is-in .viz-item { opacity: 1; transform: none; }

/* ---- steps & timeline ---- */
.viz-steps, .viz-timeline {
    list-style: none;
    margin: 0;
    padding: 0 0 0 0;
    position: relative;
    display: grid;
    gap: 1.1rem;
}
.viz-steps-line {
    position: absolute;
    left: 17px;
    top: 8px;
    bottom: 8px;
    width: 2px;
    background: var(--viz-border);
    overflow: hidden;
}
.viz-steps-line::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(var(--viz-accent), #7c3aed);
    transform-origin: top;
    transform: scaleY(var(--viz-progress, 1));
}
.viz-js .viz .viz-steps-line::after { transform: scaleY(var(--viz-progress, 0)); }

.viz-steps li, .viz-timeline li {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr);
    gap: .9rem;
    align-items: start;
    position: relative;
}
.viz-step-num {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    background: var(--viz-surface);
    border: 2px solid var(--viz-accent);
    color: var(--viz-accent);
    position: relative;
    z-index: 1;
}
.viz-steps strong, .viz-timeline strong { display: block; margin-top: 6px; }
.viz-steps p, .viz-timeline p { margin: .25rem 0 0; color: var(--viz-muted); font-size: .95rem; line-height: 1.6; }

.viz-timeline li { grid-template-columns: 36px minmax(0, 1fr); }
.viz-time-label {
    grid-column: 2;
    grid-row: 1;
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--viz-accent);
}
.viz-timeline li > div { grid-column: 2; }
.viz-timeline li::before {
    content: "";
    grid-column: 1;
    grid-row: 1 / span 2;
    justify-self: center;
    width: 14px;
    height: 14px;
    margin-top: 4px;
    border-radius: 50%;
    background: var(--viz-accent);
    box-shadow: 0 0 0 5px var(--viz-accent-soft);
    z-index: 1;
}

/* ---- flow ---- */
.viz-flow {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem;
}
.viz-flow-node {
    padding: .6rem 1rem;
    border-radius: 12px;
    border: 1px solid var(--viz-accent);
    background: var(--viz-accent-soft);
    font-weight: 600;
    white-space: nowrap;
}
.viz-flow-arrow {
    position: relative;
    flex: 1 1 28px;
    min-width: 28px;
    max-width: 80px;
    height: 2px;
    background: var(--viz-border);
}
.viz-flow-arrow::after {
    content: "";
    position: absolute;
    right: -1px;
    top: -4px;
    border: 5px solid transparent;
    border-left-color: var(--viz-accent);
    border-right: 0;
}
.viz-flow-pulse {
    position: absolute;
    top: -3px;
    left: 0;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--viz-accent);
    box-shadow: 0 0 10px var(--viz-accent);
    opacity: 0;
}
.viz.is-in .viz-flow-pulse { animation: vizPulse 2.4s ease-in-out infinite; animation-delay: calc(var(--i, 1) * 300ms); }
@keyframes vizPulse {
    0% { left: 0; opacity: 0; }
    15% { opacity: 1; }
    85% { opacity: 1; }
    100% { left: calc(100% - 8px); opacity: 0; }
}
.viz-note { margin: 1rem 0 0; color: var(--viz-muted); font-size: .9rem; }

/* Wenig Platz (nach Breite des Visuals, nicht des Fensters): Kette senkrecht,
   damit am Zeilenende kein einzelner Pfeil "haengt". */
@keyframes vizPulseV {
    0% { top: 0; left: -3px; opacity: 0; }
    15%, 85% { opacity: 1; }
    100% { top: calc(100% - 8px); left: -3px; opacity: 0; }
}
@container viz (max-width: 700px) {
    .viz-flow { flex-direction: column; align-items: stretch; }
    .viz-flow-node { text-align: center; white-space: normal; }
    .viz-flow-arrow { width: 2px; height: 22px; min-width: 0; max-width: none; flex: none; align-self: center; }
    .viz-flow-arrow::after { right: -4px; top: auto; bottom: -1px; border: 5px solid transparent; border-top-color: var(--viz-accent); border-bottom: 0; }
    .viz.is-in .viz-flow-pulse { animation-name: vizPulseV; }
}

/* ---- stats ---- */
.viz-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr));
    gap: 1rem;
}
.viz-stat {
    padding: 1rem;
    border-radius: 14px;
    background: var(--viz-accent-soft);
    border: 1px solid rgba(183, 117, 255, .25);
    text-align: center;
}
.viz-stat-value {
    display: block;
    font-size: clamp(1.8rem, 4vw, 2.4rem);
    font-weight: 800;
    line-height: 1.1;
    color: var(--viz-accent);
    font-variant-numeric: tabular-nums;
}
.viz-stat-label { display: block; margin-top: .35rem; color: var(--viz-muted); font-size: .9rem; }

/* ---- bars ---- */
.viz-bars { display: grid; gap: .8rem; }
.viz-bar {
    display: grid;
    grid-template-columns: minmax(90px, 30%) minmax(0, 1fr) auto;
    gap: .75rem;
    align-items: center;
    font-size: .92rem;
}
.viz-bar-track { height: 10px; border-radius: 999px; background: var(--viz-border); overflow: hidden; }
.viz-bar-fill {
    display: block;
    height: 100%;
    width: var(--w, 0%);
    border-radius: inherit;
    background: linear-gradient(90deg, #7c3aed, var(--viz-accent));
    transform-origin: left;
    transition: transform 1.1s cubic-bezier(.16, 1, .3, 1);
    transition-delay: calc(var(--i, 1) * 120ms + 150ms);
}
.viz-js .viz .viz-bar-fill { transform: scaleX(0); }
.viz-js .viz.is-in .viz-bar-fill { transform: scaleX(1); }
.viz-bar-value { font-weight: 700; font-variant-numeric: tabular-nums; }
@media (max-width: 575.98px) {
    .viz-bar { grid-template-columns: minmax(0, 1fr) auto; }
    .viz-bar-track { grid-column: 1 / -1; grid-row: 2; }
}

/* ---- compare ---- */
.viz-compare {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    gap: 1rem;
    align-items: stretch;
}
.viz-compare-col {
    padding: 1rem 1.1rem;
    border-radius: 14px;
    border: 1px solid var(--viz-border);
    background: rgba(255, 255, 255, .02);
}
.viz-compare-right { border-color: rgba(183, 117, 255, .45); background: var(--viz-accent-soft); }
.viz-compare-col ul { margin: .6rem 0 0; padding-left: 1.1rem; color: var(--viz-muted); }
.viz-compare-col li { margin-bottom: .35rem; }
.viz-compare-vs {
    align-self: center;
    font-weight: 800;
    font-size: .8rem;
    text-transform: uppercase;
    color: var(--viz-muted);
}
.viz-js .viz .viz-compare-left { transform: translateX(-24px); }
.viz-js .viz .viz-compare-right { transform: translateX(24px); }
.viz-js .viz.is-in .viz-compare-col { transform: none; }
@media (max-width: 575.98px) {
    .viz-compare { grid-template-columns: minmax(0, 1fr); }
    .viz-compare-vs { justify-self: center; }
}

/* ---- callout ---- */
.viz--callout { padding: 0; border: none; background: none; }
.viz-callout {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr);
    gap: .9rem;
    align-items: start;
    padding: 1.1rem 1.25rem;
    border-radius: 16px;
    border: 1px solid rgba(183, 117, 255, .4);
    border-left-width: 4px;
    background: var(--viz-accent-soft);
}
.viz-callout--warning { border-color: rgba(250, 204, 21, .55); background: rgba(250, 204, 21, .08); }
.viz-callout--tip { border-color: rgba(34, 197, 94, .5); background: rgba(34, 197, 94, .08); }
.viz-callout-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    background: var(--viz-accent);
    color: #fff;
}
.viz-callout--warning .viz-callout-icon { background: #facc15; color: #111; }
.viz-callout--tip .viz-callout-icon { background: #22c55e; }
.viz-callout p { margin: .25rem 0 0; color: var(--viz-text); opacity: .9; line-height: 1.6; }

/* ---- Admin-Vorschau: fehlerhafter Block ---- */
.viz-error {
    margin: 1.5rem 0;
    padding: .8rem 1rem;
    border-radius: 10px;
    border: 1px solid #ef4444;
    background: rgba(239, 68, 68, .1);
    color: #fca5a5;
    font-size: .9rem;
}

@media (prefers-reduced-motion: reduce) {
    .viz-js .viz .viz-item, .viz-js .viz .viz-bar-fill, .viz-js .viz .viz-compare-col { opacity: 1; transform: none; transition: none; }
    .viz-js .viz .viz-steps-line::after { transform: scaleY(1); }
    .viz.is-in .viz-flow-pulse { animation: none; }
}

@media print {
    .viz .viz-item, .viz .viz-bar-fill { opacity: 1 !important; transform: none !important; }
}

/* ---- Admin: KI-Vorschlaege (viz-ai.js) ---- */
.viz-ai-bar { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin: .35rem 0; }
.viz-ai-hint { font-size: .8rem; color: var(--text-3, #8b8b94); }
.viz-ai-panel { margin-top: .75rem; padding: 1rem; border: 1px dashed var(--border-strong, #63636f); border-radius: 12px; background: var(--surface-2, #18181d); }
.viz-ai-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .75rem; }
.viz-ai-head strong { flex: 1; }
.viz-ai-item { border-top: 1px solid var(--border, rgba(255,255,255,.06)); padding-top: .75rem; margin-top: .75rem; }
.viz-ai-item:first-of-type { border-top: 0; margin-top: 0; padding-top: 0; }
.viz-ai-meta { font-size: .82rem; color: var(--text-2, #a1a1aa); }
.viz-ai-preview .viz { margin: .6rem 0; }
.viz-ai-loading { font-size: .9rem; color: var(--text-2, #a1a1aa); }
