.lore-section {
  position: relative;
  scroll-margin-top: 5rem;
  overflow: hidden;
  border-top: 1px solid rgba(233, 231, 221, 0.12);
  background:
    radial-gradient(circle at 88% 8%, rgba(255, 92, 22, 0.1), transparent 28rem),
    radial-gradient(circle at 12% 42%, rgba(216, 255, 62, 0.045), transparent 32rem),
    #050605;
  color: var(--bone);
}

.lore-section::before {
  position: absolute;
  inset: 0;
  content: "";
  pointer-events: none;
  opacity: 0.18;
  background-image:
    linear-gradient(rgba(233, 231, 221, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(233, 231, 221, 0.035) 1px, transparent 1px);
  background-size: 5rem 5rem;
  mask-image: linear-gradient(to bottom, #000, transparent 72%);
}

.lore-shell {
  position: relative;
  width: min(100%, 96rem);
  margin: 0 auto;
  padding: clamp(5rem, 10vw, 10rem) clamp(1.25rem, 5vw, 5rem);
}

.lore-header {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(18rem, 0.65fr);
  align-items: end;
  gap: clamp(2.5rem, 8vw, 9rem);
  margin-bottom: clamp(5rem, 11vw, 11rem);
}

.lore-header > p,
.lore-copy > p:first-child,
.lore-final-line {
  font-family: "DM Mono", monospace;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.lore-header > p {
  grid-column: 1 / -1;
  margin: 0 0 -1rem;
  color: rgba(233, 231, 221, 0.48);
  font-size: 0.68rem;
}

.lore-header > p span {
  margin-right: 0.75rem;
  color: var(--acid);
}

.lore-header h2 {
  margin: 0;
  font-family: "Archivo Black", sans-serif;
  font-size: clamp(4.4rem, 10.5vw, 11rem);
  line-height: 0.77;
  letter-spacing: -0.072em;
}

.lore-intro {
  margin-bottom: 0.3rem;
  padding: 1.5rem 0;
  border-top: 1px solid rgba(233, 231, 221, 0.18);
  border-bottom: 1px solid rgba(233, 231, 221, 0.18);
}

.lore-intro strong {
  color: var(--acid);
  font: 500 0.68rem/1.55 "DM Mono", monospace;
  letter-spacing: 0.1em;
}

.lore-intro p {
  margin: 1rem 0 0;
  color: rgba(233, 231, 221, 0.64);
  font-size: clamp(0.92rem, 1.25vw, 1.08rem);
  line-height: 1.72;
}

.lore-chapters {
  display: grid;
  gap: clamp(5rem, 10vw, 10rem);
  margin: 0;
  padding: 0;
  list-style: none;
}

.lore-chapter {
  display: grid;
  grid-template-columns: minmax(0, 1.03fr) minmax(18rem, 0.78fr);
  align-items: center;
  gap: clamp(2.5rem, 8vw, 9rem);
  min-height: min(78svh, 58rem);
  padding-top: clamp(2.5rem, 5vw, 5rem);
  border-top: 1px solid rgba(233, 231, 221, 0.14);
}

.lore-chapter-reverse {
  grid-template-columns: minmax(18rem, 0.78fr) minmax(0, 1.03fr);
}

.lore-chapter-reverse .lore-visual {
  grid-column: 2;
}

.lore-chapter-reverse .lore-copy {
  grid-row: 1;
  grid-column: 1;
}

.lore-visual {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 0.92;
  margin: 0;
  overflow: hidden;
  border: 1px solid rgba(233, 231, 221, 0.14);
  background: #14110d;
  box-shadow: 0 2rem 7rem rgba(0, 0, 0, 0.38);
}

.lore-visual::before,
.lore-visual::after {
  position: absolute;
  inset: 0;
  z-index: 1;
  content: "";
  pointer-events: none;
}

.lore-visual::before {
  background:
    linear-gradient(180deg, transparent 48%, rgba(5, 6, 5, 0.84)),
    radial-gradient(circle at 75% 18%, transparent, rgba(5, 6, 5, 0.2));
}

.lore-visual::after {
  inset: 0.8rem;
  border: 1px solid rgba(216, 255, 62, 0.18);
}

.lore-sprite img {
  position: absolute;
  top: calc(var(--row) * -100%);
  left: calc(var(--col) * -100%);
  width: 500%;
  max-width: none;
  height: 300%;
  object-fit: fill;
  filter: saturate(0.9) contrast(1.06) brightness(0.88);
  transition: transform 800ms cubic-bezier(0.2, 0.8, 0.2, 1), filter 800ms ease;
}

.lore-chapter:hover .lore-sprite img {
  transform: scale(1.025);
  filter: saturate(1) contrast(1.08) brightness(0.94);
}

.lore-visual > span {
  position: absolute;
  right: 1.4rem;
  bottom: 0.9rem;
  z-index: 2;
  color: var(--bone);
  font-family: "Archivo Black", sans-serif;
  font-size: clamp(4rem, 8vw, 8rem);
  line-height: 0.75;
  letter-spacing: -0.075em;
}

.lore-copy {
  max-width: 38rem;
}

.lore-copy > p:first-child {
  margin: 0 0 1.4rem;
  color: var(--acid);
  font-size: 0.64rem;
}

.lore-copy h3 {
  margin: 0 0 clamp(2rem, 4vw, 3.6rem);
  font-family: "Archivo Black", sans-serif;
  font-size: clamp(3.2rem, 6.7vw, 7rem);
  line-height: 0.82;
  letter-spacing: -0.065em;
}

.lore-chapter-final h3 em {
  color: var(--acid);
  font-style: normal;
}

.lore-copy > p:not(:first-child) {
  max-width: 58ch;
  margin: 0;
  color: rgba(233, 231, 221, 0.63);
  font-size: clamp(0.95rem, 1.3vw, 1.1rem);
  line-height: 1.75;
}

.lore-copy > p:not(:first-child) + p {
  margin-top: 1.25rem;
  color: rgba(233, 231, 221, 0.84);
}

.lore-final-line {
  display: flex;
  justify-content: space-between;
  gap: 2rem;
  margin-top: clamp(6rem, 12vw, 12rem);
  padding: 1.5rem 0;
  border-top: 1px solid var(--acid);
  border-bottom: 1px solid rgba(233, 231, 221, 0.15);
  color: rgba(233, 231, 221, 0.54);
  font-size: 0.62rem;
  line-height: 1.6;
}

.lore-final-line strong {
  color: var(--acid);
  font-weight: 500;
}

@supports ((animation-timeline: scroll()) and (animation-range: 0% 100%)) {
  .lore-chapter {
    view-timeline: --lore-chapter block;
  }

  .lore-visual,
  .lore-copy {
    animation: lore-reveal linear both;
    animation-timeline: --lore-chapter;
    animation-range: entry 5% cover 36%;
  }

  .lore-copy {
    animation-name: lore-copy-reveal;
  }

  @keyframes lore-reveal {
    from { opacity: 0.24; transform: translateY(3rem) scale(0.975); }
    to { opacity: 1; transform: translateY(0) scale(1); }
  }

  @keyframes lore-copy-reveal {
    from { opacity: 0.15; transform: translateY(2.2rem); }
    to { opacity: 1; transform: translateY(0); }
  }
}

@media (max-width: 850px) {
  .lore-header,
  .lore-chapter,
  .lore-chapter-reverse {
    grid-template-columns: 1fr;
  }

  .lore-header > p {
    margin-bottom: 0;
  }

  .lore-chapter {
    gap: 2.5rem;
    min-height: auto;
  }

  .lore-chapter-reverse .lore-visual,
  .lore-chapter-reverse .lore-copy {
    grid-row: auto;
    grid-column: auto;
  }

  .lore-copy {
    max-width: 44rem;
  }
}

@media (max-width: 600px) {
  .lore-section {
    scroll-margin-top: 4rem;
  }

  .lore-shell {
    padding-top: 4.5rem;
    padding-bottom: 5.5rem;
  }

  .lore-header {
    margin-bottom: 5.5rem;
  }

  .lore-header h2 {
    font-size: clamp(3.7rem, 18vw, 6.2rem);
  }

  .lore-chapters {
    gap: 5.5rem;
  }

  .lore-visual {
    aspect-ratio: 1 / 1;
  }

  .lore-copy h3 {
    font-size: clamp(3rem, 15vw, 5.2rem);
  }

  .lore-final-line {
    flex-direction: column;
    gap: 0.8rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .lore-visual,
  .lore-copy,
  .lore-sprite img {
    animation: none !important;
    transform: none !important;
    transition: none !important;
  }
}
