/*=================================================
  RESEARCH PAGE - Media Object Layout
=================================================*/

.hero-section .hero-title {
  margin-bottom: 0.625rem;
}

.hero-section .hero-subtitle {
  max-width: 60ch;
  margin: 0 auto;
  color: var(--color-slate);
  text-align: center;
}

/*=================================================
  RESEARCH GRID & CARDS
=================================================*/

.research-grid {
  display: grid;
  gap: var(--space-2xl);
}

/*
  ResearchCard: Media-Object Layout
  Two columns on desktop/tablet, stack on mobile
*/
.research-card {
  background: var(--color-white);
  color: var(--color-charcoal);
  border-radius: var(--border-radius-md);
  padding: clamp(1.5rem, 1.25rem + 0.5vw, var(--card-padding));
  border: var(--border-width) solid var(--color-silver);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  box-shadow: none;
  transform: translateY(0);
  transition: transform var(--transition-base), border-color var(--transition-base);
}

.research-card:hover {
  border-color: var(--color-sage);
  transform: translateY(-2px);
}

/* First research card special styling - matches site pattern */
.research-card:first-child {
  border: 2px solid var(--color-sage);
}

.research-card-content {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  align-items: stretch;
}

.research-card-content > * {
  min-width: 0; /* Prevent overflow */
}

/*=================================================
  MEDIA FRAME - Fixed-size container
=================================================*/

.research-card-visual {
  width: 100%;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
}

.figure {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
  height: auto;
}

/* Media frame wrapper */
.figure-grid,
.figure-carousel {
  width: 100%;
  min-height: clamp(220px, 28vw, 380px);
  max-height: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--border-radius-md);
  overflow: hidden;
  background: var(--color-white);
  border: var(--border-width) solid rgba(74, 87, 89, 0.15);
  box-shadow: 0 18px 45px rgba(74, 87, 89, 0.08);
}

/*
  Image object-fit handling
  Default: cover for photos/bitmaps
  Use contain for SVG diagrams via data attribute
*/
.figure-grid picture,
.figure-grid img,
.figure-carousel picture,
.figure-carousel img {
  width: 100%;
  height: 100%;
  object-fit: cover; /* Default: crop elegantly */
  object-position: center;
  display: block;
}

/* SVG or diagram images: contain instead of cover */
.figure-grid[data-aspect="contain"] img,
.figure-carousel[data-aspect="contain"] img,
.figure-grid img[src$=".svg"],
.figure-carousel img[src$=".svg"] {
  object-fit: contain;
  padding: var(--space-sm);
}

/* Ensure diagrams never crop inside the media rail */
.research-page .figure-grid[data-aspect="contain"] img {
  object-fit: contain;
  width: 100%;
  height: 100%;
  padding: var(--space-sm);
}

/* Support for multi-image grids within media frame */
.figure-grid.cols-2,
.figure-grid.cols-3 {
  display: grid;
  gap: 0.5rem;
  padding: var(--space-xs);
}

.figure-grid.cols-2 {
  grid-template-columns: repeat(2, 1fr);
}

.figure-grid.cols-3 {
  grid-template-columns: repeat(3, 1fr);
}

.figure-grid.cols-2 img,
.figure-grid.cols-3 img {
  width: 100%;
  height: 100%;
  min-height: 80px;
  object-fit: cover;
  border-radius: calc(var(--border-radius-md) / 2);
}

/* Carousel specific adjustments */
.figure-carousel {
  position: relative;
}

.figure-carousel-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.carousel-indicators {
  bottom: 0.5rem;
}

.carousel-control-prev,
.carousel-control-next {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--color-white);
  border: var(--border-width) solid var(--color-sage);
  opacity: 1;
  transition: background-color var(--transition-base), border-color var(--transition-base);
}

.carousel-control-prev:hover,
.carousel-control-next:hover,
.carousel-control-prev:focus-visible,
.carousel-control-next:focus-visible {
  background: var(--tint-sage-08);
  border-color: var(--color-sage);
  opacity: 1;
}

.carousel-control-prev-icon,
.carousel-control-next-icon {
  width: 1.25rem;
  height: 1.25rem;
  filter: brightness(0) saturate(100%) invert(67%) sepia(11%) saturate(707%) hue-rotate(76deg) brightness(91%) contrast(86%);
}

@media (max-width: 768px) {
  .carousel-control-prev,
  .carousel-control-next {
    width: 38px;
    height: 38px;
  }

  .carousel-control-prev-icon,
  .carousel-control-next-icon {
    width: 1.125rem;
    height: 1.125rem;
  }
}

/* Caption styling */
figcaption {
  font-size: 0.85rem;
  color: rgba(74, 87, 89, 0.75);
  line-height: 1.5;
  text-align: center;
  margin-top: auto;
}

/*=================================================
  CONTENT COLUMN
=================================================*/

.research-card-text {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  width: 100%;
}

/* Title - matching Publication card style */
.research-card .title,
.research-card .card-title {
  margin: 0;
  font-family: var(--font-family-heading);
  font-weight: var(--weight-regular);
  font-size: clamp(1.45rem, 1.3rem + 0.3vw, 1.8rem);
  line-height: var(--line-height-heading);
  color: var(--color-sage);
  border-bottom: 2px solid var(--border-color);
  padding-bottom: var(--space-sm);
}

/* DOI link inline with title */
.doi-link {
  display: inline-flex;
  align-items: center;
  margin-left: 0.5rem;
  color: var(--color-sage);
  font-size: 0.875rem;
  text-decoration: none;
  opacity: 0.7;
  transition: opacity var(--transition-base);
}

.doi-link:hover {
  opacity: 1;
  text-decoration: none;
}

/* Abstract/teaser - limited to readable line length */
.research-card .teaser {
  margin: 0;
  color: var(--text-secondary-color);
  line-height: 1.6;
  width: 100%;
  max-width: none;

  /* Clamp to 4-6 lines with ellipsis */
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.research-card-text p {
  max-width: none;
}

/*=================================================
  META TAGS & CHIPS - Matching global style
=================================================*/

.meta {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin: 0;
  padding: 0;
  border-top: none;
  align-items: center;
}

.meta .tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: var(--font-size-xs);
  font-family: var(--font-family-meta);
  font-weight: var(--weight-regular);
  letter-spacing: 0;
  border: var(--border-width) solid rgba(237, 175, 184, 0.2);
  background: var(--tint-blush-08);
  color: var(--color-sage-dark);
}

/* Alternate tag colors for visual variety */
.meta .tag:nth-child(4n + 2) {
  background: rgba(176, 196, 177, 0.064);
  border-color: rgba(176, 196, 177, 0.2);
  color: var(--color-sage-dark);
}

.meta .tag:nth-child(4n + 3) {
  background: rgba(237, 175, 184, 0.072);
  border-color: rgba(237, 175, 184, 0.2);
  color: var(--accent-color);
}

.meta .tag:nth-child(4n + 4) {
  background: rgba(74, 87, 89, 0.032);
  border-color: rgba(74, 87, 89, 0.15);
  color: var(--text-secondary-color);
}

/*=================================================
  PLACEHOLDERS & EDITORIAL SECTION
=================================================*/

.figure-grid.media-placeholder {
  background: linear-gradient(135deg, var(--tint-sage-12) 0%, var(--tint-blush-08) 100%);
  color: var(--color-sage);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(2.5rem, 2rem + 0.5vw, 3.25rem);
}

.figure-grid.media-placeholder i {
  opacity: 0.45;
}

.editorial-section {
  margin-top: var(--space-2xl);
}

.service-header h2 {
  margin-bottom: 0.35rem;
  font-family: var(--font-family-heading);
  font-weight: var(--weight-regular);
  font-size: clamp(1.75rem, 1.4rem + 0.6vw, 2.15rem);
  color: var(--color-sage-dark);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.service-header h2 i {
  color: var(--accent-color);
}

.service-summary {
  margin: 0;
  color: var(--text-secondary-color);
  max-width: 65ch;
}

.service-grid {
  margin-top: var(--space-md);
  display: grid;
  gap: var(--grid-gap);
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.service-card {
  background: var(--color-white);
  border-radius: var(--border-radius-md);
  border: var(--border-width) solid var(--color-silver);
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.02);
}

.service-card-title {
  display: flex;
  gap: var(--space-sm);
  align-items: flex-start;
}

.service-card-title i {
  color: var(--accent-color);
  font-size: 1.25rem;
  margin-top: 0.15rem;
}

.service-card-heading {
  margin: 0 0 var(--space-xs) 0;
  font-family: var(--font-family-heading);
  font-weight: var(--weight-regular);
  font-size: clamp(1.15rem, 1rem + 0.3vw, 1.4rem);
  color: var(--color-sage-dark);
  line-height: 1.35;
}

.service-card ul {
  list-style: disc;
  margin: 0 0 0 1rem;
  padding: 0 0 0 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.service-card li {
  color: var(--color-slate);
  line-height: 1.5;
  font-family: var(--font-family-base);
}

.editorial-layout {
  display: grid;
  gap: var(--space-lg);
  grid-template-columns: minmax(240px, 1fr) minmax(0, 2fr);
  align-items: start;
}

.editorial-intro p {
  margin: 0;
  color: var(--text-secondary-color);
  line-height: 1.65;
  max-width: 60ch;
}

.editorial-roles {
  display: grid;
  gap: var(--space-md);
}

.role-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-family-heading);
  font-weight: var(--weight-regular);
  color: var(--color-sage-dark);
  margin-bottom: var(--space-sm);
}

.role-title i {
  color: var(--accent-color);
}

.role-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.35rem;
}

.role-list li {
  font-size: var(--font-size-base);
  color: var(--color-slate);
  line-height: 1.6;
}

/*=================================================
  RESPONSIVE BREAKPOINTS
=================================================*/

/* Tablet: 768px-992px */
@media (max-width: 992px) {
  .research-grid {
    gap: var(--space-xl);
  }

  .figure-grid,
  .figure-carousel {
    min-height: clamp(200px, 36vw, 340px);
    max-height: none;
  }

  .editorial-layout {
    grid-template-columns: minmax(200px, 1fr) minmax(0, 1fr);
  }
}

/* Mobile: < 768px - Stack vertically */
@media (max-width: 768px) {
  .research-card {
    padding: 1.4rem;
  }

  .research-card:first-child {
    padding: 1.55rem;
  }

  .figure-grid,
  .figure-carousel {
    min-height: clamp(190px, 52vw, 300px);
    max-height: none;
  }

  .research-card .teaser {
    -webkit-line-clamp: 5; /* Fewer lines on mobile */
  }

  .editorial-layout {
    grid-template-columns: 1fr;
    gap: var(--space-lg);
  }

  /* Multi-column grids collapse on mobile */
  .figure-grid.cols-3 {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Small mobile: < 576px */
@media (max-width: 576px) {
  .research-card {
    padding: 1.2rem;
  }

  .figure-grid,
  .figure-carousel {
    min-height: clamp(170px, 60vw, 260px);
  }

  /* All multi-column grids become single column */
  .figure-grid.cols-2,
  .figure-grid.cols-3 {
    grid-template-columns: 1fr;
  }

  .figure-grid.cols-2 img,
  .figure-grid.cols-3 img {
    min-height: 120px;
  }
}

/*=================================================
  ACCESSIBILITY & MOTION
=================================================*/

@media (prefers-reduced-motion: reduce) {
  .research-card,
  .research-card:hover {
    transform: none;
    transition: none;
  }

  .carousel-control-prev,
  .carousel-control-next {
    transition: none;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .research-card {
    border-width: 2px;
  }

  .figure-grid,
  .figure-carousel {
    border-width: 2px;
  }
}
