/* ===== BASE STYLES ===== */
*, *::before, *::after {
  box-sizing: border-box;
}

:root {
  --bg: #0d0d0d;
  --text: #f5f5f5;
  --muted: #888;
  --accent: #7f5af0;
  --accent-light: #9d7dff;
  --accent-dark: #6340cc;
  --glass: rgba(30, 30, 46, 0.6);
  --border: rgba(255, 255, 255, 0.1);
  --transition: all 0.3s ease;
  --ripple: #9d7dff33; /* Using a more transparent variant for the ripple */
}

html {
  scroll-behavior: smooth;
  font-size: clamp(16px, 1.5vw, 18px);
}

body {
  /* overflow-x: hidden; */ /* Temporarily removed for debugging responsive issues. Re-add only if NO horizontal scrollbar appears after fixes. */
  margin: 0;
  font-family: 'Poppins', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 40px 20px;
  width: 100%;
  box-sizing: border-box;
}

h2 {
  font-size: 2rem;
  margin-bottom: 30px;
  color: var(--accent);
  text-align: center;
  position: relative;
}

h2::after {
  content: '';
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 80px;
  height: 4px;
  background: var(--accent);
  border-radius: 2px;
}

a {
  text-decoration: none;
  color: var(--accent);
  transition: var(--transition);
}

section {
  padding: 60px 0;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease-out, transform 0.6s ease-out;
  will-change: opacity, transform;
}

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

/* ===== HEADER & HERO ===== */
.hero {
  text-align: center;
  padding: 80px 20px;
  background: linear-gradient(135deg, #0d0d0d 0%, #1a1a2e 50%, #0d0d0d 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative; /* Needed for z-index of menu-toggle */
}

.hero-title {
  font-size: clamp(2rem, 8vw, 3rem);
  margin-bottom: 0.5rem;
  text-shadow: 0 0 10px rgba(127, 90, 240, 0.4);
}

.hero-subtitle {
  font-size: clamp(1.1rem, 3.5vw, 1.2rem);
  color: var(--muted);
  margin-bottom: 2rem;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

/* Typewriter effect - default for mobile (no animation, full text visible) */
.typewriter {
  /* On mobile, we want text to wrap and be fully visible */
  line-height: 1.5; /* Allows text to break into multiple lines */
  display: block; /* Ensures it behaves like a block element, taking full width */
  text-align: center; /* Ensures text remains centered */
  /* Remove any overflow: hidden; or white-space: nowrap; from here */
  border-right: none; /* No cursor on mobile */
}

/* Typewriter animations for desktop (only apply on larger screens) */
@media (min-width: 769px) { /* Adjust breakpoint if needed */
    .typewriter {
        overflow: hidden; /* Essential for typewriter effect on desktop */
        white-space: nowrap; /* Essential for typewriter effect on desktop */
        width: 0; /* Start from 0 width for the animation */
        border-right: 2px solid var(--accent); /* Initial cursor for desktop */
        animation: 
            typing 3s steps(40, end) forwards,
            blink 0.75s step-end infinite;
    }
}

/* Ensure your @keyframes typing and @keyframes blink are still defined as before in your CSS: */
@keyframes typing {
  from { width: 0; }
  to { width: 100%; }
}

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


/* ===== NAVIGATION ===== */
nav ul {
  list-style: none;
  padding: 0;
  margin: 2.5rem 0 0;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1rem;
}

nav ul li {
  margin: 0;
}

.glow-btn {
  background-color: transparent;
  color: var(--accent);
  border: 2px solid var(--accent);
  padding: 12px 24px;
  font-weight: bold;
  font-size: 1rem;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 0 10px rgba(127, 90, 240, 0.5);
  display: inline-block;
  position: relative; /* Needed for ripple effect */
  overflow: hidden; /* Ensure ripple stays within button */
  z-index: 1; /* Ensure button is above ripple */
}

.glow-btn:hover {
  background-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 20px var(--accent), 0 0 40px var(--accent);
  transform: scale(1.05);
}

.glow-btn:active {
  transform: scale(0.98);
}

/* Ripple effect added by JavaScript */
.ripple {
  position: absolute;
  border-radius: 50%;
  background: var(--ripple);
  animation: ripple-animation 0.7s ease-out forwards;
  transform: scale(0);
  pointer-events: none; /* Allow clicks to pass through */
  opacity: 0.8;
  z-index: 0; /* Ensures ripple is behind button content */
}

@keyframes ripple-animation {
  to {
    transform: scale(30); /* Scale up a lot */
    opacity: 0;
  }
}

/* Fallback for browsers not supporting backdrop-filter */
@supports not (backdrop-filter: blur(8px)) {
    .glass, .nav {
        background: rgba(30, 30, 46, 0.95); /* Fallback solid background */
    }
}

/* Mobile menu toggle */
.menu-toggle {
  display: none; /* Hidden by default on desktop */
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 2rem;
  cursor: pointer;
  position: fixed; /* Keep it fixed so it's always available */
  top: 1.5rem;
  right: 1.5rem;
  z-index: 1000; /* Ensure it's above other content */
  transition: var(--transition);
  padding: 8px; /* Give it a larger tap area */
  border-radius: 50%;
}

.menu-toggle:hover {
  background: rgba(127, 90, 240, 0.2);
}

/* ===== SECTION STYLES ===== */
.glass {
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: 12px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  padding: 2.5rem;
  margin: 2rem auto;
}
@media (max-width: 768px) {
  .glass {
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
  }
}

blockquote {
  border-left: 4px solid var(--accent);
  padding: 1.5rem;
  margin: 2rem 0;
  background: rgba(127, 90, 240, 0.05);
  border-radius: 0 10px 10px 0;
  position: relative; /* Establish positioning context for ::before */
}
blockquote::before {
  content: '“'; /* Changed to a single opening quote for consistency */
  position: absolute;
  top: -20px;
  left: 10px;
  font-size: 5rem;
  color: rgba(127, 90, 240, 0.1);
  font-family: Georgia, serif;
  line-height: 1;
}


/* ===== SKILLS SECTION ===== */
.skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 20px;
  margin-top: 2rem;
}

.skill-card {
  background: #1a1a1a;
  padding: 15px;
  text-align: center;
  border-radius: 8px;
  box-shadow: 0 0 10px rgba(127, 90, 240, 0.2);
  font-weight: 600;
  transition: var(--transition);
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.05);
  position: relative; /* For ripple effect */
  overflow: hidden;
}

.skill-card i {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
  color: var(--accent);
}

.skill-card span {
  font-size: 1rem;
}

.skill-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 0 20px rgba(127, 90, 240, 0.4);
}

/* ===== PROJECTS SECTION ===== */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 30px;
  margin-top: 2rem;
}

.project-card {
  background: #1a1a1a;
  padding: 25px;
  border-radius: 10px;
  transition: var(--transition);
  box-shadow: 0 0 15px rgba(127, 90, 240, 0.2);
  display: flex;
  flex-direction: column;
  height: 100%;
  border: 1px solid rgba(255, 255, 255, 0.05);
  position: relative; /* For ripple effect */
  overflow: hidden;
}

.project-card img {
  display: block; /* Makes the image a block element, ensuring it stacks with text */
  margin: 0 auto 1.5rem; /* Centers horizontally and adds space below */
  max-width: 100%; /* Prevents overflow on smaller screens */
  height: auto;
  border-radius: 8px; /* Maintains aspect ratio */
}

.project-card:hover {
  transform: scale(1.02);
  box-shadow: 0 0 25px rgba(127, 90, 240, 0.4);
}

.project-card h3 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
  color: white;
}

.project-card p {
  margin-bottom: 1.5rem;
  flex-grow: 1;
  color: rgba(255, 255, 255, 0.8);
}

.project-links {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: auto; /* Push links to the bottom */
}

.project-links a {
  display: inline-block;
  padding: 0.6rem 1.2rem;
  background: rgba(127, 90, 240, 0.1);
  border-radius: 5px;
  font-weight: 500;
  transition: var(--transition);
  border: 1px solid rgba(127, 90, 240, 0.3);
  position: relative; /* For ripple effect */
  overflow: hidden;
  z-index: 1;
}

.project-links a:hover,
.project-links a:focus {
  background: var(--accent);
  color: white;
  transform: translateY(-2px);
}

/* ===== CONTACT SECTION ===== */
.contact-list {
  list-style: none;
  padding: 0;
  margin-top: 2rem;
}

.contact-list li {
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: transform 0.3s ease;
}

.contact-list li:hover {
  transform: translateX(10px);
}

.contact-list i {
  font-size: 1.5rem;
  color: var(--accent);
  min-width: 30px;
  text-align: center;
}

.contact-list a {
  color: white;
  font-weight: 500;
  transition: var(--transition);
  font-size: 1.1rem;
  display: block;
  padding: 8px 0;
  padding-left: 0.5rem;
}

.contact-list a:hover,
.contact-list a:focus {
  color: var(--accent-light);
  text-decoration: underline;
}


/* ===== FOOTER ===== */
footer {
  text-align: center;
  padding: 30px 20px;
  color: var(--muted);
  border-top: 1px solid var(--border);
  margin-top: 2rem;
  position: relative;
}
footer::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
}

/* ===== SCROLL TO TOP BUTTON ===== */
.scroll-top {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.3s ease;
  box-shadow: 0 5px 15px rgba(127, 90, 240, 0.4);
  z-index: 999;
}

.scroll-top.visible {
  opacity: 1;
  transform: translateY(0);
}

.scroll-top:hover {
  background: var(--accent-light);
  transform: translateY(-5px) scale(1.1);
}

.scroll-top i {
  font-size: 24px;
}

/* ===== RESPONSIVE DESIGN ===== */
/* Mobile First Adjustments */

/* Adjust hero padding for smaller screens to ensure header content and toggle are visible */
@media (max-width: 768px) {
    .hero {
        padding-top: 100px; /* Space for fixed menu-toggle */
        padding-bottom: 60px;
    }
}

@media (max-width: 768px) {
  .menu-toggle {
    display: block; /* Show hamburger icon on mobile */
  }

  .nav {
    position: fixed;
    top: 0;
    right: -100%; /* Off-screen by default */
    height: 100vh;
    width: 70%;
    max-width: 300px; /* Limit width even on larger tablets */
    background: rgba(30, 30, 46, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px); /* For Safari support */
    z-index: 999;
    transition: right 0.4s ease-in-out;
    padding: 6rem 2rem 2rem; /* Padding for content inside menu */
    box-shadow: -5px 0 15px rgba(0, 0, 0, 0.5); /* Corrected box-shadow syntax */
  }

  .nav.active {
    right: 0; /* Slide in */
  }
  
  /* Ensure navigation buttons stack vertically when menu is open */
  .nav ul {
    flex-direction: column;
    gap: 1.5rem; /* More space between stacked buttons */
    margin: 0; /* Reset margin */
    padding: 0; /* Reset padding */
    align-items: center; /* Center buttons horizontally */
  }

  .nav ul li {
    width: 100%; /* Ensure list items take full width for buttons */
    text-align: center;
  }

  .glow-btn {
    width: 100%; /* Make buttons take full width within menu item */
    max-width: 220px; /* Optional: limit overall width for consistency */
    padding: 12px 20px; /* Adjust padding for better touch target */
  }

  .container {
    padding: 20px 15px; /* Adjust container padding for tablets and smaller */
  }
  
  .glass {
    padding: 1.8rem;
  }
  
  .skills-grid {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  }
}

@media (max-width: 600px) {
  .hero-title {
    font-size: 2.2rem;
  }
  
  .project-grid {
    grid-template-columns: 1fr; /* Stack project cards on very small screens */
  }
  
  .project-links {
    flex-direction: column; /* Stack project links vertically */
    gap: 0.8rem;
  }
  
  .project-links a {
    width: 100%;
    text-align: center;
    padding: 0.8rem 1.5rem; /* Increased padding for better touch targets */
    margin-bottom: 0.5rem; /* Space between stacked links */
  }
  
  .contact-list li {
    flex-direction: column;
    align-items: flex-start; /* Align items to the start when stacked */
    gap: 0.5rem;
  }
  
  .section {
    padding: 40px 0;
  }
}


/* Focus States for Accessibility */
a:focus-visible,
button:focus-visible,
.skill-card:focus-visible,
.project-card:focus-visible { /* Added project-card */
  outline: 2px dashed var(--accent);
  outline-offset: 3px;
}
.scroll-top:focus-visible {
  outline: 2px dashed var(--accent);
  outline-offset: 3px;
}

/* Touch Feedback */
.glow-btn:active,
.skill-card:active,
.project-card:active {
  transform: scale(0.98) !important;
}