/* 1. LAYOUT & MODERN MESH BACKGROUND */
body {
    margin: 0; padding: 0;
    display: flex; justify-content: center; align-items: center;
    height: 100vh;
    font-family: 'Satoshi', sans-serif;
    font-weight: 400;
    -webkit-font-smoothing: antialiased;
    background-color: #0a0a2e;
    background-image:
        radial-gradient(at 46% 21%, rgba(28, 21, 229, 0.7) 0px, transparent 50%),
        radial-gradient(at 93% 53%, rgba(95, 12, 154, 0.7) 0px, transparent 50%),
        radial-gradient(at 6% 76%, rgba(186, 73, 212, 0.7) 0px, transparent 50%),
        radial-gradient(at 63% 17%, rgba(200, 20, 110, 0.7) 0px, transparent 50%),
        radial-gradient(at 6% 94%, rgba(255, 72, 237, 0.7) 0px, transparent 50%),
        radial-gradient(at 13% 75%, rgba(50, 230, 218, 0.7) 0px, transparent 50%),
        radial-gradient(at 93% 50%, rgba(41, 181, 250, 0.7) 0px, transparent 50%);
    background-size: 150% 150%;
    animation: gradient-flow 18s ease infinite alternate;
    overflow: hidden;
    color: white;
}

/* 2. TYPOGRAFIE */
h1, #detailTitle {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 700;
    font-size: 2.7rem;
    margin: 0 0 10px 0;
    letter-spacing: -0.01em;
    text-transform: uppercase;
}

p, .bottom-centered { 
    font-family: 'Satoshi', sans-serif;
    font-weight: 500;
    font-size: 1rem; 
    margin-bottom: 40px; 
    letter-spacing: 4px;
    opacity: 0.6; 
    text-transform: uppercase;
}

#detailDesc {
    font-family: 'Satoshi', sans-serif;
    text-transform: none;
    opacity: 0.8;
    line-height: 1.6;
    letter-spacing: 0;
}

/* 3. SCENE & CARDS */
.scene {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.card {
    position: relative;
    z-index: 100;
    background: linear-gradient(rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 3rem;
    border-radius: 28px;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3), inset 0 0 20px rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    min-width: 330px;
    overflow: hidden;
    transition: all 0.5s ease;
    pointer-events: auto;
}

.detail-card {
    position: absolute;
    z-index: 1100;
    background: linear-gradient(rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 3rem;
    border-radius: 28px;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3), inset 0 0 20px rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    min-width: 330px;
    max-width: 500px;
    overflow: hidden;

    /* WICHTIG FÜR DIE ANIMATION */
    opacity: 0;
    transform: scale(0.8);
    visibility: hidden;      
    pointer-events: none;    
    
    transition: 
        opacity 0.4s ease, 
        transform 0.4s cubic-bezier(0.4, 0, 0.2, 1),
        visibility 0.4s;
}

.detail-card.active {
    opacity: 1;
    transform: scale(1);
    visibility: visible;
    pointer-events: auto;
}

/* 1. Der Wrapper hält alles zusammen und schwebt */
.card-float-wrapper {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 100px; /* Deine gewünschte Tiefe */
    animation: float 6s ease-in-out infinite;
    z-index: 100;
}

/* 2. Die Karte bekommt overflow: hidden zurück! */
.card {
    position: relative;
    z-index: 2; /* Über dem Strich */
    background: linear-gradient(rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
    backdrop-filter: blur(20px);
    padding: 3rem;
    border-radius: 28px;
    min-width: 330px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    
    /* WICHTIG: Das fängt den Shine-Effekt wieder ein */
    overflow: hidden; 
}

/* 3. Der Strich wird absolut im Wrapper zentriert */
.connection-path {
    position: absolute;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.8), transparent);
    z-index: 80;
    transform-origin: left center;
    width: 0; opacity: 0;
    transition: width 0.5s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
    pointer-events: none;
}

.celebrate-active {
    /* Wir erzwingen, dass während des Wackelns kein translateY aus dem Float stört */
    animation: jelly 0.6s cubic-bezier(0.36, 0.07, 0.19, 0.97) both !important;
    border-color: rgba(255, 255, 255, 1) !important;
    box-shadow: 
        0 0 20px rgba(255, 255, 255, 0.6), 
        0 0 60px rgba(255, 255, 255, 0.3), 
        0 20px 50px rgba(0, 0, 0, 0.5) !important;
}

/* Der Shine-Effekt (bleibt jetzt innerhalb der Karte) */
.card::before {
    content: "";
    position: absolute;
    top: -50%; left: -150%;
    width: 100%; height: 200%;
    background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.2), transparent);
    transform: rotate(45deg);
    animation: card-shine 8s infinite;
}

.detail-card::before {
    content: "";
    position: absolute;
    top: -4px; left: -4px; right: -4px; bottom: -4px;
    border-radius: 32px; 
    padding: 3px; 
    background: conic-gradient(from 0deg, transparent 0%, rgba(255, 255, 255, 0.9) 50%, transparent 100%);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    z-index: -1;
    animation: drawCircleReverse 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.detail-card.active::before {
    animation: drawCircle 1s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* --- 2. STAGGERED ENTRANCE (VERZÖGERUNG) --- */
/* Das sorgt dafür, dass die Kacheln nacheinander 'ploppen' */
.sub-card:nth-child(1) { transition-delay: 0.05s; }
.sub-card:nth-child(2) { transition-delay: 0.10s; }
.sub-card:nth-child(3) { transition-delay: 0.15s; }
.sub-card:nth-child(4) { transition-delay: 0.20s; }
.sub-card:nth-child(5) { transition-delay: 0.25s; }
.sub-card:nth-child(6) { transition-delay: 0.30s; }

/* --- 3. GLASS-MORPHISM FILL (RÜCKZUG DER HAUPTKACHEL) --- */
/* Wenn die Klasse 'dimmed' aktiv ist, zieht sich die Hauptkachel dezent zurück */
.card.dimmed {
    transform: scale(0.92);
    filter: blur(4px) brightness(0.8);
    opacity: 0.6;
    pointer-events: none; /* Verhindert Interaktion während Details offen sind */
}

/* 4. SUB-KACHELN & INTERAKTION */
.sub-card {
    position: absolute;
    z-index: 10; 
    width: 155px;
    height: 130px;
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 22px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    gap: 10px; color: white; cursor: pointer;

    /* Startzustand: Versteckt und für Maus unsichtbar */
    opacity: 0;
    visibility: hidden;
    pointer-events: none; 
    transform: translate(0, 0) scale(0);

    /* Definition der Transitionen */
    /* Wichtig: pointer-events wird hier mit einer Dauer von 0s definiert */
    transition: 
        transform 0.8s cubic-bezier(0.68, -0.6, 0.32, 1.6), 
        opacity 0.5s ease, 
        visibility 0.5s, 
        background 0.3s ease, 
        pointer-events 0s;
}

.sub-card.show {
    opacity: 1;
    visibility: visible;
    z-index: 150; 
    transform: translate(calc(cos(var(--angle)) * 42vmin), calc(sin(var(--angle)) * 42vmin)) scale(1);
    
    /* DER ENTSCHEIDENDE TRICK: */
    /* Wir erlauben pointer-events (Maus) erst nach 0.8s Verzögerung. */
    /* Die Delays entsprechen der Reihenfolge oben: transform(0), opacity(0), visibility(0), background(0), pointer-events(0.8s) */
    pointer-events: auto;
    transition-delay: 0s, 0s, 0s, 0s, 0.8s;
}

/* Hover-Effekt: Nur aktiv, wenn pointer-events auf auto steht (also nach 0.8s) */
.sub-card:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.7);
    box-shadow: 0 0 40px rgba(255, 255, 255, 0.3);
    
    /* Position halten, nur leicht vergrößern */
    transform: translate(calc(cos(var(--angle)) * 42vmin), calc(sin(var(--angle)) * 42vmin)) scale(1.15);
    
    /* Eigene Transition für schnelles Feedback beim Hover */
    transition: transform 0.2s ease-out, background 0.3s ease;
}

/* Icons und Text */
.sub-card i { font-size: 2rem; margin-bottom: 4px; transition: transform 0.3s ease; }
.sub-card span { font-size: 0.85rem; font-weight: 700; text-transform: uppercase; text-align: center; padding: 0 10px; }

/* Füge dies zu deinen Styles hinzu, falls noch nicht vorhanden */
.sub-card:not(.show) {
    pointer-events: none !important;
    transition-delay: 0s !important; /* Sofort klick-unfähig machen beim Einklappen */
}

/* Effekt für die Kachel, die gerade angeklickt wurde */
.sub-card.clicked-active {
    z-index: 999 !important;
    background: rgba(255, 255, 255, 0.2) !important;
    border-color: rgba(255, 255, 255, 0.8) !important;
    box-shadow: 0 0 40px rgba(255, 255, 255, 0.4) !important;
    transform: translate(calc(cos(var(--angle)) * 42vmin), calc(sin(var(--angle)) * 42vmin)) scale(1.1) !important;
    opacity: 1 !important;
    pointer-events: none; /* Verhindert Mehrfachklicks während der Animation */
}

/* 5. BUTTONS */
.btn, .back-btn {
    font-family: 'Satoshi', sans-serif; font-weight: 700; text-transform: uppercase;
    letter-spacing: 1.5px; cursor: pointer;
}

.btn {
    position: relative; overflow: hidden; border: 2px solid white;
    padding: 16px 45px; border-radius: 50px; background: transparent; color: white; transition: 0.3s;
}

.btn:hover { background: rgba(255, 255, 255, 0.1); }
.back-btn { margin-top: 20px; border: none; background: none; color: white; opacity: 0.6; }
.back-btn:hover { opacity: 1; }

/* 6. KEYFRAMES */
@keyframes gradient-flow { 0% { background-position: 0% 50%; } 100% { background-position: 100% 50%; } }
@keyframes card-shine { 0% { left: -150%; } 20% { left: 150%; } 100% { left: 150%; } }
@keyframes float { 
    /* Die Kachel startet nun 60px tiefer als die absolute Mitte */
    0%, 100% { transform: translateY(0px); } 
    /* Sie schwingt hoch auf 40px (bleibt also immer noch unter der Mitte) */
    50% { transform: translateY(-15px); } 
}

/* Jelly: Muss JEDEN Schritt auf der 60px-Ebene ausführen */
@keyframes jelly {
    0%   { transform: translateY(0px) scale(1, 1); }
    30%  { transform: translateY(0px) scale(1.08, 0.92); }
    40%  { transform: translateY(0px) scale(0.92, 1.08); }
    50%  { transform: translateY(0px) scale(1.05, 0.95); }
    65%  { transform: translateY(0px) scale(0.98, 1.02); }
    100% { transform: translateY(0px) scale(1, 1); }
}

@keyframes drawCircle { 
    0% { transform: rotate(0deg); opacity: 0; } 
    20% { opacity: 1; } 
    100% { transform: rotate(360deg); opacity: 1; } 
}

@keyframes drawCircleReverse { 
    0% { transform: rotate(360deg); opacity: 1; } 
    80% { opacity: 1; } 
    100% { transform: rotate(0deg); opacity: 0; } 
}

.bottom-centered {
    position: fixed; bottom: 20%; left: 50%;
    transform: translateX(-50%); padding: 10px 20px;
    text-align: center;
}

/* Diese Klasse wird vermutlich per JS hinzugefügt, wenn eine Sub-Kachel aktiv ist */
.sub-card.active ~ .connection-path, 
.connection-path.visible {
    opacity: 1;
    /* Die Breite wird meistens direkt im Style-Attribut via JS berechnet */
}

/* 8. RESPONSIVE DESIGN: SCROLL-STORY + INTERAKTION */
@media (max-width: 850px), (max-height: 700px) {
    body {
        overflow-x: hidden;
        overflow-y: auto; 
        height: auto;
        min-height: 100vh;
        scroll-snap-type: y proximity;
        display: block;
    }

    .scene {
        display: flex;
        flex-direction: column;
        align-items: center;
        width: 100%;
        height: auto;
        min-height: 100vh;
        padding: 40px 0;
    }

    /* 1. BUTTONS & EFFEKTE */
    .btn { display: none !important; }
    .card-float-wrapper { animation: none !important; }

    /* 2. HAUPTKACHEL */
    .card {
        position: relative;
        z-index: 10;
        width: 310px;
        margin: 11vh auto 4vh auto; 
        scroll-snap-align: center;
        animation: none; /* Stoppt Floating auf Mobile für sauberes Snapping */
    }

    /* 2.2 TYPOGRAFIE */
    h1, #detailTitle {
        font-family: 'Plus Jakarta Sans', sans-serif;
        font-weight: 700;
        font-size: 2.8rem;
        margin: 0 0 10px 0;
        letter-spacing: -0.01em;
        text-transform: uppercase;
    }

    /* 3. SUB-KACHELN (Klickbar & Sichtbar) */
    .scene .sub-card {
        display: flex !important;
        position: relative !important;
        left: auto !important;
        top: auto !important;
        pointer-events: auto !important;
        transform: none !important;
        display: flex !important;
        opacity: 1 !important;
        visibility: visible !important;
        width: 310px;
        height: 140px;
        margin: 0 auto 20px auto;
        scroll-snap-align: center;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        cursor: pointer;
        transition: background 0.3s ease, transform 0.2s ease;
        z-index: 100 !important;
    }

    .sub-card:active { transform: scale(0.96); background: rgba(255, 255, 255, 0.2); }

    /* 4. DETAIL-KACHELN & RING-EFFEKT */
    .detail-card.active {
        display: block !important;
        opacity: 1 !important;
        position: fixed !important;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) scale(1) !important;
        z-index: 2000 !important;
        width: 90vw !important;
        max-width: 340px !important;
        box-shadow: 0 0 100px rgba(0,0,0,0.8);
        isolation: isolate;
    }

    .detail-card.active::before {
        content: "";
        position: absolute;
        top: -4px; left: -4px; right: -4px; bottom: -4px;
        border-radius: 32px; 
        padding: 3px; 
        background: conic-gradient(from 0deg, transparent 0%, rgba(255, 255, 255, 0.9) 50%, transparent 100%);
        -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
        mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
        -webkit-mask-composite: xor;
        mask-composite: exclude;
        animation: drawCircle 1s cubic-bezier(0.4, 0, 0.2, 1) forwards;
        z-index: -1;
    }

    @keyframes drawCircle {
        0% { transform: rotate(0deg); opacity: 0; }
        20% { opacity: 1; }
        100% { transform: rotate(360deg); opacity: 1; }
    }

    /* Dimming-Effekt bei Detail-Ansicht */
    .scene:has(.detail-card.active) .card,
    .scene:has(.detail-card.active) .sub-card {
        opacity: 0.1 !important;
        filter: blur(4px) grayscale(100%);
        pointer-events: none;
    }

    /* Nur wenn die Detail-Karte offen ist, blenden wir sie aus */
    .scene.detail-open .sub-card {
        visibility: hidden !important;
        pointer-events: none !important;
    }

 /* 5. FOOTER ZENTRIERUNG MOBILE (KORRIGIERT) */
    .bottom-centered {
        position: relative !important; /* Löst ihn vom Bildschirmrand */
        bottom: auto !important;
        left: auto !important;
        transform: none !important;
        
        width: 100% !important;
        box-sizing: border-box;
        padding: 60px 20px !important; /* Mehr Platz nach oben und unten */
        
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important; /* Horizontale Zentrierung der Texte */
        justify-content: center !important;
        text-align: center !important;
        
        margin-top: 50px !important;
        opacity: 0.5;
        scroll-snap-align: end; /* Lässt den Footer sauber einrasten beim Scrollen */
    }

    /* Stellt sicher, dass die Texte im Footer auch untereinander zentriert sind */
    .bottom-centered p, 
    .bottom-centered span {
        margin: 5px 0 !important;
        width: 100%;
        display: block;
    }    
    body:has(.detail-card.active) { overflow: hidden; }
}