/* Character Selection Styles */
/* Kid-friendly, colorful, and engaging design */

/* Import root CSS variables */
:root {
    --blue: #007DFF;
    --red: #ff0000;
    --purple: #803E80;
    --orange: #F2B443;
    --grey: #3e4545;
    --lightgrey: #f5f5f5;
    --blueShadow: 0px 10px 30px 0px rgb(0 125 255 / 25%);
    --g1: 8%;
    --g2: 70%;
    --g3: 100%;
    --deg: 35deg;
    --grad: linear-gradient(var(--deg), var(--blue) var(--g1), var(--red) var(--g2), var(--orange) var(--g3));
    --border: 15px;
    
    /* Character Skin Tones */
    --skin-tone1: #734A00;
    --skin-tone2: #D38C0A;
    --skin-tone3: #FFF0D4;
    
    /* Hair Colors */
    --hair-brown: #87624d;
    --hair-blonde: #f0d9ad;
    --hair-black: #000000;
    --hair-red: #d16842;
}

/* Reset and base styles */
* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

/* Main Wrapper */
.at-character-selection-wrapper {
    background: #ffffff;
	border-radius: 20px;
    padding: 1rem;
    position: relative;
    overflow-x: hidden;
}

/* Container */
.at-character-selection-container {
    max-width: 600px;
    margin: 0 auto;
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Title */

@media (max-width: 480px) {
    .at-character-title {
        font-size: 2rem;
    }
}

/* Character Preview Container */
.at-character-preview-container {
    background: white;
    border-radius: var(--border);
    padding: 0;
    margin-bottom: 30px;
    position: relative;
}

/* Character Preview */
.at-character-preview {
    width: 100%;
    height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    position: relative;
    overflow: hidden;
    touch-action: pan-y;
}

.at-character-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: transform 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    user-select: none;
    -webkit-user-drag: none;
}

/* Bounce animation for character swipe */
@keyframes bounceIn {
    0% {
        transform: scale(0.8) rotate(-5deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.05) rotate(2deg);
    }
    70% {
        transform: scale(0.95) rotate(-1deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

.at-character-image.bounce {
    animation: bounceIn 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* Navigation Dots */
.at-character-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

.at-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ddd;
    border: none;
    padding: 0;
    cursor: pointer;
    transition: all 0.3s ease;
}

.at-dot.active {
    background: var(--blue);
    width: 30px;
    border-radius: 5px;
}

.at-dot:hover {
    background: var(--blue);
    opacity: 0.7;
}

/* Selection Sections */
.at-selection-section {
    background: white;
    border-radius: var(--border);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: inset 0px 0px 4px 4px rgba(0, 0, 0, 0.05);
}

.at-section-title {
    color: var(--grey);
    font-size: 1rem;
    font-weight: 600;
    text-align: center;
	padding-bottom: .5em;
}

/* Color Options */
.at-color-options {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.at-color-option {
    width: 70px;
    height: 70px;
    border-radius: 12px;
    border: 3px solid transparent;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 0;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
}

.at-color-option:hover {
    transform: scale(1.1);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
}

.at-color-option.active {
    border-color: var(--blue);
    transform: scale(1.1);
}

.at-color-swatch {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 8px;}

/* Save Button */
.at-save-button {
    width: 100%;
    background: var(--grad);
    color: white;
    font-size: 1.5rem;
    font-weight: 800;
    padding: 20px 40px;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 10px;
}

.at-save-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.3);
}

.at-save-button:active {
    transform: translateY(-1px);
}

.at-save-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Bottom Navigation */
.at-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--blue);
    padding: 15px 20px;
    display: flex;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    border-radius: 30px 30px 0 0;
}

.at-nav-btn {
    background: transparent;
    border: none;
    color: white;
    padding: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.at-nav-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.at-nav-btn.at-nav-center {
    background: white;
    color: var(--blue);
    width: 60px;
    height: 60px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
}

.at-nav-btn svg {
    width: 24px;
    height: 24px;
}

.at-nav-center svg {
    width: 32px;
    height: 32px;
}

/* Confirmation Modal */
.at-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.at-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    animation: fadeIn 0.3s ease;
}

.at-modal-content {
    background: white;
    border-radius: var(--border);
    padding: 40px 30px;
    max-width: 400px;
    width: 100%;
    position: relative;
    z-index: 1;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(100px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.at-modal-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    animation: bounce 0.6s ease;
}

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

.at-modal-content h2 {
    color: var(--grey);
    font-size: 1.8rem;
    margin: 0 0 15px 0;
    font-weight: 800;
}

.at-modal-content p {
    color: #666;
    font-size: 1.1rem;
    margin: 0 0 30px 0;
    line-height: 1.5;
}

.at-modal-buttons {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.at-modal-btn {
    flex: 1;
    padding: 15px 25px;
    border: none;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 120px;
}

.at-modal-cancel {
    background: #eee;
    color: var(--grey);
}

.at-modal-cancel:hover {
    background: #ddd;
}

.at-modal-confirm {
    background: var(--grad);
    color: white;
}

.at-modal-confirm:hover {
    transform: translateY(-2px);
}

/* Loading Overlay */
.at-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 10001;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
}

.at-loading-spinner {
    width: 60px;
    height: 60px;
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.at-loading-overlay p {
    font-size: 1.2rem;
    font-weight: 600;
}

/* Locked Character View */
.at-character-locked {
    display: flex;
    align-items: center;
    justify-content: center;
}

.at-character-locked-container {
    background: white;
    border-radius: var(--border);
    padding: 40px;
    max-width: 500px;
    width: 100%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.at-character-locked h2 {
    color: var(--grey);
    font-size: 2rem;
    margin: 0 0 30px 0;
    font-weight: 800;
}

.at-character-locked-image {
    width: 100%;
    max-width: 300px;
    margin: 0 auto 30px;
}

.at-character-locked-image img {
    width: 100%;
    height: auto;
}

.at-character-locked-message {
    color: #666;
    font-size: 1.1rem;
    line-height: 1.6;
    margin: 0;
}

/* Error State */
.at-character-error {
    background: #fee;
    color: #c00;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    font-weight: 600;
    margin: 20px;
}

/* Touch/Swipe Feedback */
.at-character-preview.swiping .at-character-image {
    transition: none;
    cursor: grabbing;
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus styles for keyboard navigation */
.at-color-option:focus,
.at-save-button:focus,
.at-dot:focus,
.at-modal-btn:focus,
.at-nav-btn:focus {
    outline: 3px solid var(--blue);
    outline-offset: 3px;
}

/* Mobile Optimization */
@media (max-width: 480px) {
    .at-character-preview {
        height: 280px;
    }
    
    .at-color-option {
        width: 60px;
        height: 60px;
    }
    
    .at-save-button {
        font-size: 1.3rem;
        padding: 18px 30px;
    }
    
    .at-section-title {
        font-size: 1.1rem;
    }
}

/* Landscape mode adjustments */
@media (max-height: 600px) and (orientation: landscape) {
    .at-character-preview {
        height: 250px;
    }
    
    .at-character-selection-wrapper {
        padding-bottom: 80px;
    }
}


/* Character Preview in Customization Modal */
#preview-character,
#character-avatar {
    background: linear-gradient(135deg, var(--lightgrey) 0%, #fff 100%);
    position: relative;
}

#preview-character::before,
#character-avatar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at center, transparent 60%, rgba(0, 125, 255, 0.05) 100%);
    pointer-events: none;
}

/* Customization Modal Character Preview */
.character-preview {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
}

#preview-character {
    width: 100%;
    max-width: 300px;
    height: 380px;
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    border: 3px solid var(--blue);
}

#preview-character .at-kids-character-image {
    animation: characterAppear 0.5s ease-out;
}

@keyframes characterAppear {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Bounce animation for character changes */
.character-bounce {
    animation: bounce 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes bounce {
    0%, 100% {
        transform: scale(1) rotate(0deg);
    }
    25% {
        transform: scale(1.05) rotate(-5deg);
    }
    50% {
        transform: scale(1.1) rotate(5deg);
    }
    75% {
        transform: scale(1.05) rotate(-2deg);
    }
}

/* Loading state for character image */
.character-loading {
    position: relative;
}

.character-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 4px solid var(--lightgrey);
    border-top-color: var(--blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .at-kids-character-display {
        flex-direction: column;
        text-align: center;
    }
    
    .character-avatar {
        flex: 0 0 180px;
        height: 220px;
        margin: 0 auto;
    }
    
    .character-info {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .character-avatar {
        flex: 0 0 150px;
        height: 190px;
    }
    
    .character-info p {
        font-size: 1rem;
    }
}