/* =====================================================
   ONBOARDING - Kindgerecht & Responsive
   ===================================================== */

:root {
    --wizard-max-width: 500px;
    --avatar-size: 100px;
    --btn-min-height: 56px;
}

/* Tablet */
@media (min-width: 600px) {
    :root {
        --wizard-max-width: 560px;
        --avatar-size: 120px;
        --btn-min-height: 64px;
    }
}

/* Desktop */
@media (min-width: 900px) {
    :root {
        --wizard-max-width: 640px;
        --avatar-size: 140px;
    }
}

body {
    background: var(--color-background);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
}

/* =====================================================
   WIZARD CONTAINER
   ===================================================== */

.wizard-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-md);
    padding-bottom: calc(var(--space-xl) + env(safe-area-inset-bottom, 0));
    position: relative;
    min-height: 100%;
}

/* =====================================================
   STEP PROGRESS - Kindgerechte Punkte
   ===================================================== */

.step-progress {
    position: fixed;
    top: var(--space-md);
    top: calc(var(--space-md) + env(safe-area-inset-top, 0));
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: var(--space-sm);
    z-index: 100;
    background: var(--color-surface);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-md);
}

.step-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--color-text-muted);
    opacity: 0.3;
    transition: all 0.4s var(--ease-bounce);
}

.step-dot.active {
    background: var(--color-primary);
    opacity: 1;
    transform: scale(1.3);
    box-shadow: 0 0 12px var(--color-primary);
}

.step-dot.completed {
    background: var(--color-success);
    opacity: 1;
}

/* =====================================================
   WIZARD CARD - Hauptcontainer
   ===================================================== */

.wizard-card {
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    padding: var(--space-lg);
    padding-top: var(--space-xl);
    max-width: var(--wizard-max-width);
    width: 100%;
    box-shadow: var(--shadow-lg);
    text-align: center;
    animation: cardEnter 0.5s var(--ease-bounce);
    border: 2px solid transparent;
    background-clip: padding-box;
    position: relative;
}

.wizard-card::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: calc(var(--radius-xl) + 2px);
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    z-index: -1;
    opacity: 0.5;
}

@keyframes cardEnter {
    0% {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Tablet+ mehr Padding */
@media (min-width: 600px) {
    .wizard-card {
        padding: var(--space-xl);
        padding-top: var(--space-2xl);
    }
}

/* =====================================================
   AVATAR - Freundlicher Charakter
   ===================================================== */

.avatar {
    width: var(--avatar-size);
    height: var(--avatar-size);
    margin: 0 auto var(--space-md);
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        0 8px 32px color-mix(in srgb, var(--color-primary) 50%, transparent),
        inset 0 -4px 12px rgba(0, 0, 0, 0.2);
    position: relative;
    animation: avatarFloat 3s ease-in-out infinite;
}

.avatar::after {
    content: '';
    position: absolute;
    width: 20%;
    height: 20%;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    top: 15%;
    left: 20%;
}

.avatar svg {
    width: 50%;
    height: 50%;
    color: white;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

@keyframes avatarFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.avatar.speaking {
    animation: avatarFloat 3s ease-in-out infinite, avatarPulse 1.5s ease-in-out infinite;
}

@keyframes avatarPulse {
    0%, 100% { box-shadow: 0 8px 32px color-mix(in srgb, var(--color-primary) 50%, transparent); }
    50% { box-shadow: 0 8px 48px color-mix(in srgb, var(--color-primary) 70%, transparent); }
}

.avatar.success {
    background: linear-gradient(135deg, var(--color-success), var(--color-accent-1));
}

/* =====================================================
   SPEECH BUBBLE - Sprechblase
   ===================================================== */

.speech-bubble {
    background: var(--color-background);
    border-radius: var(--radius-lg);
    padding: var(--space-md) var(--space-lg);
    margin-bottom: var(--space-lg);
    position: relative;
    font-size: var(--font-size-lg);
    line-height: 1.6;
    border: 2px solid var(--color-primary);
}

.speech-bubble::before {
    content: '';
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 12px solid transparent;
    border-right: 12px solid transparent;
    border-bottom: 12px solid var(--color-primary);
}

.speech-bubble::after {
    content: '';
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-bottom: 10px solid var(--color-background);
}

@media (min-width: 600px) {
    .speech-bubble {
        font-size: var(--font-size-xl);
        padding: var(--space-lg) var(--space-xl);
    }
}

/* =====================================================
   TITLES & TEXT
   ===================================================== */

.wizard-title {
    font-size: var(--font-size-xl);
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: var(--space-sm);
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

@media (min-width: 600px) {
    .wizard-title {
        font-size: var(--font-size-2xl);
    }
}

.wizard-instruction {
    font-size: var(--font-size-md);
    color: var(--color-text-muted);
    margin-bottom: var(--space-lg);
    line-height: 1.6;
}

@media (min-width: 600px) {
    .wizard-instruction {
        font-size: var(--font-size-lg);
    }
}

/* =====================================================
   CAMERA PREVIEW
   ===================================================== */

.camera-preview {
    width: 100%;
    aspect-ratio: 4/3;
    background: var(--color-background);
    border-radius: var(--radius-lg);
    overflow: hidden;
    position: relative;
    margin-bottom: var(--space-lg);
    border: 3px solid var(--color-primary);
}

.camera-preview video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.camera-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    font-size: var(--font-size-lg);
    gap: var(--space-md);
}

.camera-overlay svg {
    width: 48px;
    height: 48px;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.5; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.1); }
}

/* =====================================================
   STATUS BADGES
   ===================================================== */

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-lg);
    border-radius: var(--radius-full);
    font-size: var(--font-size-md);
    font-weight: 600;
}

.status-badge.searching {
    background: linear-gradient(135deg, var(--color-accent-2), var(--color-secondary));
    color: white;
    animation: badgePulse 1.5s ease-in-out infinite;
}

.status-badge.success {
    background: linear-gradient(135deg, var(--color-success), var(--color-accent-1));
    color: white;
}

@keyframes badgePulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.02); }
}

/* =====================================================
   MARKER SEARCH PROGRESS
   ===================================================== */

.marker-search-status {
    width: 100%;
}

.search-progress-bar {
    width: 100%;
    height: 12px;
    background: var(--color-background);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-bottom: var(--space-sm);
    border: 2px solid var(--color-border);
}

.search-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--color-primary), var(--color-secondary));
    border-radius: var(--radius-full);
    transition: width 0.3s ease-out;
    animation: progressPulse 1.5s ease-in-out infinite;
}

@keyframes progressPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.marker-tips {
    background: var(--color-background);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    border-left: 4px solid var(--color-warning);
}

.tip-list {
    margin: var(--space-sm) 0 0 var(--space-md);
    padding: 0;
    list-style: none;
}

.tip-list li {
    position: relative;
    padding-left: var(--space-md);
    margin-bottom: var(--space-xs);
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
}

.tip-list li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.5em;
    width: 6px;
    height: 6px;
    background: var(--color-primary);
    border-radius: 50%;
}

/* =====================================================
   BUTTONS - Gross & Kindgerecht
   ===================================================== */

.marker-question {
    margin-top: var(--space-xl);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--color-border);
}

.marker-question-text {
    font-size: var(--font-size-lg);
    font-weight: 600;
    text-align: center;
    margin-bottom: var(--space-md);
}

.wizard-buttons {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    margin-top: var(--space-lg);
}

@media (min-width: 500px) {
    .wizard-buttons {
        flex-direction: row;
        justify-content: center;
    }
}

.wizard-btn {
    padding: var(--space-md) var(--space-xl);
    min-height: var(--btn-min-height);
    border-radius: var(--radius-full);
    font-size: var(--font-size-lg);
    font-weight: 700;
    cursor: pointer;
    border: none;
    transition: all 0.3s var(--ease-bounce);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    width: 100%;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

@media (min-width: 500px) {
    .wizard-btn {
        width: auto;
        min-width: 180px;
    }
}

.wizard-btn-primary {
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    color: white;
    box-shadow:
        0 6px 20px color-mix(in srgb, var(--color-primary) 50%, transparent),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.wizard-btn-primary:hover,
.wizard-btn-primary:focus {
    transform: translateY(-3px) scale(1.02);
    box-shadow:
        0 10px 30px color-mix(in srgb, var(--color-primary) 60%, transparent),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.wizard-btn-primary:active {
    transform: translateY(0) scale(0.98);
}

.wizard-btn-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.wizard-btn-secondary {
    background: var(--color-background);
    color: var(--color-text);
    border: 3px solid var(--color-primary);
}

.wizard-btn-secondary:hover,
.wizard-btn-secondary:focus {
    background: var(--color-primary);
    color: white;
    transform: translateY(-2px);
}

/* =====================================================
   CORNER MARKER PREVIEW
   ===================================================== */

.corner-preview {
    display: grid;
    grid-template-columns: repeat(2, 70px);
    gap: var(--space-md);
    justify-content: center;
    margin: var(--space-lg) 0;
}

@media (min-width: 600px) {
    .corner-preview {
        grid-template-columns: repeat(2, 90px);
        gap: var(--space-lg);
    }
}

.corner-marker {
    aspect-ratio: 1;
    background: var(--color-background);
    border: 4px solid var(--color-text-muted);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-sm);
    font-weight: 700;
    color: var(--color-text-muted);
    transition: all 0.4s var(--ease-bounce);
}

.corner-marker.detected {
    border-color: var(--color-success);
    background: color-mix(in srgb, var(--color-success) 15%, var(--color-background));
    color: var(--color-success);
    transform: scale(1.05);
    box-shadow: 0 0 20px color-mix(in srgb, var(--color-success) 40%, transparent);
}

/* =====================================================
   GRID CALIBRATION (Step 4)
   ===================================================== */

.wizard-card-wide {
    max-width: 500px;
}

.corner-marker-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
    margin: var(--space-md) 0;
    padding: var(--space-md);
    background: var(--color-surface);
    border-radius: var(--radius-lg);
}

.corner-marker-preview {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.corner-marker-preview canvas {
    border: 2px solid var(--color-text-muted);
    border-radius: var(--radius-sm);
}

.corner-marker-id {
    font-size: var(--font-size-lg);
    font-weight: 700;
    color: var(--color-primary);
}

.grid-calibration-preview {
    position: relative;
    width: 100%;
    aspect-ratio: 16/10;
    background: var(--color-background);
    border: 3px dashed var(--color-text-muted);
    border-radius: var(--radius-lg);
    margin: var(--space-md) 0;
}

.calibration-corner {
    position: absolute;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-surface);
    border: 3px solid var(--color-text-muted);
    border-radius: var(--radius-sm);
    color: var(--color-text-muted);
    transition: all 0.3s var(--ease-bounce);
}

.calibration-corner.top-left { top: 8px; left: 8px; }
.calibration-corner.top-right { top: 8px; right: 8px; }
.calibration-corner.bottom-left { bottom: 8px; left: 8px; }
.calibration-corner.bottom-right { bottom: 8px; right: 8px; }

.calibration-corner.detected {
    border-color: var(--color-success);
    background: var(--color-success);
    color: white;
    transform: scale(1.1);
    box-shadow: 0 0 15px color-mix(in srgb, var(--color-success) 50%, transparent);
}

.calibration-grid-lines {
    position: absolute;
    inset: 50px;
    border: 2px dashed var(--color-text-muted);
    opacity: 0.3;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(4, 1fr);
}

.calibration-grid-lines::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        repeating-linear-gradient(90deg, var(--color-text-muted) 0, var(--color-text-muted) 1px, transparent 1px, transparent 12.5%),
        repeating-linear-gradient(0deg, var(--color-text-muted) 0, var(--color-text-muted) 1px, transparent 1px, transparent 25%);
    opacity: 0.2;
}

.calibration-status {
    position: absolute;
    bottom: 50%;
    left: 50%;
    transform: translate(-50%, 50%);
    padding: var(--space-sm) var(--space-md);
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    font-size: var(--font-size-sm);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.calibration-status .status-searching {
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.calibration-status .status-searching svg {
    animation: pulse 1.5s ease-in-out infinite;
}

.calibration-status .status-success {
    color: var(--color-success);
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

/* =====================================================
   LEARNED MARKERS
   ===================================================== */

.learned-markers {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    justify-content: center;
    margin-bottom: var(--space-lg);
    min-height: 40px;
}

.marker-chip {
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    color: white;
    padding: var(--space-xs) var(--space-md);
    border-radius: var(--radius-full);
    font-size: var(--font-size-md);
    font-weight: 600;
    animation: chipPop 0.4s var(--ease-bounce);
    box-shadow: 0 4px 12px color-mix(in srgb, var(--color-primary) 40%, transparent);
}

@keyframes chipPop {
    0% { transform: scale(0) rotate(-10deg); opacity: 0; }
    50% { transform: scale(1.2) rotate(5deg); }
    100% { transform: scale(1) rotate(0); opacity: 1; }
}

/* =====================================================
   MODE SELECTOR
   ===================================================== */

.mode-selector {
    width: 100%;
    margin-bottom: var(--space-lg);
}

.mode-label {
    text-align: center;
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    margin-bottom: var(--space-sm);
}

.mode-buttons {
    display: flex;
    gap: var(--space-sm);
    justify-content: center;
    flex-wrap: wrap;
}

.mode-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-md);
    min-width: 90px;
    background: var(--color-surface);
    border: 3px solid var(--color-border);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.3s var(--ease-bounce);
    font-size: var(--font-size-sm);
    color: var(--color-text);
}

.mode-btn svg {
    width: 28px;
    height: 28px;
    stroke: var(--color-text-muted);
    transition: stroke 0.3s;
}

.mode-btn:hover {
    border-color: var(--color-primary);
    transform: translateY(-2px);
}

.mode-btn:hover svg {
    stroke: var(--color-primary);
}

.mode-btn.active {
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    border-color: transparent;
    color: white;
    transform: scale(1.05);
    box-shadow: 0 6px 20px color-mix(in srgb, var(--color-primary) 40%, transparent);
}

.mode-btn.active svg {
    stroke: white;
}

.mode-name {
    font-weight: 700;
    font-size: var(--font-size-sm);
}

.mode-desc {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    line-height: 1.3;
    max-width: 100px;
}

.mode-btn.active .mode-desc {
    color: rgba(255, 255, 255, 0.8);
}

@media (min-width: 500px) {
    .mode-btn {
        min-width: 130px;
        padding: var(--space-md) var(--space-lg);
    }
    .mode-btn svg {
        width: 32px;
        height: 32px;
    }
    .mode-name {
        font-size: var(--font-size-md);
    }
    .mode-desc {
        font-size: var(--font-size-sm);
        max-width: 120px;
    }
}

/* =====================================================
   WELCOME BACK OVERLAY
   ===================================================== */

.welcome-back-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(8px);
    padding: var(--space-md);
}

/* =====================================================
   HELPER
   ===================================================== */

.text-small {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
}

.text-center {
    text-align: center;
}

.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }

/* Hidden elements */
[x-cloak] {
    display: none !important;
}
