/* ============================================================
   EFFECTS.CSS — Boredom Eraser
   Static/Glitch/CRT, fade & reveal text, transitions, easter eggs
   ============================================================ */

/* ------------------------------------------------------------
   1. TV STATIC / NOISE OVERLAYS
------------------------------------------------------------ */
.tv-static {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 1500;
    mix-blend-mode: overlay;
    opacity: 0;
    background-color: #888;
    background-image: repeating-linear-gradient(
        0deg,
        rgba(255,255,255,0.05) 0px,
        rgba(0,0,0,0.05) 1px,
        transparent 2px,
        transparent 4px
    );
    animation: staticFlicker 0.15s steps(2) infinite;
}
.tv-static.active { opacity: 0.85; }

@keyframes staticFlicker {
    0%   { background-position: 0 0; filter: brightness(1) contrast(1.2); }
    25%  { background-position: -10px 5px; filter: brightness(1.3) contrast(1.5); }
    50%  { background-position: 5px -10px; filter: brightness(0.8) contrast(1.1); }
    75%  { background-position: -5px -5px; filter: brightness(1.1) contrast(1.4); }
    100% { background-position: 10px 10px; filter: brightness(1) contrast(1.2); }
}

.tv-static.grayscale {
    background-color: #777;
    filter: grayscale(1);
}

.tv-static.bw {
    background-color: #000;
    background-image: repeating-linear-gradient(
        90deg,
        #fff 0px, #fff 1px,
        #000 1px, #000 3px
    );
    mix-blend-mode: difference;
}

.tv-static.soft { opacity: 0.25 !important; }

.tv-static.heavy {
    opacity: 0.95 !important;
    animation-duration: 0.08s;
}

/* ------------------------------------------------------------
   2. CRT SCREEN EFFECTS
------------------------------------------------------------ */
.crt-screen {
    position: relative;
    overflow: hidden;
}
.crt-screen::before {
    content: "";
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: repeating-linear-gradient(
        to bottom,
        rgba(0,0,0,0.18) 0px,
        rgba(0,0,0,0.18) 1px,
        transparent 1px,
        transparent 3px
    );
    pointer-events: none;
    z-index: 50;
}
.crt-screen::after {
    content: "";
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: radial-gradient(
        ellipse at center,
        rgba(255,255,255,0.05) 0%,
        rgba(0,0,0,0.35) 100%
    );
    pointer-events: none;
    z-index: 51;
}

.crt-flicker {
    animation: crtFlicker 4s infinite;
}
@keyframes crtFlicker {
    0%, 100% { opacity: 1; }
    2% { opacity: 0.92; }
    4% { opacity: 1; }
    50% { opacity: 0.97; }
    52% { opacity: 1; }
}

.crt-power-on {
    animation: crtPowerOn 0.6s ease-out;
}
@keyframes crtPowerOn {
    0% {
        transform: scale(1, 0.02);
        filter: brightness(8);
        opacity: 0;
    }
    30% {
        transform: scale(1, 0.04);
        opacity: 1;
    }
    100% {
        transform: scale(1, 1);
        filter: brightness(1);
        opacity: 1;
    }
}

.crt-curve {
    border-radius: 18px;
    box-shadow:
        inset 0 0 60px rgba(0,0,0,0.6),
        inset 0 0 12px rgba(0,0,0,0.4);
}

/* ------------------------------------------------------------
   3. VHS DISTORTION
------------------------------------------------------------ */
.vhs-distort {
    position: relative;
    overflow: hidden;
}
.vhs-distort::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        rgba(255,0,0,0.04),
        rgba(0,255,0,0.03) 2px,
        rgba(0,0,255,0.04) 4px
    );
    mix-blend-mode: screen;
    pointer-events: none;
    animation: vhsJitter 2.5s infinite linear;
    z-index: 40;
}
@keyframes vhsJitter {
    0%   { transform: translateX(0) translateY(0); }
    10%  { transform: translateX(-1px) translateY(0); }
    20%  { transform: translateX(1px) translateY(1px); }
    30%  { transform: translateX(0) translateY(-1px); }
    40%  { transform: translateX(-2px) translateY(0); }
    50%  { transform: translateX(1px) translateY(0); }
    60%  { transform: translateX(0) translateY(1px); }
    70%  { transform: translateX(-1px) translateY(-1px); }
    80%  { transform: translateX(2px) translateY(0); }
    90%  { transform: translateX(0) translateY(0); }
    100% { transform: translateX(0) translateY(0); }
}

.vhs-tracking {
    position: relative;
}
.vhs-tracking::after {
    content: "";
    position: absolute;
    left: 0; right: 0;
    height: 6px;
    background: rgba(255,255,255,0.15);
    mix-blend-mode: overlay;
    animation: trackingLine 6s linear infinite;
    pointer-events: none;
    z-index: 41;
}
@keyframes trackingLine {
    0%   { top: -10%; opacity: 0; }
    5%   { opacity: 0.6; }
    15%  { opacity: 0; }
    100% { top: 110%; opacity: 0; }
}

.vhs-bleed {
    text-shadow:
        1px 0 rgba(255,0,0,0.5),
        -1px 0 rgba(0,255,255,0.5);
}

/* ------------------------------------------------------------
   4. GLITCH TEXT
------------------------------------------------------------ */
.glitch-text {
    position: relative;
    display: inline-block;
}
.glitch-text::before,
.glitch-text::after {
    content: attr(data-text);
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    opacity: 0.8;
}
.glitch-text::before {
    color: #ff0000;
    animation: glitchShift1 1.2s infinite linear alternate-reverse;
    z-index: -1;
}
.glitch-text::after {
    color: #00ffff;
    animation: glitchShift2 1.4s infinite linear alternate-reverse;
    z-index: -2;
}
@keyframes glitchShift1 {
    0%   { transform: translate(0,0); }
    20%  { transform: translate(-2px, 1px); }
    40%  { transform: translate(2px, -1px); }
    60%  { transform: translate(-1px, 2px); }
    80%  { transform: translate(1px, -2px); }
    100% { transform: translate(0,0); }
}
@keyframes glitchShift2 {
    0%   { transform: translate(0,0); }
    20%  { transform: translate(2px, -1px); }
    40%  { transform: translate(-2px, 1px); }
    60%  { transform: translate(1px, -2px); }
    80%  { transform: translate(-1px, 2px); }
    100% { transform: translate(0,0); }
}

.glitch-hover:hover {
    animation: hoverGlitch 0.3s steps(2) infinite;
}
@keyframes hoverGlitch {
    0%   { transform: translate(0,0) skew(0deg); }
    50%  { transform: translate(2px,-1px) skew(2deg); }
    100% { transform: translate(-2px,1px) skew(-2deg); }
}

/* ------------------------------------------------------------
   5. FADE-OUT / DISAPPEARING TEXT
------------------------------------------------------------ */
.fade-out-text {
    animation: textVanish 6s ease forwards;
}
@keyframes textVanish {
    0%   { opacity: 1; filter: blur(0px); }
    70%  { opacity: 0.4; filter: blur(1px); }
    100% { opacity: 0; filter: blur(4px); visibility: hidden; }
}

.fade-out-text.fast { animation-duration: 2.5s; }
.fade-out-text.slow { animation-duration: 12s; }

.fade-pulse {
    animation: fadePulse 5s ease-in-out infinite;
}
@keyframes fadePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

.dissolve-text {
    animation: dissolve 4s ease forwards;
}
@keyframes dissolve {
    0%   { opacity: 1; letter-spacing: normal; filter: blur(0); }
    60%  { opacity: 0.5; letter-spacing: 4px; filter: blur(2px); }
    100% { opacity: 0; letter-spacing: 12px; filter: blur(6px); }
}

/* ------------------------------------------------------------
   6. "WAIT UNTIL IT APPEARS" REVEAL TEXT
------------------------------------------------------------ */
.wait-for-it .hidden-msg {
    opacity: 0;
    animation: slowReveal 8s ease-in forwards;
    font-style: italic;
    letter-spacing: 1px;
}
@keyframes slowReveal {
    0%   { opacity: 0; transform: translateY(10px); }
    80%  { opacity: 0; }
    100% { opacity: 1; transform: translateY(0); }
}

.wait-for-it .placeholder-msg {
    opacity: 0.6;
    animation: placeholderFade 8s ease forwards;
}
@keyframes placeholderFade {
    0%   { opacity: 0.6; }
    80%  { opacity: 0.6; }
    100% { opacity: 0; }
}

.wait-for-it .hidden-msg.with-cursor::after {
    content: "_";
    animation: blink 1s infinite;
}
@keyframes blink {
    0%, 49% { opacity: 1; }
    50%, 100% { opacity: 0; }
}

.wait-for-it.long .hidden-msg { animation-duration: 15s; }
.wait-for-it.long .placeholder-msg { animation-duration: 15s; }

.wait-for-it.short .hidden-msg { animation-duration: 3s; }
.wait-for-it.short .placeholder-msg { animation-duration: 3s; }

/* ------------------------------------------------------------
   7. SCREEN TRANSITIONS (between random picks)
------------------------------------------------------------ */
.screen-transition-fade {
    animation: screenFadeIn 0.6s ease;
}
@keyframes screenFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.screen-transition-slide {
    animation: screenSlideIn 0.5s ease;
}
@keyframes screenSlideIn {
    from { transform: translateX(40px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.screen-transition-zoom {
    animation: screenZoomIn 0.4s ease;
}
@keyframes screenZoomIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.screen-transition-flip {
    animation: screenFlipIn 0.6s ease;
    transform-style: preserve-3d;
}
@keyframes screenFlipIn {
    from { transform: rotateY(90deg); opacity: 0; }
    to { transform: rotateY(0deg); opacity: 1; }
}

.screen-transition-curtain {
    animation: curtainOpen 0.7s ease;
}
@keyframes curtainOpen {
    0%   { clip-path: inset(0 50% 0 50%); }
    100% { clip-path: inset(0 0 0 0); }
}

/* ------------------------------------------------------------
   8. LOADING SPINNERS / TRANSITION INDICATORS
------------------------------------------------------------ */
.loader-spinner {
    width: 40px; height: 40px;
    border: 4px solid var(--text-color, #00FF00);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 20px auto;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

.loader-dots span {
    display: inline-block;
    width: 8px; height: 8px;
    margin: 0 3px;
    border-radius: 50%;
    background: var(--text-color, #00FF00);
    animation: dotPulse 1.2s infinite ease-in-out;
}
.loader-dots span:nth-child(2) { animation-delay: 0.2s; }
.loader-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dotPulse {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

.loader-bar {
    width: 100%;
    height: 6px;
    background: rgba(255,255,255,0.1);
    border-radius: 3px;
    overflow: hidden;
}
.loader-bar::after {
    content: "";
    display: block;
    width: 40%;
    height: 100%;
    background: var(--accent, #ff0000);
    animation: barSlide 1.2s ease-in-out infinite;
}
@keyframes barSlide {
    0% { transform: translateX(-100%); }
    50% { transform: translateX(150%); }
    100% { transform: translateX(-100%); }
}

/* ------------------------------------------------------------
   9. RARE VISUAL EASTER EGGS (non-link, pure visual)
   Triggered by JS adding these classes briefly
------------------------------------------------------------ */
.confetti-burst {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 2000;
    overflow: hidden;
}
.confetti-piece {
    position: absolute;
    width: 8px; height: 14px;
    opacity: 0.9;
    animation: confettiFall 3s linear forwards;
}
@keyframes confettiFall {
    0%   { transform: translateY(-10vh) rotate(0deg); opacity: 1; }
    100% { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}
.confetti-piece.c1 { background: #ff0000; }
.confetti-piece.c2 { background: #00ff00; }
.confetti-piece.c3 { background: #00ffff; }
.confetti-piece.c4 { background: #ffff00; }
.confetti-piece.c5 { background: #ff00ff; }

.invert-flash {
    animation: invertFlash 0.6s ease;
}
@keyframes invertFlash {
    0%   { filter: invert(0); }
    50%  { filter: invert(1); }
    100% { filter: invert(0); }
}

.screen-shake {
    animation: shake 0.5s ease;
}
@keyframes shake {
    0%, 100% { transform: translate(0,0); }
    10% { transform: translate(-4px, 2px); }
    20% { transform: translate(4px, -2px); }
    30% { transform: translate(-3px, 3px); }
    40% { transform: translate(3px, -3px); }
    50% { transform: translate(-2px, 2px); }
    60% { transform: translate(2px, -2px); }
    70% { transform: translate(-1px, 1px); }
    80% { transform: translate(1px, -1px); }
    90% { transform: translate(-1px, 0); }
}

.rainbow-sweep {
    background: linear-gradient(90deg, red, orange, yellow, green, cyan, blue, violet, red);
    background-size: 200% auto;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: rainbowSweep 3s linear infinite;
}
@keyframes rainbowSweep {
    to { background-position: 200% center; }
}

.flip-upside-down {
    animation: flipPage 1s ease forwards;
}
@keyframes flipPage {
    from { transform: rotate(0deg); }
    to { transform: rotate(180deg); }
}

.matrix-rain {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 1400;
    overflow: hidden;
    opacity: 0.5;
}
.matrix-column {
    position: absolute;
    top: -100%;
    font-family: monospace;
    color: #00ff00;
    font-size: 14px;
    line-height: 16px;
    animation: matrixFall linear infinite;
    white-space: pre;
}
@keyframes matrixFall {
    from { transform: translateY(-100%); }
    to { transform: translateY(200%); }
}

.alive-border {
    animation: aliveBorder 1.5s ease-in-out infinite;
}
@keyframes aliveBorder {
    0%, 100% { box-shadow: 0 0 0px var(--accent, #ff0000); }
    50% { box-shadow: 0 0 25px var(--accent, #ff0000); }
}

/* ------------------------------------------------------------
   10. HOVER REVEAL / HIDDEN CONTENT
------------------------------------------------------------ */
.hover-reveal {
    position: relative;
}
.hover-reveal .reveal-content {
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    transition: opacity 0.4s ease, max-height 0.4s ease;
}
.hover-reveal:hover .reveal-content {
    opacity: 1;
    max-height: 500px;
}

.blur-reveal {
    filter: blur(6px);
    transition: filter 0.4s ease;
}
.blur-reveal:hover {
    filter: blur(0);
}

/* ------------------------------------------------------------
   11. PAGE-LOAD ENTRANCE EFFECTS
------------------------------------------------------------ */
.entrance-fade {
    animation: entranceFade 1s ease both;
}
@keyframes entranceFade {
    from { opacity: 0; }
    to { opacity: 1; }
}

.entrance-rise {
    animation: entranceRise 0.8s ease both;
}
@keyframes entranceRise {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

.entrance-typewriter-cursor {
    border-right: 2px solid currentColor;
    animation: cursorBlink 0.8s steps(1) infinite;
}
@keyframes cursorBlink {
    50% { border-color: transparent; }
}

/* ------------------------------------------------------------
   12. UTILITY ANIMATION HELPERS
------------------------------------------------------------ */
.delay-1 { animation-delay: 0.2s; }
.delay-2 { animation-delay: 0.4s; }
.delay-3 { animation-delay: 0.6s; }
.delay-4 { animation-delay: 0.8s; }
.delay-5 { animation-delay: 1s; }

.duration-fast { animation-duration: 0.3s !important; }
.duration-normal { animation-duration: 1s !important; }
.duration-slow { animation-duration: 3s !important; }

.paused { animation-play-state: paused !important; }
.running { animation-play-state: running !important; }
