/* ═══════════════════════════════════════════
   OPSALIA — L'ESPRIT TOURMENTÉ
   "every pixel is a prison bar"
   ═══════════════════════════════════════════ */

/* --- RESET & BASE --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --void: #0a0a0a;
    --bruise: #1a0a2e;
    --sick-violet: #6b21a8;
    --blood: #8b0000;
    --arterial: #dc143c;
    --bone-white: #f0f0f0;
    --nerve: #c084fc;
    --rot: #2d1b4e;
    --static: #1a1a2e;
    --scream: #ff0040;
    --pulse-speed: 4s;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--void);
    color: var(--bone-white);
    font-family: 'Courier New', monospace;
    cursor: none;
    user-select: none;
    -webkit-user-select: none;
}

/* Custom cursor */
body::after {
    content: '';
    position: fixed;
    width: 20px;
    height: 20px;
    border: 1px solid var(--nerve);
    border-radius: 50%;
    pointer-events: none;
    z-index: 10000;
    transform: translate(-50%, -50%);
    mix-blend-mode: difference;
    animation: cursor-glitch 3s infinite;
}

@keyframes cursor-glitch {
    0%, 95% { opacity: 1; border-color: var(--nerve); }
    96% { opacity: 0; transform: translate(-50%, -50%) skewX(20deg); border-color: var(--scream); }
    97% { opacity: 1; transform: translate(-45%, -55%); border-color: var(--arterial); }
    98% { opacity: 0.5; transform: translate(-55%, -45%) skewX(-10deg); }
    100% { opacity: 1; transform: translate(-50%, -50%); border-color: var(--nerve); }
}

.hidden { display: none !important; }

/* ═══════════════════════════════════════════
   ENTRANCE SCREEN
   ═══════════════════════════════════════════ */

.entrance {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--void);
    z-index: 1000;
    overflow: hidden;
}

.entrance-static {
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(26, 10, 46, 0.03) 2px,
        rgba(26, 10, 46, 0.03) 4px
    );
    animation: static-scroll 0.1s infinite linear;
    pointer-events: none;
}

@keyframes static-scroll {
    from { transform: translateY(0); }
    to { transform: translateY(4px); }
}

.entrance-content {
    text-align: center;
    z-index: 1;
}

/* Glitch text effect */
.glitch-text {
    font-size: clamp(2rem, 6vw, 5rem);
    font-weight: 700;
    letter-spacing: 0.1em;
    position: relative;
    display: inline-block;
    color: var(--bone-white);
    text-shadow: 0 0 10px rgba(192, 132, 252, 0.5);
}

.glitch-text::before,
.glitch-text::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.glitch-text::before {
    color: var(--arterial);
    animation: glitch-1 2.5s infinite linear;
    clip-path: inset(0 0 65% 0);
}

.glitch-text::after {
    color: var(--sick-violet);
    animation: glitch-2 2.5s infinite linear;
    clip-path: inset(35% 0 0 0);
}

@keyframes glitch-1 {
    0%, 80% { transform: translate(0); }
    82% { transform: translate(-3px, 2px); }
    84% { transform: translate(3px, -1px); }
    86% { transform: translate(-1px, 1px); }
    88%, 100% { transform: translate(0); }
}

@keyframes glitch-2 {
    0%, 85% { transform: translate(0); }
    87% { transform: translate(2px, -2px); }
    89% { transform: translate(-3px, 1px); }
    91% { transform: translate(1px, -1px); }
    93%, 100% { transform: translate(0); }
}

.entrance-sub {
    margin-top: 2rem;
    font-size: 0.9rem;
    color: var(--nerve);
    min-height: 1.5em;
    opacity: 0.7;
}

.typing-text::after {
    content: '█';
    animation: blink-cursor 0.7s infinite;
}

@keyframes blink-cursor {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

.enter-btn {
    margin-top: 3rem;
    padding: 1rem 3rem;
    background: transparent;
    border: 1px solid var(--nerve);
    color: var(--nerve);
    font-family: 'Courier New', monospace;
    font-size: 1rem;
    letter-spacing: 0.15em;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.enter-btn .btn-glitch {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--arterial);
    color: var(--void);
    opacity: 0;
    transition: opacity 0.1s;
}

.enter-btn:hover {
    border-color: var(--arterial);
    box-shadow: 0 0 30px rgba(220, 20, 60, 0.3), inset 0 0 30px rgba(220, 20, 60, 0.1);
}

.enter-btn:hover .btn-glitch {
    animation: btn-flicker 0.3s infinite;
}

@keyframes btn-flicker {
    0%, 70% { opacity: 0; }
    72% { opacity: 1; }
    74% { opacity: 0; }
    80% { opacity: 1; }
    82%, 100% { opacity: 0; }
}

.entrance-warning {
    margin-top: 2rem;
    font-size: 0.7rem;
    color: rgba(240, 240, 240, 0.3);
    letter-spacing: 0.05em;
}

/* ═══════════════════════════════════════════
   MAIN EXPERIENCE
   ═══════════════════════════════════════════ */

.experience {
    position: fixed;
    inset: 0;
    background: var(--void);
}

#main-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}

/* ═══════════════════════════════════════════
   HUD OVERLAY
   ═══════════════════════════════════════════ */

.hud {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 100;
    padding: 1.5rem;
    font-size: 0.75rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.hud-corner {
    position: absolute;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.hud-tl { top: 1.5rem; left: 1.5rem; }
.hud-tr { top: 1.5rem; right: 1.5rem; text-align: right; }
.hud-bl { bottom: 1.5rem; left: 1.5rem; }
.hud-br { bottom: 1.5rem; right: 1.5rem; text-align: right; }

.hud-label {
    color: rgba(192, 132, 252, 0.4);
    font-size: 0.6rem;
}

.hud-value {
    color: var(--nerve);
    text-shadow: 0 0 8px rgba(192, 132, 252, 0.3);
}

.hud-value.corrupted {
    color: var(--arterial);
    animation: corrupt-text 4s infinite;
    text-shadow: 0 0 8px rgba(220, 20, 60, 0.5);
}

@keyframes corrupt-text {
    0%, 90% { opacity: 1; }
    92% { opacity: 0.3; letter-spacing: 0.3em; }
    94% { opacity: 0.8; letter-spacing: 0.05em; }
    96% { opacity: 0.2; }
    98%, 100% { opacity: 1; }
}

.reverse-clock {
    font-variant-numeric: tabular-nums;
    font-size: 0.85rem !important;
}

/* ═══════════════════════════════════════════
   OVERLAYS
   ═══════════════════════════════════════════ */

/* Scanlines */
.scanlines {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 90;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0px,
        transparent 1px,
        rgba(0, 0, 0, 0.08) 1px,
        rgba(0, 0, 0, 0.08) 2px
    );
}

/* Vignette */
.vignette {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 80;
    background: radial-gradient(
        ellipse at center,
        transparent 40%,
        rgba(10, 10, 10, 0.4) 70%,
        rgba(10, 10, 10, 0.85) 100%
    );
}

/* Noise overlay */
.noise-overlay {
    position: fixed;
    inset: -50%;
    width: 200%;
    height: 200%;
    pointer-events: none;
    z-index: 85;
    opacity: 0.04;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    animation: noise-drift 0.5s infinite steps(10);
}

@keyframes noise-drift {
    from { transform: translate(0, 0); }
    to { transform: translate(-10%, -10%); }
}

/* Subliminal flash */
.subliminal {
    position: fixed;
    inset: 0;
    z-index: 200;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(3rem, 10vw, 8rem);
    font-weight: 900;
    letter-spacing: 0.2em;
    opacity: 0;
    color: var(--scream);
    text-shadow: 0 0 40px rgba(255, 0, 64, 0.8);
    background: rgba(10, 0, 0, 0.7);
}

.subliminal.flash {
    animation: subliminal-flash 0.15s ease-out forwards;
}

@keyframes subliminal-flash {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

/* Thought fragments */
.thoughts {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 95;
    overflow: hidden;
}

.thought {
    position: absolute;
    font-size: 0.8rem;
    color: rgba(192, 132, 252, 0.15);
    white-space: nowrap;
    animation: thought-drift 12s linear forwards;
    text-shadow: 0 0 5px rgba(192, 132, 252, 0.1);
}

@keyframes thought-drift {
    0% { transform: translateY(0) translateX(0); opacity: 0; }
    10% { opacity: 0.3; }
    50% { opacity: 0.15; }
    100% { transform: translateY(-100vh) translateX(50px); opacity: 0; }
}

/* ═══════════════════════════════════════════
   BREATHING PULSE — the room is alive
   ═══════════════════════════════════════════ */

.experience::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 70;
    pointer-events: none;
    background: radial-gradient(
        ellipse at 50% 50%,
        transparent 30%,
        rgba(107, 33, 168, 0.05) 60%,
        rgba(139, 0, 0, 0.08) 100%
    );
    animation: room-breathe var(--pulse-speed) ease-in-out infinite;
}

@keyframes room-breathe {
    0%, 100% { opacity: 0.3; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.02); }
}

/* ═══════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════ */

@media (max-width: 768px) {
    .hud { padding: 1rem; font-size: 0.6rem; }
    .glitch-text { font-size: 2rem; }
    .enter-btn { padding: 0.8rem 2rem; font-size: 0.85rem; }
}

@media (max-width: 480px) {
    .hud-corner { gap: 0.15rem; }
    .hud-tl, .hud-tr, .hud-bl, .hud-br {
        font-size: 0.5rem;
    }
}
