/* styles.css */

/* Import Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Geist:wght@300;400;500;600&display=swap');

:root {
  /* Light mode variables. Off-white page with near-black text rather than pure
     white with mid grey, which reads softer and more deliberate. */
  --bg-color: #f7f7f7;
  --text-color: #404040;
  --muted-color: #737373;
  --heading-color: #171717;
  --accent-color: #1f6feb;
  --nav-hover-color: #737373;
  --social-icon-color: #171717;
  --social-hover-color: #737373;
  --card-bg: #ffffff;
  --border-color: #e5e5e5;
  --menu-bg: #f7f7f7;
  --menu-text: #171717;
  --line-color: #e5e5e5;
  --shadow: 0 1px 2px rgba(23, 23, 23, 0.05);
  --shadow-hover: 0 6px 16px rgba(23, 23, 23, 0.08);
  --transition: all 0.3s ease;
}

/* Dark mode variables (the class is set on <html> before first paint) */
.dark-mode {
  --bg-color: #171717;
  --text-color: #d4d4d4;
  --muted-color: #a3a3a3;
  --heading-color: #fafafa;
  --accent-color: #7cb2ff;
  --nav-hover-color: #a3a3a3;
  --social-icon-color: #fafafa;
  --social-hover-color: #a3a3a3;
  --card-bg: #1f1f1f;
  --border-color: #2e2e2e;
  --menu-bg: #171717;
  --menu-text: #fafafa;
  --line-color: #2e2e2e;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-hover: 0 6px 16px rgba(0, 0, 0, 0.45);
}

/* Reset some default styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Apply base styles */
body {
  background-color: var(--bg-color);
  color: var(--text-color);
  font-family: 'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  padding-top: 70px;
  line-height: 1.6;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  transition: var(--transition);
}

/* Headings are set lighter and tighter than the browser default: large text
   with negative tracking is what reads as considered rather than generic. */
h1, h2, h3, h4, h5, h6 {
  font-family: inherit;
  color: var(--heading-color);
  font-weight: 500;
  letter-spacing: -0.022em;
  margin-bottom: 0.5rem;
}

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

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

/* Create a fixed top menu */
.top-menu {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background-color: var(--menu-bg);
  z-index: 1000;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 5%;
  /* Same colour as the page with only a hairline, so the header reads as part
     of the page rather than a band across it. The border is what stops content
     from appearing to dissolve as it scrolls under the fixed bar. */
  border-bottom: 1px solid var(--line-color);
  transition: var(--transition);
  height: 60px; /* Fixed height for consistency */
}

/* Style the logo */
.logo {
  display: flex;
  align-items: center;
}

/* The logo is a white line drawing on an opaque black background, which was
   hidden by the old black header bar. Now that the header matches the page,
   blend the backdrop away instead: invert to dark-on-white and multiply out
   the white in light mode, and screen out the black in dark mode. */
.logo img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  filter: invert(1);
  mix-blend-mode: multiply;
}

.dark-mode .logo img {
  filter: none;
  mix-blend-mode: screen;
}

/* Style the desktop menu.
   It is a flex child rather than absolutely positioned: an absolutely positioned
   box with left: 50% can never be wider than half the viewport, which made the
   nav wrap onto a second line below ~1390px. */
.desktop-menu {
  flex: 1;
  display: flex;
  justify-content: center;
}

.desktop-menu ul {
  list-style: none;
  display: flex;
  align-items: center;
  margin: 0;
  padding: 0;
  white-space: nowrap;
}

.desktop-menu li {
  margin: 0 15px;
  padding: 0;
}

.desktop-menu a {
  color: var(--muted-color);
  text-decoration: none;
  font-weight: 400;
  font-size: 14px;
  transition: var(--transition);
}

/* The nav sits muted by default, so hover resolves toward the heading colour
   rather than away from it. */
.desktop-menu a:hover {
  color: var(--heading-color);
}

/* Tighten the nav so it still fits on one line on narrow laptops */
@media (max-width: 1100px) {
  .desktop-menu li {
    margin: 0 10px;
  }

  .desktop-menu a {
    font-size: 13px;
  }
}

/* Create a centered container */
.container {
  width: 92%;
  max-width: 1320px;
  margin: 0 auto;
  padding: 20px 0;
}

/* Profile image styling */
.profile-image {
  display: block;
  width: 80%;
  max-width: 700px;
  height: auto;
  border-radius: 10px;
  margin: 20px auto 40px;
  transition: var(--transition);
}

/* Section styling */
.section {
  margin-bottom: 40px;
  padding: 20px 0;
  scroll-margin-top: 70px; /* clears the 60px fixed header */
}

/* Add specific styling for blog posts section */
#blog-posts.section {
  margin-bottom: 30px;
  padding: 15px 0;
}

/* Center the text in the About section */
.about-text {
  max-width: 760px;
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--muted-color);
  margin: 0 auto;
  text-align: center;
}

.about-text p {
  text-align: left;
  margin: 0;
  padding: 0;
  display: inline-block;
}

#about .section-text-wrapper {
  text-align: center;
}

.heading-container {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 25px;
}

/* Specific styling for blog posts heading */
#blog-posts .heading-container {
  margin-bottom: 20px;
}

.heading-container h1,
.heading-container h2 {
  font-size: 2.1rem;
  font-weight: 500;
  letter-spacing: -0.028em;
  line-height: 1.15;
  padding: 0 20px;
  text-align: center;
}

/* Section text wrapper */
.section-text-wrapper {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Prose stays near a comfortable measure even though the grid got wider. */
.publications-section {
  max-width: 900px;
}

/* Specific styling for blog posts section wrapper */
#blog-posts .section-text-wrapper {
  padding: 0 20px;
}

/* Social icons styling */
.social-icons {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 40px 45px;
  margin-top: 12px;
}

.icon-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: var(--transition);
}

.icon-container a {
  font-size: 2rem;
  color: var(--social-icon-color);
  margin-bottom: 10px;
}

.icon-container a:hover {
  color: var(--social-hover-color);
}

.icon-container p {
  font-size: 0.9rem;
  text-align: center;
  color: var(--muted-color);
}

/* Blog posts styling */
.blog-posts-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 30px;
  margin-top: 20px;
}

.blog-post-link {
  text-decoration: none;
  color: var(--text-color);
  display: block;
}

.blog-post {
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: var(--transition);
  height: 100%;
  display: flex;
  flex-direction: column;
}

.blog-post-link:hover .blog-post {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
}

.blog-post img {
  width: 100%;
  height: 160px;
  object-fit: cover;
}

.blog-post-content {
  padding: 12px 15px;
  padding-bottom: 40px;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  position: relative;
}

.blog-post h3 {
  font-size: 1.05rem;
  margin-bottom: 6px;
  line-height: 1.3;
  /* Set a fixed height for title to ensure consistent layout */
  min-height: 2.6rem;
}

.blog-post p {
  font-size: 0.8rem;
  color: var(--muted-color);
  margin-top: auto;
  position: absolute;
  bottom: 12px;
  left: 15px;
}

/* Publications styling */
.publications {
  list-style-type: none;
}

.publications li {
  margin-bottom: 20px;
  padding-bottom: 20px;
}

.publications a {
  color: var(--accent-color);
  word-break: break-word;
}

/* Experience table styling */
.experience-table {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  border-collapse: collapse;
  table-layout: fixed;
}

.experience-table td {
  padding: 8px 0;
  vertical-align: top;
}

.experience-table tr:not(:last-child) td {
  padding-bottom: 12px;
}

.experience-table td:first-child {
  width: 33.3%;
  white-space: nowrap;
  text-align: right;
  padding-right: 40px;
}

.experience-table td:nth-child(2) {
  width: 33.4%;
  text-align: center;
}

.experience-table td:last-child {
  width: 33.3%;
  padding-left: 40px;
}

.experience-table a {
  color: var(--accent-color);
}

/* Video container */
.video-container {
  display: flex;
  flex-direction: row;
  justify-content: center;
  gap: 30px;
  margin: 20px auto;
  width: 100%;
  max-width: 1000px;
}

.video-wrapper {
  flex: 0 0 auto;
  position: relative;
  width: 480px;
  max-width: 45%;
}

.video-link {
  position: relative;
  display: block;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.video-link img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16/9;
  object-fit: cover;
}

.video-link:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
}

/* Play badge overlaid on the thumbnail */
.video-play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 68px;
  height: 48px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.65);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  transition: background 0.3s ease, transform 0.3s ease;
}

.video-link:hover .video-play {
  background: #ff0000;
  transform: translate(-50%, -50%) scale(1.06);
}

/* Video responsive adjustments */
@media (max-width: 767px) {
  .video-container {
    flex-direction: column;
    align-items: center;
  }

  .video-wrapper {
    width: 100%;
    max-width: 480px;
    margin-bottom: 20px;
  }
}

/* Dark mode toggle */
.theme-toggle {
  background: none;
  border: none;
  color: var(--menu-text);
  font-size: 1.5rem;
  cursor: pointer;
  margin-left: 15px;
  transition: var(--transition);
}

.theme-toggle:hover {
  color: var(--nav-hover-color);
}

/* Show the icon for the theme you can switch to. Doing this in CSS keeps the
   button in sync with the class set before first paint, with no icon flash. */
.theme-toggle .fa-sun {
  display: none;
}

.dark-mode .theme-toggle .fa-moon {
  display: none;
}

.dark-mode .theme-toggle .fa-sun {
  display: inline-block;
}

/* Responsive styles */
@media (max-width: 992px) {
  .experience-table td {
    padding: 8px 10px;
  }
}

@media (max-width: 768px) {
  body {
    padding-top: 60px;
  }

  .container {
    padding-top: 10px;
  }

  /* Ensure menu layout is correct */
  .top-menu {
    display: flex;
    justify-content: space-between;
    padding: 0 15px;
    height: 60px;
  }

  /* Only show one logo in the left corner */
  .logo {
    display: flex;
    position: relative;
    z-index: 1000;
  }

  /* Hide the desktop menu on mobile */
  .desktop-menu {
    display: none;
  }

  /* Show and position mobile controls correctly */
  .mobile-controls {
    display: flex;
    align-items: center;
    position: relative;
    z-index: 1000;
  }

  /* Show the hamburger menu button */
  .mobile-menu-toggle {
    display: block;
    margin-right: 10px;
  }

  /* Remove any duplicate menu items */
  .top-menu ul {
    display: none;
  }

  /* Fix scrolling issues when menu is open */
  body.menu-open {
    overflow: hidden;
  }

  .section {
    position: relative;
    z-index: 1; /* Lower z-index than the menu */
    margin-top: 30px; /* Increase space between sections */
    margin-bottom: 30px; /* Add bottom margin */
    clear: both; /* Ensure it clears any floats */
  }

  .profile-image {
    margin-top: 40px; /* Increase space between menu and profile image */
    margin-bottom: 40px; /* Add bottom margin */
    width: 90%;
    position: relative;
    z-index: 1;
    display: block; /* Ensure it's a block element */
    clear: both; /* Ensure it clears any floats */
  }

  .heading-container h1,
  .heading-container h2 {
    font-size: 1.5rem;
  }

  .experience-table {
    border-spacing: 0;
  }

  /* The per-cell selectors are repeated so these win over the desktop
     alignment rules without needing !important */
  .experience-table td,
  .experience-table td:first-child,
  .experience-table td:nth-child(2),
  .experience-table td:last-child {
    display: block;
    width: 100%;
    text-align: left;
    padding-left: 15px;
    padding-right: 15px;
  }

  .experience-table td:first-child {
    font-weight: bold;
    padding-bottom: 0;
  }

  .experience-table td:last-child {
    padding-top: 5px;
    padding-bottom: 15px;
  }

  .experience-table tr:not(:last-child) td:last-child {
    padding-bottom: 20px;
  }
}

@media (max-width: 576px) {
  .container {
    width: 95%;
  }

  .social-icons {
    gap: 20px;
  }

  .icon-container a {
    font-size: 1.5rem;
  }

  .heading-container h1,
  .heading-container h2 {
    font-size: 1.3rem;
    padding: 0 10px;
  }
}

/* Smooth scrolling. Anchor offsets come from scroll-margin-top on .section,
   which is why no scroll-padding-top is needed here. */
html {
  scroll-behavior: smooth;
}

/* Side Projects styling */
.side-projects-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 30px;
  margin-top: 20px;
}

/* No max-width: the cards fill their half of the row so the gutter between
   them stays the same 30px as the blog grid rather than opening up. */
.side-project-link {
  text-decoration: none;
  color: var(--text-color);
  display: block;
  width: calc(50% - 15px);
}

.side-project {
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 20px;
  width: 100%;
  box-shadow: var(--shadow);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  height: 100%;
}

.side-project:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-hover);
}

.side-project h3 {
  margin-top: 0;
  margin-bottom: 10px;
  font-size: 1.5rem;
  color: var(--heading-color);
}

.side-project p {
  margin: 0;
  color: var(--text-color);
  font-size: 1rem;
}

/* Project demo styling */
.project-demo {
  margin-top: 10px;
  width: 100%;
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 250px;
}

.demo-video {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 6px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s ease;
}

/* Make the Chess2 demo smaller */
.chess2-demo {
  max-width: 60%;
  margin: 0 auto;
  margin-top: -15px;
}

/* Style for the ArguMentor demo */
.argumentor-demo {
  max-width: 100%;
  margin: 0 auto;
  margin-top: -10px; /* Keep negative margin to move it up */
}

.side-project:hover .demo-video {
  transform: scale(1.02);
}

/* Responsive adjustments for side projects */
@media (max-width: 768px) {
  .side-projects-container {
    flex-direction: column;
    align-items: center;
  }

  .side-project-link {
    width: 100%;
    max-width: 100%;
  }

  .project-demo {
    min-height: auto; /* Remove minimum height on mobile */
    margin-bottom: 10px;
  }
}

/* Media query for larger screens to ensure side projects display properly */
@media (min-width: 769px) {
  .side-projects-container {
    align-items: stretch; /* Ensure items stretch to match the tallest item */
  }

  .side-project {
    display: flex;
    flex-direction: column;
    height: 100%;
  }

  .project-demo {
    margin-top: auto; /* Push demo to bottom of container */
    padding-top: 15px;
  }

  /* Special positioning for ArguMentor demo in desktop view */
  .side-project:first-child .project-demo {
    margin-top: 15px;
  }
}

/* Mobile controls */
.mobile-controls {
  display: flex;
  align-items: center;
}

/* Mobile menu toggle button */
.mobile-menu-toggle {
  display: none; /* Hidden by default on desktop */
  background: none;
  border: none;
  color: var(--menu-text);
  font-size: 1.8rem;
  cursor: pointer;
  margin-right: 10px;
  padding: 5px;
  z-index: 1001;
  transition: transform 0.3s ease, color 0.3s ease;
}

.mobile-menu-toggle:hover {
  color: var(--nav-hover-color);
}

/* Mobile navigation */
.mobile-nav {
  display: none; /* Hidden by default */
  position: fixed;
  top: 60px;
  left: 0;
  right: 0;
  background-color: var(--menu-bg);
  z-index: 999;
  border-bottom: 1px solid var(--line-color);
  box-shadow: var(--shadow-hover);
  padding: 15px 0;
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.mobile-nav.active {
  display: block;
  opacity: 1;
  transform: translateY(0);
}

.mobile-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.mobile-nav li {
  text-align: center;
  margin: 10px 0;
}

.mobile-nav a {
  display: block;
  color: var(--menu-text);
  text-decoration: none;
  font-size: 16px;
  padding: 10px 15px;
  transition: var(--transition);
}

.mobile-nav a:hover {
  background-color: var(--border-color);
}

/* Adjust the logo size for mobile */
@media (max-width: 768px) {
  .logo img {
    width: 32px;
    height: 32px;
  }
}

@media (min-width: 769px) {
  /* Hide mobile menu elements on desktop */
  .mobile-menu-toggle {
    display: none;
  }

  .mobile-nav {
    display: none;
  }

  /* Show desktop menu on desktop */
  .desktop-menu {
    display: flex;
  }
}

/* Add styles to prevent section headings from appearing as overlays */
.section .heading-container {
  position: relative;
  z-index: 1;
}

/* Add styles for when the mobile menu is open */
body.menu-open {
  overflow: hidden;
}
