/* Timeline Module Styles */

.timeline-module {
  position: relative;
  width: 100%;
  overflow: hidden;
}

/* Lazy loading optimization */
.timeline-module[data-lazy="true"] {
  content-visibility: auto;
  contain-intrinsic-size: 0 600px;
}

/* Header Section */
.timeline-header {
  text-align: center;
  margin-bottom: 0;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.timeline-title {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  line-height: 1.2;
}

.timeline-subtitle {
  font-size: 1.125rem;
  opacity: 0.8;
  margin-bottom: 1rem;
}

.timeline-divider {
  display: block;
  height: 3px;
  width: 80px;
  border-radius: 2px;
  margin-top: 1rem;
}

/* Timeline Container */
.timeline-container {
  position: relative;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  padding-top: var(--header-spacing, 2rem);
}

/* Timeline Line */
.timeline-line {
  position: absolute;
  width: 3px;
  top: 0;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  border-radius: 2px;
  z-index: 1;
}

/* Timeline Items */
.timeline-item {
  position: relative;
  display: flex;
  align-items: center;
  z-index: 2; /* Ensures dots stack above timeline-line (z-index: 1) */
}

/* Hidden start state ONLY in animation mode (data-animation rendered on the
   module root). Without animations — or with JS disabled and no animation — the
   items render visibly instead of being stuck at opacity:0. */
[data-animation="true"] .timeline-item {
  opacity: 0;
  transform: translateY(30px);
}

.timeline-item.animated {
  opacity: 1;
  transform: translateY(0);
}

/* Timeline Dot - size controlled by --dot-size CSS variable */
.timeline-dot {
  position: absolute;
  width: var(--dot-size, 3rem);
  height: var(--dot-size, 3rem);
  border-radius: 50%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  border: 3px solid var(--color-bg);
  box-shadow: 0 2px 8px var(--color-border);
  background: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.timeline-item.highlight .timeline-dot {
  width: calc(var(--dot-size, 3rem) * 1.3);
  height: calc(var(--dot-size, 3rem) * 1.3);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--color-primary, #007bff) 70%, transparent);
  }
  70% {
    box-shadow: 0 0 0 10px color-mix(in srgb, var(--color-primary, #007bff) 0%, transparent);
  }
  100% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--color-primary, #007bff) 0%, transparent);
  }
}

/* Timeline Icon - scales with dot size */
.timeline-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--dot-size, 3rem) * 0.5);
  z-index: 4;
  pointer-events: none;
  line-height: 1;
  /* The dot is always var(--color-primary), so pair the glyph with the
     primary's contrast colour (not the page text colour, which goes dark on
     the dot in light mode and caused the dark-on-dark star). This is correct
     in light mode, dark mode and on mobile because the dot bg never changes.
     The text-shadow hugs the glyph outline for extra separation and also
     lifts the full-colour emoji (✓★♥ take the colour; emoji ignore it). */
  color: var(--color-primary-contrast, #fff);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

/* Timeline Content */
.timeline-content {
  width: calc(50% - 40px);
  padding: 0;
}

.timeline-card {
  background: var(--color-bg);
  border-radius: 8px;
  padding: 1.5rem;
  box-shadow: 0 3px 12px var(--color-border);
  position: relative;
  transition: all 0.3s ease;
}

.timeline-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 20px var(--color-border);
}

.timeline-card::before {
  content: '';
  position: absolute;
  top: 50%;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 10px;
  border-color: transparent;
  transform: translateY(-50%);
}

/* Date Badge */
.timeline-date {
  display: inline-block;
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.5rem;
  opacity: 0.7;
}

.timeline-event-title {
  font-size: 1.375rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  line-height: 1.3;
}

.timeline-description {
  line-height: 1.6;
  opacity: 0.9;
}

.timeline-description p {
  margin: 0.5rem 0;
}

.timeline-description ul,
.timeline-description ol {
  margin: 0.5rem 0;
  padding-left: 1.5rem;
}

/* Layout: Alternating */
.timeline-layout-alternating .timeline-item:nth-child(odd) {
  flex-direction: row-reverse;
}

.timeline-layout-alternating .timeline-item:nth-child(odd) .timeline-content {
  margin-left: auto;
  text-align: right;
}

.timeline-layout-alternating .timeline-item:nth-child(even) .timeline-content {
  margin-right: auto;
}

.timeline-layout-alternating .timeline-item:nth-child(odd) .timeline-card::before {
  left: -10px;
  border-color: transparent var(--card-bg, var(--color-bg, white)) transparent transparent;
}

.timeline-layout-alternating .timeline-item:nth-child(even) .timeline-card::before {
  right: -10px;
  border-color: transparent transparent transparent var(--card-bg, var(--color-bg, white));
}

/* Layout: Left */
.timeline-layout-left .timeline-line {
  left: 40px;
}

.timeline-layout-left .timeline-dot {
  left: 40px;
}

.timeline-layout-left .timeline-content {
  width: calc(100% - 80px);
  margin-left: 80px;
}

.timeline-layout-left .timeline-card::before {
  left: -10px;
  border-color: transparent var(--card-bg, var(--color-bg, white)) transparent transparent;
}

/* Layout: Right */
.timeline-layout-right .timeline-line {
  left: calc(100% - 40px);
}

.timeline-layout-right .timeline-dot {
  left: calc(100% - 40px);
}

.timeline-layout-right .timeline-content {
  width: calc(100% - 80px);
  margin-right: 80px;
  text-align: right;
}

.timeline-layout-right .timeline-card::before {
  right: -10px;
  border-color: transparent transparent transparent var(--card-bg, var(--color-bg, white));
}

/* Layout: Centered */
.timeline-layout-centered .timeline-content {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
}

.timeline-layout-centered .timeline-card::before {
  display: none;
}

.timeline-layout-centered .timeline-dot {
  top: 0;
  margin-top: 1.5rem;
}

/* Highlight State */
.timeline-item.highlight .timeline-card {
  border: 2px solid var(--color-primary);
}

/* Animation Classes */
.timeline-animation-fade-up .timeline-item {
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.timeline-animation-fade-in .timeline-item {
  transition: opacity 0.6s ease;
}

.timeline-animation-slide-in .timeline-item:nth-child(odd) {
  transform: translateX(-50px);
}

.timeline-animation-slide-in .timeline-item:nth-child(even) {
  transform: translateX(50px);
}

.timeline-animation-slide-in .timeline-item.animated {
  transform: translateX(0) !important;
}

.timeline-animation-zoom-in .timeline-item {
  transform: scale(0.8);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.timeline-animation-zoom-in .timeline-item.animated {
  transform: scale(1);
}

.timeline-animation-flip-in .timeline-item {
  transform: rotateY(90deg);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.timeline-animation-flip-in .timeline-item.animated {
  transform: rotateY(0);
}

/* Mobile Styles */
@media (max-width: 992px) {
  .timeline-title {
    font-size: 2rem;
  }

  .timeline-subtitle {
    font-size: 1rem;
  }

  /*
   * Single column layout on mobile
   * Note: .timeline-line is positioned relative to .timeline-container (has 20px padding)
   *       .timeline-dot is positioned relative to .timeline-item (inside the padding)
   * So line needs to add 20px to match dot position
   */
  .timeline-mobile-single {
    --mobile-content-start: calc(var(--dot-size, 3rem) + 1.5rem);
  }

  /* Line: positioned relative to container, needs padding offset + dot center */
  .timeline-mobile-single .timeline-line {
    left: calc(20px + var(--dot-size, 3rem) / 2) !important;
    transform: translateX(-50%) !important;
  }

  /* Dot: positioned relative to timeline-item, left edge at 0 */
  .timeline-mobile-single .timeline-dot {
    left: 0 !important;
    transform: none !important;
  }

  /* Divider: align left on single column */
  .timeline-mobile-single .timeline-header {
    align-items: flex-start;
  }

  .timeline-mobile-single .timeline-header .timeline-title,
  .timeline-mobile-single .timeline-header .timeline-subtitle {
    text-align: left;
  }

  .timeline-mobile-single .timeline-item {
    flex-direction: row !important;
  }

  /* Content: positioned after the dot */
  .timeline-mobile-single .timeline-content {
    width: calc(100% - var(--mobile-content-start)) !important;
    margin-left: var(--mobile-content-start) !important;
    margin-right: 0 !important;
    text-align: left !important;
  }

  .timeline-mobile-single .timeline-card::before {
    left: -10px !important;
    right: auto !important;
    border-color: transparent var(--color-bg, white) transparent transparent !important;
  }

  .timeline-event-title {
    font-size: 1.125rem;
  }

  .timeline-description {
    font-size: 0.875rem;
  }
}

/* Dark-mode rule moved to the gated <style> in module.html (module.css can't be
   gated by theme.dark_mode.enabled). */

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
  .timeline-item {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
  
  .timeline-card {
    transition: none !important;
  }
  
  .timeline-item.highlight .timeline-dot {
    animation: none !important;
  }
}

/* Print Styles */
@media print {
  .timeline-module {
    background: white !important;
  }
  
  .timeline-item {
    opacity: 1 !important;
    transform: none !important;
    page-break-inside: avoid;
  }
  
  .timeline-card {
    box-shadow: none !important;
    border: 1px solid var(--color-border);
  }
}