/* About: "Scaleran tarina". Long-form text, words light up as read, night turns to dawn. */
.saga {
  --p: 0;
  position: relative;
  color: #f4f2ff;
  background: #04060d;
  /* The sticky background must not spill past the section (clip keeps sticky working). */
  overflow: clip;
}

/* Background stays in view while the story scrolls over it.
   Only opacity and transform change while scrolling, so the browser composites
   the layers instead of repainting large gradients on every frame. */
.saga-bg {
  position: sticky;
  top: 0;
  height: 100vh;
  margin-bottom: -100vh;
  overflow: hidden;
  pointer-events: none;
  background:
    radial-gradient(ellipse 60% 50% at 85% 15%, rgba(66, 18, 163, 0.18), transparent 70%),
    linear-gradient(180deg, #04060d 0%, #070a1c 55%, #0b0f2a 100%);
}
.saga-bg::before {
  content: "";
  position: absolute;
  inset: -20% -40%;
  background: radial-gradient(ellipse 40% 35% at 40% 40%, rgba(25, 0, 255, 0.34), transparent 70%);
  opacity: calc(0.55 + var(--p) * 0.45);
  transform: translate3d(calc(var(--p) * 22%), calc(var(--p) * 4%), 0);
  will-change: transform, opacity;
}
.saga-stars {
  position: absolute;
  inset: -10%;
  opacity: calc(0.55 - var(--p) * 0.8);
  transform: translate3d(0, calc(var(--p) * -8%), 0);
  will-change: transform, opacity;
  background-image:
    radial-gradient(1px 1px at 12% 18%, #fff, transparent 60%),
    radial-gradient(1px 1px at 27% 64%, rgba(255, 255, 255, 0.8), transparent 60%),
    radial-gradient(1.5px 1.5px at 41% 32%, #fff, transparent 60%),
    radial-gradient(1px 1px at 58% 12%, rgba(255, 255, 255, 0.7), transparent 60%),
    radial-gradient(1px 1px at 66% 48%, #fff, transparent 60%),
    radial-gradient(1.5px 1.5px at 79% 26%, rgba(255, 255, 255, 0.85), transparent 60%),
    radial-gradient(1px 1px at 88% 70%, #fff, transparent 60%),
    radial-gradient(1px 1px at 8% 82%, rgba(255, 255, 255, 0.7), transparent 60%),
    radial-gradient(1px 1px at 35% 88%, #fff, transparent 60%),
    radial-gradient(1px 1px at 93% 40%, rgba(255, 255, 255, 0.6), transparent 60%);
  background-size: 640px 640px;
}
/* Dawn rises over the horizon in the last chapters. */
.saga-dawn {
  position: absolute;
  left: -20%;
  right: -20%;
  bottom: -55vh;
  height: 110vh;
  opacity: calc((var(--p) - 0.45) * 1.1);
  transform: translate3d(0, calc((1 - var(--p)) * 30vh), 0);
  will-change: transform, opacity;
  background:
    radial-gradient(ellipse 50% 45% at 50% 50%, rgba(255, 196, 140, 0.55), transparent 70%),
    radial-gradient(ellipse 75% 60% at 50% 55%, rgba(255, 122, 92, 0.35), transparent 72%),
    radial-gradient(ellipse 100% 70% at 50% 60%, rgba(110, 92, 255, 0.35), transparent 75%);
}

.saga-content { position: relative; z-index: 1; padding: clamp(6rem, 16vh, 10rem) 0 clamp(4rem, 12vh, 8rem); max-width: min(880px, calc(100vw - 32px)); }

.saga-kicker { margin: 0 0 clamp(2.5rem, 8vh, 5rem); color: #b9b0ff; font-size: 1rem; font-weight: 800; letter-spacing: 0; }

.saga-chapter { margin-bottom: clamp(3.5rem, 14vh, 8rem); }
.saga-label { display: flex; align-items: baseline; gap: 0.9rem; margin: 0 0 1.25rem; color: rgba(244, 242, 255, 0.5); font-size: 0.95rem; font-weight: 800; }
.saga-label span:first-child { color: #b9b0ff; font-size: 0.85rem; letter-spacing: 0.08em; min-width: 2.2ch; }

.saga-line {
  margin: 0 0 1.4rem;
  font-size: clamp(1.15rem, 2vw, 1.6rem);
  font-weight: 500;
  line-height: 1.5;
  letter-spacing: -0.01em;
  max-width: 40ch;
  color: rgba(244, 242, 255, 0.92);
  text-wrap: pretty;
}
.saga-lead { font-size: clamp(1.9rem, 4vw, 3.2rem); font-weight: 700; line-height: 1.08; letter-spacing: -0.035em; max-width: 20ch; color: #fff; }

.saga-w { opacity: 0.3; transition: opacity 450ms ease; }
.saga-w.on { opacity: 1; }

.saga-closing { padding-top: clamp(2rem, 6vh, 3.5rem); border-top: 1px solid rgba(255, 255, 255, 0.12); }
.saga-closing-title { margin: 0 0 1.5rem; font-size: clamp(1.4rem, 2.6vw, 2rem); font-weight: 700; line-height: 1.15; letter-spacing: -0.02em; max-width: 26ch; }
.saga-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.saga .btn-primary { color: #fff; background: #1900ff; border-color: #1900ff; box-shadow: 0 12px 30px rgba(25, 0, 255, 0.35); }
.saga-ghost { color: #fff !important; background: transparent !important; border-color: rgba(255, 255, 255, 0.35) !important; }

.saga.is-static .saga-w { opacity: 1; }

@media (max-width: 640px) {
  .saga-line { max-width: none; }
  .saga-stars { background-size: 420px 420px; }
}

/* The last line of the story is the finale. */
.saga-chapter:last-of-type .saga-line:last-child { font-size: clamp(1.5rem, 2.8vw, 2.2rem); font-weight: 700; letter-spacing: -0.025em; color: #fff; }

/* Soft bridge from the dawn into the light, warm-green About page below. */
.saga::after {
  content: "";
  position: relative;
  z-index: 1;
  display: block;
  height: 70vh;
  margin-top: -10vh;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    rgba(11, 15, 42, 0) 0%,
    rgba(28, 44, 52, 0.55) 22%,
    rgba(52, 82, 72, 0.7) 42%,
    rgba(111, 143, 127, 0.75) 62%,
    rgba(200, 212, 202, 0.92) 82%,
    var(--bg, #f3f2ee) 100%
  );
}
html[data-theme="dark"] .saga::after {
  background: linear-gradient(180deg, rgba(11, 15, 42, 0) 0%, rgba(20, 34, 32, 0.7) 50%, var(--bg, #0b0e14) 100%);
}
