/* ===============================
   CSS Variables
================================ */
:root {
  --primary-color: #0077b6;
  --secondary-color: #00b4d8;
  --accent-color: #6a0dad;
  --green-color: #2a9d8f;
  --text-color: #333;
  --bg-color: #f4f4f9;
  --dark-bg: #121212;
  --dark-text: #f4f4f9;
  --card-bg: #fff;
  --card-shadow: rgba(0, 0, 0, 0.1);
  --transition-speed: 0.3s;
}

/* ===============================
   Reset & Base
================================ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Segoe UI', Arial, sans-serif;
  /* Upgraded font stack for better cross-platform rendering */
  background: var(--bg-color);
  color: var(--text-color);
  line-height: 1.6;
  transition: background 0.5s, color 0.5s;
}

.container {
  width: 90%;
  max-width: 1200px;
  margin: auto;
}

/* Accessibility Utility Class */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* ===============================
   Header & Navbar
================================ */
header {
  background: #222;
  color: #fff;
  padding: 1rem 2%;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
}

.logo {
  font-size: 1.8rem;
  font-weight: bold;
}

nav ul {
  list-style: none;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

nav a {
  color: #fff;
  text-decoration: none;
  padding: 0.3rem 0.6rem;
  border-radius: 5px;
  transition: all var(--transition-speed);
}

nav a:hover,
nav a:focus,
nav a.active-section {
  background-color: var(--primary-color);
  outline: none;
}

#darkModeToggle {
  margin-left: 1rem;
  font-size: 1.2rem;
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
}

/* Theme Selector */
#theme-selector {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-left: 1rem;
}

.theme-btn {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid transparent;
  /* Added border for better visibility */
  cursor: pointer;
  transition: transform var(--transition-speed);
}

.theme-btn.active,
.theme-btn:hover {
  transform: scale(1.2);
  border-color: #fff;
}

/* ===============================
   Hero Section
================================ */
#hero {
  text-align: center;
  padding: 4rem 2rem;
  background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
  color: #fff;
  transition: background 0.5s;
}

#hero .fade-text {
  font-size: 2.2rem;
  font-weight: bold;
  min-height: 2.6rem;
}

#hero .hero-subtitle {
  font-size: 1.2rem;
  margin: 1rem 0 2rem;
}

.hero-buttons {
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

#hero .btn {
  background-color: var(--primary-color);
  color: #fff;
  padding: 0.7rem 1.8rem;
  text-decoration: none;
  border-radius: 30px;
  font-weight: bold;
  transition: all var(--transition-speed);
}

#hero .btn:hover,
#hero .btn:focus {
  transform: translateY(-3px);
  box-shadow: 0 8px 15px rgba(0, 0, 0, 0.3);
}

.hero-social-links a {
  margin: 0 0.8rem;
  color: #fff;
  font-weight: bold;
  text-decoration: none;
  transition: all var(--transition-speed);
}

.hero-social-links a:hover {
  color: var(--secondary-color);
}

/* ===============================
   Content Sections
================================ */
section {
  padding: 4rem 0;
}

h2 {
  text-align: center;
  margin-bottom: 2rem;
  font-size: 2rem;
}

/* About */
.about-content {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2rem;
  justify-content: center;
}

.profile-img {
  width: 200px;
  border-radius: 50%;
  object-fit: cover;
  border: 5px solid var(--primary-color);
}

.about-text p {
  margin-bottom: 1rem;
}

/* Projects Grid */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
}

.project-card {
  background: var(--card-bg);
  padding: 1.2rem;
  border-radius: 10px;
  box-shadow: 0 4px 12px var(--card-shadow);
  transition: all 0.3s;
}

.project-card:hover,
.project-card:focus-within {
  transform: scale(1.05);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.project-link {
  display: inline-block;
  margin-top: 0.5rem;
  text-decoration: none;
  color: var(--primary-color);
  font-weight: bold;
  transition: all var(--transition-speed);
}

.project-link:hover,
.project-link:focus {
  background-color: var(--primary-color);
  color: #fff;
  padding: 0.2rem 0.5rem;
  border-radius: 5px;
}

.project-filters {
  text-align: center;
  margin-bottom: 2rem;
}

.project-filters .filter-btn {
  background: #ddd;
  border: none;
  padding: 0.5rem 1rem;
  margin: 0.2rem;
  border-radius: 5px;
  cursor: pointer;
  transition: all var(--transition-speed);
}

.project-filters .filter-btn.active,
.project-filters .filter-btn:hover,
.project-filters .filter-btn:focus {
  background-color: var(--primary-color);
  color: #fff;
}

.project-tag {
  display: inline-block;
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  background-color: var(--primary-color);
  color: #fff;
  border-radius: 5px;
  margin-top: 0.5rem;
}

/* Skills Bars */
.skills-wrapper {
  max-width: 700px;
  margin: auto;
}

.skill-bar {
  margin: 1rem 0;
}

.skill-bar span {
  display: block;
  font-weight: bold;
  margin-bottom: 0.5rem;
}

.bar {
  width: 100%;
  height: 20px;
  background: #ddd;
  border-radius: 10px;
  overflow: hidden;
}

.progress {
  height: 100%;
  border-radius: 10px;
  width: 0;
  transition: width 1.2s ease-in-out;
  will-change: width;
  /* Performance optimization */
}

/* Skill Colors */
.progress.html {
  background: #e34c26;
}

.progress.css {
  background: #264de4;
}

.progress.js {
  background: #f0db4f;
}

.progress.react {
  background: #4fbdf0;
}

.progress.node {
  background: #68a063;
}

.progress.mongo {
  background: #4db33d;
}

.progress.iot {
  background: #2a9d8f;
}

/* Experience & Testimonials */
.experience-wrapper,
.testimonials-wrapper {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2rem;
}

.experience-item,
.testimonial-card {
  background: var(--card-bg);
  padding: 1.2rem;
  border-radius: 10px;
  box-shadow: 0 4px 12px var(--card-shadow);
  max-width: 350px;
  transition: all 0.3s;
}

.experience-item:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

.testimonial-card p {
  font-style: italic;
  margin-bottom: 1rem;
}

/* Contact Form */
form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 600px;
  margin: auto;
}

form input,
form textarea {
  padding: 0.7rem 1rem;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 1rem;
  width: 100%;
}

form button {
  background-color: var(--primary-color);
  color: #fff;
  padding: 0.8rem;
  border: none;
  border-radius: 30px;
  cursor: pointer;
  font-weight: bold;
  transition: all var(--transition-speed);
}

form button:hover,
form button:focus {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.contact-info {
  text-align: center;
  margin-top: 1rem;
  font-weight: bold;
}

/* ===============================
   Footer & Animations
================================ */
footer {
  text-align: center;
  padding: 1.5rem 0;
  background: #222;
  color: #fff;
  transition: all 0.5s;
}

footer a {
  color: var(--primary-color);
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

.fade-in {
  opacity: 0;
  transform: translateY(15px);
  transition: opacity 1s ease-out, transform 1s ease-out;
  will-change: opacity, transform;
  /* Boosts performance for mobile */
}

.fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ===============================
   Dark Mode Overrides
================================ */
body.dark-mode {
  background: var(--dark-bg);
  color: var(--dark-text);
}

body.dark-mode header,
body.dark-mode footer {
  background: #333;
}

body.dark-mode nav a {
  color: var(--dark-text);
}

body.dark-mode .project-card,
body.dark-mode .experience-item,
body.dark-mode .testimonial-card {
  background: #1e1e1e;
  color: var(--dark-text);
}

body.dark-mode .bar {
  background: #333;
}

body.dark-mode form input,
body.dark-mode form textarea {
  background: #1e1e1e;
  color: #fff;
  border-color: #444;
}

/* ===============================
   Media Queries
================================ */
@media (max-width: 768px) {
  #hero {
    padding: 2rem 1rem;
  }

  nav ul {
    flex-direction: column;
    gap: 0.5rem;
    text-align: center;
    width: 100%;
    margin-top: 1rem;
  }

  .hero-buttons {
    flex-direction: column;
    gap: 0.8rem;
  }

  .about-content {
    flex-direction: column;
    text-align: center;
  }
}