/* My story: a timeline you scroll through naturally; the year and the title stay beside it. */

.story {
  --warm: 0;
  position: relative;
  z-index: 1;
  border-top: 1px solid rgba(26, 24, 24, .1);
  background: #F4F1EE;
  /* light mode: a very fine diagonal weave over warm paper */
  background-image:
    repeating-linear-gradient(42deg, rgba(26, 24, 24, .022) 0 1px, transparent 1px 12px),
    linear-gradient(176deg, #FBF9F7 0%, #F7F4F1 54%, #F3EFEB 100%);
  background-attachment: local, local;
  box-shadow: inset 0 1.75rem 2.25rem -1.75rem rgba(26, 24, 24, .14);
}
html[data-mode="dark"] .story {
  border-top-color: rgba(232, 228, 224, .08);
  background: #171515;
  /* dark mode: fine dots */
  background-image: radial-gradient(rgba(232, 228, 224, .055) 1px, transparent 1.4px);
  background-position: center top;
  background-size: 1.6rem 1.6rem;
  background-attachment: scroll;
  box-shadow: inset 0 1.75rem 2.25rem -1.75rem rgba(0, 0, 0, .6);
}
.story::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: var(--warm);
  background:
    radial-gradient(60% 50% at 25% 40%, rgba(196, 150, 100, .12), transparent 70%),
    linear-gradient(180deg, transparent, rgba(170, 125, 80, .06));
}

/* soft light in the colour of each chapter's work, bleeding in from the edges */
.story__glow {
  --aa: 2.3;
  --p1: 0% 14%;
  --p2: 100% 86%;
  position: sticky;
  top: 0;
  z-index: 0;
  display: block;
  overflow: hidden;
  height: 100svh;
  margin-bottom: -100svh;
  pointer-events: none;
}
html[data-mode="dark"] .story__glow {
  --aa: 1.1;
  --p1: 24% 44%;
  --p2: 80% 74%;
}
.story__glow::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(54% 66% at 50% 50%, rgba(252, 250, 248, .9) 0%, rgba(252, 250, 248, .66) 46%, transparent 80%);
}
html[data-mode="dark"] .story__glow::after { display: none; }
.story__glow i {
  position: absolute;
  inset: -8%;
  opacity: 0;
  background:
    radial-gradient(46% 54% at var(--p1), rgba(var(--c1), calc(.34 * var(--aa))), transparent 74%),
    radial-gradient(42% 48% at var(--p2), rgba(var(--c2), calc(.26 * var(--aa))), transparent 74%);
  transition: opacity 1.2s ease;
  animation: glowDrift 24s ease-in-out infinite alternate;
  animation-play-state: paused;
}
.story__glow i:nth-child(1) { --c1: 226, 122, 58; --c2: 92, 132, 202; }
.story__glow i:nth-child(2) { --c1: 226, 122, 58; --c2: 206, 138, 150; }
.story__glow i:nth-child(3) { --c1: 132, 174, 104; --c2: 92, 132, 202; }
.story__glow i:nth-child(4) { --c1: 178, 106, 148; --c2: 226, 122, 58; }
.story__glow i:nth-child(5) { --c1: 226, 178, 70; --c2: 178, 142, 132; }
html[data-mode="dark"] .story__glow i:nth-child(1) { --c1: 164, 85, 44; --c2: 60, 82, 120; }
html[data-mode="dark"] .story__glow i:nth-child(2) { --c1: 164, 85, 44; --c2: 196, 176, 176; }
html[data-mode="dark"] .story__glow i:nth-child(3) { --c1: 122, 134, 112; --c2: 60, 82, 120; }
html[data-mode="dark"] .story__glow i:nth-child(4) { --c1: 74, 53, 64; --c2: 164, 85, 44; }
html[data-mode="dark"] .story__glow i:nth-child(5) { --c1: 214, 178, 110; --c2: 107, 92, 92; }
.story[data-ch="0"] .story__glow i:nth-child(1),
.story[data-ch="1"] .story__glow i:nth-child(2),
.story[data-ch="2"] .story__glow i:nth-child(3),
.story[data-ch="3"] .story__glow i:nth-child(4),
.story[data-ch="4"] .story__glow i:nth-child(5) {
  opacity: 1;
  animation-play-state: running;
}
@keyframes glowDrift {
  from { transform: translate3d(-2%, -1.5%, 0) scale(1); }
  to { transform: translate3d(2.5%, 2%, 0) scale(1.06); }
}
html.lite .story__glow i { animation: none; }

.story__wrap { position: relative; padding: 7rem 0 2.5rem; }
.story__grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  align-items: start;
  gap: 3.5rem;
  width: 100%;
}
.story__aside {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  height: 100svh;
  margin-top: -7rem;
  padding-top: 3rem;
}
/* the clock tunnel behind the year */
.story__tunnel {
  position: absolute;
  top: 0;
  right: -40%;
  left: -40%;
  z-index: -1;
  width: 180%;
  height: 100%;
  pointer-events: none;
  -webkit-mask: radial-gradient(closest-side, #000 55%, transparent);
  mask: radial-gradient(closest-side, #000 55%, transparent);
}
.story__title {
  margin-top: .6rem;
  font-size: 2.4rem;
  font-weight: 700;
  line-height: .98;
  letter-spacing: -.035em;
}
@media (min-width: 1024px) { .story__title { font-size: 3.4rem; } }

/* the year: four reels of digits that roll */
.odometer {
  display: flex;
  margin: 1.5rem 0 0 -.04em;
  color: var(--foreground);
  font-size: clamp(5.5rem, 11.5vw, 11.5rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  letter-spacing: -.06em;
}
.odometer__digit {
  display: block;
  overflow: hidden;
  height: 1em;
  padding-right: .02em;
}
.odometer__reel {
  display: flex;
  flex-direction: column;
  transform: translateY(calc(var(--d, 0) * -1em));
  transition: transform .9s cubic-bezier(.65, 0, .2, 1);
}
.odometer__digit:nth-child(2) .odometer__reel { transition-delay: .04s; }
.odometer__digit:nth-child(3) .odometer__reel { transition-delay: .08s; }
.odometer__digit:nth-child(4) .odometer__reel { transition-delay: .12s; }
.odometer__reel i {
  display: block;
  height: 1em;
  font-style: normal;
  text-align: center;
}
.story__dates {
  margin-top: .9rem;
  color: #5C4242;
  font-family: var(--mono);
  font-size: .8125rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
}
html[data-mode="dark"] .story__dates { color: #D9C6C6; }
.story__meter {
  display: flex;
  align-items: center;
  gap: .6rem;
  width: 100%;
  margin-top: 1.5rem;
  color: var(--foreground);
  font-size: .875rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.story__total { color: rgba(var(--fg-rgb), .55); }
.story__rewind {
  width: 1.25rem;
  height: 1.25rem;
  color: rgba(var(--fg-rgb), .6);
  transform: rotate(calc(var(--p, 0) * -720deg));
}
.story__bar {
  position: relative;
  flex: 0 1 11rem;
  overflow: hidden;
  height: 2px;
  margin-left: .6rem;
  border-radius: 2px;
  background: rgba(var(--fg-rgb), .12);
}
.story__bar b {
  position: absolute;
  inset: 0;
  background: var(--foreground);
  transform: scaleX(var(--p, 0));
  transform-origin: 0 50%;
}

/* the chapters, in normal flow: the line runs beside them and the dot travels it as you scroll */
.timeline { position: relative; padding-top: 24vh; padding-bottom: 4vh; }
.timeline__list {
  position: relative;
  margin: 0;
  padding: 0 0 0 2.75rem;
  list-style: none;
}
.timeline__rail {
  position: absolute;
  top: var(--r0, 0);
  left: .45rem;
  width: 2px;
  height: var(--rh, 0);
  border-radius: 2px;
  background: rgba(var(--fg-rgb), .14);
}
/* the travelled stretch of line, in its own track that stops exactly at the line's ends */
.timeline__tailtrack {
  position: absolute;
  top: var(--r0, 0);
  left: calc(.45rem + 1px - 1.25rem);
  z-index: 1;
  overflow: clip;
  width: 2.5rem;
  height: var(--rh, 0);
  pointer-events: none;
}
.timeline__tail {
  position: sticky;
  top: 50svh;
  display: block;
  width: 2px;
  height: 0;
  margin: 0 auto;
}
.timeline__tail::before {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  width: 2px;
  height: 300vh;
  background: var(--foreground);
}
/* the dot rides the line on the browser's own sticky positioning, so it never shakes */
.timeline__dottrack {
  position: absolute;
  top: calc(var(--r0, 0px) - 1rem);
  left: calc(.45rem + 1px - 1.25rem);
  z-index: 2;
  width: 2.5rem;
  height: calc(var(--rh, 0px) + 2rem);
  padding: .45rem 0;
  pointer-events: none;
}
.timeline__dot {
  position: sticky;
  top: calc(50svh - .55rem);
  z-index: 2;
  display: block;
  width: 1.1rem;
  height: 1.1rem;
  margin: 0 auto;
  border-radius: 50%;
  background: var(--foreground);
  box-shadow: 0 0 0 .4rem rgba(var(--fg-rgb), .08);
  transition: background .4s, box-shadow .4s;
}
.story.is-now .timeline__dot {
  background: #7FB069;
  box-shadow: 0 0 0 .45rem rgba(127, 176, 105, .18);
}
.chapter {
  position: relative;
  padding: 3rem 0;
  opacity: .52;
  transition: opacity .45s ease;
}
.chapter.on { opacity: 1; }
.chapter__dates {
  margin-bottom: .7rem;
  color: rgba(var(--fg-rgb), .66);
  font-family: var(--mono);
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.chapter__title {
  margin-bottom: .35rem;
  font-size: 1.9rem;
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: -.02em;
}
.chapter__org {
  margin-bottom: 1rem;
  color: rgba(var(--fg-rgb), .7);
  font-size: 1.0625rem;
  font-weight: 500;
}
.chapter__points {
  display: flex;
  flex-direction: column;
  gap: .55rem;
  max-width: 46ch;
  margin: 0;
  padding: 0;
  list-style: none;
}
.chapter__points li {
  position: relative;
  padding-left: 1.1rem;
  color: rgba(var(--fg-rgb), .78);
  font-size: 1rem;
  line-height: 1.55;
}
.chapter__points li::before {
  content: "";
  position: absolute;
  top: .72em;
  left: 0;
  width: .45rem;
  height: 1.5px;
  background: rgba(var(--fg-rgb), .45);
}
html:not([data-mode="dark"]) .chapter__points li { color: rgba(var(--fg-rgb), .9); }
html:not([data-mode="dark"]) .chapter__org { color: rgba(var(--fg-rgb), .82); }
html:not([data-mode="dark"]) .chapter__dates { color: rgba(var(--fg-rgb), .78); }
@media (min-width: 1280px) { .chapter__title { font-size: 2.15rem; } }

/* phones: title and year pin to the top, the chapters scroll under them */
@media (max-width: 767.98px) {
  .story__wrap { padding: 0 0 1.5rem; }
  .story__grid { grid-template-columns: 1fr; gap: 0; }
  .story__aside {
    top: 0;
    z-index: 3;
    justify-content: flex-start;
    height: auto;
    margin: 0 -1.25rem;
    padding: 1.25rem 1.25rem .9rem;
    padding-top: calc(var(--topbar-h, 4.4rem) + 1rem) !important;
    border-bottom: 1px solid rgba(26, 24, 24, .1);
    background: #F4F1EE;
    box-shadow: 0 10px 16px -12px rgba(26, 24, 24, .25);
  }
  html[data-mode="dark"] .story__aside {
    border-bottom-color: rgba(232, 228, 224, .08);
    background: #171515;
    box-shadow: 0 10px 16px -12px rgba(0, 0, 0, .7);
  }
  .story__tunnel,
  .story__aside .kicker { display: none; }
  .story__title { margin-top: 0; font-size: 1.6rem; }
  .odometer { margin-top: .35rem; font-size: clamp(3.4rem, 17vw, 4.5rem); }
  .story__dates { margin-top: .25rem; font-size: .6875rem; }
  .story__meter { margin-top: .5rem; font-size: .8125rem; }
  .timeline { padding-top: 1rem; padding-bottom: 6vh; }
  .timeline__list { padding-left: 2.1rem; }
  .chapter { padding: 1.75rem 0; }
  .chapter__title { font-size: 1.45rem; }
  .chapter__org { margin-bottom: .6rem; font-size: .9375rem; }
  .chapter__points li { font-size: .9375rem; }
}
@media (prefers-reduced-motion: reduce) {
  .chapter { opacity: 1; }
  .odometer__reel { transition: none; }
  .story__tunnel { display: none; }
}
