.timeline { position: relative; padding-bottom: 70px; overflow: hidden; }
.timeline .section-title { margin-bottom: 30px; }

/* graph-paper backdrop with a few loose doodles */
.timeline::before {
  content: "";
  position: absolute;
  inset: 120px 0 0;
  background-image:
    linear-gradient(rgba(11, 11, 12, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(11, 11, 12, 0.05) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: linear-gradient(to bottom, transparent, #000 25%, #000 75%, transparent);
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 25%, #000 75%, transparent);
  pointer-events: none;
}
.timeline .wrap { position: relative; }

.tl-scroller {
  position: relative;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 36px 24px 44px;
  margin-inline: -24px;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
  scrollbar-color: rgba(191, 0, 29, 0.5) transparent;
  cursor: grab;
  outline: none;
}
.tl-scroller.dragging { cursor: grabbing; scroll-snap-type: none; }
.tl-scroller:focus-visible { box-shadow: 0 0 0 3px var(--red); border-radius: 8px; }
.tl-scroller::-webkit-scrollbar { height: 8px; }
.tl-scroller::-webkit-scrollbar-thumb { background: rgba(191, 0, 29, 0.45); border-radius: 8px; }

.tl-track { --u: 170px; position: relative; width: max-content; min-width: 100%; }

.tl {
  --paper-shadow: 0 1px 1px rgba(11, 11, 12, 0.12), 0 16px 24px -14px rgba(11, 11, 12, 0.5);
  display: grid;
  grid-auto-columns: var(--u);
  grid-template-rows: auto auto;
  row-gap: 112px;
  list-style: none;
  padding: 0;
  margin: 0 auto;
  width: max-content;
}

/* the path: dashed ahead, solid red behind you */
.tl-track::before,
.tl-progress {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  height: 0;
  transform: translateY(-50%);
}
.tl-track::before { right: 0; border-top: 4px dashed rgba(11, 11, 12, 0.28); }
.tl-progress {
  width: 0;
  border-top: 5px solid var(--red);
  box-shadow: 0 0 14px rgba(255, 45, 68, 0.6);
  transition: width 1.8s cubic-bezier(0.2, 0.7, 0.2, 1) 0.3s;
  z-index: 1;
}
.timeline.in .tl-progress { width: var(--progress, 0); }

.tl-here {
  position: absolute;
  top: calc(50% - 74px);
  left: var(--here, 0);
  z-index: 3;
  padding: 5px 12px 3px;
  background: #ffd86b;
  color: #15151a;
  font-family: "Permanent Marker", "Comic Sans MS", cursive;
  font-size: 14px;
  white-space: nowrap;
  transform: translateX(-50%) rotate(-4deg);
  box-shadow: 0 6px 12px -6px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 0.5s 1.6s;
  animation: bob 2.4s ease-in-out infinite;
}
.tl-here::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -9px;
  border: 9px solid transparent;
  border-bottom: 0;
  border-top-color: #ffd86b;
  transform: translateX(-50%);
}
.timeline.in .tl-here { opacity: 1; }
@keyframes bob { 0%, 100% { margin-top: 0; } 50% { margin-top: -7px; } }

/* ---- cards ---- */
.tl-card {
  position: relative;
  width: calc(var(--u) * 2 - 22px);
  padding: 24px 24px 22px;
  background: #fffdf6;
  box-shadow: var(--paper-shadow);
  transform: rotate(var(--tilt, 0deg)) translateY(var(--drop, 0));
  transition: transform 0.3s cubic-bezier(0.3, 1.4, 0.5, 1), box-shadow 0.3s;
  grid-row: 1;
  align-self: end;
  opacity: 0;
}
.tl-card:nth-child(even) { grid-row: 2; align-self: start; --drop: 0; }
.tl-card:nth-child(1) { grid-column: 1 / span 2; }
.tl-card:nth-child(2) { grid-column: 2 / span 2; }
.tl-card:nth-child(3) { grid-column: 3 / span 2; }
.tl-card:nth-child(4) { grid-column: 4 / span 2; }
.tl-card:nth-child(5) { grid-column: 5 / span 2; }
.tl-card:nth-child(6) { grid-column: 6 / span 2; }
.tl-card { margin-left: 11px; }

.timeline.in .tl-card { animation: drop-in 0.7s cubic-bezier(0.3, 1.3, 0.5, 1) both; animation-delay: calc(var(--n, 0) * 0.13s); }
.tl-card:nth-child(1) { --n: 0; } .tl-card:nth-child(2) { --n: 1; } .tl-card:nth-child(3) { --n: 2; }
.tl-card:nth-child(4) { --n: 3; } .tl-card:nth-child(5) { --n: 4; } .tl-card:nth-child(6) { --n: 5; }
@keyframes drop-in {
  0% { opacity: 0; transform: rotate(calc(var(--tilt, 0deg) * 3)) translateY(-40px) scale(0.92); }
  100% { opacity: 1; transform: rotate(var(--tilt, 0deg)) translateY(0) scale(1); }
}
.tl-card:hover { transform: rotate(0deg) translateY(-8px) scale(1.03); box-shadow: 0 2px 2px rgba(11, 11, 12, 0.15), 0 28px 36px -16px rgba(11, 11, 12, 0.55); z-index: 5; }

/* tape */
.tl-card::before {
  content: "";
  position: absolute;
  top: -13px;
  left: 50%;
  width: 92px;
  height: 26px;
  background: var(--tape, rgba(236, 214, 150, 0.8));
  box-shadow: 0 1px 2px rgba(40, 30, 10, 0.2);
  transform: translateX(-50%) rotate(var(--tape-tilt, -3deg));
  clip-path: polygon(0 0, 100% 0, 97% 25%, 100% 50%, 97% 75%, 100% 100%, 0 100%, 3% 75%, 0 50%, 3% 25%);
}
.tl-card:nth-child(2)::before { --tape: rgba(191, 0, 29, 0.4); --tape-tilt: 4deg; }
.tl-card:nth-child(4)::before { --tape: rgba(120, 160, 230, 0.55); --tape-tilt: 5deg; }
.tl-card:nth-child(5)::before { --tape: rgba(150, 205, 160, 0.7); --tape-tilt: -4deg; }

/* stem and pin down to the path */
.tl-card::after {
  content: "";
  position: absolute;
  left: 50%;
  width: 0;
  height: 56px;
  border-left: 3px dotted rgba(191, 0, 29, 0.7);
  bottom: -56px;
}
.tl-card:nth-child(even)::after { bottom: auto; top: -56px; }
.tl-pin {
  position: absolute;
  left: 50%;
  bottom: -70px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ff8a97 0 16%, var(--red) 17% 100%);
  box-shadow: 0 0 0 4px var(--paper), 0 4px 8px rgba(0, 0, 0, 0.35);
  transform: translateX(-50%);
}
.tl-card:nth-child(even) .tl-pin { bottom: auto; top: -70px; }
.tl-card.is-today .tl-pin::after {
  content: "";
  position: absolute;
  inset: -9px;
  border-radius: 50%;
  border: 2px solid var(--red);
  animation: ping 1.8s ease-out infinite;
}
@keyframes ping { 0% { transform: scale(0.5); opacity: 1; } 100% { transform: scale(1.9); opacity: 0; } }

.tl-date { display: inline-block; font-family: "Permanent Marker", "Comic Sans MS", cursive; font-size: 17px; color: var(--red); transform: rotate(-2deg); }
.tl-card h3 { margin: 6px 0 4px; font-family: var(--display); font-size: 52px; font-weight: 400; line-height: 1; letter-spacing: 0.02em; text-transform: uppercase; }
.tl-card h3 a { color: inherit; }
.tl-card p { padding-right: 40px; color: #5d5759; font-size: 14.5px; line-height: 1.45; }

.tl-stamp {
  position: absolute;
  top: 16px;
  right: 14px;
  padding: 3px 10px 1px;
  border: 3px double currentColor;
  border-radius: 5px;
  font-family: var(--display);
  font-size: 18px;
  letter-spacing: 0.1em;
  color: #2f7a46;
  opacity: 0.85;
  transform: rotate(8deg);
  mix-blend-mode: multiply;
}
.tl-stamp.is-today { color: var(--red); }
.tl-stamp.is-soon { color: #7a5a14; }

.tl-doodle { position: absolute; bottom: 10px; right: 12px; width: 48px; height: 48px; fill: none; stroke: var(--red); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; opacity: 0.55; transition: transform 0.4s; }
.tl-card:hover .tl-doodle { transform: rotate(14deg) scale(1.15); }

.tl-link { display: inline-block; margin-top: 6px; font-family: "Permanent Marker", "Comic Sans MS", cursive; font-size: 13px; color: var(--red); text-decoration: underline; text-underline-offset: 3px; transform: rotate(-1deg); }

/* ---- the mystery card ---- */
.tl-mystery {
  background: #15151a;
  color: #f4f1ea;
  --tape: rgba(255, 255, 255, 0.35);
  box-shadow: var(--paper-shadow), 0 0 0 1px rgba(255, 255, 255, 0.06);
  overflow: hidden;
}
.tl-mystery::after { display: none; }
.tl-mystery > .tl-pin { background: radial-gradient(circle at 35% 30%, #fff 0 14%, #6f8cff 15% 100%); }
.tl-mystery .tl-date { color: #ff4d62; }
.tl-mystery p { padding-right: 0; color: #9a9499; font-size: 13px; }
.tl-mystery .scan { position: absolute; inset: 0; pointer-events: none; background: repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.04) 0 1px, transparent 1px 4px); mix-blend-mode: screen; }
.tl-mystery .scan::after { content: ""; position: absolute; left: 0; right: 0; height: 24px; background: linear-gradient(transparent, rgba(255, 255, 255, 0.07), transparent); animation: sweep 4s linear infinite; }
@keyframes sweep { from { top: -30px; } to { top: 100%; } }
.tl-mystery-pin { overflow: visible; }

.glitch {
  position: relative;
  display: block;
  margin: 6px 0 2px;
  padding: 0 4px;
  border: 0;
  background: none;
  cursor: pointer;
  font-family: var(--display);
  font-size: clamp(70px, 8vw, 100px);
  line-height: 1.02;
  letter-spacing: 0.06em;
  color: #f4f1ea;
  --c1: 34%;
  --c2: 66%;
  -webkit-tap-highlight-color: transparent;
}
.glitch:focus-visible { outline: 3px solid #ff4d62; outline-offset: 6px; }
.glitch[hidden], .tl-note[hidden] { display: none; }
.g-band { display: block; transform: translate(var(--dx, 0), var(--dy, 0)); transition: transform 0.12s steps(2); }
.g-band:nth-child(1) { clip-path: inset(0 0 calc(100% - var(--c1)) 0); }
.g-band:nth-child(2), .g-band:nth-child(3) { position: absolute; inset: 0; padding: inherit; }
.g-band:nth-child(2) { clip-path: inset(var(--c1) 0 calc(100% - var(--c2)) 0); color: #ff3b52; }
.g-band:nth-child(3) { clip-path: inset(var(--c2) 0 0 0); color: #6f8cff; }
@keyframes idle-glitch {
  0%, 88%, 100% { transform: translate(var(--dx, 0), var(--dy, 0)); }
  90% { transform: translate(calc(var(--dx, 0px) + 6px), var(--dy, 0)); }
  94% { transform: translate(calc(var(--dx, 0px) - 8px), var(--dy, 0)); }
}
.glitch .g-band:nth-child(2) { animation: idle-glitch 3.2s infinite; }
.glitch .g-band:nth-child(3) { animation: idle-glitch 4.1s infinite 0.7s; }
.glitch.zap .g-band { animation: none; }

.tl-note { display: block; margin: 6px 0 10px; font-family: "Permanent Marker", "Comic Sans MS", cursive; font-size: 14px; color: #ff8a97; transform: rotate(-3deg); }

.tl-reveal { display: flex; flex-wrap: wrap; gap: 8px 6px; margin: 10px 0 8px; }
.tl-reveal[hidden] { display: none; }
.chip-word { padding: 4px 10px 2px; font-size: 24px; line-height: 1.1; text-transform: uppercase; transform: rotate(var(--r, 0deg)); animation: chip-in 0.5s steps(5) both; animation-delay: calc(var(--i) * 0.12s); }
.chip-word:nth-child(1) { --r: -3deg; background: #f4f1ea; color: #15151a; font-family: Georgia, serif; font-weight: 700; }
.chip-word:nth-child(2) { --r: 2deg; background: var(--red); color: #fff; font-family: var(--display); letter-spacing: 0.06em; }
.chip-word:nth-child(3) { --r: -2deg; background: #ffd86b; color: #15151a; font-family: "Permanent Marker", cursive; font-size: 22px; }
.chip-word:nth-child(4) { --r: 3deg; background: #15151a; color: #f4f1ea; border: 2px solid #f4f1ea; font-family: "Courier New", monospace; font-weight: 700; }
.chip-word:nth-child(5) { --r: -1deg; background: #6f8cff; color: #15151a; font-family: var(--display); letter-spacing: 0.08em; }
@keyframes chip-in {
  0% { opacity: 0; transform: translate(-10px, 4px) rotate(var(--r)); }
  40% { opacity: 1; transform: translate(6px, -2px) rotate(var(--r)); }
  100% { opacity: 1; transform: translate(0, 0) rotate(var(--r)); }
}

/* arrows, shown only when the strip scrolls */
.tl-controls { display: none; justify-content: center; gap: 12px; margin-top: 6px; font-family: "Permanent Marker", "Comic Sans MS", cursive; }
.tl-controls.show { display: flex; }
.tl-arrow { width: 48px; height: 48px; border: 2px solid var(--ink); border-radius: 50%; background: #fffdf6; font-size: 20px; cursor: pointer; box-shadow: 3px 4px 0 var(--ink); transition: transform 0.15s, box-shadow 0.15s; }
.tl-arrow:hover { transform: translate(-1px, -1px); box-shadow: 4px 5px 0 var(--red); }
.tl-arrow:active { transform: translate(2px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.tl-hint { align-self: center; font-size: 14px; color: var(--muted); }

@media (max-width: 760px) {
  .tl-track { --u: 140px; }
  .tl-card { padding: 20px 18px 18px; }
  .tl-card h3 { font-size: 42px; }
  .tl-card p { font-size: 13.5px; padding-right: 30px; }
  .tl-scroller { padding-inline: 16px; margin-inline: -16px; }
}

@media (prefers-reduced-motion: reduce) {
  .tl-card, .timeline.in .tl-card { animation: none; opacity: 1; transition: none; }
  .tl-progress { transition: none; }
  .tl-here, .tl-mystery .scan::after, .tl-card.is-today .tl-pin::after, .glitch .g-band, .chip-word { animation: none; }
  .tl-here { opacity: 1; }
}
