/* ============================================================
   A KING WITH NO THRONE — the doorway

   Every other place in this collection begins in darkness.
   This one begins in light, and ends in more of it.
   ============================================================ */

* { margin: 0; padding: 0; box-sizing: border-box; }

html {
  scroll-behavior: auto;
}

html, body {
  background: #f4f1ea;   /* the kingdom is made of paper and light */
  width: 100%;
  overscroll-behavior-y: none;
}

body {
  font-family: "Cormorant Garamond", serif;
  color: #1a1a20;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  touch-action: pan-y;
}

/* the journey — scroll is not navigation, it is movement through
   reality attempting the impossible */
#journey {
  height: 2200vh;
  height: 2200svh;
  pointer-events: none;
}

/* when the universe abandons its own rules there is nowhere left to go */
body.ended #journey {
  height: 100vh;
  height: 100svh;
}

canvas#world {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 1;
}

/* ------------------------------------------------------------
   THE END — not black. white. infinite. nothing.
------------------------------------------------------------ */
#white {
  position: fixed;
  inset: 0;
  background: #ffffff;
  opacity: 0;
  pointer-events: none;
  z-index: 5;
  transition: opacity 9s cubic-bezier(0.4, 0, 0.2, 1);
}
body.ended #white { opacity: 1; }

/* the only sentence this place ever says in its own voice */
#final {
  position: fixed;
  inset: 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.9em;
  padding: 0 8vw;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 7s ease;
}
#final p {
  font-style: italic;
  font-weight: 300;
  font-size: clamp(1.05rem, 2.4vw, 1.75rem);
  line-height: 1.7;
  letter-spacing: 0.06em;
  color: rgba(26, 26, 32, 0.78);
  max-width: 22em;
  text-wrap: balance;
}
#final.speaking { opacity: 1; }
#final.forgotten {
  opacity: 0;
  transition: opacity 11s ease;
}

/* ------------------------------------------------------------
   ONE MERCY — shown only to a visitor who never moved
------------------------------------------------------------ */
#hint {
  position: fixed;
  left: 50%;
  bottom: calc(7vh + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 4;
  font-style: italic;
  font-weight: 300;
  font-size: clamp(0.95rem, 1.6vw, 1.15rem);
  letter-spacing: 0.55em;
  text-indent: 0.55em;
  white-space: nowrap;
  max-width: 90vw;
  color: rgba(26, 26, 32, 0);
  pointer-events: none;
  transition: color 3.5s ease;
}
#hint.on { color: rgba(26, 26, 32, 0.38); }

/* ------------------------------------------------------------
   THE POEM — held outside the visible kingdom, for those
   who cannot enter it
------------------------------------------------------------ */
.sr-poem {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

/* if the kingdom cannot be built, the poem remains */
html.no-js .sr-poem,
html.no-js .noscript {
  position: static;
  width: auto;
  height: auto;
  overflow: visible;
  clip: auto;
  clip-path: none;
  white-space: normal;
  max-width: 40em;
  margin: 14vh auto 0;
  padding: 0 24px;
}
html.no-js .sr-poem h1 {
  font-family: "Cinzel", serif;
  font-weight: 400;
  font-size: clamp(1.2rem, 4vw, 2rem);
  letter-spacing: 0.34em;
  text-indent: 0.34em;
  color: #8a6d1f;
  margin-bottom: 3rem;
}
html.no-js .sr-poem p {
  font-size: 1.25rem;
  font-weight: 300;
  line-height: 2.1;
  color: #33333c;
  margin-bottom: 2.2rem;
}
html.no-js .sr-poem .sig {
  margin-top: 1rem;
  font-style: italic;
  color: #7b7b88;
}
html.no-js #journey,
html.no-js canvas#world,
html.no-js #hint,
html.no-js #white,
html.no-js #final { display: none; }

.noscript { margin-top: 2rem; padding-bottom: 14vh; }
.noscript p {
  font-style: italic;
  color: #7b7b88;
  font-size: 1.05rem;
}

/* ------------------------------------------------------------
   EVERY WINDOW THE KINGDOM IS SEEN THROUGH

   The kingdom is one size. The window is not. Nothing is ever
   cropped away — the framing is held and the road shortens.
------------------------------------------------------------ */

/* a thumb is not a wheel: the same distance, fewer gestures */
@media (pointer: coarse) {
  #journey { height: 1450vh; height: 1450svh; }
  #hint { letter-spacing: 0.4em; text-indent: 0.4em; }
}

/* a phone held sideways has almost no height at all */
@media (max-height: 460px) and (orientation: landscape) {
  #journey { height: 1100vh; height: 1100svh; }
  #hint {
    bottom: calc(4vh + env(safe-area-inset-bottom, 0px));
    font-size: 0.85rem;
    letter-spacing: 0.35em;
    text-indent: 0.35em;
  }
  #final p { font-size: clamp(0.95rem, 3vw, 1.3rem); }
  #final { gap: 0.5em; }
}

@media (max-width: 560px) {
  #final p { line-height: 1.6; }
  html.no-js .sr-poem { padding: 0 20px; margin-top: 9vh; }
  html.no-js .sr-poem p { font-size: 1.1rem; line-height: 1.95; }
}

/* ------------------------------------------------------------
   STILLNESS FOR THOSE WHO ASK FOR STILLNESS
------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  #journey { height: 1000vh; height: 1000svh; }
  #white { transition: opacity 2s ease; }
  #final { transition: opacity 2s ease; }
  #final.forgotten { transition: opacity 3s ease; }
}
