/* Timeline labels & ticks */
.timeline-year-labels {
  position: relative;
  padding-left: 5px;
  min-width: 30px;
}
.timeline-year-label {
  position: absolute;
  right: 0;
  width: 40px;
  text-align: right;
  font-size: 16px;
  rotate: -90deg;
}
.timeline-year-tick {
  position: absolute;
  left: 80%;
  width: 12px;
  height: 1px;
  background-color: #333;
}

/* Base block styling */
.timeline-block {
  position: absolute;
  perspective: 1000px;
  cursor: pointer;
  transition:
    left   0.6s ease,
    top    0.6s ease,
    width  0.6s ease,
    height 0.6s ease;
  z-index: 0;
}

/* Flip container */
.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.6s ease;
  transform: rotateY(0deg); /* ensure an initial computed transform */
}


/* Flip state */
.timeline-block.flipped .card-inner {
  transform: rotateY(180deg);
}

/* Faces */
.card-front,
.card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: 10px;
  box-shadow: 0 6px 12px rgba(0,0,0,0.3);
  padding: 8px 10px;
  box-sizing: border-box;
  color: #000;
  font-size: 16px;

  white-space: normal;
  word-wrap: break-word;
}

.card-front {
  z-index: 2;
  border: 3px solid black;
border-radius: 13.5px;
}
.card-back {
  background-color: #fff;
  transform: rotateY(180deg);
  display: flex;
  font-weight: bold;
  position: relative;
  cursor: default;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  overflow-y: auto;
  padding: 16px;
  box-sizing: border-box;
  text-align: left;
  gap: 8px;
}

/* Close button */
.close-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: transparent;
  border: none;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  z-index: 3;
}

/* Bring expanded block above all siblings */
.timeline-block.expanded {
  z-index: 10000;
}

/* Within expanded, back above front */
.timeline-block.expanded.flipped .card-back {
  z-index: 2;
}
.timeline-block.expanded.flipped .card-front {
  z-index: 1;
}

/* Overlay container for reparented cards */
#timeline-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* Ensure blocks in overlay can receive events */
#timeline-overlay .timeline-block {
  pointer-events: auto;
}

/* Hint centered */
.timeline-hint {
  font-size: 14px;
  color: #444;
  user-select: none;
  text-align: center;
  margin: 6px auto 10px; /* centers the block if not full-width */
}
@media (prefers-reduced-motion: no-preference) {
  .timeline-hint { animation: th-pulse 1.6s ease-in-out 2; }
  @keyframes th-pulse { 0%{opacity:.5} 50%{opacity:1} 100%{opacity:.5} }
}

