/* =============================================================================
   3D CHARACTER DISPLAY STYLES
   ============================================================================= */

/* Character Section Container */
/* ========================== */

/* Gallery Container - holds all character sections */
.gallery-container {
    position: absolute;
    top: 110vh; /* Lower on desktop */
    left: 0;
    width: 100%;
    z-index: 3;
    display: flex;
    flex-direction: column;
    gap: 2rem; /* Space between character sections */
    padding: 2rem 0;
    background: transparent; /* Transparent background */
}

/* Individual Character Section */
.character-section {
    position: relative; /* Stack within gallery container */
    width: 100%;
    height: 80vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: transparent; /* Completely transparent */
}

/* Character Container */
.character-container {
    position: relative;
    width: 100%;
    max-width: 1400px;
    height: 90vh;
    display: flex;
    align-items: center;
    justify-content: flex-start; /* Align to start for absolute positioning */
    padding: 0 2rem;
}

/* 3D Character Viewer */
.character-3d {
    position: absolute;
    left: 15vw; /* Character positioned 15vw from left edge */
    width: 40vw; /* Make it bigger - 40% of viewport width */
    height: 100%;
    min-height: 500px;
    /* Hidden by default; visibility driven by .io-* utilities */
    opacity: 0;
    /* Transform handled by io-fade-left class */
    touch-action: pan-y; /* allow vertical scroll while interacting */
}

.character-3d spline-viewer {
    width: 100%;
    height: 100%;
    display: block;
    border: none;
    transform: scale(2.2); /* Make character even larger */
    pointer-events: auto; /* Ensure Spline is interactable */
    position: relative;
    z-index: 2;
    touch-action: pan-y; /* allow vertical scroll gestures */
}

/* Runtime canvas styling for character viewer */
.character-3d canvas#character-canvas {
    width: 100%;
    height: 100%;
    display: block;
    border: none;
    transform: scale(2.2);
    transform-origin: center center;
    pointer-events: auto;
    position: relative;
    z-index: 2;
    touch-action: pan-y;
}

/* Character Info Container */
.character-info {
    position: absolute;
    left: auto;
    right: 2vw; /* Text positioned closer to right edge on desktop */
    top: 30%; /* Higher up for earlier animation */
    width: max-content; /* shrink-to-fit so right edge aligns cleanly */
    height: auto;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-end; /* Right-align children */
    z-index: 10;
    transform: translateY(-50%); /* Only center vertically */
}

/* Shared text scaling class */
.character-text-scale {
    font-size: clamp(4.5rem, 10vw, 8rem); /* Much bigger text */
}

/* Character Name Styling */
.character-name {
    font-family: 'Jalnan2', 'Arial Black', sans-serif;
    font-weight: 900;
    letter-spacing: 2px;
    color: #000;
    margin: 0;
    text-align: right; /* Right align text */
    /* Positioning handled by parent .character-info padding-right */
    /* opacity and transform handled by io class */
    text-shadow: 2px 2px 8px rgba(255,255,255,0.9);
    pointer-events: auto; /* Ensure text is selectable */
    user-select: text; /* Allow text selection */
}

/* Sub Elements Container (subtitle + buttons) */
.sub_elements {
    display: flex;
    flex-direction: column;
    align-items: flex-end; /* Right align all children */
    width: 100%;
    margin-top: 1rem;
    /* Positioning handled by parent .character-info */
    /* Animation handled by io-fade-right-close class only */
}

/* Character Subtitle Styling (creator and year) */
.character-subtitle {
    font-family: 'OkDanDan-Bold', 'Arial', sans-serif;
    font-size: clamp(1.2rem, 3vw, 2rem); /* Smaller than main title */
    font-weight: bold;
    letter-spacing: 1px;
    color: #666; /* Slightly lighter color */
    margin: 0.5rem 0 0 0; /* Small top margin */
    text-align: right; /* Right align to match title */
    text-shadow: 1px 1px 4px rgba(255,255,255,0.8);
    pointer-events: auto;
    user-select: text;
    /* No individual animation - handled by parent sub_elements */
}

/* Character Buttons Container */
.character-buttons {
    display: grid;
    grid-template-columns: repeat(3, max-content); /* 3 columns per row */
    justify-content: end; /* Align grid to the right */
    justify-items: end;   /* Align items to the right within cells */
    align-items: center;
    column-gap: 1rem;
    row-gap: 0.75rem;
    margin-top: 1.5rem;
    width: 100%;
    /* No horizontal scrolling; we wrap to new rows every 3 */
    /* No individual padding - parent character-info handles positioning */
}

/* Individual Animation Buttons */
.animation-btn {
    background: #000;
    color: #fff;
    border: none;
    padding: 0.85rem 2rem; /* slightly taller, wider padding */
    font-family: 'OkDanDan-Bold', 'Arial', sans-serif;
    font-size: clamp(0.9rem, 2vw, 1.1rem);
    font-weight: bold;
    letter-spacing: 0.5px;
    border-radius: 25px; /* Much more rounded */
    cursor: pointer;
    transition: all 0.3s ease;
    user-select: none;
    text-transform: uppercase;
    min-width: 160px; /* roughly twice as wide as before */
}

.animation-btn:hover {
    background: #333;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.animation-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.animation-btn:focus {
    outline: 2px solid #666;
    outline-offset: 2px;
}

.animation-btn.active {
    background: #444;
    transform: translateY(-1px);
    box-shadow: 0 3px 6px rgba(0,0,0,0.4);
}

/* Old scroll-timeline animations removed - using IO classes instead */


/* Responsive Design */
/* ================ */

/* Tablet Layout */
@media (min-width: 769px) and (max-width: 1024px) {
    .character-container {
        gap: 2rem;
        padding: 0 1rem;
    }
    
    /* Remove character-info padding override - let main layout handle positioning */
    
    .character-name {
        font-size: clamp(2.5rem, 5vw, 4rem);
    }
    
    .character-subtitle {
        font-size: clamp(1.1rem, 2.5vw, 1.8rem); /* Tablet-specific size */
    }
}

/* Mobile Layout */
@media (max-width: 768px) {
    .gallery-container {
        top: 85vh; /* Higher on mobile to match gallery text */
    }
    
    .character-section {
        height: 100vh; /* Full viewport height */
        background: transparent; /* Transparent background on mobile */
    }
    
    .character-container {
        flex-direction: column;
        gap: 0.5rem; /* Much closer together */
        padding: 1rem 0 1rem 1rem; /* Remove right padding, keep others */
        justify-content: center;
        align-items: center;
        height: 90vh;
    }
    
    /* Put character first in visual order */
    .character-3d {
        width: 80%; /* Narrower than full width */
        height: 60vh; /* Smaller to fit title below */
        min-height: 350px;
        margin-left: 2rem; /* Push character further from left edge */
        /* Use same fade-left as desktop - no custom mobile transform */
        order: 1; /* Show first */
        opacity: 0; /* Start invisible, will fade in */
    }
    
    .character-info {
        width: max-content;
        height: auto;
        text-align: right; /* match desktop */
        align-items: flex-end; /* match desktop */
        order: 2; /* Show second (below the character) */
        z-index: 10;
        opacity: 1; /* Keep visible container */
        /* Use absolute positioning */
        position: absolute;
        transform: none;
        right: -5vw; /* Position extending beyond right edge on mobile */
        top: auto;
        margin: 0; /* Remove all margins */
        padding: 0; /* Remove all padding */
    }
    
    .character-3d spline-viewer {
        width: 100%;
        height: 100%;
        transform: scale(1.5) translateX(-10%); /* Scale + shift character more to the left */
    }
    
    .character-name {
        font-size: clamp(3rem, 12vw, 5rem); /* Much larger on mobile */
        /* Remove transform and opacity - io-fade-right-close handles it */
        margin-top: 0;
        margin-bottom: 0;
        color: #000;
        font-weight: 900;
        text-shadow: 2px 2px 4px rgba(255,255,255,0.8);
        text-align: right; /* Right on mobile */
    }
    
    .sub_elements {
        margin-top: 0.5rem; /* Reduce margin on mobile */
        align-items: flex-end; /* Ensure right alignment on mobile */
    }
    
    .character-subtitle {
        font-size: clamp(0.8rem, 2.5vw, 1.2rem); /* Smaller mobile size */
        margin-top: 0.5rem;
        color: #666;
    }
    
    .character-buttons {
        display: grid;
        grid-template-columns: repeat(3, max-content); /* 3 per row like desktop */
        justify-content: end; /* Right grid on mobile */
        justify-items: end;   /* Right items in cells */
        margin-top: 1rem; /* Reduce top margin on mobile */
        column-gap: 0.5rem; /* Smaller gap for 3 columns */
        row-gap: 0.5rem;
    }
    
    .animation-btn {
        padding: 0.6rem 1.2rem; /* Smaller padding on mobile */
        font-size: clamp(0.8rem, 3vw, 1rem); /* Responsive mobile button text */
        min-width: 70px; /* Smaller minimum width on mobile */
    }
    
    /* Mobile animations removed - using IO classes instead */
}

/* Small Mobile Layout */
@media (max-width: 480px) {
    .character-section {
        height: 100vh;
    }
    
    .character-container {
        height: 85vh;
        gap: 0.5rem; /* Closer together */
        padding: 1rem 0 1rem 1rem; /* Remove right padding, keep others */
    }
    
    .character-3d {
        height: 55vh; /* Slightly smaller to fit title below */
        min-height: 320px;
    }
    
    .character-3d spline-viewer {
        transform: scale(1.7); /* Even more scaling for small screens */
    }
    
    .character-name {
        font-size: clamp(2rem, 9vw, 3rem); /* Larger text on small screens */
        margin-bottom: 0;
        margin-top: 0;
    }
}


/* Character Loading States */
/* ======================= */

.character-loading {
    opacity: 0.5;
}

.character-loaded {
    opacity: 1;
}

