/* --- Basic Setup & Variables --- */
:root {
    --primary-color: #0a0f1f; /* Dark blue */
    --secondary-color: #1a2340; /* Slightly lighter blue */
    --accent-color: #00ffcc; /* Bright teal/cyan for glitch and highlights */
    --text-color: #c0c0e0; /* Light greyish blue */
    --glitch-red: #ff003c;
    --glitch-blue: #007bff;
    --font-main: 'Roboto Mono', monospace;
    --font-glitchy: 'VT323', monospace; /* More pixelated for specific glitch effects */
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-main);
    background-color: var(--primary-color);
    color: var(--text-color);
    line-height: 1.6;
    overflow-x: hidden; /* Prevent horizontal scroll from glitch effects */
    position: relative; /* For scanlines */
}

.container {
    max-width: 960px;
    margin: auto;
    padding: 0 20px;
    overflow: hidden; /* For containing floats if any */
}

/* --- Scanlines Overlay --- */
.scanlines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    background: repeating-linear-gradient(
        transparent,
        transparent 2px,
        rgba(0, 0, 0, 0.2) 3px, /* Darker scanline for contrast */
        rgba(0, 0, 0, 0.2) 4px
    );
    opacity: 0.3; /* Make it subtle */
}


/* --- Glitch Effects --- */
.glitch {
    position: relative;
    font-family: var(--font-glitchy); /* Use the more pixelated font for main glitch */
    font-size: 4rem; /* Adjust as needed */
    color: var(--accent-color);
    animation: glitch-anim 2.5s infinite steps(1);
    text-shadow:
      -1px -1px 0 var(--glitch-red),
      1px 1px 0 var(--glitch-blue),
      0 0 5px var(--accent-color),
      0 0 10px var(--accent-color);
}

.glitch::before,
.glitch::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--primary-color); /* Match body background */
    overflow: hidden;
}

.glitch::before {
    left: 2px;
    text-shadow: -1px 0 var(--glitch-red);
    clip: rect(24px, 550px, 90px, 0);
    animation: glitch-anim-2 2s infinite linear alternate-reverse;
}

.glitch::after {
    left: -2px;
    text-shadow: -1px 0 var(--glitch-blue);
    clip: rect(85px, 550px, 140px, 0);
    animation: glitch-anim-3 2.5s infinite linear alternate-reverse;
}

@keyframes glitch-anim {
    0% { transform: translate(0); opacity: 1; }
    10%, 12%, 20%, 22%, 80%, 82%, 90%, 92% { opacity: 0.8; }
    11%, 21%, 81%, 91% { transform: translate(2px, -1px); opacity: 1; }
    95% { transform: translate(-3px, 2px); opacity: 0.7; }
    100% { transform: translate(0); opacity: 1; }
}

@keyframes glitch-anim-2 {
    0% { clip: rect(42px, 9999px, 44px, 0); }
    5% { clip: rect(12px, 9999px, 60px, 0); }
    10% { clip: rect(30px, 9999px, 70px, 0); }
    /* ... more steps for variation */
    100% { clip: rect(50px, 9999px, 30px, 0); }
}
@keyframes glitch-anim-3 {
    0% { clip: rect(5px, 9999px, 105px, 0); }
    /* ... more steps */
    100% { clip: rect(80px, 9999px, 60px, 0); }
}


.glitch-header {
    font-family: var(--font-glitchy);
    color: var(--accent-color);
    position: relative;
    display: inline-block; /* To make before/after work well */
}
.glitch-header::before, .glitch-header::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    overflow: hidden;
    background: transparent; /* Ensure it doesn't cover section bg */
}
.glitch-header::before {
    color: var(--glitch-red);
    left: 1px;
    text-shadow: -0.5px 0 var(--glitch-red);
    animation: header-glitch-before 3s infinite steps(2, jump-none) alternate;
}
.glitch-header::after {
    color: var(--glitch-blue);
    left: -1px;
    text-shadow: 0.5px 0 var(--glitch-blue);
    animation: header-glitch-after 2.5s infinite steps(2, jump-none) alternate-reverse;
}
@keyframes header-glitch-before {
    0% { clip-path: inset(80% 0 0 0); }
    20% { clip-path: inset(20% 0 50% 0); }
    40% { clip-path: inset(50% 0 10% 0); }
    60% { clip-path: inset(0 0 90% 0); }
    80% { clip-path: inset(30% 0 30% 0); }
    100% { clip-path: inset(70% 0 5% 0); }
}
@keyframes header-glitch-after {
    0% { clip-path: inset(0 0 75% 0); }
    20% { clip-path: inset(40% 0 30% 0); }
    40% { clip-path: inset(15% 0 60% 0); }
    60% { clip-path: inset(85% 0 0 0); }
    80% { clip-path: inset(25% 0 45% 0); }
    100% { clip-path: inset(65% 0 15% 0); }
}


.glitch-subtle {
    position: relative;
    display: inline-block;
}
.glitch-subtle:hover::before {
    content: attr(data-text);
    position: absolute;
    left: -1px;
    top: -1px;
    color: var(--glitch-red);
    overflow: hidden;
    clip-path: inset(50% 0 0 0);
    animation: subtle-flicker 0.3s infinite steps(1);
}
.glitch-subtle:hover::after {
    content: attr(data-text);
    position: absolute;
    left: 1px;
    top: 1px;
    color: var(--glitch-blue);
    overflow: hidden;
    clip-path: inset(0 0 50% 0);
    animation: subtle-flicker 0.3s 0.1s infinite steps(1);
}
@keyframes subtle-flicker {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}


/* --- Header / Hero Section --- */
#hero {
    background: var(--primary-color) url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><rect width="100" height="100" fill="rgba(26,35,64,0.1)"/><line x1="0" y1="0" x2="100" y2="100" stroke="rgba(0,255,204,0.03)" stroke-width="1"/><line x1="100" y1="0" x2="0" y2="100" stroke="rgba(0,255,204,0.03)" stroke-width="1"/></svg>'); /* Subtle grid */
    min-height: 80vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding-top: 60px; /* Account for nav */
    position: relative;
    border-bottom: 2px solid var(--accent-color);
}

#hero .tagline {
    font-size: 1.5rem;
    margin-bottom: 30px;
    color: var(--text-color);
}

.cta-button {
    display: inline-block;
    background: var(--accent-color);
    color: var(--primary-color);
    padding: 12px 25px;
    text-decoration: none;
    font-family: var(--font-glitchy);
    font-size: 1.2rem;
    border: 2px solid var(--accent-color);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}
.cta-button:hover {
    background: var(--primary-color);
    color: var(--accent-color);
    box-shadow: 0 0 15px var(--accent-color);
}
.cta-button::before { /* Glitch bar on hover */
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: rgba(255,255,255,0.1);
    transition: left 0.4s ease;
    transform: skewX(-25deg);
}
.cta-button:hover::before {
    left: 100%;
}


/* --- Navigation --- */
nav {
    background: var(--secondary-color);
    padding: 15px 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 1px solid rgba(0, 255, 204, 0.3);
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

nav .container {
    display: flex;
    justify-content: center;
    gap: 20px;
    /* height: 20vh; */
}

nav a {
    color: var(--text-color);
    text-decoration: none;
    font-family: var(--font-glitchy);
    font-size: 1.1rem;
    padding: 5px 10px;
    transition: color 0.3s ease, text-shadow 0.3s ease;
}
nav a:hover {
    color: var(--accent-color);
    text-shadow: 0 0 5px var(--accent-color);
}


/* --- Content Sections --- */
.content-section {
    padding: 60px 0;
}
.content-section.alt-bg {
    background-color: var(--secondary-color);
    border-top: 1px dashed rgba(0, 255, 204, 0.2);
    border-bottom: 1px dashed rgba(0, 255, 204, 0.2);
}
.content-section h2 {
    font-size: 2.5rem;
    margin-bottom: 20px;
    text-align: center;
}
.content-section p {
    font-size: 1.1rem;
    margin-bottom: 15px;
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
    text-align: justify;
}

/* --- Gameplay Highlight --- */
.feature-highlight {
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--accent-color);
    padding: 20px;
    margin-top: 30px;
    font-family: var(--font-glitchy);
    color: var(--accent-color);
    text-align: left;
}
.feature-highlight p {
    text-align: left;
    margin-bottom: 10px;
    font-size: 1.2rem;
}
.fake-input-wrapper {
    display: flex;
    align-items: center;
    background: rgba(0,0,0,0.5);
    padding: 10px;
    min-height: 30px;
}
.fake-input-cursor {
    display: inline-block;
    width: 10px;
    height: 1.5em;
    background-color: var(--accent-color);
    animation: blink 1s steps(1) infinite;
    margin-right: 5px;
}
.fake-input-text {
    font-size: 1.2rem;
    color: #9fceff; /* Lighter blue for typed text */
}

@keyframes blink {
    50% { opacity: 0; }
}


/* --- Media Gallery --- */
#media h3 {
    font-family: var(--font-glitchy);
    color: var(--accent-color);
    font-size: 1.8rem;
    margin-top: 40px;
    margin-bottom: 15px;
    text-align: center;
    border-bottom: 1px dashed var(--accent-color);
    padding-bottom: 10px;
}
#media .media-subsection:first-of-type h3 {
    margin-top: 0;
}

.video-container {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 Aspect Ratio */
    height: 0;
    overflow: hidden;
    max-width: 100%;
    background: #000;
    border: 2px solid var(--accent-color);
    box-shadow: 0 0 15px rgba(0, 255, 204, 0.3);
}
.video-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 20px;
}
.gallery-item {
    border: 2px solid transparent; /* For hover effect */
    transition: border-color 0.3s ease;
    position: relative; /* For glitch hover effects */
    overflow: hidden; /* For image glitch elements */
}
.gallery-item img {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.3s ease, filter 0.3s ease;
}

.gallery-gif {
    max-height: 80vh; /* Set maximum height to 80% of the viewport height */
    width: auto;      /* Override previous width: 100% to maintain aspect ratio based on height */
    height: auto;     /* Ensure height also adjusts naturally
    display: block;   /* Ensure it's a block element for auto margins to work */
    margin-left: auto;  /* Center the image horizontally if it's narrower than the grid cell */
    margin-right: auto; /* Center the image horizontally */
    object-fit: contain; /* Ensures the entire GIF is visible within these dimensions, preserving aspect ratio */
}

.glitch-hover:hover img {
    transform: scale(1.02);
    filter: contrast(1.1) brightness(0.9);
}
.glitch-hover:hover {
    border-color: var(--accent-color);
}

/* More intense image glitch on hover - optional */
.glitch-hover::before, .glitch-hover::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: inherit; /* Copies the image */
    background-image: var(--bg-image); /* JS will set this */
    background-size: cover;
    background-position: center;
    opacity: 0;
    transition: opacity 0.1s ease;
}
.glitch-hover:hover::before {
    left: 2px;
    transform: scale(1.01);
    filter: hue-rotate(30deg) saturate(2);
    opacity: 0.3;
    animation: img-glitch-move 0.2s infinite alternate steps(2);
}
.glitch-hover:hover::after {
    left: -2px;
    transform: scale(1.01);
    filter: hue-rotate(-30deg) saturate(1.5);
    opacity: 0.3;
    animation: img-glitch-move 0.2s 0.05s infinite alternate steps(2);
}

@keyframes img-glitch-move {
    0% { clip-path: inset(10% 0 70% 0); }
    100% { clip-path: inset(60% 0 20% 0); }
}

/* --- Footer --- */
#links {
    background: var(--primary-color);
    color: var(--text-color);
    text-align: center;
    padding: 40px 0;
    border-top: 2px solid var(--accent-color);
}
#links .footer-link {
    color: var(--accent-color);
    text-decoration: none;
    font-family: var(--font-glitchy);
    font-size: 1.2rem;
    margin: 0 10px;
    transition: text-shadow 0.3s ease;
}
#links .footer-link:hover {
    text-shadow: 0 0 8px var(--accent-color);
}
#links p {
    margin-bottom: 10px;
}
.copyright {
    font-size: 0.9rem;
    color: rgba(192, 192, 224, 0.7); /* Lighter text color */
    margin-top: 20px;
}


/* --- Responsive Adjustments --- */
@media (max-width: 768px) {
    .glitch {
        font-size: 3rem;
    }
    #hero .tagline {
        font-size: 1.2rem;
    }
    .content-section h2 {
        font-size: 2rem;
    }
    nav .container {
        flex-direction: column;
        align-items: center;
    }
    .gallery {
        grid-template-columns: 1fr; /* Stack images */
    }
}

/* --- Lightbox Modal Styles --- */
.lightbox-trigger {
    cursor: zoom-in; /* Indicate it's clickable for a larger view */
}

.lightbox-modal {
    display: none; /* Hidden by default */
    position: fixed; /* Stay in place */
    z-index: 10000; /* Sit on top of everything */
    padding-top: 50px; /* Location of the box */
    left: 0;
    top: 0;
    width: 100%; /* Full width */
    height: 100%; /* Full height */
    overflow: auto; /* Enable scroll if needed */
    background-color: rgba(10, 15, 31, 0.95); /* Darker, slightly transparent background */
    justify-content: center; /* Center content horizontally */
    align-items: center; /* Center content vertically */
    flex-direction: column; /* Stack image and caption */
}

.lightbox-content {
    margin: auto;
    display: block;
    max-width: 90%;
    max-height: 80vh; /* Max height relative to viewport */
    border: 3px solid var(--accent-color);
    box-shadow: 0 0 25px var(--accent-color);
    animation: lightboxZoom 0.4s ease-out;
}

@keyframes lightboxZoom {
    from {transform: scale(0.7); opacity: 0;}
    to {transform: scale(1); opacity: 1;}
}

#lightbox-caption {
    margin-top: 15px;
    text-align: center;
    color: var(--text-color);
    font-family: var(--font-glitchy);
    font-size: 1.2rem;
}

.lightbox-close {
    position: absolute;
    top: 25px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    transition: 0.3s;
    z-index: 10001;
}

.lightbox-close:hover,
.lightbox-close:focus {
    color: var(--accent-color);
    text-decoration: none;
    cursor: pointer;
}

/* Next & previous buttons */
.lightbox-prev,
.lightbox-next {
    cursor: pointer;
    position: absolute;
    top: 50%;
    width: auto;
    padding: 16px;
    margin-top: -30px; /* Adjust to vertically center with image */
    color: white;
    font-weight: bold;
    font-size: 24px;
    transition: 0.4s ease;
    border-radius: 0 3px 3px 0;
    user-select: none;
    background-color: rgba(0, 0, 0, 0.3);
}
.lightbox-prev:hover,
.lightbox-next:hover {
    background-color: rgba(0, 255, 204, 0.5); /* Accent color with transparency */
}
.lightbox-next {
    right: 15px;
    border-radius: 3px 0 0 3px;
}
.lightbox-prev {
    left: 15px;
}

/* Hide nav buttons if only one image or at ends */
.lightbox-modal.single-image .lightbox-prev,
.lightbox-modal.single-image .lightbox-next,
.lightbox-modal.first-image .lightbox-prev,
.lightbox-modal.last-image .lightbox-next {
    display: none;
}

/* --- Generalized Typing Effect --- */
.auto-type {
    /* Base style for elements that will have text typed into them */
    display: inline; /* Or block, depending on where you use it */
    position: relative; /* For cursor positioning */
    white-space: pre-wrap; /* Preserve spaces and allow wrapping */
}

.auto-type.is-typing::after,
.auto-type.finished-typing.blinking-cursor::after {
    content: '_'; /* Or use '|' or '▋' for different cursor styles */
    display: inline-block;
    position: absolute;
    left: 100%; /* Position the pseudo-element's left edge at the parent's 100% width mark */
    bottom: 0; /* Aligns the bottom of the cursor with the bottom of the line */
    /* You might need a slight vertical adjustment depending on the font and cursor character: */
    /* transform: translateY(0.1em); */ /* Example: slightly move down */
    animation: typed-cursor-blink 1s steps(1) infinite;
    color: var(--accent-color);
    /* margin-left is no longer needed for positioning with left: 100% */
    /* If you want a tiny space between text and cursor, you can use transform: translateX(1px);
       or adjust left: calc(100% + 1px); but often left:100% is fine. */
    font-family: var(--font-glitchy); /* Ensure cursor uses same font family if it matters */
}


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

/* Example styles for the new demo in #gameplay */
.feature-highlight { /* You might already have this, adjust if needed */
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--accent-color);
    padding: 20px;
    margin-top: 30px;
    font-family: var(--font-glitchy);
    color: var(--accent-color);
    text-align: left;
}
.feature-highlight p { /* You might already have this */
    text-align: left;
    margin-bottom: 10px;
    font-size: 1.2rem;
}
.fake-terminal-output {
    min-height: 1.5em; /* Ensure space for text */
    margin-bottom: 5px;
    color: #9fceff; /* Lighter blue for typed text */
    font-size: 1.2rem;
}
.terminal-prompt {
    color: var(--accent-color);
    margin-right: 5px;
}
.terminal-prompt.user-input {
    color: #aaffaa; /* Different color for "user input" prompt */
}