@font-face {
  font-family: 'Trickster';
  src: url('../fonts/Trickster-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: block;
}
@font-face {
  font-family: 'Bluu Next';
  src: url('../fonts/BluuNext-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: block;
}
@font-face {
  font-family: 'Sporting Grotesque';
  src: url('../fonts/SportingGrotesque-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: block;
}
@font-face {
  font-family: 'Cormorant Garamond';
  src: url('../fonts/CormorantGaramond-Var.woff2') format('woff2');
  font-weight: 300 700;
  font-style: normal;
  font-display: block;
}
@font-face {
  font-family: 'Cormorant Garamond';
  src: url('../fonts/CormorantGaramond-Italic-Var.woff2') format('woff2');
  font-weight: 300 700;
  font-style: italic;
  font-display: block;
}

:root {
  --bone: #e8ddc8;
  --crimson: #ff2233;
  --ember: #ff7743;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  background: #030103;
  font-family: 'Cormorant Garamond', 'Times New Roman', serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

canvas#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  /* a grain of bone for a cursor; the hand becomes a flare over what can be touched */
  cursor: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10"><circle cx="5" cy="5" r="1.6" fill="%23e8ddc8" fill-opacity=".9"/><circle cx="5" cy="5" r="4" fill="none" stroke="%23e8ddc8" stroke-opacity=".28"/></svg>') 5 5, auto;
}

/* ------------------------------------------------ film: grain + vignette */
#grain {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  opacity: 0.05;
  mix-blend-mode: overlay;
  z-index: 70; /* film is the last layer — grain lies even over the white */
}
#vignette {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 21;
  background:
    radial-gradient(ellipse 120% 90% at 50% 45%, transparent 55%, rgba(0, 0, 0, 0.55) 100%),
    linear-gradient(rgba(8, 0, 4, 0.12), rgba(8, 0, 4, 0.12));
}

/* -------------------------------------------- the left thumb's walk stick */
/* borrowed from the hallway: it appears where the thumb lands, low on the
   left, and vanishes when the thumb lifts — bone and candle-gold, not neon */
#stickBase {
  position: fixed;
  left: 0; top: 0;
  width: 112px; height: 112px;
  margin: -56px 0 0 -56px;
  border-radius: 50%;
  border: 1px solid rgba(232, 221, 200, 0.22);
  background: rgba(10, 4, 8, 0.25);
  display: none;
  pointer-events: none;
  z-index: 24;
}
#stickBase.on { display: block; }

#stickNub {
  position: absolute;
  left: 50%; top: 50%;
  width: 46px; height: 46px;
  margin: -23px 0 0 -23px;
  border-radius: 50%;
  background: rgba(255, 216, 160, 0.16);
  border: 1px solid rgba(255, 216, 160, 0.35);
}

/* ------------------------------------------------------------- the door */
#door {
  position: fixed; inset: 0;
  z-index: 40;
  background: #030103;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 2.4s ease;
  user-select: none;
  -webkit-user-select: none;
}
#door.open { opacity: 0; pointer-events: none; }

#door .crack {
  width: 2px;
  height: 34vh;
  background: linear-gradient(
    to bottom,
    transparent,
    rgba(255, 190, 120, 0.25) 12%,
    rgba(255, 210, 150, 0.95) 50%,
    rgba(255, 60, 60, 0.35) 86%,
    transparent
  );
  box-shadow:
    0 0 18px 2px rgba(255, 170, 100, 0.35),
    0 0 60px 8px rgba(255, 60, 60, 0.12);
  animation: breathe 5.5s ease-in-out infinite;
}
@keyframes breathe {
  0%, 100% { opacity: 0.55; transform: scaleY(0.97); }
  50% { opacity: 1; transform: scaleY(1); }
}

#door .title {
  margin-top: 7vh;
  color: var(--bone);
  font-family: 'Trickster', 'Cormorant Garamond', serif;
  font-size: clamp(26px, 4.6vmin, 46px);
  font-weight: 400;
  letter-spacing: 0.38em;
  text-indent: 0.38em; /* recenters letterspaced caps */
  opacity: 0.9;
}
#door .verse {
  margin-top: 3.2vh;
  color: rgba(232, 221, 200, 0.62);
  font-size: clamp(13px, 1.9vmin, 18px);
  letter-spacing: 0.32em;
  text-indent: 0.32em;
  text-align: center;
  line-height: 2.1;
}
#door .verse em {
  display: block;
  font-style: italic;
  letter-spacing: 0.06em;
  text-indent: 0.06em;
  font-size: 0.86em;
  opacity: 0.85;
}
#door .enter {
  position: absolute;
  bottom: calc(7vh + env(safe-area-inset-bottom, 0px));
  color: rgba(232, 221, 200, 0.3);
  font-family: 'Sporting Grotesque', sans-serif;
  font-size: 11px;
  letter-spacing: 0.5em;
  text-indent: 0.5em;
  animation: breathe 5.5s ease-in-out infinite;
}

/* --------------------------------------------------------------- whispers */
#hint {
  position: fixed;
  bottom: calc(4.5vh + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  color: rgba(232, 221, 200, 0.5);
  font-family: 'Sporting Grotesque', sans-serif;
  font-size: 11px;
  letter-spacing: 0.22em;
  text-indent: 0.22em;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 1.8s ease;
  pointer-events: none;
}
#hint.show { opacity: 1; }
/* narrower screens: a fixed centered box that wraps, instead of a nowrap
   line that would run off both edges */
@media (max-width: 1000px) {
  #hint {
    width: 92vw;
    white-space: normal;
    text-align: center;
    line-height: 1.9;
    letter-spacing: 0.18em;
    text-indent: 0.18em;
    font-size: 13px;
  }
}

#votiveWhisper {
  position: fixed;
  bottom: 12vh;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  color: rgba(255, 200, 150, 0.85);
  font-size: clamp(15px, 2.2vmin, 21px);
  letter-spacing: 0.2em;
  text-indent: 0.2em;
  text-align: center;
  opacity: 0;
  transition: opacity 1.2s ease;
  pointer-events: none;
  text-shadow: 0 0 22px rgba(255, 140, 60, 0.5);
}
#votiveWhisper em {
  display: block;
  font-style: italic;
  font-size: 0.78em;
  letter-spacing: 0.05em;
  text-indent: 0.05em;
  opacity: 0.65;
  margin-top: 0.35em;
}
#votiveWhisper .n {
  display: block;
  font-family: "Sporting Grotesque", sans-serif;
  font-size: 10px;
  letter-spacing: 0.3em;
  text-indent: 0.3em;
  color: rgba(217, 179, 106, 0.7);
  margin-bottom: 0.4em;
}
#votiveWhisper.show { opacity: 1; }

#mute {
  position: fixed;
  top: calc(18px + env(safe-area-inset-top, 0px));
  right: calc(20px + env(safe-area-inset-right, 0px));
  z-index: 30;
  color: rgba(232, 221, 200, 0.35);
  font-family: 'Sporting Grotesque', sans-serif;
  font-size: 10px;
  letter-spacing: 0.3em;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  padding: 6px 8px;
  transition: color 0.6s ease, opacity 1.5s ease;
  opacity: 0;
}
#mute.show { opacity: 1; }
#mute:hover { color: rgba(232, 221, 200, 0.7); }
#mute.muted { color: rgba(140, 30, 40, 0.8); }

/* a grain-of-incense crosshair, present only while the mouse is captured */
#cross {
  position: fixed;
  top: 50%; left: 50%;
  width: 4px; height: 4px;
  margin: -2px 0 0 -2px;
  border-radius: 50%;
  background: rgba(232, 221, 200, 0.5);
  box-shadow: 0 0 6px rgba(255, 200, 140, 0.35);
  z-index: 30;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.6s ease;
}
#cross.show { opacity: 1; }
#cross.hot {
  background: rgba(255, 220, 160, 0.95);
  box-shadow: 0 0 10px rgba(255, 190, 110, 0.8);
  transform: scale(1.7);
}

/* the mirror moment: a brief silver-gold wash over everything */
#lumen {
  position: fixed; inset: 0;
  z-index: 25;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 46%, rgba(255, 244, 214, 0.85), rgba(255, 214, 160, 0.25) 55%, transparent 78%);
  opacity: 0;
  transition: opacity 2.8s ease;
}
#lumen.show { opacity: 1; transition: opacity 1.1s ease; }

/* the whiteout — step into the light column and be blinded;
   only inside the blindness can the line be read */
#blind {
  position: fixed; inset: 0;
  z-index: 26;
  background: #fff7e8;
  opacity: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.2em;
  text-align: center;
  padding: 0 8vw;
}
#blind .l {
  color: #7e5f1c;
  font-family: 'Bluu Next', 'Cormorant Garamond', serif;
  font-size: clamp(19px, 3.3vmin, 34px);
  letter-spacing: 0.14em;
  text-indent: 0.14em;
}
#blind .e {
  color: rgba(126, 95, 28, 0.7);
  font-style: italic;
  font-size: clamp(14px, 2.2vmin, 22px);
  letter-spacing: 0.08em;
}

/* the gloria — the white at the end of the Botafumeiro, and the passage
   on beauty that the whole church was walking toward */
#gloria {
  position: fixed; inset: 0;
  z-index: 60;
  background: #fff7e8;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4vh;
  text-align: left;
  padding: 8vh 8vw;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s ease;
}
#gloria.show { opacity: 1; pointer-events: auto; }
#gloria.fade { transition: opacity 5s ease; opacity: 0; }
/* the passage is set like a poem, not a landing page: three movements
   drifting on the censer's own decaying swing — at rest on the left,
   out to the full of the arc, then settling home — each translation
   hanging beneath its Latin like a gloss in the margin */
#gloria .passage {
  width: 100%;
  max-width: 44em;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4.4vh;
}
#gloria .mv {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 2.2s ease, transform 2.8s cubic-bezier(0.16, 1, 0.3, 1);
  max-width: 26em;
}
#gloria .mv.in { opacity: 1; transform: none; }
#gloria .mv:nth-child(2) { margin-left: clamp(2.2em, 17vw, 12em); }
#gloria .mv:nth-child(3) { margin-left: clamp(0.9em, 6vw, 4.2em); }
#gloria .mv .la {
  font-family: 'Bluu Next', 'Cormorant Garamond', serif;
  color: #7e5f1c;
  font-size: clamp(20px, 3.0vmin, 34px);
  line-height: 1.3;
}
#gloria .mv.last { max-width: none; } /* the knife falls in one unbroken line where it can */
#gloria .mv.last .la { font-size: clamp(23px, 3.7vmin, 41px); }
#gloria .mv .en {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  color: rgba(126, 95, 28, 0.72);
  font-size: clamp(14px, 2.0vmin, 20px);
  margin-top: 0.7em;
  margin-left: 1.6em;
  max-width: 24em;
  line-height: 1.4;
}
#gloria .attrib {
  width: 100%;
  max-width: 44em;
  text-align: right;
  font-family: 'Sporting Grotesque', sans-serif;
  color: rgba(126, 95, 28, 0.5);
  font-size: 11px;
  letter-spacing: 0.3em;
  opacity: 0;
  transition: opacity 2s ease;
}
#gloria .attrib.in { opacity: 1; }
/* narrow phones: gentler drift so the long lines keep room to breathe,
   and a tighter citation so the book-numeral is never orphaned */
@media (max-width: 420px) {
  #gloria { padding: 6vh 7vw; }
  #gloria .mv:nth-child(2) { margin-left: 11vw; }
  #gloria .mv:nth-child(3) { margin-left: 4vw; }
  #gloria .mv .en { margin-left: 1.1em; }
  #gloria .attrib { letter-spacing: 0.2em; }
}
#gloria .iterum {
  position: absolute;
  bottom: calc(7vh + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55em;
  cursor: pointer;
  opacity: 0;
  /* deaf until it appears: an invisible ITERVM must not catch a stray tap
     on the first frame of the white and skip the whole passage */
  pointer-events: none;
  transition: opacity 2s ease;
  user-select: none;
  -webkit-user-select: none;
}
#gloria .iterum.in { opacity: 1; pointer-events: auto; animation: breathe 5.5s ease-in-out infinite; }
#gloria .iterum .w {
  font-family: 'Trickster', 'Cormorant Garamond', serif;
  color: #7e5f1c;
  font-size: clamp(20px, 3vmin, 30px);
  letter-spacing: 0.34em;
  text-indent: 0.34em;
}
#gloria .iterum .e {
  font-family: 'Sporting Grotesque', sans-serif;
  color: rgba(126, 95, 28, 0.6);
  font-size: 11px;
  letter-spacing: 0.4em;
  text-indent: 0.4em;
}

/* short viewports (phones held landscape, split screens): the passage is
   taller than the glass — let the white scroll, and seat ITERVM in the
   flow below the citation instead of printing it over the text. the door's
   ENTER steps into the flow for the same reason */
@media (max-height: 520px) {
  #gloria {
    justify-content: flex-start;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    gap: 3vh;
    padding: 5vh 8vw calc(5vh + env(safe-area-inset-bottom, 0px));
  }
  #gloria .iterum { position: static; margin-top: 4vh; }
  #door .enter { position: static; margin-top: 3.5vh; }
}

@media (prefers-reduced-motion: reduce) {
  #door .crack, #door .enter, #gloria .iterum.in { animation: none; }
}
