/* ==========================================================================
   Project-Specific Styles (Compatible with styles.css & MDB)
   ========================================================================== */

:root {
  /* Mapping project-specific variables to main styles.css variables */
  --project-primary: var(--primary, #009688);
  --project-primary-dark: var(--primary-dark, #005f4f);
  --project-accent: var(--accent, #108171);
  --project-accent-light: var(--accent-light, #16c78c);
  --project-surface: var(--white, #fff);
  --project-bg: var(--background, #f8f9fa);
  --project-text-muted: var(--gray, #757575);
  --project-border: #e0e0e0;
  
  /* Spacing & Radius tokens for consistency */
  --space-2: 0.125rem;
  --space-4: 0.25rem;
  --space-8: 0.5rem;
  --space-12: 0.75rem;
  --space-16: 1rem;
  --space-24: 1.5rem;
  --space-32: 2rem;
  
  --radius-sm: 0.25rem;
  --radius-md: 0.5rem;
  --radius-lg: 1rem;
  --radius-full: 9999px;
  
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
}

/* ==========================================================================
   Project Header & Meta
   ========================================================================== */

.project-header {
  /* Ensure a strong gradient background */
  background: linear-gradient(135deg, var(--project-primary) 0%, var(--project-accent) 100%);
  color: #fff;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: var(--space-24);
  margin-bottom: 0; /* It's a card header now, so remove margin */
  border-bottom: 0;
}

/* 
   FORCE OVERRIDES for Bootstrap's text-muted 
   The HTML uses .text-muted which is gray; we need white for the green background.
*/
.project-header .text-muted {
  color: rgba(255, 255, 255, 0.85) !important;
}

.project-header h6, 
.project-header h5,
.project-header .small,
.project-header small {
  color: #fff !important;
  font-weight: 500;
}

.project-header .badge {
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
  font-size: 0.85rem;
  padding: 0.5em 1em;
}

.project-status-badge {
  position: absolute;
  top: var(--space-16);
  right: var(--space-16);
  z-index: 2;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.project-funding {
  display: inline-block;
  background: rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-12);
  backdrop-filter: blur(5px);
  border: 1px solid rgba(255,255,255,0.2);
  margin-top: var(--space-8);
  font-size: 0.9rem;
}

/* ==========================================================================
   Project Navigation
   ========================================================================== */

.project-nav {
  position: -webkit-sticky;
  position: sticky;
  top: 80px; /* Adjust based on main navbar height */
  background: var(--project-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-16);
  margin-bottom: var(--space-24);
  z-index: 10;
  border: 1px solid var(--project-border);
}

.project-nav .nav-pills .nav-link {
  color: var(--project-primary);
  border-radius: var(--radius-md);
  transition: all 0.3s ease;
  font-weight: 600;
  margin-bottom: var(--space-4);
}

.project-nav .nav-pills .nav-link:hover {
  background-color: rgba(0, 150, 136, 0.1); /* light primary */
}

.project-nav .nav-pills .nav-link.active {
  background-color: var(--project-primary);
  color: #fff;
  box-shadow: 0 2px 5px rgba(0, 150, 136, 0.4);
}

/* ==========================================================================
   Metrics Cards
   ========================================================================== */

.project-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--space-16);
  margin: var(--space-24) 0;
}

.metric-card {
  background: var(--project-surface);
  border-radius: var(--radius-md);
  padding: var(--space-16);
  text-align: center;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--project-border);
  transition: transform 0.2s ease;
}

.metric-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--project-accent-light);
}

.metric-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--project-primary);
  display: block;
  line-height: 1.2;
}

.metric-label {
  font-size: 0.85rem;
  color: var(--project-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  margin-top: var(--space-4);
}

/* ==========================================================================
   Timeline
   ========================================================================== */

.project-timeline {
  position: relative;
  padding: var(--space-24) 0;
  max-width: 800px;
  margin: 0 auto;
}

/* Vertical Line */
.project-timeline::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--project-accent-light);
  transform: translateX(-50%);
  opacity: 0.5;
}

.timeline-item {
  position: relative;
  margin: var(--space-24) 0;
  width: 100%;
  clear: both;
}

/* Dot on the line */
.timeline-item::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 1.5rem; /* Align with card title approx */
  width: 16px;
  height: 16px;
  background: var(--project-surface);
  border: 4px solid var(--project-primary);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
  box-shadow: 0 0 0 4px rgba(255,255,255,0.5);
}

.timeline-content {
  position: relative;
  width: 45%;
  background: var(--project-surface);
  padding: var(--space-16);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--project-border);
  transition: transform 0.3s ease;
}

.timeline-content:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* Alternating sides */
.timeline-item:nth-child(odd) .timeline-content {
  float: left;
  margin-right: auto;
  text-align: right;
}

.timeline-item:nth-child(even) .timeline-content {
  float: right;
  margin-left: auto;
  text-align: left;
}

/* Arrows */
.timeline-item:nth-child(odd) .timeline-content::after {
  content: " ";
  position: absolute;
  top: 1rem;
  right: -10px;
  border-width: 10px 0 10px 10px;
  border-color: transparent transparent transparent var(--project-border);
  border-style: solid;
}

.timeline-item:nth-child(even) .timeline-content::after {
  content: " ";
  position: absolute;
  top: 1rem;
  left: -10px;
  border-width: 10px 10px 10px 0;
  border-color: transparent var(--project-border) transparent transparent;
  border-style: solid;
}

/* Clearfix for floats */
.timeline-item::after {
  content: "";
  display: table;
  clear: both;
}

/* ==========================================================================
   Publications List
   ========================================================================== */

.project-publications-container {
  background: var(--project-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-16);
  border: 1px solid var(--project-border);
}

.project-publications {
  max-height: 500px;
  overflow-y: auto;
  padding-right: var(--space-8);
}

/* Scrollbar styling */
.project-publications::-webkit-scrollbar {
  width: 6px;
}
.project-publications::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: var(--radius-sm);
}
.project-publications::-webkit-scrollbar-thumb {
  background: var(--project-accent-light);
  border-radius: var(--radius-sm);
}
.project-publications::-webkit-scrollbar-thumb:hover {
  background: var(--project-primary);
}

.publication-item {
  padding: var(--space-12);
  margin-bottom: var(--space-12);
  border-left: 3px solid var(--project-accent-light);
  background: #fafafa;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  transition: all 0.2s ease;
}

.publication-item:hover {
  border-left-color: var(--project-primary);
  background: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  transform: translateX(4px);
}

/* Header for publications section */
.project-publications-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-16);
  padding-bottom: var(--space-8);
  border-bottom: 2px solid #f1f1f1;
}

.publications-count {
  background: var(--project-primary);
  color: #fff;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: bold;
}

/* ==========================================================================
   Team Members
   ========================================================================== */

.team-member-card {
  background: var(--project-surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  height: 100%;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  border: 1px solid var(--project-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-16);
}

.team-member-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-md);
  border-color: var(--project-accent-light);
}

.team-member-avatar {
  width: 100px;
  height: 100px;
  object-fit: cover;
  border-radius: 50%;
  border: 3px solid var(--project-accent-light);
  margin-bottom: var(--space-12);
  transition: border-color 0.3s ease;
}

.team-member-card:hover .team-member-avatar {
  border-color: var(--project-primary);
}

.team-member-name {
  font-weight: 700;
  color: #333;
  margin-bottom: var(--space-4);
  text-align: center;
}

.team-member-role {
  color: var(--project-text-muted);
  font-size: 0.9rem;
  text-align: center;
}

/* ==========================================================================
   Status Indicators
   ========================================================================== */

.status-active {
  background: linear-gradient(45deg, var(--success, #44aa54), var(--project-accent-light));
  color: #fff;
}

.status-completed {
  background: linear-gradient(45deg, var(--gray, #757575), #9e9e9e);
  color: #fff;
}

.status-planned {
  background: linear-gradient(45deg, var(--warning, #ffd700), #ffca28);
  color: #fff; /* or dark text if warning is too light */
  text-shadow: 0 1px 1px rgba(0,0,0,0.1);
}

/* ==========================================================================
   Loading States
   ========================================================================== */

.project-loading {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 200px;
  color: var(--project-text-muted);
}

.project-skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
  border-radius: var(--radius-sm);
  min-height: 1rem;
  margin-bottom: var(--space-8);
}

@keyframes loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

@media (max-width: 992px) {
  .project-nav {
    position: static; /* Unstick on smaller screens if content stacks */
    margin-bottom: var(--space-16);
  }
}

@media (max-width: 768px) {
  .project-header {
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    padding: var(--space-16);
    text-align: center;
  }

  .project-status-badge {
    position: relative;
    top: auto;
    right: auto;
    display: inline-block;
    margin-bottom: var(--space-12);
  }

  /* Timeline becomes single column on mobile */
  .project-timeline::before {
    left: 20px;
  }

  .timeline-item {
    margin-bottom: var(--space-16);
  }

  .timeline-item::before {
    left: 20px;
  }

  .timeline-content {
    width: calc(100% - 50px);
    float: right !important;
    margin-left: 50px !important;
    margin-right: 0 !important;
    text-align: left !important;
  }

  /* Fix arrows for mobile */
  .timeline-item:nth-child(odd) .timeline-content::after,
  .timeline-item:nth-child(even) .timeline-content::after {
    left: -10px;
    right: auto;
    border-width: 10px 10px 10px 0;
    border-color: transparent var(--project-border) transparent transparent;
  }
}


/* ==========================================================================
   Project Info Grid & Spacing
   ========================================================================== */

.project-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); /* Wider columns */
  gap: var(--space-24); /* Increased gap */
  margin-top: var(--space-8);
}

.info-item {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.info-label {
  color: var(--project-text-muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  margin-bottom: var(--space-8);
  display: flex;
  align-items: center;
}

.info-value {
  font-size: 1rem;
  font-weight: 500;
  color: #2c3e50;
  
  /* Flexbox to handle taller items like badges cleanly */
  display: flex;
  align-items: center; 
  min-height: 32px; /* Enforce a minimum height for alignment */
  line-height: 1.5;
}

/* Fix for the Status Badge causing layout jumps */
.info-value .badge {
  font-size: 0.9rem;
  padding: 0.5rem 1rem;
  line-height: 1; /* Reset line-height inside badge */
  display: inline-flex;
  align-items: center;
}

/* Link styling in info grid */
.group-link {
  color: var(--project-primary);
  text-decoration: none;
  border-bottom: 1px dotted transparent;
  transition: all 0.2s;
}

.group-link:hover {
  color: var(--project-accent);
  border-bottom-color: var(--project-accent);
}

/* ==========================================================================
   Horizontal Year Timeline (---🔵---)
   ========================================================================== */

.duration-timeline {
  width: 100%;
  padding: 10px 0; /* Padding for the node overflow */
  margin-top: 5px;
}

.year-timeline {
  display: flex;
  justify-content: space-between;
  align-items: flex-start; /* Align to top so years hang below */
  position: relative;
  width: 100%;
  padding-top: 10px; /* Space for the top half of dots */
}

/* The Connecting Line */
.year-timeline::before {
  content: "";
  position: absolute;
  top: 16px; /* Align with the center of the 12px dot (approx) */
  left: 0;
  right: 0;
  height: 3px;
  background-color: #e9ecef; /* Muted line color */
  z-index: 1;
  border-radius: 4px;
}

/* The Year Node Wrapper */
.year-dot {
  position: relative;
  z-index: 2; /* Sit on top of the line */
  display: flex;
  flex-direction: column;
  align-items: center;
  
  /* Typography for the year label */
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--project-text-muted);
  margin-top: 4px; /* Push text down slightly */
}

/* The Circle Node (Pseudo-element) */
.year-dot::before {
  content: "";
  display: block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background-color: #fff; /* White center */
  border: 3px solid #ced4da; /* Gray border by default */
  margin-bottom: 8px; /* Spacing between dot and year text */
  box-shadow: 0 0 0 4px #fff; /* White halo to mask the line behind it */
  transition: all 0.3s ease;
}

/* Active State (The Blue Nodes) */
.year-dot.active {
  color: var(--project-primary); /* Active year text color */
}

.year-dot.active::before {
  background-color: var(--project-primary); /* Filled center */
  border-color: var(--project-primary); /* Filled border */
  transform: scale(1.2); /* Make active nodes slightly larger */
  box-shadow: 0 0 0 4px #fff, 0 0 10px rgba(0, 150, 136, 0.4); /* Glow effect */
}

/* Muted State (Future/Past inactive) */
.year-dot.muted {
  opacity: 0.7;
}

.year-dot.muted::before {
  background-color: #e9ecef;
  border-color: #adb5bd;
}

@media (max-width: 480px) {
  .metric-value {
    font-size: 1.75rem;
  }
  
  .project-info-grid {
    grid-template-columns: 1fr;
  }
  
  .team-member-avatar {
    width: 80px;
    height: 80px;
  }
}
