:root {
  --fonts: "Georgia", "Times New Roman", serif, system-ui;
  --background-gradient: linear-gradient(135deg, #1a1a1a, #222); /* Darker for better contrast */
  --header-gradient: linear-gradient(180deg, rgba(0, 0, 0, 1.0), rgba(0, 0, 0, 0.0));
  --text: #e0e0e0; /* Lighter text for better readability */
  --light-text: #b0b0b0;
  --white: #fff;
  --black: #000;
  --primary-blue: #007BFF;
  --secondary-blue: #0056b3;
  --dark-blue: #0f0840;
  --heading-hover: #0056b3;
  --contact-background: #222;
  --dark-card: rgba(255, 255, 255, 0.1);
  --lighter-card: rgba(255, 255, 255, 0.2);
  --border-color: #444; /* Darker to blend naturally */
  --corners: 6px;
  --shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
  --shadow-hover: 0 6px 8px rgba(0, 0, 0, 0.4);
  --glow: 0 0 20px rgba(0, 123, 255, 0.3),
          0 0 40px rgba(255, 0, 150, 0.3),
          0 0 60px rgba(0, 255, 150, 0.3);
}

/* General Layout */
html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--fonts);
  margin: 0;
  padding: 0;
  background: var(--background-gradient);
  color: var(--text);
  line-height: 1.6;
}

/* Header Styles */
header {
  position: fixed;
  width: 100%;
  top: 0;
  left: 0;
  background: var(--header-gradient);
  color: var(--white);
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  transition: background 0.3s ease, opacity 0.3s ease;
  z-index: 1000;
}

/* Logo Adjustments */
.logo img {
  max-width: 4rem; /* Constrain size */
  height: auto;
  display: block;
}

/* Desktop Navigation */
nav {
  overflow: hidden;
  transition: max-height 0.5s ease-in-out, opacity 0.5s ease, visibility 0.5s ease;
}

.nav-toggle {
  display: none; /* Initially hidden */
  font-size: 2rem;
  cursor: pointer;
  color: white;
}

/* Navigation Links */
nav ul {
  display: flex;
  gap: 2rem;
  list-style: none;
  margin: 0;
  padding: 0 1rem 0 0;
  justify-content: center;
}

nav li {
  border-radius: var(--corners);
  overflow: hidden;
}

nav a {
  color: var(--white);
  text-decoration: none;
  padding: 0.5rem 1rem;
  display: block;
  transition: opacity 0.3s ease, background-color 0.3s ease;
}

header nav a:hover {
  background-color: var(--lighter-card);
}

/* Main Content */
main {
  padding: 2rem;
  margin-top: 4rem;
}

/* Hero Section */
.hero {
  background: var(--contact-background);
  color: var(--white);
  text-align: center;
  padding: 3rem;
  border-radius: var(--corners);
  margin-bottom: 3rem;
  box-shadow: var(--glow);
}

.hero h1 {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.hero p {
  font-size: 1.2rem;
  margin-bottom: 1rem;
}

.hero a {
  text-decoration: none;
}

.hero img {
  max-width: 100%;
  height: auto;
  border-radius: var(--corners);
  box-shadow: var(--shadow-hover);
  margin-bottom: 1rem;
}

.headshot {
  max-width: 200px;
}

/* About Section (Within Index Page) */
.about {
  background: #181818;
  padding: 2rem;
  border-radius: var(--corners);
  margin-bottom: 3rem;
  box-shadow: var(--glow);
}

/* Buttons */
.button {
  display: inline-block;
  background-color: var(--primary-blue);
  color: var(--white);
  padding: 0.8rem 1.5rem;
  border-radius: var(--corners);
  text-decoration: none;
  transition: background-color 0.3s ease, transform 0.3s ease;
}

.button:hover {
  background-color: var(--secondary-blue);
  transform: scale(1.05);
  box-shadow: var(--shadow-hover);
}

/* Resume Section */
.resume {
  max-width: 900px;
  margin: 3rem auto;
  background: var(--dark-card);
  padding: 2rem;
  border-radius: var(--corners);
  box-shadow: var(--shadow);
}

/* Resume Header */
.resume-header {
  display: flex;
  align-items: center;
  gap: 2rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border-color);
}

/* Headshot Image */
.headshot {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  box-shadow: var(--shadow);
  object-fit: cover;
}

/* Resume Intro */
.resume-intro {
  flex: 1;
  text-align: left;
}

/* Resume Content */
.resume-content {
  padding: 1rem 0;
}

/* Resume Entry */
.resume-entry {
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
}

/* Skills Section */
.resume-skills {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
  list-style: none;
}

.resume-skills li {
  background: var(--lighter-card);
  padding: 0.5rem 1rem;
  border-radius: var(--corners);
  box-shadow: var(--shadow);
}

/* Resume Download Button */
.button[download] {
  display: block;
  text-align: center;
  margin-top: 1rem;
  font-weight: bold;
}

/* Hover Effects */
.resume-header:hover {
  background: rgba(255, 255, 255, 0.05);
  transition: background 0.3s ease;
}

.resume-entry:hover {
  transform: scale(1.02);
  transition: transform 0.3s ease;
}

/* Headshot Image Enhancements */
.headshot {
  transition: box-shadow 0.3s ease, transform 0.3s ease;
}

.headshot:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow-hover);
}

/* Footer */
footer {
  background: #111;
  padding: 1rem;
  text-align: center;
  color: var(--light-text);
  border-top-left-radius: 5px;
  border-top-right-radius: 5px;
}

/* Error Pages */
.error-page {
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  height: 100vh;
  background: var(--background-gradient);
  padding: 20px;
}

.error-container {
  max-width: 600px;
  background: var(--header-gradient);
  border: 1px solid var(--border-color);
  border-radius: var(--corners);
  padding: 2rem;
  text-align: center;
}

.error-container:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow-hover);
}

.error-logo {
  width: -webkit-fill-available;
}

/* Contact Form */
.contact-info {
  max-width: 600px;
  margin: 2rem auto;
  padding: 2rem;
  background: var(--dark-card);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-color);
  border-radius: var(--corners);
  box-shadow: var(--shadow);
  text-align: center;
}

.contact-title {
  font-size: 2rem;
  font-weight: bold;
  color: var(--primary-blue);
}

.contact-info p {
  font-size: 1rem;
  color: var(--light-text);
}

/* Form Fields */
form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  align-items: center; /* Centers all child elements */
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
}

.form-group label {
  align-self: flex-start;
}

.form-group input,
.form-group textarea {
  width: 100%;
  max-width: 480px; /* Adjust input width to stay inside form-group */
  padding: 0.8rem;
  border: 1px solid var(--border-color);
  border-radius: var(--corners);
  background: rgba(255, 255, 255, 0.6);
  color: var(--secondary-blue);
  transition: box-shadow 0.3s ease;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  box-shadow: var(--shadow-hover);
}

/* Submit Button */
input[type="submit"] {
  width: 100%;
  max-width: 480px; /* Matches the form-group width */
  padding: 0.8rem;
  font-size: 1.2rem;
  color: var(--white);
  background: var(--primary-blue);
  border: none;
  border-radius: var(--corners);
  cursor: pointer;
  transition: background 0.3s ease, transform 0.3s ease;
}

input[type="submit"]:hover {
  background: var(--secondary-blue);
  transform: scale(1.05);
  box-shadow: var(--shadow-hover);
}

/* Projects Page */
.project-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); /* Adaptive grid */
  gap: 2rem;
  justify-content: center;
}

/* Individual project card */
.project-item {
  background: var(--dark-card);
  border: 1px solid var(--border-color);
  border-radius: var(--corners);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  text-align: center;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  max-width: 450px; /* Constrain card width for consistency */
}

.project-item:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow-hover);
}

/* Project Images */
.project-item img {
  max-width: 100%; /* Prevent oversizing */
  height: auto;
  border-radius: var(--corners);
}

.thumbnail a {
  text-decoration: none;
}

/* Project Titles */
.project-item h2 {
  font-size: 1.5rem;
  margin-top: 1rem;
}

/* Project Links */
.project-item .button a {
  display: inline-block;
  margin-top: 1rem;
  padding: 0.8rem 1.2rem;
  background: var(--primary-blue);
  color: var(--white);
  border-radius: var(--corners);
  text-decoration: none;
  transition: background 0.3s ease, transform 0.3s ease;
}

.project-item .button a:hover {
  background: var(--secondary-blue);
  transform: scale(1.05);
  box-shadow: var(--shadow-hover);
}

/* Project Details Section */
.project-details {
  max-width: 900px;
  margin: 3rem auto;
  background: var(--dark-card);
  padding: 2rem;
  border-radius: var(--corners);
  box-shadow: var(--shadow);
}

.project-header {
  text-align: center;
  margin-bottom: 2rem;
}

.project-content {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.project-content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--corners);
  box-shadow: var(--shadow-hover);
  margin-bottom: 2rem;
}

.project-description {
  text-align: center;
  max-width: 800px;
}

.project-details-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 2rem;
  margin-top: 2rem;
}

.project-feature {
  background: var(--dark-card);
  padding: 1rem;
  border-radius: var(--corners);
  box-shadow: var(--shadow);
  text-align: center;
}

.project-feature h3 {
  color: var(--primary-blue);
}

.project-gallery {
  margin-top: 3rem;
  text-align: center;
}

.project-gallery h2 {
  color: var(--primary-blue);
}

.back-to-projects {
  text-align: center;
  margin-top: 3rem;
}

.back-to-projects a {
  display: inline-block;
  background: var(--primary-blue);
  color: var(--white);
  padding: 1rem 1.8rem;
  font-size: 1.1rem;
  border-radius: var(--corners);
  text-decoration: none;
  transition: background 0.3s ease, transform 0.3s ease;
}

.back-to-projects a:hover {
  background: var(--secondary-blue);
  transform: scale(1.05);
  box-shadow: var(--shadow-hover);
}

/* Back to Top Button */
.back-to-top {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: var(--primary-blue);
    color: var(--white);
    padding: 10px 15px;
    border-radius: var(--corners);
    box-shadow: var(--shadow);
    opacity: 0;
    visibility: hidden;
    pointer-events: none; /* Prevent accidental clicks */
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
    z-index: 1000;
}

.back-to-top a {
    text-decoration: none;
    color: white;
    font-weight: bold;
}

.back-to-top:hover {
    background-color: var(--secondary-blue);
    transform: scale(1.05);
}

/* Show Back to Top Button */
body.scrolled .back-to-top {
    opacity: 1;
    visibility: visible;
    pointer-events: all; /* Allows clicking once shown */
}

/* Responsive Design */
@media (max-width: 600px) {
  header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    flex-wrap: wrap;
  }

  .logo {
    position: absolute;
    top: 1rem;
    right: 3rem; /* Move to the right */
  }

  .nav-toggle {
    touch-action: manipulation;
    display: block;
    position: absolute;
    top: 1rem;
    left: 1rem; /* Move to the left */
    font-size: 2.5rem;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--white);
    background: none;
    border: none;
    z-index: 1100;
  }

  nav {
    will-change: max-height, opacity, visibility; /* Helps browsers optimize animations */
    position: absolute;
    top: 100%;
    left: 0;
    width: 8rem;
    display: flex; /* Ensures visibility */
    flex-direction: column;
    align-items: center;
    margin-top: 3rem;
    background: black;
    padding: 1rem;
    max-height: 0;
    opacity: 0;
    visibility: hidden;
    overflow: hidden;
    transition: max-height 0.5s ease-in-out, opacity 0.5s ease, visibility 0.5s ease;
  }

  nav.show {
    height: auto;
    overflow-y: auto; /* Enables scrolling for larger menus */
    max-height: 100vh; /* Ensures flexibility */
    opacity: 1; /* Fully visible */
    visibility: visible;
    transition: max-height 0.5s ease-in-out, opacity 0.8s ease, visibility 0.5s ease;
  }

  nav ul {
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    padding: 0;
  }

  .hero, .about {
    padding: 2rem;
    margin-bottom: 2rem;
  }

  /* About Mobile Styling */
  .resume-header {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .headshot {
    width: 150px;
    height: 150px;
  }

  .resume-content {
    padding: 1rem;
  }

  .resume-skills {
    justify-content: center;
    flex-wrap: wrap;
    text-align: center;
  }

  .resume-entry {
    padding: 1rem;
  }

  /* Contact Mobile Styling */
  .contact-info {
    padding: 1.5rem;
  }

  /* Projects Mobile Styling */
  .project-list {
    grid-template-columns: 1fr; /* Single-column layout for smaller screens */
    gap: 1.5rem;
  }

  .project-item {
    max-width: 100%;
  }
}
