:root {
  --intro-bg: #36383f;
  --accent: #008e72;
  --ink: #1d1d1b;
  --fit: 1;
  --font: "Source Sans Pro", "Source Sans 3", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--intro-bg);
  color: #fff;
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

p, h2, h3, ul { margin: 0; }
ul { padding: 0; list-style: none; }

/* ---------- Stage ---------- */

.story { position: relative; }

.stage {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  background: var(--intro-bg);
}

/* The dark overview color, then each event's color wipes in from the bottom over the previous one. */
.bg-colors, .bg-color { position: absolute; inset: 0; }
.bg-color--intro { background: var(--intro-bg); }

.bg-pattern {
  position: absolute;
  left: -13.03%;
  top: -19.55%;
  width: 126.14%;
  aspect-ratio: 1;
  pointer-events: none;
}
.bg-pattern img { display: block; width: 100%; height: 100%; }

/* ---------- Level shapes: Makro = square, Meso = diamond, Mikro = circle ---------- */

.shape {
  --s: 8px;
  position: relative;
  display: block;
  width: var(--s);
  height: var(--s);
  flex: none;
}
.shape::before {
  content: "";
  position: absolute;
  inset: 0;
  background: #fff;
  transition: inset .25s ease, border-radius .25s ease;
}
.shape--mikro::before { border-radius: 50%; }
/* A rotated square whose corners touch the box edges. */
.shape--meso::before { inset: 14.6%; transform: rotate(45deg); }

/* ---------- Overview (frame 1) ---------- */

.overview { position: absolute; inset: 0; }

.levels {
  position: absolute;
  left: 50%;
  top: 50%;
  display: flex;
  gap: 32px;
  transform: translate(-50%, -50%) scale(var(--fit-o, 1));
}

.level {
  width: 320px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}
/* Staggered like in the design: Meso sits lower, Mikro higher. */
.level--meso { margin-top: 96px; }
.level--mikro { margin-top: -32px; }

.level-icon { width: 96px; height: 96px; margin-bottom: 20px; }
.level-name { font-size: 16px; line-height: 1.45; letter-spacing: .03em; opacity: .5; }
.level-title { font-weight: 700; font-size: 24px; line-height: 1.2; letter-spacing: .3px; margin-top: 4px; }
.level-text { font-size: 16px; line-height: 1.45; letter-spacing: .03em; margin-top: 14px; }

.scroll-hint {
  position: absolute;
  left: 50%;
  bottom: 40px;
  transform: translateX(-50%);
  padding: 8px 16px;
  border: 0;
  background: rgba(255, 255, 255, .1);
  color: #fff;
  font: inherit;
  font-size: 16px;
  line-height: 1.45;
  letter-spacing: .03em;
  cursor: pointer;
  animation: hint-bob 2s ease-in-out infinite;
  transition: background-color .2s ease;
}
.scroll-hint:hover { background: rgba(255, 255, 255, .18); }

@keyframes hint-bob {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 6px; }
}

/* ---------- Timeline (desktop: vertical on the left) ---------- */

.timeline {
  position: absolute;
  left: 37px;
  top: 36px;
  height: min(513px, calc(100% - 36px - 170px));
  width: 0;
  z-index: 20;
  --p: 0;
  --reveal: 1;
  /* Draw-in: everything above the edge at --reveal is visible (generous sides for the shapes and the label). */
  clip-path: polygon(-30px -30px, 300px -30px, 300px calc(var(--reveal) * (100% + 60px) - 30px), -30px calc(var(--reveal) * (100% + 60px) - 30px));
}

.rail { position: absolute; inset: 0; }

.rail-dotted {
  position: absolute;
  left: -1px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: repeating-linear-gradient(to bottom, rgba(255, 255, 255, .7) 0 2px, transparent 2px 5px);
}

.rail-fill {
  position: absolute;
  left: -1px;
  top: 0;
  width: 2px;
  height: calc(var(--p) * 100%);
  background: #fff;
}

.node {
  position: absolute;
  left: 0;
  top: calc(var(--t) * 100%);
  transform: translate(-50%, -50%);
  cursor: pointer;
}

.node .shape { transition: width .25s ease, height .25s ease; }
.node.is-active .shape { --s: 20px; }

/* One label that slides to the active node. */
.tl-label {
  position: absolute;
  left: 26px;
  top: calc(var(--t, 0) * 100%);
  transform: translateY(-50%);
  font-weight: 700;
  font-size: 16px;
  line-height: 1;
  letter-spacing: .03em;
  font-feature-settings: "liga" 0;
  white-space: nowrap;
  transition: top .3s ease, opacity .3s ease;
}

.caption { display: none; }

/* ---------- Legend ---------- */

.legend {
  position: absolute;
  left: 27px;
  bottom: 26px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  z-index: 20;
}

.legend li {
  display: flex;
  align-items: center;
  gap: 16px;
  font-weight: 700;
  font-size: 16px;
  line-height: 1;
  letter-spacing: .03em;
}
.legend .shape { --s: 20px; }

/* ---------- Card stack ---------- */

.stack {
  position: absolute;
  left: calc(50% + 40px);
  top: 50%;
  width: 0;
  height: 0;
  transform: scale(var(--fit));
  pointer-events: none;
}

/* Every card has its own format (--dw × --dh, set in main-d.js), centered on the stack point. */
.card {
  --w: var(--dw);
  --h: var(--dh);
  position: absolute;
  left: calc(var(--w) / -2);
  top: calc(var(--h) / -2);
  width: var(--w);
  height: var(--h);
  transform-origin: 50% 50%;
  filter: drop-shadow(0 24px 40px rgba(0, 0, 0, .22));
  pointer-events: auto;
  will-change: transform;
}

/* Chamfered corners are set per card in main-d.js via clip-path. */
.card-inner {
  position: relative;
  height: 100%;
  display: flex;
  gap: 32px;
  padding: 16px;
  background: #fff;
  color: var(--ink);
}

.card-media { position: relative; width: var(--img); flex: none; }

/* Taller cards put the image on top. */
.card--column .card-inner { flex-direction: column; gap: 20px; }
.card--column .card-media { width: auto; height: var(--img); }
.card--column .card-body { justify-content: flex-start; padding: 0 16px 8px; }
.card--column .card-title { font-size: 24px; }
.card--column .card-link { margin-top: auto; }
.card-img { display: block; width: 100%; height: 100%; object-fit: cover; }

.card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  padding-right: 16px;
}

.card-tag {
  color: var(--accent);
  font-weight: 700;
  font-size: 16px;
  line-height: 1.45;
  letter-spacing: .03em;
  margin-bottom: 4px;
}

.card-title {
  font-weight: 700;
  font-size: 28px;
  line-height: 1.2;
  letter-spacing: .35px;
}

.card-text {
  font-size: 16px;
  line-height: 1.45;
  letter-spacing: .03em;
  margin-top: 8px;
}

.card-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  padding: 8px 16px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-size: 16px;
  line-height: 1.45;
  letter-spacing: .03em;
  transition: filter .2s ease;
}
.card-link:hover { filter: brightness(1.12); }
.card-link img { width: 5px; height: 9px; opacity: .5; transition: opacity .2s ease; }
.card-link:hover img { opacity: 1; }

/* Darkens cards further back in the stack. */
.card-shade {
  position: absolute;
  inset: 0;
  background: #000;
  opacity: 0;
  pointer-events: none;
}

/* Play button: solid circle stays put, a halo pulses outwards behind it. */
.play {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 64px;
  height: 64px;
  margin: -32px 0 0 -32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  isolation: isolate;
  transition: transform .25s ease;
}
.play:hover { transform: scale(1.12); }
.play svg { position: absolute; left: 28px; top: 24px; }
.play::before,
.play::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: 50%;
  background: var(--accent);
  animation: play-pulse 2.4s cubic-bezier(.2, .6, .35, 1) infinite;
}
.play::after { animation-delay: 1.2s; }
@keyframes play-pulse {
  from { transform: scale(1); opacity: .4; }
  to { transform: scale(1.9); opacity: 0; }
}
.play:focus-visible { outline: 2px solid #fff; outline-offset: 4px; }

/* ---------- Mobile: timeline becomes a bar at the top, card goes vertical ---------- */

@media (max-width: 767px) {
  .levels { flex-direction: column; gap: 20px; }
  .level, .level--meso, .level--mikro { width: min(320px, calc(100vw - 48px)); margin-top: 0; }
  .level-icon { width: 40px; height: 40px; margin-bottom: 8px; }
  .level-title { font-size: 20px; }
  .level-text { font-size: 14px; margin-top: 6px; }
  .scroll-hint { bottom: 20px; }

  .timeline {
    left: 24px;
    right: 24px;
    top: 24px;
    width: auto;
    height: 0;
  }
  .timeline {
    clip-path: polygon(-30px -30px, calc(var(--reveal) * (100% + 60px) - 30px) -30px, calc(var(--reveal) * (100% + 60px) - 30px) 60px, -30px 60px);
  }
  .rail-dotted {
    left: 0;
    right: 0;
    top: -1px;
    bottom: auto;
    width: auto;
    height: 2px;
    background: repeating-linear-gradient(to right, rgba(255, 255, 255, .7) 0 2px, transparent 2px 5px);
  }
  .rail-fill { left: 0; top: -1px; height: 2px; width: calc(var(--p) * 100%); }
  .node { left: calc(var(--t) * 100%); top: 0; }
  .node .shape { --s: 7px; }
  .node.is-active .shape { --s: 14px; }
  .tl-label { display: none; }

  .caption {
    display: block;
    position: absolute;
    left: -6px;
    top: 18px;
    font-weight: 700;
    font-size: 14px;
    line-height: 1.2;
    letter-spacing: .03em;
    white-space: nowrap;
  }
  .caption span { opacity: .7; font-weight: 400; }

  .legend { display: none; }

  .stack {
    left: 50%;
    top: calc(50% + 28px);
    transform: none;
  }
  .card { --w: calc(100vw - 32px); --h: min(var(--mh), calc(100vh - 120px)); }
  .card-inner, .card--column .card-inner { flex-direction: column; gap: 16px; padding: 12px; }
  .card-media, .card--column .card-media { width: auto; height: 40%; }
  .card-body { justify-content: flex-start; padding: 0 8px 8px; overflow: hidden; }
  .card-title, .card--column .card-title { font-size: 20px; }
  .card-link { margin-top: auto; } /* every card is vertical on mobile */
  .card-text { font-size: 15px; }
}

@media (prefers-reduced-motion: reduce) {
  .shape::before, .node .shape, .tl-label, .play { transition: none; }
  .scroll-hint { animation: none; }
  .play::before { animation: none; transform: scale(1.5); opacity: .25; }
  .play::after { animation: none; opacity: 0; }
}
