*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --primary-color: #00ff00; /* Neon Green */
  --secondary-color: #ff00ff; /* Magenta */
  --accent-color: #00ffff; /* Cyan */
  --bg-color: #1a1a1a; /* Dark Grey */
  --text-color: #e0e0e0; /* Light Grey */
  --glitch-offset: 5px;
}

body {
  margin: 0;
  font-family: "Roboto Mono", monospace;
  background-color: var(--bg-color);
  color: var(--text-color);
  overflow-x: hidden; /* Prevent horizontal scroll from glitch effect */
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

#particle-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  opacity: 0.15;
}

.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem;
  text-align: center;
  z-index: 1;
  position: relative;
}

.hero {
  padding: 4rem 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
}

h1, h2 {
  font-family: "Press Start 2P", cursive;
}

h1 {
  font-size: clamp(1.8rem, 10vw, 5rem); /* Responsive font size, smaller minimum */
  color: var(--primary-color);
  text-shadow: 0 0 10px var(--primary-color);
  margin-bottom: 1.5rem;
  line-height: 1.2;
  position: relative;
  animation: text-shadow-pulse 2s infinite alternate;
}

@keyframes text-shadow-pulse {
  0% {
    text-shadow: 0 0 5px var(--primary-color), 0 0 10px var(--primary-color);
  }
  100% {
    text-shadow: 0 0 15px var(--primary-color), 0 0 25px var(--primary-color);
  }
}

/* Glitch Effect for H1 */
.glitch {
  position: relative;
  color: var(--primary-color);
}

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

.glitch::before {
  left: var(--glitch-offset);
  text-shadow: -2px 0 var(--secondary-color);
  animation: glitch-anim-1 2s infinite linear alternate-reverse;
}

.glitch::after {
  left: calc(var(--glitch-offset) * -1);
  text-shadow: -2px 0 var(--accent-color);
  animation: glitch-anim-2 2s infinite linear alternate;
}

@keyframes glitch-anim-1 {
  0% {
    clip: rect(10px, 9999px, 50px, 0);
  }
  10% {
    clip: rect(80px, 9999px, 120px, 0);
  }
  20% {
    clip: rect(10px, 9999px, 50px, 0);
  }
  30% {
    clip: rect(150px, 9999px, 180px, 0);
  }
  40% {
    clip: rect(20px, 9999px, 70px, 0);
  }
  50% {
    clip: rect(100px, 9999px, 140px, 0);
  }
  60% {
    clip: rect(30px, 9999px, 90px, 0);
  }
  70% {
    clip: rect(180px, 9999px, 220px, 0);
  }
  80% {
    clip: rect(50px, 9999px, 100px, 0);
  }
  90% {
    clip: rect(120px, 9999px, 160px, 0);
  }
  100% {
    clip: rect(10px, 9999px, 50px, 0);
  }
}

@keyframes glitch-anim-2 {
  0% {
    clip: rect(120px, 9999px, 160px, 0);
  }
  10% {
    clip: rect(30px, 9999px, 90px, 0);
  }
  20% {
    clip: rect(180px, 9999px, 220px, 0);
  }
  30% {
    clip: rect(50px, 9999px, 100px, 0);
  }
  40% {
    clip: rect(10px, 9999px, 50px, 0);
  }
  50% {
    clip: rect(80px, 9999px, 120px, 0);
  }
  60% {
    clip: rect(150px, 9999px, 180px, 0);
  }
  70% {
    clip: rect(20px, 9999px, 70px, 0);
  }
  80% {
    clip: rect(100px, 9999px, 140px, 0);
  }
  90% {
    clip: rect(10px, 9999px, 50px, 0);
  }
  100% {
    clip: rect(120px, 9999px, 160px, 0);
  }
}

/* Typing Effect */
.typing-text {
  font-size: clamp(1rem, 4vw, 1.5rem);
  white-space: normal; /* Allow text to wrap */
  margin: 2rem auto;
  max-width: 90%; /* Constrain to 90% of parent width */
  min-height: 3.5em; /* Reserve space to prevent layout shift as text types out */
  color: var(--accent-color);
  text-shadow: 0 0 5px var(--accent-color);
}

@keyframes blink-caret {
  from,
  to {
    border-color: transparent;
  }
  50% {
    border-color: var(--primary-color);
  }
}

/* Buttons */
.button {
  display: inline-block;
  padding: 1rem 2rem;
  margin-top: 2rem;
  background: linear-gradient(45deg, var(--primary-color), var(--accent-color));
  color: var(--bg-color);
  text-decoration: none;
  border: none;
  border-radius: 5px;
  font-family: "Press Start 2P", cursive;
  font-size: 1rem;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
  box-shadow: 0 0 15px rgba(0, 255, 0, 0.5);
}

.button:hover {
  transform: translateY(-3px);
  box-shadow: 0 0 25px rgba(0, 255, 0, 0.8);
}

.glitch-button span {
  position: relative;
  z-index: 2;
}

.glitch-button::before,
.glitch-button::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(45deg, var(--secondary-color), var(--primary-color));
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 1;
}

.glitch-button:hover::before {
  opacity: 1;
  animation: button-glitch-1 0.3s infinite alternate;
}

.glitch-button:hover::after {
  opacity: 1;
  animation: button-glitch-2 0.3s infinite alternate;
}

@keyframes button-glitch-1 {
  0% {
    transform: translate(2px, 2px);
  }
  50% {
    transform: translate(-2px, -2px);
  }
  100% {
    transform: translate(2px, 2px);
  }
}

@keyframes button-glitch-2 {
  0% {
    transform: translate(-2px, 2px);
  }
  50% {
    transform: translate(2px, -2px);
  }
  100% {
    transform: translate(-2px, 2px);
  }
}

/* Sections */
.section {
  padding: 4rem 0;
  border-top: 1px dashed rgba(0, 255, 0, 0.2);
  margin-top: 2rem;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

.section.fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}

.section h2 {
  font-size: clamp(1.5rem, 6vw, 2.5rem);
  color: var(--secondary-color);
  text-shadow: 0 0 8px var(--secondary-color);
  margin-bottom: 1.5rem;
}

.section p {
  font-size: clamp(0.9rem, 2.5vw, 1.1rem);
  line-height: 1.6;
  max-width: 700px;
  margin: 0 auto 1rem auto;
}

/* Contact Form */
.contact-form {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  max-width: 500px;
  margin: 2rem auto;
  padding: 2rem;
  background-color: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--primary-color);
  border-radius: 8px;
  box-shadow: 0 0 20px rgba(0, 255, 0, 0.3);
}

.form-group {
  text-align: left;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--accent-color);
  font-family: "Press Start 2P", cursive;
  font-size: 0.9rem;
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 10px;
  background-color: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--primary-color);
  border-radius: 4px;
  color: var(--text-color);
  font-family: "Roboto Mono", monospace;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.form-group input:focus,
.form-group textarea:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
}

.form-group textarea {
  resize: vertical;
  min-height: 100px;
}

/* Accessibility: Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  .glitch::before,
  .glitch::after,
  .glitch-button::before,
  .glitch-button::after {
    animation: none !important;
    transition: none !important;
  }
  .typing-text {
    animation: none !important;
    white-space: normal;
    border-right: none;
  }
  .section {
    opacity: 1;
    transform: translateY(0);
    transition: none !important;
  }
  h1 {
    animation: none !important;
  }
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .container {
    padding: 1.5rem;
  }
  .hero {
    min-height: auto;
    padding: 4rem 0;
  }
  .typing-text {
    min-height: 0; /* No need to reserve space if animation is off */
    max-width: 100%;
  }
  .button {
    padding: 0.8rem 1.5rem;
    font-size: 0.9rem;
  }
  .section {
    padding: 3rem 0;
  }
  .contact-form {
    padding: 1.5rem;
    width: 100%;
  }
  h1 {
    font-size: clamp(2.5rem, 10vw, 3.5rem);
  }
  .section h2 {
    font-size: clamp(1.8rem, 8vw, 2.2rem);
  }
}

@media (max-width: 480px) {
  .container {
    padding: 1rem;
  }
  .hero {
    padding: 3rem 0;
  }
  h1 {
    font-size: 2.2rem;
  }
  .typing-text {
    font-size: 1rem;
  }
  .button {
    width: 100%;
    text-align: center;
  }
  .section h2 {
    font-size: 1.8rem;
  }
  .section p {
    font-size: 0.9rem;
  }
  .form-group label {
    font-size: 0.8rem;
  }
}
