/* =========================================================
   ASTRONAUTENBAR · GEHIRN v0.4
   Maßstab näher an der Startseite
   + individuelles neuronales Eigenleben
   + seltenes Aufleuchten ganzer Areale
   ========================================================= */

.archive-mode-switch {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
    margin-top: 22px;
    padding-bottom: 17px;
    border-bottom: 1px solid var(--line);
}

.archive-mode-button {
    appearance: none;
    border: 1px solid var(--line);
    background: transparent;
    color: var(--muted);
    padding: 9px 13px;
    font: inherit;
    font-size: var(--font-ui);
    letter-spacing: 0.07em;
    cursor: pointer;
    transition:
        color 0.15s ease,
        border-color 0.15s ease,
        background 0.15s ease;
}

.archive-mode-button:hover {
    color: var(--cyan);
    border-color: rgba(98, 217, 232, 0.5);
}

.archive-mode-button.is-active {
    color: var(--foreground);
    border-color: var(--accent);
    background: rgba(255, 79, 216, 0.035);
}

.archive-view {
    display: none;
}

.archive-view.is-active {
    display: block;
}


/* =========================================================
   GEHIRN · STATUS
   ========================================================= */

.brain-view {
    margin-top: 23px;
}

.brain-status {
    color: var(--cyan);
    font-size: var(--font-system);
    letter-spacing: 0.025em;
}

.brain-status span {
    color: var(--accent);
    animation: brainStatusPulse 8.9s steps(1, end) infinite;
}

@keyframes brainStatusPulse {
    0%, 91%, 100% { opacity: 1; }
    92% { opacity: 0.4; }
    94% { opacity: 1; }
}

.brain-intro {
    margin-top: 8px;
    color: var(--muted);
    font-size: var(--font-system);
    letter-spacing: 0.045em;
}

.brain-warning {
    margin-top: 13px;
    max-width: 760px;
    color: var(--muted);
    font-size: var(--font-system);
    line-height: 1.55;
    letter-spacing: 0.025em;
}


/* =========================================================
   GEHIRN · KACHELN
   ========================================================= */

.brain-grid {
    display: grid;
    grid-template-columns: repeat(3, 205px);
    justify-content: start;
    gap: 14px;
    margin-top: 30px;
}

.brain-tile {
    position: relative;
    width: 205px;
    min-height: 148px;

    display: flex;
    flex-direction: column;
    justify-content: flex-end;

    padding: 16px;

    border: 1px solid rgba(98, 217, 232, 0.24);

    background:
        linear-gradient(
            180deg,
            rgba(98, 217, 232, 0.018),
            rgba(255, 79, 216, 0.012)
        );

    color: var(--foreground);
    text-decoration: none;

    overflow: hidden;

    transition:
        transform 0.16s ease,
        border-color 0.16s ease,
        background 0.16s ease;

    /* Die ganze Kachel "feuert" nur sehr selten. */
    animation: areaFlash 16s ease-in-out infinite;
}

.brain-tile:nth-child(1) { animation-delay: -2.0s; }
.brain-tile:nth-child(2) { animation-delay: -11.4s; }
.brain-tile:nth-child(3) { animation-delay: -6.8s; }
.brain-tile:nth-child(4) { animation-delay: -14.1s; }
.brain-tile:nth-child(5) { animation-delay: -4.7s; }
.brain-tile:nth-child(6) { animation-delay: -9.6s; }
.brain-tile:nth-child(7) { animation-delay: -1.1s; }
.brain-tile:nth-child(8) { animation-delay: -12.7s; }
.brain-tile:nth-child(9) { animation-delay: -7.9s; }

/*
   Fast die gesamte Zeit passiert nichts.
   Dann: kurzer elektronischer Impuls durch das ganze Areal.
*/
@keyframes areaFlash {
    0%, 84%, 100% {
        border-color: rgba(98, 217, 232, 0.24);
        background:
            linear-gradient(
                180deg,
                rgba(98, 217, 232, 0.018),
                rgba(255, 79, 216, 0.012)
            );
        box-shadow: none;
    }

    85% {
        border-color: rgba(98, 217, 232, 0.42);
        background:
            linear-gradient(
                180deg,
                rgba(98, 217, 232, 0.04),
                rgba(255, 79, 216, 0.018)
            );
        box-shadow:
            inset 0 0 17px rgba(98, 217, 232, 0.035),
            0 0 8px rgba(98, 217, 232, 0.025);
    }

    86% {
        border-color: rgba(98, 217, 232, 0.78);
        background:
            linear-gradient(
                180deg,
                rgba(98, 217, 232, 0.11),
                rgba(255, 79, 216, 0.045)
            );
        box-shadow:
            inset 0 0 25px rgba(98, 217, 232, 0.09),
            0 0 14px rgba(98, 217, 232, 0.07);
    }

    86.6% {
        border-color: rgba(255, 79, 216, 0.48);
        background:
            linear-gradient(
                180deg,
                rgba(98, 217, 232, 0.045),
                rgba(255, 79, 216, 0.05)
            );
        box-shadow:
            inset 0 0 18px rgba(255, 79, 216, 0.045);
    }

    88% {
        border-color: rgba(98, 217, 232, 0.27);
        background:
            linear-gradient(
                180deg,
                rgba(98, 217, 232, 0.022),
                rgba(255, 79, 216, 0.014)
            );
        box-shadow: none;
    }
}

.brain-tile:hover,
.brain-tile:focus-visible {
    transform: translateY(-2px);
    border-color: rgba(98, 217, 232, 0.68);
    background: rgba(98, 217, 232, 0.03);
    outline: none;
}


/* =========================================================
   NEURONALE AKTIVITÄT · JE AREAL ANDERS
   ========================================================= */

.brain-tile::before,
.brain-tile::after {
    content: "";
    position: absolute;
    pointer-events: none;
}

.brain-tile::before {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--cyan);
    opacity: 0.42;
    box-shadow: 0 0 7px rgba(98, 217, 232, 0.45);
}

.brain-tile::after {
    height: 1px;
    width: 48px;
    opacity: 0.16;
    background: linear-gradient(
        90deg,
        transparent,
        var(--cyan),
        transparent
    );
}


/* MENSCH */
.brain-tile:nth-child(1)::before {
    top: 26px;
    left: 39px;
    animation: neuronSoftPulse 7.2s ease-in-out infinite;
}

.brain-tile:nth-child(1)::after {
    top: 37px;
    left: 41px;
    transform: rotate(19deg);
    animation: neuronSoftFlash 9.5s ease-in-out infinite;
}


/* KÖRPER */
.brain-tile:nth-child(2)::before {
    top: 31px;
    right: 41px;
    background: var(--accent);
    box-shadow: 0 0 7px rgba(255, 79, 216, 0.42);
    animation: neuronDoublePulse 8.6s ease-in-out infinite;
}

.brain-tile:nth-child(2)::after {
    display: none;
}


/* BEZIEHUNGEN */
.brain-tile:nth-child(3)::before {
    top: 27px;
    left: 43%;
    box-shadow:
        0 0 7px rgba(98, 217, 232, 0.4),
        31px 14px 0 -1px rgba(255, 79, 216, 0.35);
    animation: neuronRelation 10s ease-in-out infinite;
}

.brain-tile:nth-child(3)::after {
    width: 35px;
    top: 35px;
    left: 89px;
    transform: rotate(24deg);
    animation: neuronRelationLine 10s ease-in-out infinite;
}


/* DENKEN */
.brain-tile:nth-child(4)::before {
    top: 25px;
    right: 48px;
    animation: neuronThink 11.2s steps(1, end) infinite;
}

.brain-tile:nth-child(4)::after {
    width: 62px;
    top: 30px;
    right: 41px;
    transform: rotate(-8deg);
    opacity: 0.09;
}


/* GESELLSCHAFT */
.brain-tile:nth-child(5)::before {
    top: 29px;
    left: 35px;
    box-shadow:
        0 0 6px rgba(98, 217, 232, 0.35),
        23px 7px 0 -1px rgba(244, 234, 247, 0.25),
        46px -3px 0 -1px rgba(255, 79, 216, 0.25);
    animation: neuronSociety 12s ease-in-out infinite;
}

.brain-tile:nth-child(5)::after {
    display: none;
}


/* WISSENSCHAFT */
.brain-tile:nth-child(6)::before {
    top: 33px;
    left: 52%;
    animation: neuronScience 7.8s steps(1, end) infinite;
}

.brain-tile:nth-child(6)::after {
    top: 33px;
    left: 45px;
    width: 82px;
    opacity: 0.12;
    animation: neuronScienceLine 13s ease-in-out infinite;
}


/* TECHNIK */
.brain-tile:nth-child(7)::before {
    top: 26px;
    left: 40px;
    border-radius: 0;
    animation: neuronTech 9.3s steps(1, end) infinite;
}

.brain-tile:nth-child(7)::after {
    top: 28px;
    left: 45px;
    width: 62px;
    background: repeating-linear-gradient(
        90deg,
        rgba(98, 217, 232, 0.22) 0 4px,
        transparent 4px 8px
    );
    opacity: 0.22;
}


/* KULTUR */
.brain-tile:nth-child(8)::before {
    top: 32px;
    right: 42px;
    background: var(--accent);
    box-shadow: 0 0 8px rgba(255, 79, 216, 0.38);
    animation: neuronCulture 10.8s ease-in-out infinite;
}

.brain-tile:nth-child(8)::after {
    top: 27px;
    right: 37px;
    width: 48px;
    transform: rotate(-31deg);
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 79, 216, 0.38),
        transparent
    );
    animation: neuronCultureLine 10.8s ease-in-out infinite;
}


/* LEBEN */
.brain-tile:nth-child(9)::before {
    top: 30px;
    left: 44%;
    background: var(--foreground);
    box-shadow: 0 0 6px rgba(244, 234, 247, 0.3);
    animation: neuronLife 14s ease-in-out infinite;
}

.brain-tile:nth-child(9)::after {
    display: none;
}


/* =========================================================
   KLEINE IMPULSE
   ========================================================= */

@keyframes neuronSoftPulse {
    0%, 76%, 100% { opacity: 0.3; transform: scale(0.9); }
    80% { opacity: 0.75; transform: scale(1.08); }
    84% { opacity: 0.36; transform: scale(0.95); }
}

@keyframes neuronSoftFlash {
    0%, 78%, 100% { opacity: 0.05; }
    81% { opacity: 0.32; }
    84% { opacity: 0.08; }
}

@keyframes neuronDoublePulse {
    0%, 72%, 100% { opacity: 0.28; transform: scale(0.92); }
    75% { opacity: 0.75; transform: scale(1.12); }
    78% { opacity: 0.34; transform: scale(0.94); }
    81% { opacity: 0.62; transform: scale(1.04); }
    84% { opacity: 0.3; transform: scale(0.92); }
}

@keyframes neuronRelation {
    0%, 68%, 100% { opacity: 0.28; }
    72% { opacity: 0.75; }
    76% { opacity: 0.38; }
    80% { opacity: 0.65; }
}

@keyframes neuronRelationLine {
    0%, 70%, 100% { opacity: 0.05; }
    75% { opacity: 0.3; }
    80% { opacity: 0.08; }
}

@keyframes neuronThink {
    0%, 81%, 100% { opacity: 0.26; }
    82% { opacity: 0.75; }
    84% { opacity: 0.18; }
    86% { opacity: 0.6; }
    88% { opacity: 0.28; }
}

@keyframes neuronSociety {
    0%, 74%, 100% { opacity: 0.25; transform: translateX(0); }
    78% { opacity: 0.58; transform: translateX(2px); }
    82% { opacity: 0.3; transform: translateX(0); }
}

@keyframes neuronScience {
    0%, 87%, 100% { opacity: 0.24; }
    88% { opacity: 0.72; }
    90% { opacity: 0.22; }
}

@keyframes neuronScienceLine {
    0%, 83%, 100% { opacity: 0.04; }
    87% { opacity: 0.25; }
    90% { opacity: 0.06; }
}

@keyframes neuronTech {
    0%, 79%, 100% { opacity: 0.24; }
    80% { opacity: 0.8; }
    81% { opacity: 0.16; }
    83% { opacity: 0.55; }
    85% { opacity: 0.24; }
}

@keyframes neuronCulture {
    0%, 75%, 100% { opacity: 0.24; transform: rotate(0deg); }
    80% { opacity: 0.62; transform: rotate(10deg); }
    85% { opacity: 0.28; transform: rotate(0deg); }
}

@keyframes neuronCultureLine {
    0%, 76%, 100% { opacity: 0.04; }
    81% { opacity: 0.24; }
    85% { opacity: 0.06; }
}

@keyframes neuronLife {
    0%, 66%, 100% { opacity: 0.24; transform: scale(0.95); }
    72% { opacity: 0.5; transform: scale(1.02); }
    78% { opacity: 0.3; transform: scale(0.97); }
}


/* =========================================================
   BESCHRIFTUNG
   näher am Maßstab der Startseite
   ========================================================= */

.brain-tile-title {
    position: relative;
    z-index: 2;
    display: block;

    color: var(--foreground);

    font-size: 1rem;
    font-weight: bold;
    line-height: 1.25;
    letter-spacing: 0.055em;
}

.brain-tile-meta {
    position: relative;
    z-index: 2;
    display: block;

    margin-top: 6px;

    color: var(--muted);

    font-size: var(--font-meta);
    line-height: 1.5;
    letter-spacing: 0.015em;
}


/* =========================================================
   GEHIRN · SYSTEMMELDUNG
   ========================================================= */

.brain-system-message {
    margin-top: 32px;
    padding: 13px 0;
    border-top: 1px solid var(--line);

    color: var(--cyan);

    font-size: var(--font-system);
    line-height: 1.65;
}


/* =========================================================
   TABLET / MOBILE
   ========================================================= */

@media (max-width: 760px) {
    .brain-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
    }

    .brain-tile {
        width: auto;
        min-height: 142px;
    }
}

@media (max-width: 600px) {
    .archive-mode-button {
        flex: 1 1 0;
        padding: 8px 7px;
        font-size: var(--font-ui);
    }

    .brain-grid {
        margin-top: 25px;
        gap: 10px;
    }

    .brain-tile {
        min-height: 126px;
        padding: 13px;
    }

    .brain-tile-title {
        font-size: 0.88rem;
        letter-spacing: 0.035em;
    }

    .brain-tile-meta {
        font-size: var(--font-meta);
    }

    .brain-warning {
        font-size: var(--font-system);
    }

    .brain-system-message {
        font-size: var(--font-system);
    }
}

@media (prefers-reduced-motion: reduce) {
    .brain-status span,
    .brain-tile,
    .brain-tile::before,
    .brain-tile::after {
        animation: none;
    }

    .brain-tile {
        transition: none;
    }
}
