/**
 * Character Configurator Styles for Landing Page
 * IMPROVED LAYOUT - 2025-01-20
 * VISUAL PREVIEW - 2025-11-20
 */

.character-configurator,
#configuratorContainer {
    max-width: 100%; /* Don't exceed parent width */
    margin: 0 auto;
    padding: 0;
    box-sizing: border-box;
    overflow: hidden; /* Prevent horizontal overflow */
}

/* Avatar Preview Styles */
.character-avatar-preview {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 50%;
}

/* Smooth transitions for all avatar parts */
.character-avatar-preview * {
    transition: fill 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                stroke 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.3s ease;
}

/* Avatar container hover effect */
.character-avatar {
    position: relative;
    cursor: pointer;
    overflow: visible !important;
}

.character-avatar:hover .character-avatar-preview {
    transform: scale(1.05);
    filter: drop-shadow(0 4px 12px rgba(155, 135, 217, 0.3));
}

/* Eye blink animation */
@keyframes blink {
    0%, 90%, 100% {
        opacity: 1;
        transform: scaleY(1);
    }
    93%, 97% {
        opacity: 0;
        transform: scaleY(0.1);
    }
}

.avatar-eye-shine-left,
.avatar-eye-shine-right {
    animation: blink 4s infinite;
}

.avatar-eye-shine-left {
    animation-delay: 0s;
}

.avatar-eye-shine-right {
    animation-delay: 0.1s;
}

/* Subtle breathing animation */
@keyframes breathe {
    0%, 100% {
        transform: translateY(0) scale(1);
    }
    50% {
        transform: translateY(-1px) scale(1.01);
    }
}

.avatar-head-group {
    animation: breathe 3s ease-in-out infinite;
    transform-origin: center;
}

/* Shadow pulse */
@keyframes shadowPulse {
    0%, 100% {
        opacity: 0.08;
        transform: scale(1);
    }
    50% {
        opacity: 0.12;
        transform: scale(1.05);
    }
}

.avatar-shadow {
    animation: shadowPulse 3s ease-in-out infinite;
    transform-origin: center;
}

.character-configurator h3 {
    text-align: center;
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: #2C2C2C;
    font-weight: 700;
}

.characters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

/* Responsive grid */
@media (max-width: 768px) {
    .characters-grid {
        grid-template-columns: 1fr;
        gap: 1.25rem;
    }
}

@media (max-width: 480px) {
    .characters-grid {
        gap: 1rem;
    }
}

.character-card {
    /* Inline styles applied - CSS kept for hover state */
    /* Do NOT override inline styles as they match design system */
}

.character-card:hover {
    transform: translateY(-4px) !important;
    box-shadow: 0 8px 24px rgba(155, 135, 217, 0.15) !important;
    border-color: rgba(155, 135, 217, 0.2) !important;
}

/* Avatar preview card layout - LARGER for sequential wizard */
.character-avatar-container {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 160px;
    height: 160px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(155, 135, 217, 0.08) 0%, rgba(255, 159, 102, 0.08) 100%);
    border: 4px solid rgba(155, 135, 217, 0.2);
    box-shadow: 0 8px 20px rgba(155, 135, 217, 0.15);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    margin: 0 auto 20px;
    overflow: visible;
}

.character-avatar-container:hover {
    transform: scale(1.05) rotate(2deg);
    box-shadow: 0 8px 20px rgba(155, 135, 217, 0.2);
    border-color: rgba(155, 135, 217, 0.3);
}

/* Pulse animation on trait update */
@keyframes avatarPulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.08);
    }
    100% {
        transform: scale(1);
    }
}

.character-avatar-container.pulse {
    animation: avatarPulse 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.character-header {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 2px solid #f0f0f0;
}

.character-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    color: rgba(255, 255, 255, 0.8);
    flex-shrink: 0;
    transition: background-color 0.3s ease;
}

.character-info {
    flex: 1;
}

.character-info h4 {
    /* Inline styles applied - kept for specificity */
    font-family: 'Quicksand', sans-serif !important;
}

.character-role {
    /* Inline styles applied - kept for specificity */
    font-family: 'Inter', sans-serif !important;
}

.character-description {
    /* Inline styles applied - kept for specificity */
    font-family: 'Inter', sans-serif !important;
}

.character-traits {
    width: 100%; /* Ensure traits section doesn't exceed card width */
    box-sizing: border-box;
}

.character-traits h5 {
    /* Inline styles applied - kept for specificity */
    font-family: 'Quicksand', sans-serif !important;
}

.trait-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.trait-row label {
    /* Inline styles applied - kept for specificity */
    font-family: 'Inter', -apple-system, system-ui, sans-serif;
}

.trait-row label i {
    font-size: 16px;
    color: #9B87D9;
}

.trait-select,
.trait-input {
    /* Inline styles applied - kept for focus states */
    font-family: 'Inter', -apple-system, system-ui, sans-serif !important;
}

.trait-select:focus,
.trait-input:focus {
    outline: none !important;
    border-color: #9B87D9 !important;
}

.trait-select:hover {
    border-color: rgba(155, 135, 217, 0.4) !important;
}

.trait-input:hover {
    border-color: rgba(155, 135, 217, 0.4) !important;
}

.trait-input::placeholder {
    color: #aaa;
}

.generate-story-btn {
    display: block;
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    padding: 16px 32px;
    font-size: 18px;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, #9B87D9 0%, #FF9F66 100%);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.generate-story-btn:hover {
    transform: scale(1.02);
    box-shadow: 0 8px 24px rgba(155, 135, 217, 0.4);
}

.generate-story-btn:active {
    transform: scale(0.98);
}

/* Loading state */
.character-configurator.loading {
    opacity: 0.6;
    pointer-events: none;
}

.loading-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px;
}

.loading-spinner::after {
    content: '';
    width: 48px;
    height: 48px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #9B87D9;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Trait display pulse animation */
@keyframes traitPulse {
    0% {
        transform: scale(1);
        background: linear-gradient(135deg, rgba(155, 135, 217, 0.08) 0%, rgba(255, 159, 102, 0.08) 100%);
    }
    50% {
        transform: scale(1.05);
        background: linear-gradient(135deg, rgba(155, 135, 217, 0.15) 0%, rgba(255, 159, 102, 0.15) 100%);
    }
    100% {
        transform: scale(1);
        background: linear-gradient(135deg, rgba(155, 135, 217, 0.08) 0%, rgba(255, 159, 102, 0.08) 100%);
    }
}

/* Rotation buttons hover effects */
.trait-prev:hover,
.trait-next:hover {
    border-color: #9B87D9 !important;
    background: linear-gradient(135deg, rgba(155, 135, 217, 0.05) 0%, rgba(255, 159, 102, 0.05) 100%) !important;
    transform: scale(1.1) !important;
}

.trait-prev:active,
.trait-next:active {
    transform: scale(0.95) !important;
}

/* Modal z-index for proper layering */
.modal {
    z-index: 10000 !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    /* DON'T force display - controlled by JS */
    align-items: center !important;
    justify-content: center !important;
}

/* When modal is visible (controlled by JS with style.display = 'flex') */
.modal[style*="display: flex"] {
    display: flex !important;
}

.modal-backdrop {
    z-index: 9999 !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: rgba(0, 0, 0, 0.5) !important;
}

.modal-content {
    z-index: 10001 !important;
    position: relative !important;
}

/* Sequential wizard animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.character-card {
    animation: fadeInUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Progress bar subtle pulse */
@keyframes progressPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(155, 135, 217, 0.4);
    }
    50% {
        box-shadow: 0 0 12px 4px rgba(155, 135, 217, 0.2);
    }
}

.character-card[data-index="0"] {
    animation: fadeInUp 0.4s cubic-bezier(0.4, 0, 0.2, 1), progressPulse 2s ease-in-out infinite 0.5s;
}

/* Responsive */
@media (max-width: 768px) {
    .characters-grid {
        grid-template-columns: 1fr !important;
    }

    .character-configurator h3 {
        font-size: 1.5rem !important; /* 24px */
    }

    .character-card {
        padding: 1.25rem !important;
    }

    .character-avatar-container {
        width: 110px !important;
        height: 110px !important;
        margin: 0 auto 12px !important;
    }

    .trait-row {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 8px !important;
    }

    .trait-row label {
        min-width: auto !important;
    }

    .trait-select,
    .trait-input {
        width: 100% !important;
        padding: 10px 12px !important; /* Większy padding na mobile dla lepszego touch target */
    }
}

@media (max-width: 480px) {
    .character-card {
        padding: 1rem !important;
    }

    .character-header {
        gap: 12px !important;
    }

    .character-avatar-container {
        width: 96px !important;
        height: 96px !important;
        margin: 0 auto 10px !important;
    }

    .character-info h4 {
        font-size: 18px !important;
    }

    .character-role {
        font-size: 14px !important;
    }

    .character-description {
        font-size: 13px !important;
    }

    .character-traits h5 {
        font-size: 15px !important;
    }

    /* Disable hover animations on mobile for better performance */
    .avatar-head-group {
        animation: none !important;
    }

    .avatar-shadow {
        animation: none !important;
    }

    .avatar-eye-shine-left,
    .avatar-eye-shine-right {
        animation: none !important;
    }
}
