/* --- 1. CSS VARIABLES FOR THEMES --- */
:root {
  /* Light Mode (Default) */
  --bg-color: #f8f9fa;
  --text-color: #343a40;
  --card-bg-color: #ffffff;
  --card-shadow: 0 4px 15px rgba(0, 0, 0, 0.07);
  --card-hover-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
  --subtitle-color: #6c757d;
  --tag-bg-color: #e9ecef;
  --tag-text-color: #495057;
  --link-color: #007bff;
  --toggle-bg: #e9ecef;
  --toggle-fg: #ffffff;
  --sun-color: #f39c12;
  --moon-color: #6c757d;
}

[data-theme="dark"] {
  /* Dark Mode */
  --bg-color: #121212;
  --text-color: #e0e0e0;
  --card-bg-color: #1e1e1e;
  --card-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  --card-hover-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
  --subtitle-color: #888;
  --tag-bg-color: #333;
  --tag-text-color: #bbb;
  --link-color: #87ceeb; /* Sky Blue */
  --toggle-bg: #333;
  --toggle-fg: #121212;
  --sun-color: #e0e0e0;
  --moon-color: #f1c40f;
}

/* --- 2. GENERAL STYLES --- */
html {
  box-sizing: border-box;
  scroll-behavior: smooth;
}
*,
*::before,
*::after {
  box-sizing: inherit;
}

body {
  font-family: "Lato", sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  margin: 0;
  padding: 2rem;
  transition: background-color 0.3s ease, color 0.3s ease;
}

h1,
h2,
h3 {
  font-family: "Montserrat", sans-serif;
  font-weight: 600;
}

/* --- NAVIGATION HEADER STYLES --- */
.main-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1200px;
  margin: 0 auto 3rem auto;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--tag-bg-color);
}

.nav-links {
  display: flex;
  gap: 1rem;
}

.nav-links a {
  text-decoration: none;
  color: var(--subtitle-color);
  font-weight: 600;
  font-size: 1rem;
  transition: color 0.2s ease;
}

.nav-links a:hover {
  color: var(--link-color);
}

.nav-links a.active {
  color: var(--link-color);
}

/* --- HEADER AND LAYOUT --- */
.page-header {
  text-align: center;
  margin-bottom: 3rem;
}

.page-header h1 {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.page-header .subtitle {
  font-size: 1.1rem;
  color: var(--subtitle-color);
  max-width: 600px;
  margin: 0 auto;
}

/* --- GRID STYLES (FOR BOTH PAGES) --- */
.research-grid,
.team-grid {
  display: grid;
  gap: 2rem;
  max-width: 1200px;
  margin: 0 auto;
}

.research-grid {
  grid-template-columns: repeat(3, 1fr);
}

.team-grid {
  grid-template-columns: repeat(4, 1fr);
}

/* --- CARD STYLES --- */

/* Research Page Card */
.project-card {
  background-color: var(--card-bg-color);
  border-radius: 8px;
  box-shadow: var(--card-shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease, box-shadow 0.3s ease,
    background-color 0.3s ease;
}

.project-card:hover {
  transform: scale(1.03);
  box-shadow: var(--card-hover-shadow);
}

.project-card img {
  width: 100%;
  height: 225px;
  object-fit: cover;
  filter: brightness(0.95);
}

.project-card .card-content {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.project-card .project-title {
  font-size: 1.25rem;
  margin-top: 0;
  margin-bottom: 0.75rem;
}

.project-card .project-summary {
  font-size: 1rem;
  line-height: 1.6;
  color: var(--subtitle-color);
  flex-grow: 1;
}

.project-card .tags {
  margin-top: 1rem;
  margin-bottom: 1.5rem;
}

.project-card .tag {
  display: inline-block;
  background-color: var(--tag-bg-color);
  color: var(--tag-text-color);
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  font-size: 0.8rem;
  margin-right: 0.5rem;
  margin-bottom: 0.5rem;
}

.project-card .learn-more {
  color: var(--link-color);
  text-decoration: none;
  font-weight: 700;
  align-self: flex-end;
}

.project-card .learn-more:hover {
  text-decoration: underline;
}

/* Team Page Card */
.team-card {
  background-color: var(--card-bg-color);
  border-radius: 8px;
  box-shadow: var(--card-shadow);
  text-align: center;
  padding: 1.5rem;
  transition: transform 0.3s ease, box-shadow 0.3s ease,
    background-color 0.3s ease;
}

.team-card:hover {
  transform: scale(1.05);
  box-shadow: var(--card-hover-shadow);
}

/* --- MODIFIED FOR RESPONSIVENESS --- */
.team-card img {
  width: 90%; /* Use a percentage to allow shrinking */
  max-width: 140px; /* Set a max-width to prevent it getting too big */
  aspect-ratio: 5/5; /* Use aspect-ratio for a consistent oval shape (width/height) */
  border-radius: 40%;
  object-fit: cover;
  margin: 0 auto 1rem auto; /* Use auto margin to center the image */
  border: 3px solid var(--bg-color);
  display: block;
}

.team-card .name {
  font-size: 1.2rem;
  margin: 0;
}

.team-card .title {
  font-size: 0.9rem;
  color: var(--link-color);
  margin-top: 0.25rem;
}

.detailed-content {
  padding-top: 2rem;
  padding-left: 1rem;
  padding-right: 1rem;
  padding-bottom: 2rem;
  background-color: var(--card-bg-color);
}
/* --- THEME TOGGLE SWITCH --- */
.theme-switch-wrapper {
  display: flex;
  align-items: center;
}

.theme-switch {
  display: inline-block;
  height: 34px;
  position: relative;
  width: 60px;
}

.theme-switch input {
  display: none;
}

.slider {
  background-color: var(--toggle-bg);
  bottom: 0;
  cursor: pointer;
  left: 0;
  position: absolute;
  right: 0;
  top: 0;
  transition: 0.4s;
  border-radius: 34px;
}

.slider:before {
  background-color: var(--toggle-fg);
  bottom: 4px;
  content: "";
  height: 26px;
  left: 4px;
  position: absolute;
  transition: 0.4s;
  width: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.slider:before {
  content: "☀️";
  color: var(--sun-color);
}
input:checked + .slider:before {
  content: "🌙";
  color: var(--moon-color);
}
input:checked + .slider {
  background-color: var(--toggle-bg);
}
input:checked + .slider:before {
  transform: translateX(26px);
}

/* --- NEW: GALLERY STYLES --- */
.gallery-row {
  display: flex;
  flex-wrap: wrap;
  padding: 0 4px;
  max-width: 1200px;
  margin: 0 auto;
}

.gallery-column {
  flex: 25%;
  max-width: 25%;
  padding: 0 4px;
}

.gallery-column img {
  margin-top: 8px;
  vertical-align: middle;
  width: 100%;
  border-radius: 4px; /* Added for consistency */
}

.video-section {
  text-align: center;
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--tag-bg-color);
}

.video-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 2rem;
  max-width: 1200px;
  margin: 0 auto;
}

.video-wrapper {
  margin-bottom: 2rem;
}

.video-wrapper h3 {
  color: var(--subtitle-color);
}

.video-wrapper video {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}

/* --- RESPONSIVE DESIGN --- */
@media (max-width: 992px) {
  .research-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .team-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 768px) {
  body {
    padding: 1rem;
  }
  .page-header h1 {
    font-size: 2rem;
  }
  .research-grid {
    grid-template-columns: 1fr;
  }
  .team-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }
  .main-nav {
    padding: 0.5rem 0;
  }
  .nav-links {
    gap: 1rem;
  }
  .nav-links a {
    font-size: 0.9rem;
  }
  /* Gallery responsive */
  .gallery-column {
    flex: 50%;
    max-width: 50%;
  }
  /* Make videos stack on mobile -> one column */
  .video-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .gallery-column {
    flex: 100%;
    max-width: 100%;
  }
}

/* --- FOOTER STYLES --- */
footer {
  text-align: center;
  margin-top: 4rem;
  padding: 2rem;
  border-top: 1px solid var(--tag-bg-color);
  color: var(--subtitle-color);
  font-size: 0.9rem;
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
}

footer a {
  color: var(--link-color);
  text-decoration: none;
  font-weight: 600;
}

footer a:hover {
  text-decoration: underline;
}
