/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-serif: 'Source Serif 4', Georgia, serif;
  --color-bg: #ffffff;
  --color-text: #2d3436;
  --color-text-light: #636e72;
  --color-accent: #0a7e8c;
  --color-accent-dark: #076872;
  --color-accent-light: #d4f0f4;
  --color-border: #e8e8e8;
  --color-card-bg: #fafbfc;
  --max-width: 1100px;
}

html { font-size: 17px; scroll-behavior: smooth; scrollbar-gutter: stable; overflow-x: hidden; }

body {
  font-family: var(--font-sans);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

.container { max-width: var(--max-width); margin: 0 auto; padding: 0 2rem; }

a { color: var(--color-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { font-family: var(--font-serif); font-weight: 600; line-height: 1.3; }
h1 { font-size: 2.2rem; margin-bottom: 0.5rem; }
h2 { font-size: 1.6rem; margin-bottom: 0.5rem; }
h3 { font-size: 1.2rem; margin-bottom: 0.3rem; }

p { margin-bottom: 1rem; }

/* ===== Header ===== */
.site-header {
  border-bottom: 1px solid var(--color-border);
  padding: 1rem 0;
  position: sticky;
  top: 0;
  background: rgba(255,255,255,0.97);
  backdrop-filter: blur(8px);
  z-index: 100;
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-name {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--color-text);
  text-decoration: none;
}

.site-nav a {
  color: var(--color-text-light);
  margin-left: 2rem;
  font-size: 0.95rem;
  font-weight: 500;
  text-decoration: none;
  transition: color 0.2s;
}

.site-nav a:hover,
.site-nav a.active { color: var(--color-accent); text-decoration: none; }

.nav-toggle { display: none; background: none; border: none; cursor: pointer; padding: 0.5rem; }
.nav-toggle span {
  display: block; width: 22px; height: 2px;
  background: var(--color-text); margin: 5px 0;
  transition: 0.3s;
}

/* ===== Hero (banner + text overlay) ===== */
.hero {
  position: relative;
  overflow: hidden;
}

.hero-banner {
  position: relative;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 2rem;
}

.hero-banner-image {
  position: relative;
  width: 100%;
  border-radius: 0 0 12px 12px;
  overflow: hidden;
}

.hero-banner-image > img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: cover;
  margin-top: -5%;
}

/* Gradient fade from image into white at the bottom */
.hero-banner-image::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60%;
  background: linear-gradient(
    to bottom,
    transparent 0%,
    rgba(255,255,255,0.4) 40%,
    rgba(255,255,255,0.85) 70%,
    var(--color-bg) 100%
  );
  pointer-events: none;
}

/* Profile photo + buttons overlaid in top-right of banner */
.hero-sidebar {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
}

.hero-profile {
  width: 160px;
  height: auto;
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
}

.hero-sidebar .hero-links {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
}

.hero-sidebar .hero-links .btn {
  text-align: center;
  font-size: 0.85rem;
  padding: 0.45rem 1rem;
}

/* Text overlaid on the faded lower portion of the image */
.hero-overlay {
  position: relative;
  margin-top: -13rem;
  z-index: 2;
  padding-bottom: 0.5rem;
}

.hero-text {
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}

.hero-bio { text-align: justify; }

.subtitle {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  color: var(--color-accent);
  font-weight: 600;
  margin-bottom: 1rem;
}

.hero-bio { color: var(--color-text); line-height: 1.8; margin-bottom: 1.5rem; }
.hero-bio p { font-size: 1rem; }

.hero-links { display: flex; gap: 1rem; flex-wrap: wrap; }

/* When there's no banner image, add some top padding */
.hero-no-banner .hero-overlay {
  margin-top: 0;
  padding-top: 3rem;
}

.hero-no-banner .hero-text {
  padding-left: 0;
}

/* ===== Buttons ===== */
.btn {
  display: inline-block;
  padding: 0.6rem 1.4rem;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.2s;
}

.btn { background: var(--color-accent); color: white; }
.btn:hover { background: var(--color-accent-dark); color: white; text-decoration: none; }

.btn-outline {
  background: transparent;
  color: var(--color-accent);
  border: 1.5px solid var(--color-accent);
}
.btn-outline:hover { background: var(--color-accent-light); text-decoration: none; }

.btn-small { padding: 0.35rem 0.9rem; font-size: 0.85rem; }

/* ===== Sections ===== */
.section { padding: 1.5rem 0 3rem; }
.section .container { padding-left: 2rem; }
.section-title {
  font-size: 1.8rem;
  margin-bottom: 1.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--color-accent-light);
}

/* ===== Section Headings in Page Content ===== */
.page-content h2 {
  margin-top: 2.5rem;
  margin-bottom: 0.5rem;
}

.page-content .card-grid {
  margin-top: 1.5rem;
}

/* ===== Cards ===== */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
}

.card {
  background: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 1.5rem;
  transition: box-shadow 0.2s;
  aspect-ratio: 1 / 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.card:hover { box-shadow: 0 2px 12px rgba(0,0,0,0.06); }

.card h3 a { color: var(--color-text); }
.card h3 a:hover { color: var(--color-accent); text-decoration: none; }
.card p { color: var(--color-text-light); font-size: 0.95rem; margin-top: 0.5rem; }

/* Card with background image */
.card-has-bg {
  position: relative;
  overflow: hidden;
  background-size: cover;
  background-position: center;
}

.card-has-bg::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.75);
  z-index: 0;
  transition: background 0.3s ease;
}

.card-has-bg:hover::after { background: rgba(255, 255, 255, 0.65); }

.card-has-bg h3,
.card-has-bg p,
.card-has-bg .tag,
.card-has-bg .card-actions { position: relative; z-index: 1; }

.card-actions {
  margin-top: auto;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.tag {
  display: inline-block;
  background: var(--color-accent-light);
  color: var(--color-accent);
  padding: 0.15rem 0.6rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 500;
  margin-top: 0.5rem;
  margin-right: 0.3rem;
}

.tag-muted {
  background: #f0f0f0;
  color: var(--color-text-light);
}

/* ===== Page Banner (for project landing pages) ===== */
.page-banner {
  position: relative;
  width: 100%;
  max-height: 280px;
  overflow: hidden;
  border-radius: 8px;
  margin-bottom: 2rem;
}

.page-banner img {
  width: 100%;
  height: auto;
  display: block;
}

.page-banner::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60%;
  background: linear-gradient(to bottom, transparent 0%, var(--color-bg) 100%);
  pointer-events: none;
}

/* ===== Page Content ===== */
.page-content {
  padding-top: 3rem;
  padding-bottom: 0;
}

.page-content h1 { margin-bottom: 1.5rem; }

.lead {
  font-size: 1.15rem;
  color: var(--color-text-light);
  line-height: 1.7;
  margin-bottom: 2rem;
}

/* ===== Publications ===== */
.pub-year {
  font-size: 1.3rem;
  color: var(--color-accent);
  margin-top: 2rem;
  margin-bottom: 1rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--color-border);
}

.pub-entry {
  margin-bottom: 1.5rem;
  padding-left: 1rem;
  border-left: 3px solid var(--color-accent-light);
}

.pub-title {
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 0.2rem;
  color: var(--color-text);
}

.pub-authors {
  font-size: 0.9rem;
  color: var(--color-text-light);
  margin-bottom: 0.2rem;
}

.pub-journal {
  font-size: 0.9rem;
  color: var(--color-text-light);
}

/* ===== Footer ===== */
.site-footer {
  border-top: 1px solid var(--color-border);
  padding: 2rem 0;
  margin-top: 4rem;
  text-align: center;
  color: var(--color-text-light);
  font-size: 0.9rem;
}

.footer-links { margin-bottom: 0.8rem; }
.footer-links a {
  color: var(--color-text-light);
  margin: 0 0.8rem;
  font-weight: 500;
}
.footer-links a:hover { color: var(--color-accent); }

/* ===== Gallery ===== */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}

.gallery-item {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  aspect-ratio: 4 / 3;
  background: var(--color-card-bg);
  border: 1px solid var(--color-border);
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.gallery-item:hover img { transform: scale(1.03); }

.gallery-caption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.8rem 1rem;
  background: linear-gradient(transparent, rgba(0,0,0,0.7));
  color: white;
  font-size: 0.85rem;
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.gallery-item:hover .gallery-caption { opacity: 1; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  html { font-size: 16px; }

  .hero-overlay { margin-top: -4rem; }
  .hero-text { padding-left: 0; }

  .hero-sidebar {
    position: relative;
    top: auto;
    right: auto;
    flex-direction: row;
    align-items: center;
    padding: 1rem;
    gap: 1rem;
  }

  .hero-profile { width: 100px; }

  .hero-sidebar .hero-links {
    flex-direction: row;
  }

  .subtitle { text-align: center; }

  .site-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border-bottom: 1px solid var(--color-border);
    padding: 1rem 2rem;
    flex-direction: column;
  }

  .site-nav.open { display: flex; }
  .site-nav a { margin: 0.5rem 0; margin-left: 0; }

  .nav-toggle { display: block; }

  .section .container { padding-left: 2rem; }
  .page-content { padding-top: 2rem; padding-bottom: 0; }
  .card-grid { grid-template-columns: 1fr; }
  .gallery-grid { grid-template-columns: 1fr; }
}
