/* Global typography improvements */
body {
  line-height: 1.4;
}

/* Large name styling */
.large-name {
  display: block;
  font-size: 2.5em;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 0.5em;
}

@media (max-width: 768px) {
  .large-name {
    font-size: 1.6em;
  }
}

/* Header section with avatar and text side by side */
.header-section {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 2em;
  margin-bottom: 2em;
  margin-top: 3em;
}

.header-section .avatar {
  flex-shrink: 0;
  margin: 0 !important;
  padding: 0 !important;
}

.header-section .avatar img {
  margin: 0 !important;
  padding: 0 !important;
  display: block;
}

.header-section .header-text {
  flex: 1;
}

.header-section .header-text h1 {
  margin-top: 0 !important;
  margin-bottom: 0.5em;
  padding-top: 0 !important;
  font-size: 3em;
  line-height: 1.2;
}

.header-section .header-text p {
  margin: 0.2em 0;
  font-size: 1.05em;
  color: #444;
}

.header-section .header-text p a {
  color: inherit;
}

@media (max-width: 768px) {
  .header-section {
    flex-direction: column;
    gap: 1em;
    align-items: center;
  }

  .header-section .avatar {
    order: -1;
  }

  .header-section .avatar img {
    width: 120px !important;
    height: 120px !important;
    max-width: 120px !important;
  }

  .header-section .header-text {
    text-align: center;
  }

  .header-section .header-text h1 {
    font-size: 1.8em;
  }
}

/* Affiliation logos */
.affiliation-logos {
  display: flex;
  flex-wrap: nowrap;
  gap: 2.5em;
  align-items: flex-start;
  justify-content: center;
  margin-top: 1.5em;
  margin-bottom: 2em;
  width: 100%;
  text-align: center;
}

.affiliation-logos .affiliation-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5em;
  flex-shrink: 0;
}

.affiliation-logos img {
  height: 60px;
  width: 60px;
  object-fit: contain;
  display: block;
  margin: 0;
}

.affiliation-logos .affiliation-name {
  font-size: 1em;
  color: #222;
  font-weight: 600;
  margin-top: 0.3em;
}

.affiliation-logos .affiliation-title {
  font-size: 0.85em;
  color: #888;
  font-weight: 400;
  margin-top: -0.2em;
}

@media (max-width: 768px) {
  .affiliation-logos {
    flex-wrap: wrap;           /* Enable wrapping to multiple rows */
    gap: 0.8em 1em;           /* Tighter spacing: 0.8em vertical, 1em horizontal */
    justify-content: center;   /* Center wrapped items */
  }

  .affiliation-logos .affiliation-item {
    flex-shrink: 1;            /* Allow items to shrink */
    min-width: 0;              /* Enable shrinking below content size */
  }

  .affiliation-logos img {
    height: 40px;              /* Reduce from 48px */
    width: 40px;
  }

  .affiliation-logos .affiliation-name {
    font-size: 0.85em;         /* Reduce institution name size */
  }

  .affiliation-logos .affiliation-title {
    font-size: 0.75em;         /* Reduce role/period text size */
  }
}

/* Intro section box */
.intro-box {
  margin-bottom: 2em;
  text-align: justify;
}

.intro-box p {
  text-align: justify;
  margin-bottom: 1em;
}

.intro-box p:last-child {
  margin-bottom: 0;
}

#content ul ul {
  padding-left: 0.75em;
}

/* Profile header styling */
.profile-header {
  display: flex;
  flex-direction: column;
  margin: 2em 0 3em;
}

.profile-title h1 {
  margin-top: 0.5em;
  margin-bottom: 0.2em;
  font-size: 2em;
}

.profile-title .subtitle {
  font-size: 1.2em;
  color: #555;
  margin-top: 0;
  margin-bottom: 1em;
}

.profile-details p {
  margin-bottom: 0.7em;
}

.profile-links {
  margin-top: 1em;
}

.profile-links a {
  text-decoration: none;
  font-weight: 500;
}

.profile-links a:hover {
  text-decoration: underline;
}

@media (max-width: 768px) {
  .profile-header {
    margin: 1em 0 2em;
  }
  
  .profile-title h1 {
    font-size: 1.7em;
  }
  
  .profile-title .subtitle {
    font-size: 1.1em;
  }
}

h1, h2, h3, h4, h5, h6 {
  margin-top: 1em;
  margin-bottom: 0.5em;
}

h2 {
  font-size: 1.6em;
  border-bottom: 1px solid #eaecef;
  padding-bottom: 0.2em;
}

h3 {
  font-size: 1.3em;
}

p {
  margin-bottom: 0.8em;
}

section {
  margin-bottom: 1.5em;
}

/* Improved spacing between sections */
#content article {
  margin-bottom: 2em;
}

/* Custom styles for publications with teaser images */
.publication-with-teaser {
  display: flex;
  margin-bottom: 0.8em;
  align-items: center;
  padding: 0.8em;
  border-radius: 8px;
  transition: all 0.3s ease;
  gap: 16px;
}

.publication-teaser {
  flex: 0 0 180px;
  margin-right: 0;
  transition: transform 0.3s ease;
}

.teaser-container {
  position: relative;
  width: 100%;
  overflow: hidden;
  border-radius: 6px;
  background-color: #f5f5f5;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  transition: all 0.3s ease;
}

.teaser-image,
#content .teaser-container .teaser-image {
  position: relative;
  width: 100%;
  height: auto;
  margin: 0;
  padding: 0;
  display: block;
  transition: opacity 0.3s ease;
}

.teaser-video,
#content .teaser-container .teaser-video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.3s ease;
}

/* Show video/hover-image on hover */
.teaser-container.has-hover:hover .teaser-image,
.teaser-container.has-hover.active .teaser-image {
  opacity: 0;
}

.teaser-container:hover .teaser-video,
.teaser-container.active .teaser-video {
  opacity: 1;
}

/* Hover hint badge */
.teaser-hint {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  font-size: 0.7em;
  padding: 4px 8px;
  border-radius: 4px;
  z-index: 10;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.teaser-container:hover .teaser-hint,
.teaser-container.active .teaser-hint {
  opacity: 0;
}

/* Hover image specific rules - needs high specificity to override theme's #content img */
#content .teaser-container .teaser-hover-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.3s ease;
}

#content .teaser-container:hover .teaser-hover-image,
#content .teaser-container:hover .teaser-video,
#content .teaser-container.active .teaser-hover-image,
#content .teaser-container.active .teaser-video {
  opacity: 1;
}

.publication-content {
  flex: 1;
}

/* Hover effects for publications */
.publication-with-teaser:hover {
  background-color: rgba(0,0,0,0.02);
  box-shadow: 0 3px 10px rgba(0,0,0,0.1);
}

.publication-with-teaser:hover .teaser-container {
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
  transform: translateY(-2px);
}

/* Improved typography for publication content */
.publication-content .publication-meta {
  line-height: 1.5;
}

.publication-content .publication-title {
  font-weight: bold;
  font-size: 1em;
  text-decoration: none;
}

.publication-content .publication-title:hover {
  text-decoration: underline;
}

.publication-content .authors {
  font-size: 0.9em;
  color: #444;
}

.publication-content .authors a,
.publication-content .authors strong {
  font-size: inherit;
}

.publication-content .venue {
  font-size: 0.9em;
}

.publication-content .publication-abstract {
  margin-top: 0.4em;
  font-size: 0.9em;
  line-height: 1.4;
  color: #555;
}

.publication-content .publication-links {
  font-size: 0.9em;
}

.publication-content .publication-links a,
.publication-content .publication-links strong {
  font-size: inherit;
}

.publication-content .publication-links a {
  text-decoration: none;
}

.publication-content .publication-links a:hover {
  text-decoration: underline;
}

/* GitHub star counts on publication code links */
.publication-content .publication-links .gh-stars {
  display: inline-block; /* confines the anchor's hover underline to the word "code" */
  margin-left: 0.35em;
  font-size: 0.85em;
  color: #888;
}

/* Publication placeholder styles */
.publication-placeholder {
  width: 100%;
  height: 200px;
  display: flex;
  justify-content: center;
  align-items: center;
  color: white;
  text-align: center;
  border-radius: 4px;
}

.publication-placeholder h4 {
  margin: 0 0 10px 0;
  font-size: 1.2em;
}

.publication-placeholder p {
  margin: 0;
  font-size: 0.9em;
  opacity: 0.9;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .publication-with-teaser {
    flex-direction: column;
    padding: 0.8em;
  }
  
  .publication-teaser {
    flex: 0 0 100%;
    margin-right: 0;
    margin-bottom: 0em;
  }
  
  h2 {
    font-size: 1.5em;
  }
  
  h3 {
    font-size: 1.2em;
  }
  
  .publication-content h3 {
    font-size: 1.2em;
  }
}
