/* ===========================================
   WFM Funnel Frontend – v1.2
   =========================================== */

:root {
    --wfm-primary: #163c63;
    --wfm-primary-light: #3a76b3;
    --wfm-primary-dark: #0f2a46;
    --wfm-accent: #4CAF50;
    --wfm-accent-light: #81C784;
    --wfm-white: #ffffff;
    --wfm-gray-50: #f8fafc;
    --wfm-gray-100: #f1f5f9;
    --wfm-gray-200: #e2e8f0;
    --wfm-gray-300: #cbd5e1;
    --wfm-gray-400: #94a3b8;
    --wfm-gray-500: #64748b;
    --wfm-gray-600: #475569;
    --wfm-gray-700: #334155;
    --wfm-gray-800: #1e293b;
    --wfm-error: #ef4444;
    --wfm-success: #22c55e;
    --wfm-check-green: #43a047;
    --wfm-radius: 20px;
    --wfm-radius-sm: 10px;
    --wfm-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    --wfm-transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset ─────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Eigene Klasse + !important: Theme/wp_head kann sonst html { background } danach setzen. */
html.wfm-funnel-html {
    height: 100%;
    height: -webkit-fill-available;
    min-height: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    min-height: -webkit-fill-available;
    background: linear-gradient(0deg, var(--wfm-primary) 0%, var(--wfm-primary-light) 100%) !important;
}

body.wfm-funnel-body,
.wfm-funnel-body {
    min-height: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.5;
    color: var(--wfm-gray-800);
    background: transparent;
    display: flex;
    flex-direction: column;
    position: relative;
    -webkit-font-smoothing: antialiased;
}

/* Skalierungs-Wrapper: ab 901px kein eigenes Layout (Kinder wie direkt unter body) */
.wfm-funnel-viewport {
    display: contents;
}

/* ══════════════════════════════════════════
   Swoosh Background (decorative layer)
   ══════════════════════════════════════════ */
.wfm-swoosh-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 75vh;
    z-index: 0;
    pointer-events: none;
}

.wfm-swoosh-bg svg {
    display: block;
    width: 100%;
    height: 100%;
    filter: drop-shadow(0px 0px 15px #1e1e1e);
}

/* ══════════════════════════════════════════
   Page Content (on top of swoosh)
   ══════════════════════════════════════════ */
.wfm-page {
    position: relative;
    z-index: 1;
    flex: 1 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px 20px 4px;
}

/* ── Logo ──────────────────────────────── */
.wfm-hero-logo {
    flex-shrink: 0;
    margin-bottom: 16px;
    text-align: center;
}

.wfm-hero-logo img {
    height: auto;
    width: 15rem;
    max-width: 100%;
    display: block;
}

/* ── Progress (blau auf hellem Grund / Swoosh – gut lesbar) ── */
.wfm-progress-container {
    flex-shrink: 0;
    width: 100%;
    max-width: 520px;
    margin-bottom: 12px;
    text-align: center;
    padding: 12px 18px 14px;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(22, 60, 99, 0.12);
    border-radius: 999px;
    box-shadow: 0 4px 20px rgba(15, 42, 70, 0.08);
}

.wfm-progress-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--wfm-primary-dark);
    margin-bottom: 10px;
}

.wfm-progress-circles {
    display: flex;
    align-items: center;
    justify-content: center;
}

.wfm-step-circle {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: var(--wfm-transition);
}

.wfm-step-circle.completed {
    background: var(--wfm-check-green);
}

.wfm-step-circle.completed svg {
    width: 14px;
    height: 14px;
    stroke: #fff;
    stroke-width: 3;
    fill: none;
}

.wfm-step-circle.current {
    background: rgba(58, 118, 179, 0.15);
    border: 3px solid var(--wfm-primary);
    box-shadow: 0 0 0 2px rgba(58, 118, 179, 0.2);
}

.wfm-step-circle.future {
    background: rgba(22, 60, 99, 0.06);
    border: 2px solid rgba(22, 60, 99, 0.28);
}

.wfm-step-line {
    width: 32px;
    height: 3px;
    flex-shrink: 0;
    border-radius: 2px;
    transition: background 0.3s ease;
}

.wfm-step-line.done { background: var(--wfm-check-green); }
.wfm-step-line.pending { background: rgba(22, 60, 99, 0.18); }

/* ── Card ──────────────────────────────── */
.wfm-funnel-main {
    width: 100%;
    max-width: 520px;
    flex: 0 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

.wfm-funnel-card {
    position: relative;
    background: var(--wfm-white);
    border-radius: var(--wfm-radius);
    box-shadow: var(--wfm-shadow);
    padding: 28px 28px 24px;
    flex: 0 0 auto;
    width: 100%;
    min-height: 120px;
    overflow-x: hidden;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    will-change: height;
}

/* Parkplatz für Zurück-Button (Geschwister von #wfm-funnel-app, kein Layout) */
.wfm-prev-parking {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
    padding: 0;
    margin: 0;
    pointer-events: none;
}

.wfm-prev-parking:focus-within {
    pointer-events: auto;
}

/* Gemeinsame Leiste: links Zurück, rechts Weiter */
.wfm-funnel-card-nav {
    display: none;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    width: 100%;
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--wfm-gray-200);
}

.wfm-card-nav-back {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    min-height: 40px;
}

.wfm-card-nav-next {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    min-width: 0;
    min-height: 40px;
}

.wfm-card-nav-next .wfm-btn-primary {
    width: auto;
    max-width: 100%;
    padding: 12px 20px;
    flex-shrink: 1;
}

/* ── Zurück (neben Weiter in der Kartenleiste) ──────────────────────────── */
.wfm-nav-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.1);
    border: 1.5px solid rgba(255, 255, 255, 0.25);
    border-radius: var(--wfm-radius-sm);
    color: rgba(255, 255, 255, 0.75);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--wfm-transition);
    backdrop-filter: blur(4px);
}

.wfm-nav-btn.wfm-nav-prev-inline {
    padding: 5px 10px;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    background: var(--wfm-gray-100);
    border: 1px solid var(--wfm-gray-200);
    color: var(--wfm-primary-dark);
    backdrop-filter: none;
    flex-shrink: 0;
    line-height: 1.2;
}

.wfm-nav-btn:hover {
    background: rgba(255, 255, 255, 0.18);
    border-color: rgba(255, 255, 255, 0.5);
    color: #fff;
}

/* Inline-Zurück überschreibt generisches .wfm-nav-btn:hover */
.wfm-nav-btn.wfm-nav-prev-inline:hover {
    background: var(--wfm-gray-200);
    border-color: var(--wfm-gray-300);
    color: var(--wfm-primary);
}

/* ══════════════════════════════════════════
   Footer
   ══════════════════════════════════════════ */
.wfm-funnel-footer {
    position: relative;
    z-index: 1;
    flex-shrink: 0;
    padding: 6px 20px 12px;
    text-align: center;
    margin-top: auto;
}

.wfm-footer-legal {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.wfm-footer-legal a {
    color: rgba(255, 255, 255, 0.55);
    text-decoration: none;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    transition: var(--wfm-transition);
}

.wfm-footer-legal a:hover { color: rgba(255, 255, 255, 0.9); }

.wfm-footer-dot {
    color: rgba(255, 255, 255, 0.3);
    font-size: 10px;
}

/* ══════════════════════════════════════════
   Question Layout
   ══════════════════════════════════════════ */
.wfm-question-container { text-align: center; }

.wfm-question-title-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 6px;
}

.wfm-question-title-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    line-height: 0;
}

.wfm-question-title-icon img {
    height: 32px;
    width: auto;
    max-width: 48px;
    object-fit: contain;
    display: block;
}

.wfm-question-title {
    font-size: 20px;
    font-weight: 800;
    color: var(--wfm-primary-dark);
    margin: 0;
    line-height: 1.25;
    letter-spacing: -0.01em;
    text-transform: uppercase;
    text-align: center;
}

.wfm-question-desc {
    font-size: 12px;
    font-weight: 600;
    color: var(--wfm-gray-400);
    margin-bottom: 20px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    max-width: 440px;
    margin-left: auto;
    margin-right: auto;
}

/* ── Options Grid ──────────────────────── */
.wfm-options-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.wfm-options-grid.wfm-grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

.wfm-options-grid.wfm-grid-2 .wfm-option-card:last-child:nth-child(odd) {
    grid-column: 1 / -1;
}

.wfm-option-card {
    background: var(--wfm-white);
    border: 2px solid var(--wfm-gray-200);
    padding: 16px 12px;
    border-radius: var(--wfm-radius-sm);
    cursor: pointer;
    transition: var(--wfm-transition);
    text-align: center;
    font-weight: 700;
    font-size: 13px;
    color: var(--wfm-primary-dark);
    position: relative;
    overflow: hidden;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    min-height: 100%;
}

.wfm-option-card-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    position: relative;
    z-index: 1;
    flex: 1 1 auto;
    min-height: 0;
}

.wfm-option-card-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
}

.wfm-option-card-icon img {
    height: 40px;
    width: auto;
    max-width: 100%;
    object-fit: contain;
    display: block;
}

.wfm-option-card-label {
    position: relative;
    z-index: 1;
    line-height: 1.25;
}

.wfm-option-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--wfm-primary), var(--wfm-primary-light));
    opacity: 0;
    transition: opacity 0.25s ease;
    z-index: 0;
}

.wfm-option-card:hover {
    border-color: var(--wfm-primary-light);
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(22, 60, 99, 0.12);
}

.wfm-option-card.selected {
    border-color: var(--wfm-primary);
    background: var(--wfm-primary);
    color: var(--wfm-white);
}

.wfm-option-card.selected::before { opacity: 1; }

.wfm-option-card.selected .wfm-option-card-icon img {
    filter: brightness(0) invert(1);
    opacity: 0.95;
}

/* ── Input Fields ──────────────────────── */
.wfm-input-group {
    margin-bottom: 12px;
    text-align: left;
}

.wfm-input-group label {
    display: block;
    margin-bottom: 4px;
    font-weight: 700;
    color: var(--wfm-gray-700);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* !important: Divi/Theme setzt oft input { padding: 2px } und überschreibt sonst alles */
.wfm-text-input,
.wfm-textarea {
    width: 100%;
    padding: 12px 14px 12px 10px !important;
    border: 2px solid var(--wfm-gray-200);
    border-radius: 8px;
    font-size: 15px;
    color: var(--wfm-gray-800);
    background: var(--wfm-white);
    transition: var(--wfm-transition);
    font-family: inherit;
    height: auto;
    min-height: 46px;
}

.wfm-select {
    width: 100%;
    padding: 12px 44px 12px 10px !important;
    border: 2px solid var(--wfm-gray-200);
    border-radius: 8px;
    font-size: 15px;
    color: var(--wfm-gray-800);
    background: var(--wfm-white);
    transition: var(--wfm-transition);
    font-family: inherit;
    height: auto;
    min-height: 46px;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    cursor: pointer;
}

.wfm-text-input:focus,
.wfm-textarea:focus,
.wfm-select:focus {
    outline: none;
    border-color: var(--wfm-primary-light);
    box-shadow: 0 0 0 3px rgba(58, 118, 179, 0.12);
}

.wfm-text-input::placeholder,
.wfm-textarea::placeholder { color: var(--wfm-gray-400); }

.wfm-textarea { min-height: 100px; resize: vertical; }

.wfm-large-select {
    padding-top: 14px !important;
    padding-bottom: 14px !important;
    padding-left: 10px !important;
}

.wfm-input-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.wfm-input-row.wfm-three-col {
    grid-template-columns: 110px 1fr;
}

/* ── CTA Button ────────────────────────── */
.wfm-btn-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px 24px;
    background: linear-gradient(135deg, var(--wfm-primary), var(--wfm-primary-light));
    color: var(--wfm-white);
    border: none;
    border-radius: var(--wfm-radius-sm);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    cursor: pointer;
    transition: var(--wfm-transition);
    box-shadow: 0 4px 16px rgba(22, 60, 99, 0.3);
}

.wfm-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(22, 60, 99, 0.4);
}

.wfm-btn-primary:active { transform: translateY(0); }

/* ── Success Screen ────────────────────── */
.wfm-success-screen { text-align: center; padding: 24px 12px; }

.wfm-success-icon {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--wfm-success), var(--wfm-accent-light));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    font-size: 32px;
    color: white;
}

.wfm-success-title {
    font-size: 20px;
    font-weight: 800;
    color: var(--wfm-primary-dark);
    margin-bottom: 8px;
    text-transform: uppercase;
}

.wfm-success-text {
    font-size: 14px;
    color: var(--wfm-gray-500);
    max-width: 380px;
    margin: 0 auto;
}

/* ── Loading ───────────────────────────── */
.wfm-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    color: var(--wfm-gray-500);
}

.wfm-loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--wfm-gray-200);
    border-top-color: var(--wfm-primary);
    border-radius: 50%;
    animation: wfmSpin 0.8s linear infinite;
    margin-bottom: 12px;
}

@keyframes wfmSpin { to { transform: rotate(360deg); } }

/* ── Errors ────────────────────────────── */
.wfm-error-msg { color: var(--wfm-error); font-size: 12px; margin-top: 4px; display: none; }
.wfm-input-group.has-error .wfm-text-input,
.wfm-input-group.has-error .wfm-select { border-color: var(--wfm-error); }
.wfm-input-group.has-error .wfm-error-msg { display: block; }

/* ── Contact / Address Blocks ──────────── */
.wfm-contact-block,
.wfm-address-block { text-align: left; }

/* ── Confetti ──────────────────────────── */
#wfm-confetti-canvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
}

/* ══════════════════════════════════════════
   Animations
   ══════════════════════════════════════════ */
.wfm-animation-0 .wfm-option-card:hover { transform: none; box-shadow: none; }
.wfm-animation-0 .wfm-btn-primary:hover { transform: none; }
.wfm-animation-0 .wfm-slide-in { animation: none; }

.wfm-slide-in { animation: wfmSlideIn 0.35s ease-out; }
@keyframes wfmSlideIn {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

.wfm-animation-1 .wfm-option-card.selected { animation: wfmPulse 0.25s ease; }
@keyframes wfmPulse {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.02); }
    100% { transform: scale(1); }
}

.wfm-animation-2 .wfm-slide-in { animation: wfmBounceIn 0.45s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes wfmBounceIn {
    from { opacity: 0; transform: translateY(30px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.wfm-animation-2 .wfm-option-card:hover { transform: translateY(-3px) scale(1.01); }
.wfm-animation-2 .wfm-option-card.selected { animation: wfmBounceSelect 0.35s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes wfmBounceSelect {
    0%   { transform: scale(1); }
    30%  { transform: scale(0.96); }
    60%  { transform: scale(1.04); }
    100% { transform: scale(1); }
}

.wfm-animation-3 .wfm-slide-in { animation: wfmFlipIn 0.55s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes wfmFlipIn {
    from { opacity: 0; transform: translateY(50px) rotateX(-8deg); }
    to   { opacity: 1; transform: translateY(0) rotateX(0); }
}
.wfm-animation-3 .wfm-option-card:hover { transform: translateY(-5px) scale(1.02); box-shadow: 0 10px 24px rgba(22, 60, 99, 0.18); }
.wfm-animation-3 .wfm-option-card.selected { animation: wfmCelebrate 0.45s ease; }
@keyframes wfmCelebrate {
    0%   { transform: scale(1); }
    25%  { transform: scale(0.92) rotate(-2deg); }
    50%  { transform: scale(1.08) rotate(2deg); }
    75%  { transform: scale(1.04) rotate(-1deg); }
    100% { transform: scale(1) rotate(0); }
}
.wfm-animation-3 .wfm-success-icon { animation: wfmSuccessPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes wfmSuccessPop {
    0%   { transform: scale(0); opacity: 0; }
    50%  { transform: scale(1.15); }
    100% { transform: scale(1); opacity: 1; }
}

/* ══════════════════════════════════════════
   Responsive: < 901px — flüssiges Layout (kein CSS zoom: auf iOS/WebKit oft abgeschnitten/zerstört)
   ══════════════════════════════════════════ */

@media (max-width: 900px) {
    .wfm-funnel-viewport {
        display: flex;
        flex-direction: column;
        flex: 1 0 auto;
        min-height: 100vh;
        width: 100%;
        max-width: 100%;
        margin-inline: 0;
        box-sizing: border-box;
    }

    .wfm-page {
        padding: 16px 14px 10px;
    }

    .wfm-hero-logo {
        margin-bottom: 12px;
    }

    .wfm-hero-logo img {
        width: 100%;
        max-width: min(15rem, 100%);
        height: auto;
        margin-inline: auto;
    }

    .wfm-progress-container {
        max-width: min(520px, 100%);
        margin-inline: auto;
        padding: 10px 14px 12px;
    }

    .wfm-progress-label {
        font-size: 9px;
        margin-bottom: 8px;
        letter-spacing: 0.14em;
    }

    .wfm-funnel-main {
        max-width: min(520px, 100%);
        margin-inline: auto;
    }

    .wfm-funnel-card {
        padding: 22px 18px 20px;
        border-radius: 18px;
    }

    .wfm-question-title {
        font-size: clamp(15px, 4.2vw, 20px);
    }

    .wfm-question-desc {
        font-size: 11px;
        margin-bottom: 16px;
    }

    .wfm-input-group label {
        font-size: 11px;
    }

    .wfm-text-input,
    .wfm-textarea,
    .wfm-select {
        font-size: 16px; /* verhindert Auto-Zoom iOS bei Fokus */
    }

    .wfm-btn-primary {
        font-size: 12px;
        padding: 12px 18px;
    }
}

@media (max-width: 600px) {
    .wfm-page {
        padding: 12px 12px 8px;
    }

    .wfm-funnel-card {
        padding: 18px 14px 16px;
    }

    .wfm-input-row {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .wfm-input-row.wfm-three-col {
        grid-template-columns: 1fr;
    }

    .wfm-options-grid.wfm-grid-2 {
        grid-template-columns: 1fr;
    }

    .wfm-options-grid.wfm-grid-2 .wfm-option-card:last-child:nth-child(odd) {
        grid-column: auto;
    }

    .wfm-progress-circles {
        flex-wrap: wrap;
        justify-content: center;
        row-gap: 6px;
    }

    .wfm-step-line {
        width: min(32px, 6vw);
    }
}

/* Kurze Displays: nur bei breitem Viewport (≥901px) */
@media (max-height: 700px) and (min-width: 901px) {
    .wfm-page {
        padding: 6px 14px 8px;
    }

    .wfm-hero-logo {
        margin-bottom: 4px;
    }

    .wfm-hero-logo img {
        max-width: 10rem;
        max-height: 56px;
    }

    .wfm-progress-container {
        margin-bottom: 6px;
        padding: 5px 10px 7px;
    }

    .wfm-progress-label {
        margin-bottom: 4px;
        font-size: 8px;
    }

    .wfm-funnel-card {
        padding: 14px 16px 14px;
    }

    .wfm-funnel-footer {
        padding: 4px 12px 6px;
    }
}

@media (max-width: 600px) {
    .wfm-hero-logo img {
        width: 100%;
        max-width: min(10rem, 100%);
        height: auto;
        margin-inline: auto;
    }
}