/* Univers boot — styles portail CRT (accueil recruteur retiré) */

/* Pendant la transition : pas de scroll page, seulement la console */
html:has(body.portal-void),
html:has(body.boot-logging),
html:has(body.boot-active),
html:has(body.boot-awaiting-enter),
html:has(body.portal-active),
body.portal-void,
body.boot-logging,
body.boot-active,
body.boot-awaiting-enter,
body.portal-active {
    overflow: hidden !important;
    height: 100%;
    overscroll-behavior: none;
    touch-action: none;
}

body:not(.universe-entered) .portfolio-app {
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
}

body.universe-entered .portfolio-app {
    pointer-events: auto;
    visibility: visible;
    opacity: 1;
}

body:not(.universe-entered):not(.boot-logging):not(.boot-active):not(.boot-fade) #particles,
body:not(.universe-entered):not(.boot-logging):not(.boot-active):not(.boot-fade) .noise-overlay,
body:not(.universe-entered):not(.boot-logging):not(.boot-active):not(.boot-fade) .scanlines,
body:not(.universe-entered):not(.boot-logging):not(.boot-active):not(.boot-fade) .grid-bg,
body:not(.universe-entered):not(.boot-logging):not(.boot-active):not(.boot-fade) .cursor,
body:not(.universe-entered):not(.boot-logging):not(.boot-active):not(.boot-fade) .cursor-follower {
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
}

/* ========== Transition portail (blackout) ========== */
body.portal-active::before,
body.portal-void::before,
body.boot-logging::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 100040;
    background: #000;
    pointer-events: none;
}

body.portal-active::before {
    opacity: 0;
    animation: portal-blackout 0.7s ease forwards;
}

body.portal-void::before,
body.boot-logging::before {
    opacity: 1;
    animation: none;
}

body.portal-void #portfolio-app,
body.boot-logging #portfolio-app,
body.portal-active #portfolio-app,
body.portal-active #particles,
body.portal-active .noise-overlay,
body.portal-active .scanlines,
body.portal-active .grid-bg,
body.portal-void #particles,
body.portal-void .noise-overlay,
body.portal-void .scanlines,
body.portal-void .grid-bg,
body.boot-logging #particles,
body.boot-logging .noise-overlay,
body.boot-logging .scanlines,
body.boot-logging .grid-bg {
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

@keyframes portal-blackout {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

/* ========== Boot console + allumage CRT ========== */
body.portal-void,
body.boot-logging,
body.boot-active {
    background: #000;
}

.universe-boot {
    position: fixed;
    inset: 0;
    z-index: 100050;
    background: #000;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    overflow: hidden;
    touch-action: none;
}

body.boot-logging .universe-boot,
body.boot-active .universe-boot {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
}

body.boot-active .universe-boot {
    background: transparent;
}

body.boot-fade .universe-boot {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease;
    pointer-events: none;
}

.boot-console {
    position: absolute;
    inset: 0;
    z-index: 4;
    display: flex;
    align-items: stretch;
    justify-content: stretch;
    padding: clamp(1.25rem, 4vh, 2.5rem) clamp(1rem, 4vw, 2.5rem);
    opacity: 0;
    pointer-events: none;
}

body.boot-logging .boot-console {
    opacity: 1;
    pointer-events: auto;
}

body.boot-active .boot-console,
body.boot-fade .boot-console {
    opacity: 0;
    transition: opacity 0.25s ease;
    pointer-events: none;
}

.boot-console-inner {
    position: relative;
    width: 100%;
    max-width: 52rem;
    margin: 0 auto;
    max-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    scrollbar-width: thin;
    scrollbar-color: #5aeffa55 transparent;
    padding-right: 0.35rem;
}

.boot-console-inner::-webkit-scrollbar {
    width: 8px;
}

.boot-console-inner::-webkit-scrollbar-track {
    background: transparent;
}

.boot-console-inner::-webkit-scrollbar-thumb {
    background: rgba(90, 239, 250, 0.35);
    border-radius: 99px;
}

.boot-console-inner::-webkit-scrollbar-thumb:hover {
    background: rgba(90, 239, 250, 0.55);
}

.boot-log {
    margin: 0;
    padding-bottom: 1.5rem;
    font-family: var(--font-mono), 'JetBrains Mono', monospace;
    font-size: clamp(0.65rem, 1.5vw, 0.8rem);
    line-height: 1.55;
    letter-spacing: 0.02em;
    color: #3dffb0;
    text-shadow: 0 0 8px rgba(61, 255, 176, 0.35);
    white-space: pre-wrap;
    word-break: break-word;
}

.boot-log .boot-ok { color: #7dffa8; }
.boot-log .boot-dim { color: #3aa87a; }
.boot-log .boot-warn { color: #ffe08a; }
.boot-log .boot-accent { color: #5aeffa; }
.boot-log .boot-title {
    color: #e8ffff;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-shadow: 0 0 12px rgba(94, 239, 250, 0.75), 0 0 2px rgba(255, 255, 255, 0.5);
}
.boot-log .boot-prompt {
    color: #e8ffff;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-shadow: 0 0 14px rgba(94, 239, 250, 0.9), 0 0 4px rgba(255, 255, 255, 0.55);
    animation: boot-prompt-pulse 1.15s ease-in-out infinite;
}

@keyframes boot-prompt-pulse {
    0%, 100% { opacity: 1; filter: brightness(1); }
    50% { opacity: 0.72; filter: brightness(1.15); }
}

.boot-cursor {
    display: inline-block;
    margin-left: 2px;
    color: #3dffb0;
    animation: boot-cursor-blink 0.7s step-end infinite;
    font-size: clamp(0.65rem, 1.5vw, 0.8rem);
    vertical-align: baseline;
}

@keyframes boot-cursor-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

.boot-screen {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    opacity: 0;
}

body.boot-active .boot-screen {
    opacity: 1;
}

.boot-beam {
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 2px;
    margin-top: -1px;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(94, 239, 250, 0.45) 10%,
        rgba(240, 255, 255, 1) 50%,
        rgba(94, 239, 250, 0.45) 90%,
        transparent 100%
    );
    box-shadow:
        0 0 16px rgba(94, 239, 250, 0.95),
        0 0 50px rgba(46, 200, 214, 0.55);
    opacity: 0;
    z-index: 2;
}

body.boot-active .boot-beam {
    animation: boot-crt-beam 1.35s cubic-bezier(0.22, 0.61, 0.2, 1) forwards;
}

@keyframes boot-crt-beam {
    0% {
        opacity: 0;
        transform: scaleX(0);
        height: 2px;
        margin-top: -1px;
    }
    10% {
        opacity: 1;
        transform: scaleX(1);
        height: 2px;
        margin-top: -1px;
    }
    100% {
        opacity: 0;
        transform: scaleX(1);
        height: 100vh;
        margin-top: -50vh;
    }
}

.boot-flash {
    position: absolute;
    inset: 0;
    z-index: 1;
    background: #c8ffff;
    opacity: 0;
    mix-blend-mode: screen;
}

body.boot-active .boot-flash {
    animation: boot-flash 1.35s ease forwards;
}

@keyframes boot-flash {
    0%, 8% { opacity: 0; }
    16% { opacity: 0.55; }
    35% { opacity: 0.12; }
    100% { opacity: 0; }
}

.boot-scanlines {
    position: absolute;
    inset: 0;
    z-index: 3;
    opacity: 0;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.2) 0px,
        rgba(0, 0, 0, 0.2) 1px,
        transparent 1px,
        transparent 3px
    );
    pointer-events: none;
}

body.boot-active .boot-scanlines {
    animation: boot-scan-fade 1.35s ease forwards;
}

@keyframes boot-scan-fade {
    0%, 15% { opacity: 0; }
    35% { opacity: 0.35; }
    100% { opacity: 0; }
}

body.boot-active #portfolio-app {
    pointer-events: none;
    transform-origin: center center;
    animation: boot-monitor-on 1.35s cubic-bezier(0.22, 0.61, 0.2, 1) forwards;
}

body.boot-fade #portfolio-app {
    pointer-events: none;
    transform: none;
    filter: none;
    animation: none;
}

@keyframes boot-monitor-on {
    0% {
        transform: scaleY(0.004) scaleX(1);
        filter: brightness(8) contrast(1.4);
        opacity: 1;
    }
    12% {
        transform: scaleY(0.004) scaleX(1);
        filter: brightness(12) contrast(1.5);
        opacity: 1;
    }
    100% {
        transform: scaleY(1) scaleX(1);
        filter: brightness(1) contrast(1);
        opacity: 1;
    }
}

/* Perf / a11y */
html.low-perf .gate-eyebrow-dot {
    animation: none;
}

html.low-perf .gate-grain {
    display: none;
}

html.low-perf body.portal-active::before {
    animation: none;
    opacity: 1;
}

html.low-perf body.boot-active .boot-beam,
html.low-perf body.boot-active .boot-flash,
html.low-perf body.boot-active .boot-scanlines,
html.low-perf body.boot-active #portfolio-app {
    animation: none;
}

html.low-perf body.boot-active .universe-boot {
    background: #000;
    transition: opacity 0.45s ease;
}

html.low-perf body.boot-fade .universe-boot {
    opacity: 0;
}

@media (prefers-reduced-motion: reduce) {
    .gate-eyebrow-dot,
    .gate-panel {
        animation: none;
    }

    .gate-panel {
        opacity: 1;
        transform: none;
    }

    body.portal-active::before {
        animation: none;
        opacity: 1;
    }

    body.boot-active .boot-beam,
    body.boot-active .boot-flash,
    body.boot-active .boot-scanlines,
    body.boot-active #portfolio-app {
        animation: none;
    }

    body.boot-active .universe-boot {
        background: #000;
        transition: opacity 0.4s ease;
    }
}
