/* Import Fira Code font */
@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;600&display=swap');

/* Universal box-sizing for mobile compatibility */
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    overflow-x: hidden;
    width: 100%;
    min-height: 100%;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #000000 0%, #001a1a 25%, #000a14 50%, #001a1a 75%, #000000 100%);
    background-size: 400% 400%;
    animation: gradient-shift 30s ease infinite;
    color: #ffffff;
    display: block; /* Changed from flex to block */
    min-height: 100vh;
    margin: 0;
    padding: 50px 20px 20px 20px; /* Added top padding for status bar */
    box-sizing: border-box;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent; /* Remove tap highlight on mobile */
    touch-action: manipulation; /* Prevent zoom on double-tap */
}

@keyframes gradient-shift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Canvas Background Layers */
#matrix-rain, #particle-field {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

#matrix-rain {
    z-index: 0;
}

#particle-field {
    z-index: 1;
}

/* Scanline Overlay */
.scanline-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.15),
        rgba(0, 0, 0, 0.15) 1px,
        transparent 1px,
        transparent 2px
    );
    pointer-events: none;
    z-index: 9999;
    animation: scanline-scroll 60s linear infinite;
}

@keyframes scanline-scroll {
    0% { transform: translateY(0); }
    100% { transform: translateY(100px); }
}

/* Grid Overlay */
.grid-overlay {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 50%;
    background-image:
        linear-gradient(rgba(0, 255, 255, 0.1) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 255, 255, 0.1) 1px, transparent 1px);
    background-size: 50px 50px;
    transform: perspective(500px) rotateX(60deg);
    transform-origin: bottom;
    opacity: 0.15;
    pointer-events: none;
    z-index: 2;
    mask-image: linear-gradient(to top, rgba(0,0,0,1) 0%, rgba(0,0,0,0) 100%);
    -webkit-mask-image: linear-gradient(to top, rgba(0,0,0,1) 0%, rgba(0,0,0,0) 100%);
}

/* Status Bar */
.status-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    padding: 8px 20px;
    background-color: rgba(0, 255, 255, 0.05);
    border-bottom: 1px solid rgba(0, 255, 255, 0.3);
    font-family: 'Fira Code', monospace;
    font-size: 0.75rem;
    color: #00ffff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    z-index: 100;
    flex-wrap: wrap;
    box-sizing: border-box;
}

.status-item {
    white-space: nowrap;
    flex-shrink: 0;
}

/* Boot Sequence Overlay */
.boot-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #000;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-family: 'Fira Code', monospace;
    opacity: 1;
    transition: opacity 0.5s ease-out;
    box-sizing: border-box;
}

.boot-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.boot-content {
    color: #00ff00;
    font-size: 1rem;
    line-height: 1.6;
    text-align: left;
    max-width: 600px;
    width: 100%;
    padding: 20px;
    box-sizing: border-box;
}

.boot-content div {
    margin-bottom: 10px;
    opacity: 0;
    animation: boot-line-appear 0.3s ease-out forwards;
}

@keyframes boot-line-appear {
    to { opacity: 1; }
}

.boot-skip {
    position: absolute;
    bottom: 30px;
    color: #666;
    font-size: 0.8rem;
    animation: blink 1.5s infinite;
}

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

/* Glitch Effect on Animated Text */
#animated-text-container.glitch {
    animation: text-glitch 0.2s ease;
}

@keyframes text-glitch {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px) skew(-2deg); }
    50% { transform: translateX(5px) skew(2deg); }
    75% { transform: translateX(-3px) skew(-1deg); }
}

#animated-text-container {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    padding: 20px 0;
    min-height: 60px;
    border-bottom: none;
    margin-bottom: 20px;
    margin-left: 0;
    margin-right: 0;
    position: relative;
    z-index: 10;
}

.animated-text {
    position: absolute;
    left: 100%;
    white-space: nowrap;
    font-size: 1.8rem;
    font-weight: 600;
    color: #00ffff;
    text-shadow: 0 0 4px #00ffff; /* Adjusted blur radius from 8px to 4px */
    text-transform: uppercase;
    animation:
        scroll-single-item 10s linear infinite,
        title-flicker 4s infinite;
    top: 50%;
    transform: translateY(-50%);
}

@keyframes scroll-single-item {
    0%   { left: 100%; transform: translateX(0) translateY(-50%); }
    15%  { left: 50%; transform: translateX(-50%) translateY(-50%); }
    85%  { left: 50%; transform: translateX(-50%) translateY(-50%); }
    100% { left: 0%; transform: translateX(-100%) translateY(-50%); }
}
.container {
    text-align: center;
    width: 100%;
    max-width: 600px;
    border: 1px solid rgba(0, 255, 255, 0.5);
    padding: 25px;
    box-shadow:
        0 0 25px rgba(0, 255, 255, 0.2),
        inset 0 0 100px rgba(0, 0, 0, 0.5); /* Vignette effect */
    background-color: rgba(0, 5, 5, 0.8); /* Dark, slightly transparent background */
    z-index: 20;
    margin: 0 auto; /* Center the container */
    position: relative;
    box-sizing: border-box;
}

/* Corner Brackets */
.corner-brackets::before,
.corner-brackets::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid #00ffff;
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
    animation: bracket-pulse 2s ease-in-out infinite;
}

.corner-brackets::before {
    top: -1px;
    left: -1px;
    border-right: none;
    border-bottom: none;
}

.corner-brackets::after {
    top: -1px;
    right: -1px;
    border-left: none;
    border-bottom: none;
}

.corner-brackets {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.corner-brackets {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* Bottom corner brackets using container pseudo-elements */
.container::before,
.container::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid #00ffff;
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
    animation: bracket-pulse 2s ease-in-out infinite;
}

.container::before {
    bottom: -1px;
    left: -1px;
    border-right: none;
    border-top: none;
}

.container::after {
    bottom: -1px;
    right: -1px;
    border-left: none;
    border-top: none;
}

@keyframes bracket-pulse {
    0%, 100% {
        opacity: 0.7;
        box-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
    }
    50% {
        opacity: 1;
        box-shadow: 0 0 20px rgba(0, 255, 255, 0.8);
    }
}

.server-banner {
    max-width: 100%;
    margin-bottom: 20px;
    border-radius: 0; /* Sharp corners */
    border: 1px solid rgba(0, 255, 255, 0.5);
}

.title {
    font-size: 1.8rem;
    font-weight: 600;
    margin-bottom: 5px;
    color: #00ffff;
    text-shadow: 0 0 8px #00ffff;
    text-transform: uppercase;
    animation: title-flicker 4s infinite;
}

/* Terminal Prompt */
.terminal-prompt {
    display: inline-block;
    animation: cursor-blink 0.8s step-end infinite;
}

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

@keyframes title-flicker {
    0%, 18%, 22%, 25%, 53%, 57%, 100% {
        text-shadow:
            0 0 1px #fff,
            0 0 2px #fff,
            0 0 5px #00ffff,
            0 0 8px #00ffff;
    }
    20%, 24%, 55% {
        text-shadow: none;
    }
}
.subtitle {
    font-size: 1rem;
    margin-bottom: 30px;
    color: #00ffff;
}

/* Stats Container */
.stats-container {
    display: flex;
    justify-content: space-around;
    align-items: center;
    margin: 30px 0;
    padding: 20px 0;
    border-top: 1px solid rgba(0, 255, 255, 0.3);
    border-bottom: 1px solid rgba(0, 255, 255, 0.3);
}

.stat-item {
    text-align: center;
    flex: 1;
}

.stat-number {
    font-size: 2rem;
    font-weight: 600;
    color: #00ffff;
    text-shadow: 0 0 10px rgba(0, 255, 255, 0.8);
    font-family: 'Fira Code', monospace;
}

.stat-label {
    font-size: 0.7rem;
    color: #999;
    text-transform: uppercase;
    margin-top: 5px;
    letter-spacing: 1px;
}

.stat-separator {
    width: 1px;
    height: 40px;
    background: linear-gradient(
        to bottom,
        transparent,
        rgba(0, 255, 255, 0.5) 50%,
        transparent
    );
}

/* Feature Highlights */
.feature-highlights {
    position: relative;
    height: 50px;
    margin: 20px 0 30px 0;
    overflow: hidden;
}

.feature-item {
    position: absolute;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 0.9rem;
    color: #00ffff;
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
    padding-left: 20px;
    border-left: 2px solid #00ffff;
}

.feature-item.active {
    opacity: 1;
}

.feature-item i {
    font-size: 1.2rem;
}

/* Network Status Panel */
.network-status {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: rgba(0, 5, 5, 0.9);
    border: 1px solid rgba(0, 255, 255, 0.5);
    padding: 15px;
    border-radius: 0;
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.2);
    z-index: 25;
    min-width: 180px;
}

.status-title {
    font-size: 0.75rem;
    color: #00ffff;
    margin-bottom: 10px;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 1px;
    border-bottom: 1px solid rgba(0, 255, 255, 0.3);
    padding-bottom: 5px;
}

.status-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.network-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.7rem;
    color: #999;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-dot.online {
    background-color: #00ff00;
    box-shadow: 0 0 10px rgba(0, 255, 0, 0.8);
    animation: status-pulse 1.5s ease-in-out infinite;
}

@keyframes status-pulse {
    0%, 100% {
        box-shadow: 0 0 10px rgba(0, 255, 0, 0.8);
    }
    50% {
        box-shadow: 0 0 20px rgba(0, 255, 0, 1);
    }
}

.links-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.link-button {
    background-color: transparent;
    color: #00ffff;
    border: 1px solid #00ffff;
    padding: 15px 25px;
    border-radius: 0; /* Sharp corners */
    font-size: 1rem;
    font-family: inherit; /* Use the Fira Code from body */
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    text-transform: uppercase; /* Classic terminal feel */
    position: relative;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
}

.link-button:hover {
    background-color: #00ffff;
    color: #000;
    box-shadow:
        0 0 20px rgba(0, 255, 255, 0.8),
        0 0 30px rgba(0, 255, 255, 0.6),
        0 0 40px rgba(0, 255, 255, 0.4);
    animation: button-glow-pulse 1.5s ease-in-out infinite;
}

/* Active state for touch devices */
.link-button:active {
    background-color: #00ffff;
    color: #000;
    transform: scale(0.98);
    box-shadow:
        0 0 15px rgba(0, 255, 255, 0.6),
        0 0 25px rgba(0, 255, 255, 0.4);
}

@keyframes button-glow-pulse {
    0%, 100% {
        box-shadow:
            0 0 20px rgba(0, 255, 255, 0.8),
            0 0 30px rgba(0, 255, 255, 0.6);
    }
    50% {
        box-shadow:
            0 0 25px rgba(0, 255, 255, 1),
            0 0 35px rgba(0, 255, 255, 0.8),
            0 0 45px rgba(0, 255, 255, 0.6);
    }
}

/* Glitch Effect on Hover */
.link-button::before,
.link-button::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
}

.link-button:hover::before {
    opacity: 0.8;
    color: #ff0000;
    animation: glitch-1 0.3s infinite;
    clip-path: polygon(0 0, 100% 0, 100% 45%, 0 45%);
}

.link-button:hover::after {
    opacity: 0.8;
    color: #0000ff;
    animation: glitch-2 0.3s infinite;
    clip-path: polygon(0 55%, 100% 55%, 100% 100%, 0 100%);
}

@keyframes glitch-1 {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-2px); }
    40% { transform: translateX(2px); }
    60% { transform: translateX(-2px); }
    80% { transform: translateX(2px); }
}

@keyframes glitch-2 {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(2px); }
    40% { transform: translateX(-2px); }
    60% { transform: translateX(2px); }
    80% { transform: translateX(-2px); }
}

/* Ripple Effect */
.ripple {
    position: absolute;
    border-radius: 50%;
    background-color: rgba(0, 255, 255, 0.6);
    transform: scale(0);
    animation: ripple-animation 0.6s ease-out;
    pointer-events: none;
}

@keyframes ripple-animation {
    to {
        transform: scale(2);
        opacity: 0;
    }
}

/* Data Stream Effect */
.data-stream {
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    font-family: 'Fira Code', monospace;
    font-size: 0.7rem;
    color: #00ffff;
    opacity: 0.3;
    white-space: nowrap;
    overflow: hidden;
    pointer-events: none;
    animation: data-stream-scroll 2s linear infinite;
}

@keyframes data-stream-scroll {
    0% { left: -100%; }
    100% { left: 100%; }
}

.link-button i {
    font-size: 1.2rem;
    z-index: 1;
}

/* Desktop: ensure layout is stable and centered */
@media (min-width: 769px) {
    body {
        display: block;
        overflow-x: hidden;
    }

    .container {
        margin-left: auto;
        margin-right: auto;
    }
}

@media (max-width: 768px) {
    /* Simplify grid overlay on tablets and mobile */
    .grid-overlay {
        opacity: 0.05;
    }

    /* Reduce status bar items on mobile */
    .status-bar {
        font-size: 0.6rem;
        padding: 6px 10px;
        gap: 6px;
        justify-content: flex-start;
    }

    .status-item {
        font-size: 0.6rem;
    }

    /* Better body padding for mobile */
    body {
        padding: 40px 15px 15px 15px;
    }

    /* Stack stats vertically on mobile */
    .stats-container {
        flex-direction: column;
        gap: 20px;
        padding: 15px 0;
    }

    .stat-separator {
        display: none;
    }

    .stat-number {
        font-size: 1.5rem;
    }

    /* Position network status differently on mobile */
    .network-status {
        bottom: 10px;
        right: 10px;
        padding: 10px;
        min-width: 150px;
        font-size: 0.65rem;
    }

    .status-title {
        font-size: 0.65rem;
    }

    .network-item {
        font-size: 0.6rem;
    }

    /* Simplify button effects on mobile */
    .link-button:hover::before,
    .link-button:hover::after {
        display: none; /* Disable glitch effect on mobile */
    }

    /* Adjust boot sequence for mobile */
    .boot-content {
        font-size: 0.85rem;
        padding: 15px;
    }

    .boot-skip {
        font-size: 0.7rem;
        bottom: 20px;
    }
}

@media (max-width: 600px) {
    .animated-text {
        font-size: 1rem; /* Reduce font size on smaller screens */
    }

    #animated-text-container {
        padding: 15px 0; /* Adjust padding for smaller screens */
    }

    /* Further simplify on very small screens */
    .scanline-overlay {
        animation: none; /* Static scanlines on mobile */
    }

    .feature-highlights {
        font-size: 0.75rem;
        height: 40px;
        margin: 15px 0 25px 0;
    }

    .feature-item {
        font-size: 0.75rem;
        padding-left: 10px;
    }

    .feature-item i {
        font-size: 0.9rem;
    }

    /* Hide network status on very small screens */
    .network-status {
        display: none;
    }

    /* Make container more compact on mobile */
    .container {
        padding: 20px 15px;
    }

    /* Smaller stats on mobile */
    .stats-container {
        margin: 20px 0;
        padding: 15px 0;
    }

    .stat-number {
        font-size: 1.3rem;
    }

    .stat-label {
        font-size: 0.65rem;
    }

    /* Better button sizing for mobile */
    .link-button {
        padding: 12px 20px;
        font-size: 0.9rem;
        min-height: 44px; /* Better touch target */
    }

    .link-button i {
        font-size: 1rem;
    }

    /* Adjust status bar for very small screens */
    .status-bar {
        font-size: 0.55rem;
        padding: 5px 8px;
        gap: 4px;
    }

    .status-item {
        font-size: 0.55rem;
    }

    /* Hide some status items on very small screens */
    .status-item:nth-child(3) {
        display: none; /* Hide uptime on very small screens */
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    /* Keep background and scrolling text visible and animated */
    #matrix-rain,
    #particle-field {
        animation-duration: revert !important;
        animation-iteration-count: revert !important;
    }

    #animated-text-container,
    .animated-text {
        animation-duration: 10s !important;
        animation-iteration-count: infinite !important;
        transition-duration: 0.3s !important;
    }

    .animated-text {
        animation: scroll-single-item 10s linear infinite, title-flicker 4s infinite !important;
    }

    /* Disable scanline animation */
    .scanline-overlay {
        animation: none;
    }

    /* Disable glitch effects */
    #animated-text-container.glitch {
        animation: none;
    }

    .link-button:hover::before,
    .link-button:hover::after {
        display: none;
    }
}