
/* 
   FOKUS PRO // AVATAR SELECTOR v3.5
   Local File Grid // Mobile Scroll Fix (Touch Action)
   Fix: Sticky Header Clipping (Padding moved to children)
*/

.av-window {
    width: 100%;
    max-width: 450px !important;
    background: #020617;
    border: 1px solid rgba(16, 185, 129, 0.3);
    box-shadow: 0 0 50px rgba(0,0,0,0.8), 0 0 20px rgba(16, 185, 129, 0.1);
    display: flex;
    flex-direction: column;
    /* Desktop Default */
    height: 80vh;
    max-height: 800px;
    overflow: hidden; /* Container selbst scrollt nicht */
    border-radius: 20px;
    position: relative;
    margin: auto;
    
    /* WICHTIG: Verhindert das Verschieben des Fensters auf Mobile */
    touch-action: none; 
}

/* 
   NEU: Wrapper für den Inhalt unter dem Header.
   Nimmt den Restplatz ein (flex: 1) und erlaubt Kindern das Scrollen (min-height: 0).
*/
.avatar-creator-ui {
    display: flex;
    flex-direction: column;
    flex: 1; 
    min-height: 0; 
    overflow: hidden;
    position: relative;
}

/* --- HERO SECTION (PREVIEW) --- */
.av-hero-section {
    position: relative;
    height: 220px; /* Desktop Höhe */
    flex-shrink: 0; /* Fixe Höhe */
    background: radial-gradient(circle at center, #0f172a 0%, #020617 70%);
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    overflow: hidden;
    transition: height 0.3s ease;
    /* Hero darf nicht gescrollt werden */
    touch-action: none; 
}

/* Background Grid Effect in Hero */
.av-hero-bg-grid {
    position: absolute; inset: 0;
    background-image: 
        linear-gradient(rgba(16, 185, 129, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(16, 185, 129, 0.05) 1px, transparent 1px);
    background-size: 30px 30px;
    mask-image: radial-gradient(circle, black 40%, transparent 80%);
    z-index: 0;
}

/* The Glowing Ring */
.av-scanner-ring {
    position: absolute;
    width: 170px; height: 170px;
    border-radius: 50%;
    border: 2px dashed rgba(16, 185, 129, 0.3);
    animation: rotate-slow 20s linear infinite;
    z-index: 1;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
}
.av-scanner-ring::before {
    content: ''; position: absolute; inset: -10px; border-radius: 50%;
    border: 1px solid rgba(16, 185, 129, 0.1);
    border-left-color: var(--c-primary);
    border-right-color: var(--c-primary);
    animation: rotate-fast 4s linear infinite reverse;
}

/* Main Image */
#av-preview-img {
    width: 150px; height: 150px;
    border-radius: 50%;
    object-fit: cover;
    z-index: 5;
    background: #000;
    box-shadow: 0 0 30px rgba(0,0,0,0.8);
    border: 2px solid var(--c-primary);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform: translateY(-10px);
}

/* Glitch Effect on Change */
#av-preview-img.glitching {
    animation: glitch-anim 0.3s cubic-bezier(.25, .46, .45, .94) both infinite;
    filter: hue-rotate(90deg) contrast(1.5);
}

/* Name Tag below image */
.av-identity-tag {
    position: absolute; 
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--font-tech);
    color: var(--c-primary);
    font-size: 0.7rem; letter-spacing: 2px;
    background: rgba(2, 6, 23, 0.8);
    backdrop-filter: blur(4px);
    padding: 6px 16px; border-radius: 20px;
    border: 1px solid rgba(16, 185, 129, 0.3);
    z-index: 10;
    text-transform: uppercase;
    white-space: nowrap;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
}

/* --- GRID SECTION (SCROLL AREA) --- */
.av-grid-scroll {
    flex: 1; /* Nimmt den Restplatz ein */
    min-height: 0; /* WICHTIG */
    overflow-y: auto; /* Nur hier wird gescrollt */
    
    /* FIX: Padding entfernt, damit Header ganz oben klebt (0px) */
    padding: 0; 
    
    background: rgba(0,0,0,0.2);
    
    /* WICHTIG: Erlaubt NUR hier vertikales Scrollen auf Mobile */
    touch-action: pan-y;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.av-section-title {
    font-size: 0.7rem; color: var(--c-text-sec); 
    font-family: var(--font-tech); letter-spacing: 1px;
    
    /* Sticky Setup */
    position: sticky; top: 0; z-index: 10; 
    
    /* Opaque Background & Padding moved here */
    background: #020617; 
    padding: 15px 15px 10px 15px; 
    margin: 0;
    
    display: flex; justify-content: space-between; align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    box-shadow: 0 4px 15px rgba(0,0,0,0.5); /* Schatten verdeckt Inhalt darunter */
}

.av-grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 12px;
    
    /* Padding moved here */
    padding: 15px;
}

.av-card {
    position: relative;
    aspect-ratio: 1;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    cursor: pointer;
    overflow: hidden;
    transition: all 0.2s ease-out;
}

.av-card img {
    width: 100%; height: 100%;
    object-fit: cover;
    opacity: 0.7;
    transition: 0.3s;
}

/* Hover Effects */
.av-card:hover {
    border-color: rgba(255,255,255,0.5);
    transform: translateY(-2px);
}
.av-card:hover img { opacity: 1; transform: scale(1.1); }

/* Active (Selected) State */
.av-card.selected {
    border-color: var(--c-primary);
    background: rgba(16, 185, 129, 0.1);
    box-shadow: 0 0 10px var(--c-primary-dim);
}
.av-card.selected img { opacity: 1; }
.av-card.selected::after {
    content: '\f00c'; /* FontAwesome Check */
    font-family: "Font Awesome 6 Free"; font-weight: 900;
    position: absolute; top: 4px; right: 4px;
    color: #000; background: var(--c-primary);
    width: 18px; height: 18px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.7rem;
    box-shadow: 0 0 5px var(--c-primary);
}

/* Empty State */
.av-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 30px;
    color: var(--c-text-dim);
    font-size: 0.8rem;
    border: 1px dashed rgba(255,255,255,0.1);
    border-radius: 12px;
}

/* --- FOOTER --- */
.av-footer {
    padding: 15px;
    border-top: 1px solid rgba(255,255,255,0.1);
    background: #020617;
    display: flex; gap: 10px;
    flex-shrink: 0;
    touch-action: none; /* Footer nicht verschiebbar */
}

/* --- ANIMATIONS --- */
@keyframes rotate-slow { from { transform: translate(-50%, -50%) rotate(0deg); } to { transform: translate(-50%, -50%) rotate(360deg); } }
@keyframes rotate-fast { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes glitch-anim {
  0% { transform: translate(0) }
  20% { transform: translate(-2px, 2px) }
  40% { transform: translate(-2px, -2px) }
  60% { transform: translate(2px, 2px) }
  80% { transform: translate(2px, -2px) }
  100% { transform: translate(0) }
}

/* --- MOBILE SPECIFIC OPTIMIZATIONS --- */
@media (max-width: 600px), (max-height: 750px) {
    .av-window {
        width: 90%; 
        height: 70vh; 
        max-height: 600px;
        position: relative;
        bottom: auto;
        margin: auto;
    }

    .av-hero-section {
        height: 150px; 
    }

    .av-scanner-ring {
        width: 120px; height: 120px;
    }

    #av-preview-img {
        width: 100px; height: 100px;
        transform: translateY(-8px);
    }

    .av-identity-tag {
        bottom: 8px;
        font-size: 0.65rem;
        padding: 4px 12px;
    }

    .av-grid-scroll {
        padding: 0; /* Keep 0 for mobile too */
    }
    
    .av-section-title {
        padding: 10px 12px 8px 12px;
    }

    .av-grid-container {
        grid-template-columns: repeat(4, 1fr);
        gap: 8px;
        padding: 10px;
    }
}
