/* Custom Cool Timeline Frontend CSS */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Lora:ital,wght@0,400;0,600;1,400&family=Montserrat:wght@300;400;500;600;700&family=Playfair+Display:ital,wght@0,400;0,700;1,400&family=Poppins:wght@300;400;500;600;700&family=Source+Code+Pro:wght@400;600&display=swap');

/* Default Style Variables fallbacks */
:root {
  --ctl-title-font: 'Poppins', sans-serif;
  --ctl-title-size: 20px;
  --ctl-title-bg: #2563eb;
  --ctl-title-color: #ffffff;
  --ctl-body-font: 'Inter', sans-serif;
  --ctl-body-size: 15px;
  --ctl-body-bg: #ffffff;
  --ctl-body-color: #374151;
  --ctl-accent-color: #2563eb;
  --ctl-accent-color-rgb: 37, 99, 235;
}

.cool-timeline-wrapper {
  position: relative;
  width: 100%;
  box-sizing: border-box;
  padding: 40px 0;
  overflow: hidden;
  background-color: transparent;
}

.cool-timeline-wrapper *,
.cool-timeline-wrapper *::before,
.cool-timeline-wrapper *::after {
  box-sizing: border-box;
}

/* ==========================================================================
   VERTICAL LAYOUT
   ========================================================================== */
.cool-timeline-wrapper.layout-vertical .timeline-container {
  position: relative;
  max-width: 1000px;
  margin: 0 auto;
  padding: 20px 0;
}

/* The vertical center line */
.cool-timeline-wrapper.layout-vertical .timeline-line {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 4px;
  background: linear-gradient(to bottom, transparent, rgba(var(--ctl-accent-color-rgb), 0.2) 5%, var(--ctl-accent-color) 50%, rgba(var(--ctl-accent-color-rgb), 0.2) 95%, transparent);
  transform: translateX(-50%);
  z-index: 1;
}

.cool-timeline-wrapper.layout-vertical .timeline-items {
  position: relative;
  z-index: 2;
}

.cool-timeline-wrapper.layout-vertical .timeline-item {
  position: relative;
  display: flex;
  justify-content: flex-end;
  width: 50%;
  padding: 20px 40px;
  margin-bottom: 10px;
  transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.cool-timeline-wrapper.layout-vertical .timeline-item:nth-child(even) {
  justify-content: flex-start;
  margin-left: 50%;
}

/* Node (the circle on the timeline) */
.cool-timeline-wrapper.layout-vertical .timeline-node {
  position: absolute;
  top: 40px;
  right: -16px; /* Half of width */
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--ctl-title-bg);
  border: 4px solid var(--ctl-body-bg);
  box-shadow: 0 0 0 4px rgba(var(--ctl-accent-color-rgb), 0.2), 0 4px 10px rgba(0,0,0,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  transition: all 0.3s ease;
}

.cool-timeline-wrapper.layout-vertical .timeline-item:nth-child(even) .timeline-node {
  right: auto;
  left: -16px;
}

/* Node position badge number */
.cool-timeline-wrapper .node-number {
  color: var(--ctl-title-color);
  font-family: var(--ctl-title-font);
  font-size: 11px;
  font-weight: 700;
}

/* Timeline Card */
.cool-timeline-wrapper .timeline-card {
  width: 100%;
  max-width: 440px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  background-color: var(--ctl-body-bg);
  position: relative;
  transition: all 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.cool-timeline-wrapper .timeline-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 30px rgba(var(--ctl-accent-color-rgb), 0.15);
  border-color: rgba(var(--ctl-accent-color-rgb), 0.3);
}

.cool-timeline-wrapper.layout-vertical .timeline-item:hover .timeline-node {
  transform: scale(1.2);
  box-shadow: 0 0 0 6px rgba(var(--ctl-accent-color-rgb), 0.4), 0 6px 15px rgba(0,0,0,0.25);
}

/* Card Header & Title */
.cool-timeline-wrapper .timeline-card-header {
  background-color: var(--ctl-title-bg);
  padding: 12px 20px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  position: relative;
}

.cool-timeline-wrapper .timeline-card-title {
  margin: 0;
  font-family: var(--ctl-title-font), sans-serif;
  font-size: var(--ctl-title-size);
  color: var(--ctl-title-color);
  font-weight: 600;
  line-height: 1.4;
  word-wrap: break-word;
}

/* Card Body */
.cool-timeline-wrapper .timeline-card-body {
  padding: 20px;
  font-family: var(--ctl-body-font), sans-serif;
  font-size: var(--ctl-body-size);
  color: var(--ctl-body-color);
  line-height: 1.6;
}

.cool-timeline-wrapper .timeline-card-body p {
  margin: 0 0 10px 0;
}
.cool-timeline-wrapper .timeline-card-body p:last-child {
  margin-bottom: 0;
}

/* Arrow pointing to node */
.cool-timeline-wrapper.layout-vertical .timeline-card::after {
  content: '';
  position: absolute;
  top: 48px;
  right: -8px;
  width: 16px;
  height: 16px;
  background-color: var(--ctl-body-bg);
  border-right: 1px solid rgba(0, 0, 0, 0.05);
  border-top: 1px solid rgba(0, 0, 0, 0.05);
  transform: translateY(-50%) rotate(45deg);
  z-index: 2;
  transition: border-color 0.3s ease;
}

.cool-timeline-wrapper.layout-vertical .timeline-item:nth-child(even) .timeline-card::after {
  right: auto;
  left: -8px;
  border-right: none;
  border-top: none;
  border-left: 1px solid rgba(0, 0, 0, 0.05);
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

/* Hover border arrow fix */
.cool-timeline-wrapper.layout-vertical .timeline-item:hover .timeline-card::after {
  border-color: rgba(var(--ctl-accent-color-rgb), 0.3);
}

/* Floating index helper inside cards (optional backup check) */
.cool-timeline-wrapper .timeline-card-index {
  position: absolute;
  top: 12px;
  right: 15px;
  font-size: 11px;
  font-weight: 700;
  color: var(--ctl-title-color);
  opacity: 0.5;
  background: rgba(0,0,0,0.15);
  padding: 2px 6px;
  border-radius: 20px;
}


/* ==========================================================================
   HORIZONTAL LAYOUT
   ========================================================================== */
.cool-timeline-wrapper.layout-horizontal {
  padding: 60px 20px;
}

.cool-timeline-wrapper.layout-horizontal .timeline-container {
  position: relative;
  width: 100%;
  overflow-x: auto;
  padding: 120px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--ctl-accent-color) rgba(0, 0, 0, 0.05);
  cursor: grab;
}

.cool-timeline-wrapper.layout-horizontal .timeline-container:active {
  cursor: grabbing;
}

.cool-timeline-wrapper.layout-horizontal .timeline-container::-webkit-scrollbar {
  height: 6px;
}

.cool-timeline-wrapper.layout-horizontal .timeline-container::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.05);
  border-radius: 10px;
}

.cool-timeline-wrapper.layout-horizontal .timeline-container::-webkit-scrollbar-thumb {
  background-color: var(--ctl-accent-color);
  border-radius: 10px;
}

/* Horizontal line running straight through center */
.cool-timeline-wrapper.layout-horizontal .timeline-line {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(to right, transparent, rgba(var(--ctl-accent-color-rgb), 0.2) 2%, var(--ctl-accent-color) 20%, var(--ctl-accent-color) 80%, rgba(var(--ctl-accent-color-rgb), 0.2) 98%, transparent);
  transform: translateY(-50%);
  z-index: 1;
}

.cool-timeline-wrapper.layout-horizontal .timeline-items {
  display: flex;
  flex-direction: row;
  gap: 40px;
  padding: 0 100px;
  width: max-content;
  z-index: 2;
  position: relative;
}

.cool-timeline-wrapper.layout-horizontal .timeline-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 280px;
  min-height: 250px;
  justify-content: flex-end; /* Odd elements align cards above node */
}

/* Nodes on the horizontal timeline */
.cool-timeline-wrapper.layout-horizontal .timeline-node {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--ctl-title-bg);
  border: 4px solid var(--ctl-body-bg);
  box-shadow: 0 0 0 4px rgba(var(--ctl-accent-color-rgb), 0.2), 0 4px 10px rgba(0,0,0,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  transition: all 0.3s ease;
}

.cool-timeline-wrapper.layout-horizontal .timeline-item:hover .timeline-node {
  transform: translate(-50%, -50%) scale(1.2);
  box-shadow: 0 0 0 6px rgba(var(--ctl-accent-color-rgb), 0.4), 0 6px 15px rgba(0,0,0,0.25);
}

/* Odd cards go above the line */
.cool-timeline-wrapper.layout-horizontal .timeline-item:nth-child(odd) {
  justify-content: flex-end;
  padding-bottom: 30px; /* Space between card and node */
}

.cool-timeline-wrapper.layout-horizontal .timeline-item:nth-child(odd) .timeline-card {
  margin-bottom: 0;
}

/* Even cards go below the line */
.cool-timeline-wrapper.layout-horizontal .timeline-item:nth-child(even) {
  justify-content: flex-start;
  padding-top: 30px; /* Space between card and node */
}

.cool-timeline-wrapper.layout-horizontal .timeline-item:nth-child(even) .timeline-card {
  margin-top: 0;
}

/* Horizontal card arrows */
.cool-timeline-wrapper.layout-horizontal .timeline-item:nth-child(odd) .timeline-card::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 50%;
  width: 16px;
  height: 16px;
  background-color: var(--ctl-body-bg);
  border-right: 1px solid rgba(0, 0, 0, 0.05);
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  transform: translateX(-50%) rotate(45deg);
  z-index: 2;
  transition: border-color 0.3s ease;
}

.cool-timeline-wrapper.layout-horizontal .timeline-item:nth-child(even) .timeline-card::after {
  content: '';
  position: absolute;
  top: -8px;
  left: 50%;
  width: 16px;
  height: 16px;
  background-color: var(--ctl-body-bg);
  border-left: 1px solid rgba(0, 0, 0, 0.05);
  border-top: 1px solid rgba(0, 0, 0, 0.05);
  transform: translateX(-50%) rotate(45deg);
  z-index: 2;
  transition: border-color 0.3s ease;
}

.cool-timeline-wrapper.layout-horizontal .timeline-item:hover .timeline-card::after {
  border-color: rgba(var(--ctl-accent-color-rgb), 0.3);
}

/* Navigation controls for horizontal timeline */
.cool-timeline-nav-container {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin-top: 20px;
}

.cool-timeline-nav-btn {
  background: var(--ctl-body-bg);
  color: var(--ctl-accent-color);
  border: 1px solid rgba(var(--ctl-accent-color-rgb), 0.3);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0,0,0,0.05);
  transition: all 0.2s ease;
  user-select: none;
}

.cool-timeline-nav-btn:hover {
  background: var(--ctl-accent-color);
  color: #ffffff;
  box-shadow: 0 6px 15px rgba(var(--ctl-accent-color-rgb), 0.2);
  transform: scale(1.05);
}

.cool-timeline-nav-btn:active {
  transform: scale(0.95);
}

.cool-timeline-nav-btn.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* ==========================================================================
   RESPONSIVE DESIGN (MOBILE / TABLET BREAKPOINT)
   ========================================================================== */
@media screen and (max-width: 768px) {
  /* Vertical Timeline collapses into single column on the right of the line */
  .cool-timeline-wrapper.layout-vertical .timeline-line {
    left: 24px;
    transform: none;
  }

  .cool-timeline-wrapper.layout-vertical .timeline-item {
    width: 100%;
    justify-content: flex-start;
    padding-left: 54px; /* Space for the line and node */
    padding-right: 15px;
    margin-bottom: 25px;
  }

  .cool-timeline-wrapper.layout-vertical .timeline-item:nth-child(even) {
    margin-left: 0;
  }

  .cool-timeline-wrapper.layout-vertical .timeline-node {
    left: 8px; /* Centered around 24px line: 24px line - 16px radius */
    right: auto;
    top: 25px;
  }

  .cool-timeline-wrapper.layout-vertical .timeline-item:nth-child(even) .timeline-node {
    left: 8px;
  }

  .cool-timeline-wrapper.layout-vertical .timeline-card {
    max-width: 100%;
  }

  .cool-timeline-wrapper.layout-vertical .timeline-card::after {
    top: 33px; /* Align with node at 25px (25px + 8px arrow center offset) */
    left: -8px;
    right: auto;
    border-right: none;
    border-top: none;
    border-left: 1px solid rgba(0, 0, 0, 0.05);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  }

  /* Horizontal Timeline switches to vertical scrollable stacks (mobile friendly) */
  .cool-timeline-wrapper.layout-horizontal .timeline-container {
    padding: 20px 0;
    overflow-x: hidden;
  }

  .cool-timeline-wrapper.layout-horizontal .timeline-line {
    left: 24px;
    right: auto;
    top: 0;
    bottom: 0;
    width: 4px;
    height: 100%;
    transform: none;
    background: linear-gradient(to bottom, transparent, rgba(var(--ctl-accent-color-rgb), 0.2) 5%, var(--ctl-accent-color) 50%, rgba(var(--ctl-accent-color-rgb), 0.2) 95%, transparent);
  }

  .cool-timeline-wrapper.layout-horizontal .timeline-items {
    flex-direction: column;
    width: 100%;
    padding: 0 15px 0 54px;
    gap: 30px;
  }

  .cool-timeline-wrapper.layout-horizontal .timeline-item {
    width: 100%;
    min-height: auto;
    justify-content: flex-start !important;
    align-items: flex-start;
    padding: 0 !important;
  }

  .cool-timeline-wrapper.layout-horizontal .timeline-node {
    left: -30px; /* Centered on the 24px line relative to container padding: 24px - 54px = -30px */
    top: 25px;
    transform: translateY(-50%);
  }

  .cool-timeline-wrapper.layout-horizontal .timeline-item:hover .timeline-node {
    transform: translateY(-50%) scale(1.2);
  }

  .cool-timeline-wrapper.layout-horizontal .timeline-card {
    max-width: 100%;
  }

  /* Reset odd/even arrow placements in mobile-horizontal (which now behaves like vertical) */
  .cool-timeline-wrapper.layout-horizontal .timeline-card::after {
    top: 25px !important;
    left: -8px !important;
    right: auto !important;
    bottom: auto !important;
    border-right: none !important;
    border-top: none !important;
    border-left: 1px solid rgba(0, 0, 0, 0.05) !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05) !important;
    transform: translateY(-50%) rotate(45deg) !important;
  }

  .cool-timeline-nav-container {
    display: none; /* Hide scroll nav on mobile since scroll vertical is native */
  }
}

/* Dashicon Alignment inside Timeline Nodes */
.cool-timeline-wrapper .timeline-node .dashicons {
  font-size: 16px;
  width: 16px;
  height: 16px;
  line-height: 16px;
  color: var(--ctl-title-color);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
