/* --- 0. CSS Variables --- */
/* Using variables allows you to change colors in one place and makes dark mode logic much simpler. */
:root {
  --primary-color: #007acc;
  --primary-hover: #0056b3;
  --text-color: #222;
  --title-color: #003366; /* Your original dark navy for light mode */
  --bg-color: #ffffff;
  --bg-secondary: #f0f4f8;
  --border-color: #ccc;
  --footer-bg: #f9f9f9;
  --max-width: 1000px;
  --font-main: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Dark Mode Variable Overrides */
body.dark-mode {
  --primary-color: #80b3ff;
  --primary-hover: #a1c9ff;
  --text-color: #e0e0e0;
  --title-color: #99c2ff; /* A much lighter, readable blue for dark mode */
  --bg-color: #121212;
  --bg-secondary: #2c2c2c;
  --border-color: #333;
  --footer-bg: #1a1a1a;
}

/* --- 1. General Resets & Base Styles --- */
html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--font-main);
  font-size: 17px;
  line-height: 1.5;
  color: var(--text-color);
  background-color: var(--bg-color);
  display: flex;
  flex-direction: column;
}

/* Base link styling */
a {
  color: var(--primary-color);
  text-decoration: none;
  transition: all 0.2s ease-in-out;
}

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

/* --- 2. Layout Containers --- */
.page-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1em;
  box-sizing: border-box;
}

main {
  flex: 1; /* Pushes footer to bottom */
}

/* --- 3. Typography & Alignment --- */
h1, h2, h3, h4 {
  text-align: left;
  margin-bottom: 0.5rem;
}

header h1, nav {
  text-align: center;
}

p {
  text-align: justify;
  text-justify: inter-word;
  hyphens: auto;
  line-height: 1.6;
  margin-bottom: 1.2em;
  max-width: 85ch; /* Optimized for readability */
}

/* List spacing fix */
p + ul, p + ol {
  margin-top: -1.2em; 
}

li {
  margin-bottom: 0.2em;
}

hr {
  border: 0;
  border-top: 1px solid var(--border-color);
  margin: 1.5em 0;
}

/* --- 4. Navigation --- */
nav {
  margin: 20px 0;
}

nav a {
  margin: 0 5px; 
  padding: 8px 12px;
  font-weight: 600;
  border-radius: 6px;
}

nav a:hover, nav a.active {
  background-color: var(--bg-secondary);
}

nav a.active {
  color: var(--text-color);
  border-bottom: 2px solid var(--primary-color);
}

/* --- 5. Components --- */

/* Bio Section */
.bio-container {
  display: flex;
  align-items: flex-start;
  gap: 30px;
  margin-top: 20px;
}

.bio-text { flex: 2; }

.bio-image {
  flex: 1;
  max-width: 280px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  object-fit: cover;
}

/* Publication Navigation Bar */
.pub-nav {
  background: var(--bg-secondary);
  padding: 15px;
  border-radius: 8px;
  margin: 20px 10px 30px 10px;
  display: flex;
  justify-content: center;
  gap: 25px;
  flex-wrap: wrap;
  max-width: var(--max-width) !important;
}

.pub-nav a {
  font-weight: bold;
  white-space: nowrap;
}

/* Data Tables (CV) */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
}

th, td {
  text-align: left;
  padding: 12px 8px;
  border-bottom: 1px solid var(--border-color);
}

td:first-child {
  width: 25%;
  font-variant-numeric: tabular-nums;
}

/* Utility Links */
.back-to-top {
  display: inline-block;
  float: left;
  font-size: 0.8em;
  font-weight: 700;
  opacity: 0.6;
}

.back-to-top:hover {
  opacity: 1;
  text-decoration: none;
}

/* --- 6. Footer --- */
footer {
  text-align: center;
  font-size: 0.9em;
  margin-top: 3em;
  padding: 2em 1em;
  border-top: 1px solid var(--border-color);
  background-color: var(--footer-bg);
}

.footer-grid {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

/* Ensure footer paragraphs remain centered */
footer p {
  margin: 0 auto;
}

/* FIX: Override the global 'text-align: justify' for footer text */
footer p {
  text-align: center; /* Forces the text to the middle */
  margin: 0 auto;     /* Centers the paragraph block itself */
  max-width: 100%;    /* Allows it to use the full width of the footer */
}

/* Responsive adjustments for mobile */
@media (max-width: 600px) {
  .bio-container {
    flex-direction: column;
    align-items: center;
  }
  
  .bio-image {
    max-width: 100%;
  }

  td:first-child {
    width: auto;
  }
}

/* Styling for Publication Titles */
.pub-title {
  color: var(--title-color);
  font-weight: bold;
  text-decoration: none;
  display: inline-block; /* Helps with spacing */
  margin-bottom: 2px;
  line-height: 1.3;
}

/* Hover effect for the titles that are links */
a.pub-title:hover {
  text-decoration: underline;
  color: var(--primary-hover);
}





