/* CSS Variables for Theme */
:root {
  --bg-primary: #ffffff;
  --bg-secondary: #f8f9fa;
  --text-primary: #1a1a1a;
  --text-secondary: #6c757d;
  --accent: #0066cc;
  --accent-hover: #0052a3;
  --border: #e0e0e0;
  --shadow: rgba(0, 0, 0, 0.1);
  --timeline-line: #d0d0d0;
  --card-bg: #ffffff;
}

[data-theme="dark"] {
  --bg-primary: #1a1a1a;
  --bg-secondary: #2d2d2d;
  --text-primary: #f0f0f0;
  --text-secondary: #a0a0a0;
  --accent: #4da6ff;
  --accent-hover: #66b3ff;
  --border: #404040;
  --shadow: rgba(0, 0, 0, 0.3);
  --timeline-line: #505050;
  --card-bg: #2d2d2d;
}

/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg-primary);
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Navigation */
#navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background-color: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  z-index: 1000;
  transition: background-color 0.3s ease;
}


.nav-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
  position: relative;
  height: 70px;
}

.nav-brand {
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--accent);
  transition: all 0.3s ease;
}

.nav-links {
  display: flex;
  list-style: none;
  gap: 2rem;
}

.nav-links a {
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.3s ease;
}

.nav-links a:hover {
  color: var(--accent);
}

#theme-toggle {
  background: none;
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  font-size: 1.25rem;
  transition: all 0.3s ease;
}

#theme-toggle:hover {
  border-color: var(--accent);
  transform: scale(1.05);
}

/* Container */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
}

/* Sections */
.section {
  padding: 5rem 0;
  min-height: 50vh;
}

.section:first-of-type {
  margin-top: 80px;
}

.section-title {
  font-size: 2.5rem;
  margin-bottom: 2rem;
  color: var(--text-primary);
}

.lead {
  font-size: 1.25rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

/* About Section */
#about {
  /* keep section-level spacing; internal layout handled by .about-container */
  min-height: 80vh;
}

#about p {
  margin-bottom: 1rem;
  color: var(--text-secondary);
}

/* About content layout: text on left, portrait on right */
.about-container {
  display: flex;
  align-items: center;
  gap: 2rem;
}

.about-text {
  flex: 1 1 60%;
}

.about-photo {
  flex: 0 0 300px;
  max-width: 300px;
}

.about-photo-img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 12px;
  object-fit: cover;
  border: 1px solid var(--border);
}

/* Education Section */
.education-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
}

.education-card {
  background: var(--card-bg);
  padding: 2rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.education-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 16px var(--shadow);
}

.education-card h3 {
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.institution {
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.date {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

/* Timeline */
.timeline {
  position: relative;
  padding-left: 2rem;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--timeline-line);
}

.timeline-item {
  position: relative;
  padding-bottom: 3rem;
  display: grid;
  grid-template-columns: 150px 40px 1fr;
  gap: 2rem;
  opacity: 0;
  transform: translateX(-20px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.timeline-item.animate-in {
  opacity: 1;
  transform: translateX(0);
}

.timeline-date {
  color: var(--text-secondary);
  font-weight: 600;
  text-align: left;
  padding-top: 0.25rem;
  /* Keep the date on a single line on larger viewports so year parts don't wrap */
  white-space: nowrap;
}

.timeline-marker {
  position: relative;
  width: 16px;
  height: 16px;
  background: var(--accent);
  border-radius: 50%;
  margin-left: -9px;
  margin-top: 0.5rem;
  box-shadow: 0 0 0 4px var(--bg-primary);
}

.timeline-content {
  background: var(--card-bg);
  padding: 1.5rem;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.timeline-content h3 {
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.company {
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 1rem;
}

.timeline-content ul {
  margin-left: 1.5rem;
  color: var(--text-secondary);
}

.timeline-content li {
  margin-bottom: 0.5rem;
}

/* Projects Section */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
}

.project-card {
  background: var(--card-bg);
  padding: 2rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.project-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 16px var(--shadow);
}

.project-card h3 {
  color: var(--text-primary);
  margin-bottom: 1rem;
}

.project-card p {
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

/* --- Projects carousel styles (appended, does not remove grid styles) --- */
.projects-carousel-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.projects-carousel {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  gap: 1rem;
  padding: 1rem 0.25rem;
  width: 100%;
}

.projects-carousel::-webkit-scrollbar {
  display: none;
}

.project-slide {
  scroll-snap-align: start;
  min-width: 280px;
  max-width: 420px;
  flex: 0 0 auto;
}

.carousel-nav {
  background: var(--card-bg);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 1.4rem;
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.carousel-nav:hover {
  background: var(--bg-secondary);
  transform: scale(1.03);
}

.project-more {
  color: var(--text-secondary);
  margin-top: 0.5rem;
}

.see-more {
  margin-top: 0.75rem;
  background: none;
  border: 1px solid var(--border);
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
}

.project-card.expanded {
  transform: translateY(-6px);
  box-shadow: 0 12px 24px var(--shadow);
}

@media (max-width: 768px) {
  .project-slide {
    min-width: 240px;
  }
}

@media (max-width: 480px) {
  .projects-carousel {
    gap: 0.5rem;
  }

  .carousel-nav {
    display: none;
    /* rely on touch swipe on small screens */
  }
}

.project-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tag {
  background: var(--bg-secondary);
  color: var(--text-primary);
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.85rem;
  border: 1px solid var(--border);
}

/* Skills Section */
.skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 2rem;
}

.skill-category {
  background: var(--card-bg);
  padding: 2rem;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.skill-category h3 {
  color: var(--accent);
  margin-bottom: 1rem;
}

.skill-category ul {
  list-style: none;
}

.skill-category li {
  color: var(--text-secondary);
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.skill-category li:last-child {
  border-bottom: none;
}

/* Click Tracker Section */
.click-counter {
  text-align: center;
  padding: 2rem;
}

.click-button {
  background: var(--accent);
  color: white;
  border: none;
  padding: 1rem 3rem;
  font-size: 1.1rem;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-bottom: 1.5rem;
}

.click-button:hover {
  background: var(--accent-hover);
  transform: scale(1.05);
}

.click-button:active {
  transform: scale(0.98);
}

.click-count-display {
  font-size: 1.25rem;
  color: var(--text-primary);
  font-weight: 600;
}

/* Contact Section */
.contact-content {
  text-align: center;
  margin-top: 2rem;
}

.contact-message {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-bottom: 2rem;
}

.contact-icons {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-top: 2rem;
}

.contact-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  text-decoration: none;
  font-size: 1.5rem;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px var(--shadow);
}

.contact-icon svg {
  width: 1.25rem;
  height: 1.25rem;
  display: block;
  fill: currentColor;
}

.contact-icon .icon-emoji {
  font-size: 2rem;
  line-height: 1;
}

.contact-icon:hover {
  background: var(--accent-hover);
  transform: translateY(-4px);
  box-shadow: 0 8px 20px var(--shadow);
}

.contact-icon:active {
  transform: translateY(-2px);
}

/* Backup styles for old contact-links (if needed) */
.contact-links {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-top: 2rem;
}

.contact-link {
  display: inline-block;
  padding: 0.75rem 2rem;
  background: var(--accent);
  color: white;
  text-decoration: none;
  border-radius: 8px;
  font-weight: 600;
  transition: all 0.3s ease;
}

.contact-link:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px var(--shadow);
}

/* Footer */
footer {
  background: var(--bg-secondary);
  padding: 2rem 0;
  text-align: center;
  color: var(--text-secondary);
  border-top: 1px solid var(--border);
}

/* View Counter */
.view-counter {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--card-bg);
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  box-shadow: 0 4px 12px var(--shadow);
  font-weight: 600;
  color: var(--text-primary);
  z-index: 999;
}

/* Mobile Responsive */
@media (max-width: 768px) {

  /* keep nav container relative so we can absolutely position the toggles/brand */
  .nav-container {
    display: flex;
    justify-content: space-between;
    /* Spreads toggle and hamburger to ends */
    position: relative;
    /* already set earlier but keep for clarity */
  }

  /* center the brand and make it non-interactive so it won't block the
     hamburger/theme buttons when they move to the corners */
  .nav-brand {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1rem;
    white-space: nowrap;
    pointer-events: none;
    z-index: 1;
  }

  /* ensure the toggles sit in the left/right corners on mobile */
  #theme-toggle {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    order: 1;
  }

  .menu-toggle {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    order: 3;
  }

  /* mobile nav links dropdown */
  .nav-links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: var(--bg-primary);
    flex-direction: column;
    padding: 1rem;
    z-index: 1001;
    /* stay above other content */
    box-shadow: 0 4px 10px var(--shadow);
  }

  .nav-links.active {
    display: flex;
  }

  .nav-links.active {
    display: flex;
  }

  .nav-links li {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
  }

  .section-title {
    font-size: 2rem;
  }

  .timeline {
    padding-left: 1rem;
  }

  .timeline-item {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .timeline-date {
    text-align: left;
  }

  .timeline-marker {
    position: absolute;
    left: -1rem;
  }

  .view-counter {
    bottom: 1rem;
    right: 1rem;
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
  }

  .contact-icons {
    gap: 1.5rem;
  }

  .contact-icon {
    width: 50px;
    height: 50px;
    font-size: 1.25rem;
  }

  .contact-links {
    flex-direction: column;
  }

  .contact-link {
    text-align: center;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 0 1rem;
  }

  .section {
    padding: 3rem 0;
  }

  .section-title {
    font-size: 1.75rem;
  }

  .lead {
    font-size: 1.1rem;
  }

  /* Allow timeline dates to wrap on very small screens to avoid overflow */
  .timeline-date {
    white-space: normal;
  }
}

/* Mobile Hamburger Menu Styles */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-primary);
  cursor: pointer;
}

@media (max-width: 768px) {
  .menu-toggle {
    display: block;
  }

  .nav-links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: var(--bg-primary);
    flex-direction: column;
    padding: 1rem;
    box-shadow: 0 4px 10px var(--shadow);
  }

  .nav-links.active {
    display: flex;
  }

  /* Fix About Section Layout */
  .about-container {
    flex-direction: column-reverse;
    text-align: center;
  }

  .about-photo {
    margin-bottom: 2rem;
  }

  /* Fix Timeline for Mobile */
  .timeline-item {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .timeline-date {
    margin-bottom: 0.5rem;
  }
}

/* Infrastructure Badge Style */
.iac-badge,
.resume-badge {
  margin-top: 1rem;
  padding: 0.5rem;
  background: var(--bg-secondary);
  border-left: 4px solid var(--accent);
  display: inline-block;
  font-size: 0.8rem;
  color: var(--text-primary);
  min-width: 300px;
  /* keep badges visually equal length on larger viewports */
}

.iac-badge code,
.resume-badge code,
.resume-badge a {
  color: inherit;
  text-decoration: none;
}

@media (max-width: 520px) {

  .iac-badge,
  .resume-badge {
    min-width: auto;
    display: block;
    width: 100%;
  }
}

/* Subtle Click Lock Icon */
.click-lock {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-left: 0.5rem;
  cursor: pointer;
  opacity: 0.4;
  transition: opacity 0.3s ease, color 0.3s ease, transform 0.2s ease;
  vertical-align: baseline;
}

.click-lock:hover {
  opacity: 1;
  color: var(--accent);
}

[data-theme="dark"] .click-lock {
  opacity: 0.3;
}

[data-theme="dark"] .click-lock:hover {
  opacity: 1;
}