:root {
  --page-bg: #050607;
  --text: #f7efe2;
  --accent: #e9b45d;
  --story-height: 470vh;
  --frame-radius: 0;
  --button-bg: rgba(9, 12, 18, 0.62);
  --button-border: rgba(255, 227, 167, 0.65);
  --button-shadow: 0 1.2rem 2.6rem rgba(0, 0, 0, 0.35);
  --cover-aspect: 1.4071702945;
  --cover-width-from-height: 71.061%;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--page-bg);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 50% 18%, rgba(35, 92, 129, 0.34), transparent 32%),
    radial-gradient(circle at 50% 62%, rgba(255, 150, 53, 0.16), transparent 24%),
    linear-gradient(180deg, #06070c 0%, #06080d 44%, #070404 100%);
  color: var(--text);
  font-family: "Cormorant Garamond", Georgia, serif;
  overflow-x: hidden;
}

a {
  color: inherit;
}

.page-shell {
  position: relative;
}

.story {
  position: relative;
  height: var(--story-height);
}

.story-pin {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
}

.scene-frame {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  border-radius: var(--frame-radius);
  isolation: isolate;
  background: #030507;
}

.scene-layer,
.artboard,
.flame-stage,
.author-mask,
.finale,
.scene-vignette,
.scene-glow,
.scroll-hint {
  position: absolute;
  inset: 0;
}

.artboard {
  left: 50%;
  top: 50%;
  width: 100vw;
  height: max(100vh, calc(100vw / 0.71061));
  transform: translate(-50%, -50%);
}

.flame-stage {
  z-index: 4;
  left: 50%;
  top: 50%;
  width: 100vw;
  height: max(100vh, calc(100vw / 0.71061));
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.scene-layer {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  will-change: transform, opacity, filter;
  user-select: none;
  -webkit-user-drag: none;
}

.scene-layer-bg {
  z-index: 1;
}

.scene-layer-buildings {
  z-index: 2;
  opacity: 0;
}

.author-mask {
  z-index: 3;
  overflow: hidden;
  pointer-events: none;
}

.author-name {
  position: absolute;
  left: 50%;
  top: clamp(1.8rem, 5.6vh, 4.8rem);
  width: clamp(18rem, 34vw, 34rem);
  transform: translate(-50%, 0);
  transform-origin: center top;
  will-change: transform, opacity, filter;
  filter: drop-shadow(0 0.65rem 1rem rgba(0, 0, 0, 0.55));
}

.scene-layer-flame {
  z-index: 4;
  opacity: 0;
  filter: drop-shadow(0 0 1.9rem rgba(255, 145, 40, 0.2));
}

.finale {
  z-index: 5;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: clamp(1rem, 2.4vh, 1.45rem);
  padding: 1.5rem;
  pointer-events: none;
}

.book-title {
  width: clamp(15rem, 28vw, 29rem);
  transform: translateY(18vh);
  opacity: 0;
  will-change: transform, opacity, filter;
  filter: drop-shadow(0 0.8rem 1.2rem rgba(0, 0, 0, 0.55));
}

.enter-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: clamp(1rem, 3vh, 1.8rem);
  min-width: 10.5rem;
  min-height: 3.45rem;
  padding: 0.86rem 1.8rem 0.84rem;
  border: 1px solid var(--button-border);
  border-radius: 999px;
  background: var(--button-bg);
  box-shadow: var(--button-shadow);
  color: var(--text);
  font-size: clamp(1.15rem, 2vw, 1.45rem);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-decoration: none;
  text-transform: uppercase;
  backdrop-filter: blur(10px);
  opacity: 0;
  transform: translateY(2.8rem);
  pointer-events: none;
  transition:
    background 180ms ease,
    border-color 180ms ease,
    transform 180ms ease,
    box-shadow 180ms ease,
    opacity 180ms ease;
}

.enter-button:hover,
.enter-button:focus-visible {
  background: rgba(18, 23, 33, 0.82);
  border-color: rgba(255, 234, 182, 0.92);
  transform: translateY(0) scale(1.02);
  box-shadow: 0 1.45rem 2.8rem rgba(0, 0, 0, 0.42);
  outline: none;
}

.scene-vignette {
  z-index: 6;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(2, 5, 8, 0.55) 0%, transparent 18%, transparent 76%, rgba(1, 3, 5, 0.76) 100%),
    linear-gradient(90deg, rgba(2, 5, 8, 0.5) 0%, transparent 14%, transparent 86%, rgba(2, 5, 8, 0.52) 100%);
  mix-blend-mode: multiply;
}

.scene-glow {
  z-index: 0;
  pointer-events: none;
}

.scene-glow-top {
  background: radial-gradient(circle at 50% 12%, rgba(77, 157, 203, 0.18), transparent 36%);
}

.scene-glow-bottom {
  background: radial-gradient(circle at 50% 78%, rgba(255, 170, 71, 0.16), transparent 24%);
}

.scroll-hint {
  z-index: 7;
  inset: auto auto 2.2rem 50%;
  width: auto;
  height: auto;
  transform: translateX(-50%);
  color: rgba(247, 239, 226, 0.88);
  opacity: 1;
  will-change: opacity, transform;
  pointer-events: none;
}

.scroll-hint-body {
  display: grid;
  justify-items: center;
  gap: 0.55rem;
}

.scroll-hint-label {
  font-size: 0.9rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.scroll-hint-arrow {
  width: 1rem;
  height: 1rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  animation: hintPulse 1.8s ease-in-out infinite;
}

@keyframes hintPulse {
  0%,
  100% {
    transform: rotate(45deg) translateY(0);
  }

  50% {
    transform: rotate(45deg) translateY(0.45rem);
  }
}

@media (max-width: 900px) {
  .author-name {
    top: clamp(1.6rem, 5.8vh, 3.8rem);
    width: clamp(14rem, 46vw, 24rem);
  }

  .book-title {
    width: clamp(13rem, 42vw, 21rem);
  }
}

@media (min-aspect-ratio: 4 / 3) and (min-width: 900px) {
  .book-title {
    width: clamp(22rem, 42vw, 43rem);
  }
}

@media (max-width: 640px) {
  :root {
    --story-height: 430vh;
  }

  .author-name {
    top: clamp(1.4rem, 5.2vh, 3rem);
    width: min(78vw, 24rem);
  }

  .book-title {
    width: min(76vw, 20rem);
  }

  .scroll-hint {
    bottom: 1.6rem;
  }

  .enter-button {
    min-width: 9.25rem;
    padding-inline: 1.55rem;
    font-size: 1.05rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .story {
    height: auto;
  }

  .story-pin {
    position: relative;
    min-height: 100vh;
    padding: 0;
  }

  .scene-layer-bg,
  .scene-layer-buildings,
  .scene-layer-flame,
  .author-name,
  .book-title,
  .enter-button {
    transform: none !important;
    transition: none !important;
  }

  .artboard {
    width: 100vw;
    height: max(100vh, calc(100vw / 0.71061));
  }

  .flame-stage {
    width: 100vw;
    height: max(100vh, calc(100vw / 0.71061));
  }

  .scene-layer-buildings,
  .scene-layer-flame,
  .book-title,
  .enter-button {
    opacity: 1 !important;
  }

  .author-name {
    opacity: 0 !important;
  }

  .finale {
    align-content: center;
  }

  .enter-button {
    pointer-events: auto;
  }

  .scroll-hint {
    display: none;
  }

  .scroll-hint-arrow {
    animation: none;
  }
}
