:root {
  --bg: #050b12;
  --deep: #0b1825;
  --sand: #e6d8bd;
  --sand-soft: rgba(230, 216, 189, 0.72);
  --line: rgba(230, 216, 189, 0.12);
  --amber: #e2b16a;
  --teal: #6d9ba1;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--sand);
  font-family: Georgia, "Times New Roman", serif;
}

body::before,
body::after {
  content: none;
}

a {
  color: inherit;
  text-decoration: none;
}

.experience {
  position: relative;
  z-index: 2;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

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

.scene-shell {
  position: absolute;
  inset: 0;
  isolation: isolate;
  overflow: hidden;
  background:
    radial-gradient(circle at 52% 74%, rgba(236, 228, 210, 0.028), transparent 22%),
    radial-gradient(circle at 24% 18%, rgba(236, 228, 210, 0.04), transparent 22%),
    radial-gradient(circle at 72% 28%, rgba(109, 155, 161, 0.055), transparent 28%),
    radial-gradient(circle at 62% 82%, rgba(226, 177, 106, 0.05), transparent 22%),
    linear-gradient(180deg, #03070d, #08111a 56%, #071018);
}

.scene-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  animation: page-canvas-fade-in 900ms cubic-bezier(0.2, 0.8, 0.18, 1) both;
}

.chapter-four-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.018), transparent 18%),
    radial-gradient(circle at 52% 48%, rgba(236, 228, 210, 0.018), transparent 22%),
    radial-gradient(circle at 18% 58%, rgba(231, 191, 121, 0.04), transparent 20%),
    radial-gradient(circle at 82% 38%, rgba(122, 163, 170, 0.028), transparent 28%),
    repeating-linear-gradient(
      90deg,
      transparent 0,
      transparent 56px,
      rgba(255, 255, 255, 0.008) 57px
    );
  mix-blend-mode: soft-light;
}

.chapter-four-shell::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    radial-gradient(circle at 48% 54%, transparent 14%, rgba(2, 7, 14, 0.24) 66%, rgba(2, 7, 14, 0.42) 100%),
    linear-gradient(180deg, rgba(2, 7, 14, 0.2), transparent 16%, transparent 72%, rgba(2, 7, 14, 0.36));
}

.chapter-four-overlay {
  position: relative;
  z-index: 10;
  min-height: 100vh;
  padding: 6vh clamp(1.4rem, 3.8vw, 4rem) 4vh;
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 2rem;
  animation: page-ui-fade-in 780ms cubic-bezier(0.2, 0.8, 0.18, 1) both;
  animation-delay: 90ms;
}

.chapter-four-hero {
  position: absolute;
  right: 3rem;
  bottom: calc(50% + 3.9rem);
  z-index: 12;
  width: min(38rem, 68vw);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
}

.chapter-four-title {
  margin: 0;
  font-size: clamp(3.8rem, 8.4vw, 6.8rem);
  line-height: 0.92;
  font-weight: 500;
  letter-spacing: -0.045em;
  color: rgba(236, 228, 210, 0.92);
  text-shadow:
    0 0 14px rgba(232, 219, 188, 0.06),
    0 0 36px rgba(226, 177, 106, 0.028),
    0 20px 48px rgba(0, 0, 0, 0.46),
    0 0 64px rgba(236, 228, 210, 0.02);
}

.chapter-four-description {
  margin: 2.2rem 0 0;
  width: 100%;
  color: rgba(227, 223, 212, 0.68);
  line-height: 1.9;
  font-size: clamp(0.98rem, 1.02vw, 1.06rem);
  letter-spacing: 0.012em;
  word-break: keep-all;
  overflow-wrap: normal;
  text-shadow:
    0 10px 28px rgba(0, 0, 0, 0.38),
    0 0 18px rgba(236, 228, 210, 0.018),
    0 0 36px rgba(236, 228, 210, 0.012);
}

.chapter-four-description span {
  display: block;
  white-space: nowrap;
}

.chapter-four-ticker {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
  align-items: center;
  justify-self: end;
  color: rgba(224, 220, 209, 0.26);
  font-family: "Courier New", monospace;
  font-size: 0.65rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  padding-bottom: 0.45rem;
  animation: page-ui-fade-in 780ms cubic-bezier(0.2, 0.8, 0.18, 1) both;
  animation-delay: 140ms;
}

.chapter-four-ticker p {
  margin: 0;
}

.chapter-four-ticker p::after {
  content: " /";
  margin-left: 1.25rem;
  color: rgba(226, 177, 106, 0.24);
}

.chapter-four-ticker p:last-child::after {
  content: "";
  margin: 0;
}

.panel-nav {
  position: absolute;
  z-index: 11;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.92rem 1rem;
  color: var(--sand);
  border: 1px solid rgba(230, 216, 189, 0.14);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.018), rgba(255, 255, 255, 0.006)),
    rgba(7, 12, 20, 0.56);
  box-shadow:
    inset 0 0 0 1px rgba(226, 177, 106, 0.025),
    0 18px 36px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(6px);
  font-family: "Courier New", monospace;
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  cursor: pointer;
  transition:
    border-color 180ms ease,
    transform 180ms ease,
    box-shadow 180ms ease;
  animation: page-ui-fade-in 820ms cubic-bezier(0.2, 0.8, 0.18, 1) both;
  animation-delay: 180ms;
}

.panel-prev {
  left: 3rem;
}

.panel-prev::after {
  content: "\2190";
  font-size: 1rem;
}

.panel-next {
  right: 3rem;
}

.panel-next::after {
  content: "\2192";
  font-size: 1rem;
}

.panel-nav:hover {
  transform: translateY(calc(-50% - 2px));
  border-color: rgba(226, 177, 106, 0.42);
  box-shadow:
    inset 0 0 0 1px rgba(226, 177, 106, 0.08),
    0 24px 42px rgba(0, 0, 0, 0.26);
}

.chapter-transition {
  position: fixed;
  inset: 0;
  z-index: 12;
  pointer-events: none;
  opacity: 0;
  overflow: hidden;
  transition: opacity 220ms ease;
  will-change: opacity;
}

.transition-film {
  position: absolute;
  inset: 0;
  opacity: 0;
  background:
    radial-gradient(circle at 46% 52%, rgba(255, 247, 228, 0.24), transparent 24%),
    radial-gradient(circle at 24% 54%, rgba(226, 177, 106, 0.18), transparent 18%),
    linear-gradient(90deg, rgba(226, 177, 106, 0), rgba(226, 177, 106, 0.12), rgba(226, 177, 106, 0));
}

body.arrival-transition .chapter-transition,
body.departure-transition .chapter-transition {
  opacity: 1;
}

body.arrival-transition .transition-film {
  animation: transition-film-fade 900ms cubic-bezier(0.18, 0.82, 0.14, 1) forwards;
}

body.departure-transition .transition-film {
  animation: chapter-four-fade-out 1000ms ease forwards;
  background: rgba(0, 0, 0, 1);
}

body.arrival-transition .chapter-four-shell {
  animation: chapter-four-shell-arrive 960ms cubic-bezier(0.18, 0.82, 0.14, 1) both;
}

body.departure-transition .chapter-four-shell {
  animation: none;
}

body:not(.text-ready) .chapter-four-overlay,
body:not(.text-ready) .panel-nav {
  opacity: 0;
  transform: translateY(12px);
  filter: blur(8px);
  pointer-events: none;
  animation: none !important;
}

body.text-ready .chapter-four-overlay,
body.text-ready .chapter-four-ticker,
body.text-ready .panel-nav {
  animation: page-ui-fade-in 780ms cubic-bezier(0.2, 0.8, 0.18, 1) both;
}

@keyframes chapter-four-shell-arrive {
  0% {
    opacity: 0.48;
    transform: scale(1.024);
    filter: blur(9px) brightness(0.64) saturate(0.86);
  }
  56% {
    opacity: 0.92;
    transform: scale(1.008);
    filter: blur(3px) brightness(0.84) saturate(0.94);
  }
  100% {
    opacity: 1;
    transform: scale(1);
    filter: blur(0) brightness(1) saturate(1);
  }
}

@keyframes chapter-four-shell-depart {
  0% {
    opacity: 1;
    transform: scale(1);
    filter: blur(0) brightness(1) saturate(1);
  }
  100% {
    opacity: 0.68;
    transform: scale(1.018);
    filter: blur(7px) brightness(0.74) saturate(0.84);
  }
}

@keyframes chapter-four-fade-out {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

@keyframes page-ui-fade-in {
  0% {
    opacity: 0;
    transform: translateY(14px);
    filter: blur(8px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}

@keyframes page-canvas-fade-in {
  0% {
    opacity: 0;
    filter: blur(12px) brightness(0.72);
  }
  100% {
    opacity: 1;
    filter: blur(0) brightness(1);
  }
}

@keyframes transition-film-fade {
  0% {
    opacity: 0;
    transform: scale(1.04);
    filter: blur(10px);
  }
  48% {
    opacity: 0.84;
  }
  100% {
    opacity: 0;
    transform: scale(1);
    filter: blur(0);
  }
}

@media (max-width: 900px) {
  .chapter-four-hero {
    right: 1.4rem;
    bottom: 8.5rem;
    width: min(34rem, calc(100vw - 2.8rem));
  }

  .panel-prev {
    left: 1.4rem;
  }

  .panel-next {
    right: 1.4rem;
  }
}

@media (max-width: 720px) {
  .chapter-four-overlay {
    padding: 1.25rem;
  }

  .chapter-four-hero {
    bottom: 7.4rem;
    width: calc(100vw - 2.5rem);
  }

  .chapter-four-description span {
    white-space: normal;
  }

  .chapter-four-ticker {
    justify-self: start;
    padding-bottom: 4.8rem;
  }

  .panel-nav {
    top: auto;
    bottom: 1.25rem;
    transform: none;
  }

  .panel-nav:hover {
    transform: translateY(-2px);
  }
}
