/* CSS Variables for Dynamic Config via CSV */
:root {
  --track1-color: #bc0000;
  --track2-color: #a47e03;
  --merged-color: #5d5745;
  --milestone-color: #5a5a5a;

  --bg-outer: #f2eee9;
  --bg-inner: #faf6f0;
  --bg-card: #ffffff;
  --border-color: rgba(0, 0, 0, 0.1);
  --border-inactive: rgba(0, 0, 0, 0.2);
  --font-serif: 'IBM Plex Serif', Georgia, serif;
  --font-sans: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --text-gray: #8d8d8d;
  --text-light-gray: #aeaeae;
  --text-black: #111111;
  --shadow-subtle: 0 4px 12px rgba(0, 0, 0, 0.03);
  --shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.08);
  --transition-speed: 0.3s;
}

/* Base resets */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  font-family: var(--font-sans);
  background-color: transparent;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

/* Timeline Container (Outer Window Frame) */
#timeline-container {
  background-color: var(--bg-outer);
  border: 1px solid var(--border-color);
  border-radius: 25px;
  width: 100vw;
  max-width: 100vw;
  height: 100vh;
  max-height: none;
  display: flex;
  flex-direction: column;
  padding: 10px 0 0 0;
  overflow: hidden;
  transition: all 0.3s ease;
  position: relative;
}

/* Fullscreen Mode override */
#timeline-container.fullscreen {
  width: 100vw;
  height: 100vh;
  max-width: none;
  max-height: none;
  border-radius: 0;
  padding: 15px;
  box-shadow: none;
  border: none;
}



/* Header Bar */
.timeline-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 15px;
  width: 100%;
  height: 70px;
  flex-shrink: 0;
}

/* Nav buttons layout */
.nav-controls {
  display: flex;
  gap: 10px;
  height: 48px;
}

.nav-btn {
  background-color: #e6ded5;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 12px;
  width: 52px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  outline: none;
  cursor: pointer;
  color: #333333;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.nav-btn svg {
  display: block;
  width: 26px;
  height: 26px;
}

.nav-btn:hover {
  background-color: #faf8f5;
  border-color: rgba(0, 0, 0, 0.2);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.02);
  transform: translateY(-1px);
}

.nav-btn:active {
  background-color: #dcd3c5;
  border-color: rgba(0, 0, 0, 0.1);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
  transform: translateY(0);
}

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

/* Center Instruction Text */
.instruction-text {
  font-family: var(--font-serif);
  font-size: 12px;
  color: var(--text-black);
  text-align: center;
  user-select: none;
}

/* Fullscreen Toggle Block */
.fullscreen-control {
  display: flex;
  height: 48px;
}

/* Inner Window (Timeline Canvas Viewport) */
.timeline-window {
  background-color: var(--bg-inner);
  border: none;
  border: 0.5px solid var(--border-color);
  border-radius: 26px 26px 24px 24px;
  flex-grow: 1;
  height: 800px;
  width: 100%;
  overflow: hidden;
  position: relative;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.01);
  touch-action: pan-y;
}

/* Scrolling Canvas */
.timeline-canvas {
  height: 100vh;
  width: 2500px;
  /* Will be set dynamically by app.js */
  position: absolute;
  top: 0;
  left: 0;
  cursor: grab;
  user-select: none;
  touch-action: pan-y;
  /* Canvas handles its own touch events via JS */
}

.timeline-canvas:active {
  cursor: grabbing;
}

/* Unmasked SVG for central tracks */
.timeline-svg-unmasked {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

/* Background/Track SVG */
.timeline-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

/* DOM Elements Overlay */
.timeline-elements {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 3;
  pointer-events: none;
}

/* Track Names / Labels (Left side) */
.track-label {
  position: absolute;
  font-family: var(--font-serif);
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  pointer-events: none;
  left: 65px;
  z-index: 10;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

.track-label.creator {
  color: var(--track1-color);
  top: 201px;
}

.track-label.persona {
  color: var(--track2-color);
  top: 429px;
}

/* Year Label Capsules on dashed axis */
.year-label {
  position: absolute;
  background-color: var(--bg-inner);
  padding: 5px 12px;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 400;
  color: var(--text-light-gray);
  transform: translate(-50%, -50%);
  user-select: none;
  white-space: nowrap;
}

/* Card layout styles */
.timeline-card {
  position: absolute;
  background-color: #ffffff;
  border: 1.5px solid rgba(0, 0, 0, 0.22);
  border-radius: 20px;
  width: 320px;
  min-height: 120px;
  padding: 20px 18px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: none;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s ease, filter 0.4s ease;
  cursor: default;
  pointer-events: auto;
}

/* Shorter sizing for middle cards */
.timeline-card.track-3 {
  min-height: 100px;
  padding: 12px 16px;
  gap: 4px;
}

.timeline-card.track-3 .card-description {
  margin-top: 2px;
}

.timeline-card.pre-merge-tech {
  border-radius: 0;
  box-shadow: none;
  background-color: var(--bg-inner);
}

.timeline-card.pre-merge-tech:hover {
  transform: none;
  box-shadow: none;
}

/* Taller sizing for merged cards after the merge */
.timeline-card.track-merged {
  min-height: auto;
  padding: 24px 20px 20px 20px;
  gap: 8px;
}

/* Unique spacious layout for the conclusion card */
.timeline-card.final-card {
  width: 440px;
  padding: 32px 28px;
}

.timeline-card.final-card .card-title {
  font-size: 17px;
  margin-bottom: 6px;
}

.timeline-card.final-card .card-date {
  font-size: 13px;
  margin-bottom: 16px;
}

.timeline-card.final-card .card-description {
  font-size: 13px;
  line-height: 1.7;
}

.timeline-card.final-card.pre-merge-tech {
  gap: 8px;
  min-height: auto;
}

.timeline-card.final-card.pre-merge-tech .card-description {
  margin-top: 4px;
}


.timeline-card:hover {
  transform: scale(1.01);
  box-shadow: none;
}

/* Card inner text elements */
.card-title {
  font-family: var(--font-serif);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.3;
}

/* Dynamic colors for card titles based on tracks */
.timeline-card.track-1 .card-title {
  color: var(--track1-color);
}

.timeline-card.track-2 .card-title {
  color: var(--track2-color);
}

.timeline-card.track-3 .card-title {
  color: var(--milestone-color);
}

.timeline-card.track-merged .card-title {
  color: var(--merged-color);
}

.timeline-card.track-merged .card-description {
  color: var(--merged-color);
}

.timeline-card.track-merged .card-date {
  color: var(--merged-color);
  opacity: 0.8;
}

.card-date {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  color: var(--text-gray);
  line-height: 1;
}

.card-description {
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--text-black);
  line-height: 1.5;
  margin-top: 4px;
  white-space: pre-line;
}

.timeline-elements.has-highlighted .timeline-card:not(.highlighted) {
  filter: grayscale(40%) blur(0.2px);
  border-color: rgba(0, 0, 0, 0.05);
}

.timeline-elements.has-highlighted .timeline-card:not(.highlighted)>* {
  opacity: 0.3;
}

/* Highlighted states for Cards */
.timeline-card.highlighted {
  transform: scale(1.04);
  z-index: 20 !important;
  border-width: 2px;
  pointer-events: auto !important;
}

.timeline-card.highlighted.track-1 {
  border-color: var(--track1-color);
  box-shadow: none;
}

.timeline-card.highlighted.track-2 {
  border-color: var(--track2-color);
  box-shadow: none;
}

.timeline-card.highlighted.track-3 {
  border-color: var(--milestone-color);
  box-shadow: none;
}

.timeline-card.highlighted.track-merged {
  border-color: var(--merged-color);
  box-shadow: none;
}

/* Footer Attribution */
.timeline-footer {
  position: absolute;
  bottom: 10px;
  right: 15px;
  z-index: 2;
  opacity: 0.25;
  transition: opacity 0.2s ease;
}

.timeline-footer:hover {
  opacity: 0.8;
}

.timeline-footer a {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  color: var(--text-black);
  text-decoration: none;
}

.timeline-footer a:hover {
  text-decoration: underline;
}

@media (max-width: 600px) {
  #timeline-container {
    width: calc(100vw - 2px);
    height: 100vh;
    margin: 1px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 25px;
    padding: 8px 0 0 0;
  }

  .timeline-window {
    height: 550px;
  }



  .timeline-header {
    height: 56px;
    padding: 5px 10px;
  }

  .nav-controls {
    height: 36px;
    gap: 6px;
  }

  .nav-btn {
    width: 44px;
    height: 36px;
    border-radius: 10px;
  }

  .nav-btn svg {
    width: 24px;
    height: 24px;
  }

  .instruction-text {
    font-size: 10px;
    flex-grow: 1;
    padding: 0 5px;
    line-height: 1.2;
  }

  .fullscreen-control {
    height: 36px;
  }

  .timeline-card {
    width: 260px;
    min-height: 115px;
    padding: 18px 16px;
    border-radius: 12px;
    gap: 6px;
  }

  .timeline-card.track-3 {
    min-height: 84px;
    padding: 12px 10px;
    gap: 5px;
  }

  .timeline-card.track-merged {
    min-height: auto;
    padding: 18px 16px;
    gap: 8px;
  }

  .timeline-card.final-card {
    width: 290px;
    padding: 24px 20px;
  }

  .timeline-card.final-card .card-title {
    font-size: 14px;
    margin-bottom: 4px;
  }

  .timeline-card.final-card .card-date {
    font-size: 11px;
    margin-bottom: 10px;
  }

  .timeline-card.final-card .card-description {
    font-size: 11.5px;
    line-height: 1.55;
  }


  .card-title {
    font-size: 13px;
  }

  .card-date {
    font-size: 11px;
  }

  .card-description {
    font-size: 11px;
    line-height: 1.3;
  }

  .track-label {
    font-size: 12px;
    left: 15px;
  }

  .year-label {
    font-size: 11px;
    padding: 4px 8px;
  }

  .timeline-card.final-card.pre-merge-tech {
    gap: 8px;
    min-height: auto;
  }

  .timeline-card.final-card.pre-merge-tech .card-description {
    margin-top: 4px;
  }
}