/* BODY & GLOBAL STYLES */
html {
    height: 100%;
    overflow-y: auto;
}
body {
    margin: 0;
    padding: 0;
    /* Use new VFD-like font first, fallback to Orbitron, then monospace */
    font-family: "Share Tech Mono", "Orbitron", monospace;
    background: #000; /* deeper black */
    overflow-y: auto;
    height: 100%;
    color: #00ff55; /* default text color if needed */
}

/* MATRIX BACKGROUND CONTAINER */
.matrix {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #220033; /* cyberpunk dark purple background */
    z-index: -1; /* keep it behind content */
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* TEXT CONTAINER OVER THE MATRIX */
.text-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #00ffff; /* cyan base color */
    text-shadow:
        0 0 15px #00ffff,
        0 0 25px #00ffff;
    text-align: center;
    background: rgba(10, 0, 20, 0.75); /* dark purple background */
    padding: 2rem;
    border-radius: 10px;
    box-shadow:
        0 0 30px rgba(0, 255, 255, 0.2),
        0 0 50px rgba(255, 0, 255, 0.1);
    border: 1px solid rgba(0, 255, 255, 0.3);
    width: 80%;
    max-width: 800px;
    min-height: 200px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: min-height 0.5s ease;
    z-index: 10;
    overflow-y: auto;
    /* Add some top padding for the profile pic overlap if needed */
    padding-top: 3rem;
    animation: textGlitch 2s infinite;
}

/* TEXT LINES */
.text-line {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}
.main-text {
    font-size: clamp(24px, 5vw, 48px);
    margin-bottom: 20px;
    letter-spacing: 2px;
    font-weight: bold;
    text-align: center;
    width: 100%;
    position: relative;
}
.main-text::before,
.main-text::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.main-text::before {
    left: -2px;
    text-shadow: -1px 0 #ff00cc;
    animation: glitch-1 2s linear infinite alternate-reverse;
    clip-path: polygon(0 0, 100% 0, 100% 45%, 0 45%);
    opacity: 0.8;
}

.main-text::after {
    left: 2px;
    text-shadow: 2px 0 #00ffff;
    animation: glitch-2 3s linear infinite alternate-reverse;
    clip-path: polygon(0 55%, 100% 55%, 100% 100%, 0 100%);
    opacity: 0.8;
}

.sub-text {
    font-size: clamp(14px, 3vw, 20px);
    max-width: 100%;
    text-align: left;
    line-height: 1.5;
    color: #ff9eea; /* light pink for sub-text */
    position: relative;
    animation: randomFlicker 4s ease-in-out infinite;
}

/* CURSOR BLINK */
.cursor {
    display: inline-block;
    width: 10px;
    height: 1em;
    background: #ff00cc; /* magenta cursor */
    margin-left: 5px;
    vertical-align: middle;
    animation: blink 1s step-end infinite;
}
@keyframes blink {
    0%,
    100% {
        opacity: 1;
    }
    50% {
        opacity: 0;
    }
}

/* IMAGE CONTAINER INSIDE TEXT-CONTAINER */
.image-container {
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    transition:
        opacity 1.5s ease,
        max-height 1s ease;
    margin: 20px 0;
    width: 100%;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.image-container.show {
    opacity: 1;
    max-height: 40vh;
}
.image-container img {
    max-width: 100%;
    max-height: 30vh;
    width: auto;
    height: auto;
    object-fit: contain;
    margin: 0 auto;
    display: block;
    border-radius: 8px;
    border: 1px solid rgba(0, 255, 255, 0.4);
    filter: contrast(1.2) brightness(1.1) hue-rotate(180deg);
    animation: imageGlitch 3s infinite;
}

/* PROFILE PIC */
.profile-pic {
    width: clamp(60px, 25%, 150px);
    border-radius: 50%;
    border: 3px solid #00ffff;
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.5);
    object-fit: cover;
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    background: #000;
    animation: profileGlitch 4s infinite;
    position: relative;
}

.profile-pic::before,
.profile-pic::after {
    content: "";
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
    border-radius: 50%;
    background: transparent;
    z-index: -1;
    animation: pfpPulse 3s infinite alternate;
}

.profile-pic::before {
    border: 3px solid #ff00cc;
    clip-path: polygon(0 0, 100% 0, 100% 33%, 0 33%);
    transform: translateX(-4px);
    animation: pfpGlitch1 2.5s infinite alternate;
}

.profile-pic::after {
    border: 3px solid #00ffff;
    clip-path: polygon(0 66%, 100% 66%, 100% 100%, 0 100%);
    transform: translateX(4px);
    animation: pfpGlitch2 3.7s infinite alternate;
}

/* CONTROLS (BOTTOM BUTTONS) */
.controls {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    z-index: 100;
    background: rgba(10, 0, 20, 0.8);
    padding: 10px;
    border-radius: 5px;
    border: 1px solid rgba(0, 255, 255, 0.3);
    width: auto;
    max-width: 90%;
    animation: controlsGlitch 6s infinite;
}
.control-btn {
    background: rgba(10, 0, 20, 0.5);
    color: #00ffff; /* cyan buttons */
    border: 1px solid #00ffff;
    padding: 8px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-family: "Share Tech Mono", "Orbitron", monospace;
    transition:
        background 0.3s,
        color 0.3s;
    font-size: clamp(12px, 3vw, 16px);
    position: relative;
    overflow: hidden;
    animation: buttonGlitch 4s infinite;
}
.control-btn:hover {
    background: rgba(0, 255, 255, 0.2);
    color: #ff00cc; /* magenta on hover */
    border-color: #ff00cc;
    box-shadow: 0 0 15px rgba(255, 0, 204, 0.5);
}

.control-btn::before {
    content: "";
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border: 1px solid #ff00cc;
    border-radius: 5px;
    opacity: 0;
    z-index: -1;
    animation: buttonBorderGlitch 3s infinite;
}

.control-btn:nth-child(odd)::after {
    content: attr(data-text);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    color: #ff00cc;
    z-index: -1;
    animation: buttonTextGlitch 4s infinite;
    opacity: 0;
}

/* PAGINATION TEXT */
.pagination {
    position: fixed;
    bottom: 70px;
    left: 50%;
    transform: translateX(-50%);
    color: #ff9eea; /* light pink pagination */
    font-size: clamp(12px, 3vw, 14px);
    z-index: 100;
    background: rgba(10, 0, 20, 0.8);
    padding: 5px 10px;
    border-radius: 5px;
}

/* MEDIA QUERIES FOR RESPONSIVENESS */
@media (max-height: 700px) {
    .text-container {
        top: 55%;
        max-height: 60vh;
    }
    .profile-pic {
        width: clamp(40px, 15%, 80px);
        top: 10px;
    }
    .pagination {
        bottom: 60px;
    }
    .controls {
        bottom: 10px;
    }
}
@media (max-width: 600px) {
    .text-container {
        padding: 1rem;
        width: 85%;
    }
    .main-text {
        margin-bottom: 15px;
    }
    .controls {
        padding: 5px;
    }
    .control-btn {
        padding: 6px 10px;
    }
}

/* GLITCH OVERLAY */
.glitch-overlay {
    pointer-events: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9998;
    background: url("glitch.png") repeat;
    mix-blend-mode: screen;
    opacity: 0.4; /* Increased opacity */
    animation: glitchOverlay 1.5s infinite;
}

/* RAINBOW TEXT EFFECT */
.rainbow-text span {
    display: inline-block;
    animation: rainbowShift 2s infinite alternate;
}

/* Enhanced glitch animations */
@keyframes glitchOverlay {
    0%,
    100% {
        transform: translate(0, 0);
        opacity: 0.4;
    }
    10% {
        transform: translate(-5px, 2px);
        opacity: 0.5;
    }
    20% {
        transform: translate(5px, -2px);
        opacity: 0.4;
    }
    30% {
        transform: translate(-3px, -3px);
        opacity: 0.6;
    }
    40% {
        transform: translate(3px, 3px);
        opacity: 0.4;
    }
    50% {
        transform: translate(0, 0);
        opacity: 0.5;
    }
    60% {
        transform: translate(-2px, 5px);
        opacity: 0.4;
    }
    70% {
        transform: translate(4px, -1px);
        opacity: 0.6;
    }
    80% {
        transform: translate(-4px, 2px);
        opacity: 0.5;
    }
    90% {
        transform: translate(2px, -5px);
        opacity: 0.4;
    }
}

@keyframes glitch-1 {
    0%,
    100% {
        clip-path: inset(50% 0 30% 0);
    }
    20% {
        clip-path: inset(20% 0 60% 0);
    }
    40% {
        clip-path: inset(40% 0 40% 0);
    }
    60% {
        clip-path: inset(80% 0 5% 0);
    }
    80% {
        clip-path: inset(10% 0 85% 0);
    }
}

@keyframes glitch-2 {
    0%,
    100% {
        clip-path: inset(40% 0 60% 0);
    }
    20% {
        clip-path: inset(60% 0 30% 0);
    }
    40% {
        clip-path: inset(20% 0 70% 0);
    }
    60% {
        clip-path: inset(70% 0 10% 0);
    }
    80% {
        clip-path: inset(10% 0 50% 0);
    }
}

@keyframes textGlitch {
    0%,
    100% {
        transform: translate(-50%, -50%);
        text-shadow:
            0 0 15px #00ffff,
            0 0 25px #00ffff;
    }
    5%,
    15% {
        transform: translate(-50.5%, -50%) skewX(0.5deg);
        text-shadow:
            -2px 0 #ff00cc,
            2px 2px #00ffff;
    }
    10%,
    20% {
        transform: translate(-49.5%, -50%) skewX(-0.5deg);
        text-shadow:
            2px 0 #ff00cc,
            -2px -2px #00ffff;
    }
    30%,
    70% {
        transform: translate(-50%, -50%);
        text-shadow:
            0 0 15px #00ffff,
            0 0 25px #00ffff;
    }
    40%,
    80% {
        transform: translate(-50.3%, -50.2%);
        text-shadow:
            1px -1px #ff00cc,
            -1px 1px #00ffff;
    }
    45%,
    85% {
        transform: translate(-49.7%, -49.8%);
        text-shadow:
            -1px 1px #ff00cc,
            1px -1px #00ffff;
    }
}

@keyframes randomFlicker {
    0%,
    100% {
        opacity: 1;
        color: #ff9eea;
    }
    8% {
        opacity: 0.8;
        color: #ff9eea;
    }
    10% {
        opacity: 0.95;
        color: #ff00cc;
    }
    15% {
        opacity: 0.9;
        color: #ff9eea;
    }
    20% {
        opacity: 1;
        color: #00ffff;
    }
    50% {
        opacity: 0.95;
        color: #ff9eea;
    }
    60% {
        opacity: 0.7;
        color: #cc99ff;
    }
    70% {
        opacity: 0.9;
        color: #ff9eea;
    }
}

@keyframes imageGlitch {
    0%,
    100% {
        transform: translate(0, 0) scale(1);
        filter: contrast(1.2) brightness(1.1) hue-rotate(180deg);
    }
    5% {
        transform: translate(-3px, 2px) scale(1.01);
        filter: contrast(1.3) brightness(1.2) hue-rotate(210deg);
    }
    10% {
        transform: translate(3px, -2px) scale(0.99);
        filter: contrast(1.1) brightness(1) hue-rotate(150deg);
    }
    15% {
        transform: translate(-2px, -2px) scale(1);
        filter: contrast(1.2) brightness(1.1) hue-rotate(180deg);
    }
    20%,
    80% {
        transform: translate(0, 0) scale(1);
        filter: contrast(1.2) brightness(1.1) hue-rotate(180deg);
    }
    85% {
        transform: translate(2px, 3px) scale(1.01);
        filter: contrast(1.3) brightness(0.9) hue-rotate(220deg);
    }
    90% {
        transform: translate(-2px, -1px) scale(0.99);
        filter: contrast(1.1) brightness(1.2) hue-rotate(160deg);
    }
    95% {
        transform: translate(1px, 2px) scale(1);
        filter: contrast(1.2) brightness(1.1) hue-rotate(180deg);
    }
}

@keyframes profileGlitch {
    0%,
    100% {
        transform: translateX(-50%) scale(1);
        border-color: #00ffff;
        box-shadow: 0 0 15px rgba(0, 255, 255, 0.5);
        filter: none;
    }
    10% {
        transform: translateX(-51%) scale(1.02);
        border-color: #ff00cc;
        box-shadow: 0 0 20px rgba(255, 0, 204, 0.6);
        filter: hue-rotate(30deg) contrast(1.3);
    }
    15% {
        transform: translateX(-52%) scale(1.03);
        border-color: #ffaa00;
        box-shadow: 0 0 25px rgba(255, 170, 0, 0.7);
        filter: hue-rotate(60deg) contrast(1.5) brightness(1.2);
    }
    20% {
        transform: translateX(-49%) scale(0.98);
        border-color: #00ffff;
        box-shadow: 0 0 20px rgba(0, 255, 255, 0.6);
        filter: hue-rotate(-30deg) contrast(1.1);
    }
    25% {
        transform: translateX(-48%) scale(0.97);
        border-color: #0088ff;
        box-shadow: 0 0 22px rgba(0, 136, 255, 0.65);
        filter: hue-rotate(-60deg) contrast(1.2) brightness(0.9);
    }
    30%,
    70% {
        transform: translateX(-50%) scale(1);
        border-color: #00ffff;
        box-shadow: 0 0 15px rgba(0, 255, 255, 0.5);
        filter: none;
    }
    80% {
        transform: translateX(-50.5%) scale(1.01);
        border-color: #ff00cc;
        box-shadow: 0 0 18px rgba(255, 0, 204, 0.5);
        filter: hue-rotate(15deg);
    }
    90% {
        transform: translateX(-49.5%) scale(0.99);
        border-color: #00ffff;
        box-shadow: 0 0 18px rgba(0, 255, 255, 0.5);
        filter: hue-rotate(-15deg);
    }
}

@keyframes pfpGlitch1 {
    0%,
    100% {
        transform: translateX(-4px) rotate(0deg);
        opacity: 0.5;
        clip-path: polygon(0 0, 100% 0, 100% 33%, 0 33%);
    }
    20% {
        transform: translateX(-6px) rotate(-2deg);
        opacity: 0.7;
        clip-path: polygon(0 0, 100% 0, 100% 45%, 0 25%);
    }
    40% {
        transform: translateX(-3px) rotate(2deg);
        opacity: 0.4;
        clip-path: polygon(0 0, 100% 0, 100% 28%, 0 38%);
    }
    60% {
        transform: translateX(-7px) rotate(-1deg);
        opacity: 0.6;
        clip-path: polygon(0 0, 100% 0, 100% 37%, 0 27%);
    }
    80% {
        transform: translateX(-2px) rotate(1deg);
        opacity: 0.5;
        clip-path: polygon(0 0, 100% 0, 100% 30%, 0 40%);
    }
}

@keyframes pfpGlitch2 {
    0%,
    100% {
        transform: translateX(4px) rotate(0deg);
        opacity: 0.5;
        clip-path: polygon(0 66%, 100% 66%, 100% 100%, 0 100%);
    }
    25% {
        transform: translateX(6px) rotate(2deg);
        opacity: 0.7;
        clip-path: polygon(0 72%, 100% 62%, 100% 100%, 0 100%);
    }
    50% {
        transform: translateX(3px) rotate(-2deg);
        opacity: 0.4;
        clip-path: polygon(0 68%, 100% 78%, 100% 100%, 0 100%);
    }
    75% {
        transform: translateX(7px) rotate(1deg);
        opacity: 0.6;
        clip-path: polygon(0 60%, 100% 70%, 100% 100%, 0 100%);
    }
}

@keyframes pfpPulse {
    0%,
    100% {
        box-shadow: 0 0 15px rgba(0, 255, 255, 0.5);
    }
    25% {
        box-shadow: 0 0 25px rgba(255, 0, 204, 0.6);
    }
    50% {
        box-shadow: 0 0 30px rgba(0, 255, 255, 0.7);
    }
    75% {
        box-shadow: 0 0 20px rgba(255, 170, 0, 0.6);
    }
}

@keyframes controlsGlitch {
    0%,
    100% {
        transform: translateX(-50%);
        border-color: rgba(0, 255, 255, 0.3);
    }
    20% {
        transform: translateX(-51%);
        border-color: rgba(255, 0, 204, 0.3);
    }
    40% {
        transform: translateX(-49%);
        border-color: rgba(0, 255, 255, 0.3);
    }
    50% {
        transform: translateX(-50%);
        border-color: rgba(255, 170, 0, 0.3);
    }
    60% {
        transform: translateX(-50.5%);
        border-color: rgba(255, 170, 0, 0.3);
    }
    80% {
        transform: translateX(-49.5%);
        border-color: rgba(0, 136, 255, 0.3);
    }
}

@keyframes buttonGlitch {
    0%,
    100% {
        transform: translateZ(0);
        color: #00ffff;
    }
    10% {
        transform: translate3d(2px, 1px, 0);
        color: #cc99ff;
    }
    20% {
        transform: translate3d(-2px, -1px, 0);
        color: #ff00cc;
    }
    30%,
    70% {
        transform: translateZ(0);
        color: #00ffff;
    }
    80% {
        transform: translate3d(1px, -1px, 0);
        color: #ff9eea;
    }
    90% {
        transform: translate3d(-1px, 1px, 0);
        color: #cc99ff;
    }
}

@keyframes buttonBorderGlitch {
    0%,
    100% {
        opacity: 0;
        transform: scale(1);
    }
    10%,
    15% {
        opacity: 0.5;
        transform: scale(1.05);
    }
    20% {
        opacity: 0;
        transform: scale(1);
    }
    50%,
    55% {
        opacity: 0.3;
        transform: scale(1.03);
    }
    60% {
        opacity: 0;
        transform: scale(1);
    }
    80%,
    85% {
        opacity: 0.4;
        transform: scale(1.04);
    }
    90% {
        opacity: 0;
        transform: scale(1);
    }
}

@keyframes buttonTextGlitch {
    0%,
    100% {
        opacity: 0;
        transform: translate(-50%, -50%);
    }
    15%,
    16% {
        opacity: 0.6;
        transform: translate(-52%, -48%);
    }
    17% {
        opacity: 0;
        transform: translate(-50%, -50%);
    }
    45%,
    46% {
        opacity: 0.5;
        transform: translate(-48%, -52%);
    }
    47% {
        opacity: 0;
        transform: translate(-50%, -50%);
    }
    75%,
    76% {
        opacity: 0.7;
        transform: translate(-51%, -49%);
    }
    77% {
        opacity: 0;
        transform: translate(-50%, -50%);
    }
}

@keyframes rainbowShift {
    0% {
        color: #ff00ff; /* magenta */
        text-shadow:
            0 0 10px #ff00ff,
            0 0 20px #ff00ff;
    }
    14% {
        color: #ff00cc; /* hot pink */
        text-shadow:
            0 0 10px #ff00cc,
            0 0 20px #ff00cc;
    }
    28% {
        color: #cc99ff; /* lavender */
        text-shadow:
            0 0 10px #cc99ff,
            0 0 20px #cc99ff;
    }
    42% {
        color: #00ffff; /* cyan */
        text-shadow:
            0 0 10px #00ffff,
            0 0 20px #00ffff;
    }
    57% {
        color: #00ccff; /* sky blue */
        text-shadow:
            0 0 10px #00ccff,
            0 0 20px #00ccff;
    }
    71% {
        color: #ffaa00; /* amber */
        text-shadow:
            0 0 10px #ffaa00,
            0 0 20px #ffaa00;
    }
    85% {
        color: #ff3366; /* coral */
        text-shadow:
            0 0 10px #ff3366,
            0 0 20px #ff3366;
    }
    100% {
        color: #ff00ff; /* back to magenta */
        text-shadow:
            0 0 10px #ff00ff,
            0 0 20px #ff00ff;
    }
}
