@import url("./fonts.css");

:root {
  --oxblood: #3a0608;
  --oxblood-deep: #220305;
  --pitch: #070406;
  --gold: #c5a059;
  --gold-bright: #e4c57a;
  --gold-rot: #8a6a32;
  --verdigris: #2d5a57;
  --verdigris-deep: #163836;
  --plaster: #2a1210;
  --crimson-field: #4a0b0e;
  --bone: #cbb89a;
  --magenta-gap: #ff00ff;
  --ink: #f0e6c8;
  --mute: #8a7460;
  --serif-display: "Cinzel", "Iowan Old Style", Palatino, "Times New Roman", serif;
  --serif-lore: "Cormorant Garamond", Garamond, Georgia, serif;
  --mono: "IBM Plex Mono", "Courier New", monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--pitch);
  color: var(--ink);
  font-family: var(--serif-lore);
  font-size: 20px;
  line-height: 1.35;
}

html {
  background:
    radial-gradient(120% 80% at 50% 20%, #4a0c10 0%, transparent 55%),
    radial-gradient(90% 70% at 80% 90%, #1a0808 0%, transparent 50%),
    var(--pitch);
}

body {
  background-image:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.12  0 0 0 0 0.03  0 0 0 0 0.03  0 0 0 0.28 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  background-size: 220px 220px;
}

a {
  color: var(--gold);
  text-decoration: none;
}

a:hover {
  color: var(--gold-bright);
}

::selection {
  background: var(--gold-rot);
  color: var(--pitch);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* ——— altar homepage ——— */

body.page-altar {
  overflow: hidden;
  height: 100vh;
  height: 100svh;
  height: 100dvh;
}

.chapel-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}

.page-altar .chapel-shell {
  height: 100vh;
  height: 100svh;
  height: 100dvh;
  overflow: hidden;
  position: relative;
  display: block;
}

.field {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 60% at 50% 40%, #5a1014 0%, transparent 62%),
    linear-gradient(180deg, #2c0708 0%, var(--pitch) 100%);
  pointer-events: none;
  z-index: 0;
}

.page-altar .altar-piece {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  line-height: 0;
  overflow: hidden;
}

.page-altar .altar-fit {
  position: relative;
  margin: 0;
  padding: 0;
  line-height: 0;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  aspect-ratio: 1536 / 1024;
  /* largest contain box in the viewport frame */
  width: min(100%, calc(100svh * 1536 / 1024));
  width: min(100%, calc(100dvh * 1536 / 1024));
  max-height: 100svh;
  max-height: 100dvh;
}

.page-altar .altar-fit img#seal {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center;
  user-select: none;
  -webkit-user-drag: none;
}

.page-altar .altar-fit .hotspots {
  position: absolute;
  inset: 0;
  z-index: 3;
}

.hotspots.show-map .hot {
  outline: 1px solid rgba(255, 0, 255, 0.55);
  background: rgba(255, 0, 255, 0.08);
}

.hot {
  position: absolute;
  display: block;
  cursor: pointer;
  z-index: 3;
  background: transparent;
  border: 0;
  padding: 0;
  color: inherit;
  font: inherit;
  touch-action: manipulation;
}

.hot::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  transform: translate(-50%, -50%);
}

.hot:focus-visible {
  outline: 1px solid var(--gold);
  outline-offset: 2px;
}

.hot.dead {
  cursor: default;
  pointer-events: none;
}

.hot.halo-svg {
  left: 18%;
  top: 0;
  width: 64%;
  height: 78%;
  pointer-events: none;
}

.hot.halo-svg circle {
  pointer-events: stroke;
  cursor: pointer;
}

.hot.halo-svg.locked circle {
  pointer-events: none;
  cursor: default;
}

.smoke {
  position: absolute;
  width: 18px;
  height: 70px;
  pointer-events: none;
  z-index: 4;
  transform: translateX(-50%);
  opacity: 0.7;
}

.smoke span {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(190, 190, 190, 0.35);
  filter: blur(2px);
  animation: rise 3.6s ease-out infinite;
}

.smoke span:nth-child(2) { animation-delay: 1.1s; left: 30%; }
.smoke span:nth-child(3) { animation-delay: 2.2s; left: 70%; }

@keyframes rise {
  0% { transform: translate(-50%, 0) scale(0.7); opacity: 0.55; }
  70% { opacity: 0.2; }
  100% { transform: translate(-50%, -68px) scale(1.8); opacity: 0; }
}


.eye-r-flicker {
  position: absolute;
  pointer-events: none;
  border-radius: 50%;
  box-shadow: inset 0 0 18px rgba(45, 90, 87, 0.0);
  animation: flicker 5.4s ease-in-out infinite;
  z-index: 2;
}

@keyframes flicker {
  0%, 100% { opacity: 0.15; filter: brightness(1); }
  40% { opacity: 0.05; filter: brightness(0.85); }
  52% { opacity: 0.28; filter: brightness(1.15); }
  61% { opacity: 0.1; }
}

.gold-patch {
  position: absolute;
  pointer-events: none;
  z-index: 2;
  mix-blend-mode: color-dodge;
  opacity: 0;
  transition: opacity 900ms ease;
  background:
    radial-gradient(ellipse at 40% 40%, rgba(228, 197, 122, 0.55), transparent 70%);
  filter: contrast(1.1);
}

.gold-patch.show {
  opacity: 0.72;
}

.crack-flash {
  position: absolute;
  pointer-events: none;
  z-index: 5;
  background: var(--magenta-gap);
  mix-blend-mode: screen;
  opacity: 0;
  clip-path: polygon(10% 0, 18% 8%, 8% 40%, 22% 70%, 4% 100%, 0 60%, 6% 20%);
}

.crack-flash.go {
  animation: mag-then-gold 720ms ease forwards;
}

@keyframes mag-then-gold {
  0% { opacity: 0; background: #ff00ff; }
  12% { opacity: 1; background: #ff00ff; }
  38% { opacity: 0.9; background: #ff00ff; }
  55% { opacity: 0.85; background: #e4c57a; }
  100% { opacity: 0; background: #c5a059; }
}

.varnish {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  background: linear-gradient(
    115deg,
    transparent 36%,
    rgba(255, 230, 170, 0.07) 48%,
    transparent 58%
  );
  background-size: 220% 220%;
  animation: varnish 16s linear infinite;
  mix-blend-mode: soft-light;
}

@keyframes varnish {
  0% { background-position: 0% 40%; }
  100% { background-position: 100% 60%; }
}

.litany {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 2.4%;
  z-index: 6;
  text-align: center;
  pointer-events: none;
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.85), 0 0 24px rgba(20, 0, 0, 0.7);
}

.masthead {
  position: fixed;
  top: 0.75rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 11;
  font-family: var(--serif-display);
  font-size: 0.62rem;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--gold-rot);
}

.masthead a {
  color: inherit;
}

.page-altar .masthead {
  top: 0.55rem;
  left: 0.85rem;
  transform: none;
}

.litany .bio {
  font-family: var(--serif-display);
  font-weight: 400;
  font-size: clamp(1.15rem, 2.4vw, 1.85rem);
  letter-spacing: 0.18em;
  text-transform: lowercase;
  line-height: 1.25;
  margin: 0 0 0.55rem;
  color: var(--gold-bright);
}

.litany .inventory {
  margin: 0.85rem 0 0.2rem;
  font-family: var(--serif-lore);
  font-style: italic;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  color: var(--mute);
  text-shadow: 0 1px 8px #000;
}

.litany .house-foot {
  margin: 0;
  font-family: var(--serif-display);
  font-size: 0.52rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold-rot);
  pointer-events: auto;
}

.litany .cite {
  pointer-events: auto;
}

.whisper {
  font-family: var(--serif-lore);
  font-style: normal;
  font-size: 0.92rem;
  letter-spacing: 0.02em;
}

.condition {
  width: 100%;
  border-collapse: collapse;
  margin: 1.4rem 0 0;
}

.condition th,
.condition td {
  border-bottom: 1px solid rgba(197, 160, 89, 0.18);
  padding: 0.55rem 0.35rem;
  text-align: left;
  vertical-align: top;
}

.condition th {
  font-family: var(--serif-display);
  font-size: 0.6rem;
  letter-spacing: 0.16em;
  font-weight: 400;
  color: var(--gold-rot);
  width: 28%;
  text-transform: lowercase;
}

.condition td {
  font-family: var(--serif-lore);
  color: var(--bone);
}

.accession {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--gold);
  margin: 0 0 1rem;
}

.hours {
  font-family: var(--serif-lore);
  font-style: italic;
  color: var(--mute);
  margin: 1.4rem 0 0;
}

.latch-room {
  max-width: 40rem;
  padding-bottom: 2rem;
}

.latch-head {
  margin-bottom: 2.2rem;
}

.latch-head h1 {
  font-family: var(--serif-display);
  font-weight: 400;
  letter-spacing: 0.16em;
  text-transform: lowercase;
  font-size: clamp(1.4rem, 3vw, 2rem);
  color: var(--gold);
  margin: 0 0 0.45rem;
}

.latch-head .ticker {
  font-family: var(--serif-display);
  letter-spacing: 0.2em;
  color: var(--gold-bright);
  margin: 0 0 0.8rem;
}

.latch-head .bio {
  font-family: var(--serif-display);
  letter-spacing: 0.14em;
  color: var(--gold);
  margin: 0 0 0.75rem;
}

.latch-head .lede {
  font-family: var(--serif-lore);
  font-style: italic;
  color: var(--bone);
  margin: 0 0 1.2rem;
  max-width: 28rem;
}

.latch-head .acts {
  justify-content: flex-start;
}

.page-latch .object,
.page-latch h2 + p,
.page-latch .contract-line,
.page-plates h2 + p,
.page-plates p,
.page-privacy p,
.page-terms p,
.page-registry p {
  font-family: var(--serif-lore);
  color: var(--bone);
  max-width: 36rem;
}

.page-latch h2,
.page-plates h2,
.page-privacy h2,
.page-terms h2 {
  font-family: var(--serif-display);
  font-weight: 400;
  font-size: 0.68rem;
  letter-spacing: 0.2em;
  text-transform: lowercase;
  color: var(--gold-rot);
  margin: 2.1rem 0 0.55rem;
}

.page-latch .contract-line {
  scroll-margin-top: 4rem;
}

.latch-colophon {
  width: min(920px, calc(100% - 2rem));
  margin: 0 auto 3.5rem;
  font-family: var(--serif-display);
  font-size: 0.58rem;
  letter-spacing: 0.12em;
  color: var(--gold-rot);
}

.latch-colophon p {
  margin: 0.2rem 0;
}

.latch-door {
  position: fixed;
  left: 0.85rem;
  bottom: 0.7rem;
  z-index: 12;
  font-family: var(--serif-display);
  font-size: 0.62rem;
  letter-spacing: 0.2em;
  text-transform: lowercase;
}

.latch-door a {
  color: var(--gold-rot);
}

.latch-door a:hover {
  color: var(--gold);
}

.page-altar .latch-door {
  bottom: auto;
  top: 0.55rem;
  left: auto;
  right: 0.85rem;
}

.page-latch .latch-door {
  display: none;
}

.binder {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: #c4b49a;
  background: #16120c;
  border: 1px solid #3a2e1c;
  padding: 1.3rem 1.15rem;
  line-height: 1.75;
  white-space: pre-wrap;
}

.ir-plate {
  position: relative;
  width: min(720px, 94vw);
  aspect-ratio: 1536 / 1024;
  margin: 1rem auto 0;
  overflow: hidden;
  border: 1px solid #2a2018;
  filter: grayscale(1) contrast(1.35) brightness(0.62);
}

.ir-plate img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0.55;
}

.ir-hand {
  position: absolute;
  left: 8%;
  top: 58%;
  width: 38%;
  height: 38%;
  background-image: url("/img/seal_unclosed.jpg");
  background-size: 280%;
  background-position: 10% 108%;
  opacity: 0.7;
  mix-blend-mode: screen;
  filter: contrast(1.5) brightness(1.2);
  pointer-events: none;
}

.xray-plate {
  filter: grayscale(1) invert(0.86) contrast(1.25);
  border-color: #4a4a4a;
}

.notice {
  font-family: var(--serif-display);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  color: var(--gold);
  text-align: center;
}

.acts {
  display: flex;
  gap: 1.4rem;
  justify-content: center;
  flex-wrap: wrap;
  pointer-events: auto;
}

.acts a,
.plaque {
  pointer-events: auto;
  display: inline-block;
  font-family: var(--serif-display);
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: lowercase;
  color: var(--gold);
  border: 1px solid var(--gold-rot);
  padding: 0.45rem 0.95rem 0.4rem;
  background: rgba(10, 2, 2, 0.45);
  box-shadow: inset 0 0 0 1px rgba(197, 160, 89, 0.15);
}

.acts a:hover,
.plaque:hover {
  color: var(--gold-bright);
  border-color: var(--gold);
  background: rgba(30, 8, 6, 0.62);
}

.whisper {
  position: absolute;
  z-index: 8;
  max-width: 16rem;
  font-family: var(--serif-lore);
  font-style: normal;
  font-size: 0.92rem;
  color: var(--bone);
  text-shadow: 0 1px 8px #000;
  opacity: 0;
  transform: translateY(4px);
  pointer-events: none;
  transition: opacity 280ms ease, transform 280ms ease;
}

.whisper.show {
  opacity: 1;
  transform: translateY(0);
}

.status {
  position: fixed;
  top: 1.1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 12;
  font-family: var(--serif-display);
  font-size: 0.68rem;
  letter-spacing: 0.28em;
  text-transform: lowercase;
  color: var(--gold);
  opacity: 0;
  pointer-events: none;
  transition: opacity 400ms ease;
}

.status.show {
  opacity: 1;
}

.latch-ring {
  position: fixed;
  width: 72px;
  height: 72px;
  margin: -36px 0 0 -36px;
  border: 2px solid var(--gold-bright);
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--gold-rot), 0 0 18px rgba(228, 197, 122, 0.55);
  pointer-events: none;
  z-index: 20;
  opacity: 0;
}

.latch-ring.slam {
  animation: slam 400ms ease-out forwards;
}

@keyframes slam {
  0% { transform: scale(2.1); opacity: 0; }
  25% { opacity: 1; }
  100% { transform: scale(0.42); opacity: 0; }
}

.toast {
  position: fixed;
  bottom: 1.4rem;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  z-index: 14;
  font-family: var(--serif-lore);
  font-style: italic;
  color: var(--gold-bright);
  opacity: 0;
  transition: opacity 300ms ease, transform 300ms ease;
  text-shadow: 0 1px 10px #000;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.votive {
  position: fixed;
  right: 0.7rem;
  bottom: 0.7rem;
  z-index: 10;
  width: 72px;
  border: 1px solid var(--gold-rot);
  background: var(--oxblood-deep);
  padding: 3px;
  line-height: 0;
}

.votive img {
  width: 100%;
  height: auto;
  display: block;
  filter: saturate(0.9);
}

.votive.snuffed img {
  filter: grayscale(0.7) brightness(0.55);
}

.votive .v-smoke {
  position: absolute;
  left: 42%;
  top: 4%;
  width: 10px;
  height: 22px;
}

.votive .gold-veil {
  position: absolute;
  inset: 3px;
  background: radial-gradient(circle at 45% 40%, rgba(197, 160, 89, 0.28), transparent 60%);
  pointer-events: none;
  opacity: 0;
}

.votive.gilded .gold-veil {
  opacity: 1;
}

.hand-closed #seal {
  /* no smile motion — only a dedicated overlay when latch piece was clamped */
}

.hand-shut-mark {
  position: absolute;
  pointer-events: none;
  z-index: 3;
  border: 1.5px solid var(--gold-bright);
  border-radius: 50%;
  box-shadow: 0 0 10px rgba(197, 160, 89, 0.45);
  opacity: 0;
}

.hand-shut-mark.on {
  opacity: 0.85;
  animation: hush 1.2s ease;
}

@keyframes hush {
  from { transform: scale(1.25); opacity: 0; }
  to { transform: scale(1); opacity: 0.85; }
}

.rub-canvas {
  position: absolute;
  inset: 0;
  z-index: 4;
  cursor: pointer;
  touch-action: none;
}

/* ——— inner rooms ——— */

.room {
  position: relative;
  z-index: 1;
  width: min(920px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 3.2rem 0 5rem;
}

.room h1,
.inscription {
  font-family: var(--serif-display);
  font-weight: 400;
  letter-spacing: 0.16em;
  text-transform: lowercase;
  font-size: clamp(1.3rem, 3vw, 2rem);
  color: var(--gold);
  margin: 0 0 1rem;
}

.lore {
  font-family: var(--serif-lore);
  font-style: italic;
  color: var(--bone);
  max-width: 36rem;
}

.mono,
.error-plain,
.terminal {
  font-family: var(--mono);
  font-size: 0.86rem;
  letter-spacing: 0.02em;
  color: var(--gold);
  line-height: 1.55;
  white-space: pre-wrap;
}

.back-wall {
  position: fixed;
  top: 0.85rem;
  left: 0.9rem;
  z-index: 12;
  font-family: var(--serif-display);
  font-size: 0.62rem;
  letter-spacing: 0.2em;
  text-transform: lowercase;
  color: var(--gold-rot);
}

.back-wall:hover {
  color: var(--gold);
}

.janitor-plaster {
  position: fixed;
  bottom: 0.4rem;
  left: 0.6rem;
  font-family: var(--serif-lore);
  font-size: 10px;
  letter-spacing: 0.18em;
  color: rgba(197, 160, 89, 0.22);
  z-index: 1;
}

/* 404 / cold wick */

body.page-404,
body.page-cold {
  min-height: 100vh;
}

.fallen-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
  position: relative;
  z-index: 1;
}

.fallen-page h1 {
  font-family: var(--serif-display);
  font-weight: 400;
  letter-spacing: 0.14em;
  color: var(--gold);
  font-size: clamp(1.2rem, 3vw, 1.8rem);
  margin: 0 0 0.8rem;
}

.fallen-page p.err {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--mute);
  margin: 0.2rem 0;
}

.crack-line {
  width: min(280px, 60vw);
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-rot), transparent);
  margin: 1.2rem 0;
}

/* glitched */

.unrender {
  position: relative;
  width: min(1100px, 96vw);
  margin: 1rem auto 0;
  aspect-ratio: 1536 / 1024;
  overflow: hidden;
  border: 1px solid var(--gold-rot);
}

.unrender .half {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.unrender .half img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  user-select: none;
  pointer-events: none;
  -webkit-user-drag: none;
}

.unrender .half.gold {
  clip-path: inset(0 50% 0 0);
  z-index: 2;
}

.unrender .half.teal {
  clip-path: inset(0 0 0 50%);
  z-index: 2;
}

.unrender .half.fallen {
  z-index: 4;
  cursor: grab;
  filter: drop-shadow(0 18px 18px rgba(0, 0, 0, 0.55));
}

.unrender.dragging .half.fallen {
  cursor: grabbing;
}

.seam-rail {
  width: min(1100px, 96vw);
  margin: 1.2rem auto 0;
  display: none;
}

.seam-rail.on {
  display: block;
}

.seam-rail label {
  font-family: var(--serif-display);
  font-size: 0.62rem;
  letter-spacing: 0.2em;
  color: var(--gold-rot);
  display: block;
  margin-bottom: 0.4rem;
}

.seam-rail input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 2px;
  background: var(--gold-rot);
  outline: none;
}

.seam-rail input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 28px;
  background: var(--gold);
  border: 1px solid var(--pitch);
  cursor: pointer;
}

.unlock-src {
  display: none;
  text-align: center;
  margin-top: 1rem;
  font-family: var(--serif-display);
  letter-spacing: 0.2em;
  font-size: 0.75rem;
}

.unlock-src.on {
  display: block;
}

/* latched rite */

.seal-stage {
  position: relative;
  width: min(1100px, 96vw);
  margin: 1rem auto 0;
  aspect-ratio: 1536 / 1024;
  overflow: hidden;
  border: 1px solid var(--gold-rot);
}

.seal-stage img.ground {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  user-select: none;
}

.flake {
  position: absolute;
  width: 64px;
  height: 52px;
  background-image: url("/img/seal_unclosed.jpg");
  background-size: 900% 700%;
  cursor: grab;
  z-index: 5;
  box-shadow: 0 6px 10px rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(197, 160, 89, 0.35);
}

.flake.latch-piece {
  border-radius: 50%;
  width: 54px;
  height: 54px;
  background-position: 12% 82%;
  background-size: 400% 300%;
}

.flake.clamped {
  opacity: 0;
  pointer-events: none;
}

.drop-tooth {
  position: absolute;
  z-index: 3;
}

.stage-crack {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      118deg,
      transparent 0 38px,
      rgba(255, 0, 255, 0) 38px,
      transparent 40px
    );
  opacity: 0;
}

.stage-crack.hurt {
  opacity: 1;
  background: linear-gradient(105deg, transparent 40%, rgba(255, 0, 255, 0.55) 41.2%, transparent 42%);
  animation: mag-then-gold 800ms ease forwards;
}

/* tooth */

.tooth-stage {
  min-height: 80vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.2rem;
  padding: 4rem 1rem;
}

.tooth-crop {
  width: min(72vw, 420px);
  height: min(72vw, 420px);
  overflow: hidden;
  border: 1px solid var(--gold-rot);
  position: relative;
  background: var(--pitch);
}

.tooth-crop img {
  position: absolute;
  width: 1536px;
  height: 1024px;
  max-width: none;
  left: 0;
  top: 0;
  transform-origin: 910px 575px;
  transform: translate(calc(50% - 910px), calc(50% - 575px)) scale(7.2) rotate(var(--spin, 0deg));
  user-select: none;
  pointer-events: none;
}

.rotate-row {
  display: flex;
  gap: 0.8rem;
  align-items: center;
}

.rotate-row input[type="range"] {
  width: min(280px, 60vw);
  accent-color: var(--gold);
}

.cross-door {
  opacity: 0;
  pointer-events: none;
  font-family: var(--serif-display);
  letter-spacing: 0.24em;
  font-size: 0.78rem;
  transition: opacity 400ms ease;
}

.cross-door.on {
  opacity: 1;
  pointer-events: auto;
}

/* hand hole */

body.page-hand {
  background: #000;
}

.hand-void {
  min-height: 100vh;
  display: grid;
  place-items: center;
  position: relative;
  background: #000;
}

.hand-stage {
  position: relative;
  width: min(92vw, 480px);
  aspect-ratio: 480 / 500;
  background: #000;
}

.gap-under {
  position: absolute;
  z-index: 1;
  left: 57.8%;
  top: 42.7%;
  width: 22%;
  height: 21%;
  min-width: 44px;
  min-height: 44px;
  border-radius: 50%;
  display: block;
}

.hand-plate {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  -webkit-mask-image: radial-gradient(circle at 68.8% 53.2%, transparent 7.4%, #000 7.9%);
  mask-image: radial-gradient(circle at 68.8% 53.2%, transparent 7.4%, #000 7.9%);
}

.finger-rim {
  position: absolute;
  z-index: 3;
  border-radius: 50%;
  pointer-events: auto;
  box-shadow: 0 0 0 1px rgba(197, 160, 89, 0.15);
}

/* the-gap */

body.page-gap {
  background: #120308;
}

body.page-gap .status {
  font-size: 0.95rem;
  letter-spacing: 0.34em;
  color: var(--gold-bright);
  text-shadow: 0 0 18px rgba(228, 197, 122, 0.55), 0 0 2px rgba(255, 0, 255, 0.35);
}

body.page-gap .status.show {
  opacity: 1;
}

.gap-room {
  min-height: 100vh;
  padding: 5rem 1.4rem 4rem;
  position: relative;
}

.gap-room .sparse {
  font-family: var(--serif-lore);
  font-style: italic;
  color: #6a4038;
  max-width: 22rem;
}

.one-crack {
  position: absolute;
  width: 5px;
  height: 48vh;
  left: 62%;
  top: 18%;
  background: linear-gradient(180deg, transparent, var(--magenta-gap), transparent);
  opacity: 1;
  filter: blur(0.2px);
  transform: rotate(12deg);
  box-shadow: 0 0 16px rgba(255, 0, 255, 0.55), 0 0 4px rgba(255, 0, 255, 0.8);
}

.one-crack::after {
  content: "";
  position: absolute;
  inset: 20% -48px;
  background: linear-gradient(90deg, transparent, rgba(255, 0, 255, 0.28), transparent);
}

/* chart */

.tablet {
  width: min(420px, 90vw);
  margin: 4rem auto;
  border: 1px solid var(--gold-rot);
  background: linear-gradient(180deg, #2a0c0c, #120606);
  padding: 2.2rem 1.6rem 2.4rem;
  text-align: center;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.45);
}

.tablet h1 {
  font-family: var(--serif-display);
  font-size: 0.95rem;
  letter-spacing: 0.2em;
  color: var(--gold);
}

.unlit-wick {
  width: 10px;
  height: 28px;
  margin: 1.4rem auto 1rem;
  background: linear-gradient(#3a2a18, #1a1008);
  border: 1px solid #2a1c10;
}

.tablet .say {
  font-family: var(--serif-lore);
  font-style: italic;
  color: var(--bone);
}

.tablet .no-numbers {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--mute);
  margin-top: 1.4rem;
}

/* reliquary */

.halo-tick {
  width: 160px;
  height: 160px;
  margin: 2rem auto;
  border: 1px solid var(--gold-rot);
  border-radius: 50%;
  position: relative;
}

.halo-tick i {
  position: absolute;
  left: 50%;
  top: 8px;
  width: 2px;
  height: 18px;
  background: var(--gold);
  transform-origin: 50% 72px;
  animation: tickhand 2.4s linear infinite;
}

@keyframes tickhand {
  to { transform: rotate(360deg); }
}

/* 67 */

.quiet-67 {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
}

.instrument {
  width: 120px;
  height: 120px;
  border: 1px solid var(--gold);
  border-radius: 50%;
  position: relative;
}

.instrument .needle {
  position: absolute;
  left: 50%;
  top: 18%;
  width: 2px;
  height: 40%;
  background: var(--gold);
  transform-origin: 50% 90%;
  animation: ticktiny 1.8s steps(2, end) infinite;
}

@keyframes ticktiny {
  0% { transform: rotate(-8deg); }
  50% { transform: rotate(10deg); }
  100% { transform: rotate(-8deg); }
}

/* src room */

.src-room {
  max-width: 640px;
  margin: 0 auto;
  padding: 4.5rem 1.2rem 4rem;
}

.src-room .terminal {
  border: 1px solid #3a2a18;
  padding: 1.2rem 1.1rem;
  background: rgba(8, 2, 2, 0.72);
}

/* rubbing */

.rub-room {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4rem 1rem 3rem;
}

.rub-frame {
  position: relative;
  width: min(960px, 96vw);
  aspect-ratio: 1536 / 1024;
  border: 1px solid var(--gold-rot);
  overflow: hidden;
  touch-action: none;
}

.rub-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  filter: contrast(0.9) brightness(0.55);
}

.rub-frame canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.decoded {
  margin-top: 1rem;
  font-family: var(--serif-display);
  letter-spacing: 0.28em;
  font-size: 0.78rem;
  color: var(--gold);
  min-height: 1.4em;
  opacity: 0;
}

.decoded.on {
  opacity: 1;
}

/* cross */

.spec {
  width: min(420px, 88vw);
  height: 120px;
  margin: 1.2rem auto;
  background:
    repeating-linear-gradient(
      90deg,
      transparent 0 6px,
      rgba(197, 160, 89, 0.08) 6px 7px
    ),
    linear-gradient(#140808, #0a0404);
  border: 1px solid #3a2418;
  position: relative;
  overflow: hidden;
}

.spec i {
  position: absolute;
  bottom: 0;
  width: 3px;
  background: var(--gold);
  opacity: 0.55;
  animation: bars 2s ease-in-out infinite;
}

@keyframes bars {
  0%, 100% { height: 20%; }
  40% { height: 88%; }
  55% { height: 30%; }
}

.reveal-key {
  font-family: var(--serif-display);
  letter-spacing: 0.2em;
  text-align: center;
  color: var(--gold);
  opacity: 0;
  transition: opacity 1.2s ease;
  margin-top: 1.5rem;
}

.reveal-key.on {
  opacity: 1;
}

/* chapel index */

.rite-list {
  list-style: none;
  padding: 0;
  margin: 1.5rem 0 0;
}

.rite-list li {
  margin: 0 0 0.85rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid rgba(197, 160, 89, 0.18);
}

.rite-list a {
  font-family: var(--serif-display);
  letter-spacing: 0.16em;
  font-size: 0.95rem;
}

.rite-list span {
  display: block;
  font-family: var(--serif-lore);
  font-style: italic;
  color: var(--mute);
  font-size: 1rem;
  margin-top: 0.15rem;
}

/* soot */

.soot-board {
  width: min(640px, 94vw);
  margin: 1rem auto;
}

.soot-label {
  position: relative;
  margin: 1.1rem 0;
  padding: 0.8rem 0.4rem;
  font-family: var(--serif-lore);
  font-style: italic;
  color: var(--bone);
}

.soot-label canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  touch-action: none;
}

.soot-label.sacred {
  font-family: var(--serif-display);
  letter-spacing: 0.16em;
  font-style: normal;
  color: var(--gold);
}

.soot-label.binder-line {
  font-family: var(--mono);
  font-style: normal;
  font-size: 0.82rem;
  color: #c4b49a;
  letter-spacing: 0.02em;
}

/* compass needle on altar */

.compass-needle {
  position: absolute;
  pointer-events: none;
  z-index: 4;
  width: 2px;
  height: 7%;
  background: var(--gold-bright);
  transform-origin: 50% 90%;
  box-shadow: 0 0 6px rgba(197, 160, 89, 0.6);
}

.tick-dot {
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--gold);
  pointer-events: none;
  z-index: 4;
  animation: pulse-tick 1.7s steps(2, end) infinite;
}

@keyframes pulse-tick {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

.wrong-smear {
  position: absolute;
  pointer-events: none;
  z-index: 2;
  background: linear-gradient(90deg, transparent, rgba(180, 40, 90, 0.18), transparent);
  mix-blend-mode: multiply;
}

.organ {
  position: fixed;
  top: 2.15rem;
  left: 0.75rem;
  z-index: 14;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.organ-mute {
  font-family: var(--serif-display);
  font-size: 0.58rem;
  letter-spacing: 0.16em;
  text-transform: lowercase;
  color: var(--gold-rot);
  background: transparent;
  border: 1px solid var(--gold-rot);
  padding: 0.28rem 0.5rem;
  min-height: 44px;
  min-width: 44px;
  cursor: pointer;
}

.organ-mute[aria-pressed="true"] {
  color: var(--gold);
  border-color: var(--gold);
}

.organ--await .organ-mute {
  color: var(--gold);
  border-color: var(--gold);
  animation: organ-pulse 1.8s ease-in-out infinite;
}

@keyframes organ-pulse {
  0%, 100% { opacity: 0.72; }
  50% { opacity: 1; }
}

.organ-vol {
  width: 72px;
  accent-color: var(--gold);
  height: 44px;
}

.cite {
  font-family: var(--serif-display);
  font-size: 0.58rem;
  letter-spacing: 0.16em;
  text-transform: lowercase;
  color: var(--gold-rot);
  background: transparent;
  border: 0;
  padding: 0.4rem 0.2rem;
  min-height: 44px;
  cursor: pointer;
}

.label-room p {
  font-family: var(--serif-lore);
  color: var(--bone);
  margin: 0.45rem 0;
}

.label-room .bio {
  font-family: var(--serif-display);
  letter-spacing: 0.14em;
  color: var(--gold);
  margin: 1.1rem 0 1.2rem;
}

.label-room .acts {
  justify-content: flex-start;
}

.viewer-room {
  width: min(1100px, 100%);
  margin: 0 auto;
  padding: 3.4rem 0.6rem 4.5rem;
  position: relative;
  z-index: 1;
}

.lamp {
  display: flex;
  gap: 0.5rem;
  margin: 0 0 0.7rem 0.2rem;
}

.lamp-btn {
  font-family: var(--serif-display);
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: lowercase;
  color: var(--gold-rot);
  background: transparent;
  border: 1px solid var(--gold-rot);
  padding: 0.45rem 0.7rem;
  min-height: 44px;
  cursor: pointer;
}

.lamp-btn.on {
  color: var(--gold-bright);
  border-color: var(--gold);
}

.viewer-frame {
  overflow: hidden;
  border: 1px solid var(--gold-rot);
  touch-action: none;
  background: #0a0404;
}

.viewer-plate {
  transform-origin: 50% 50%;
}

.viewer-plate img {
  width: 100%;
  height: auto;
  display: block;
  user-select: none;
}

.viewer-plate.raking img {
  filter: contrast(1.28) saturate(0.82) brightness(0.88);
}

.viewer-plate.raking::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    98deg,
    rgba(0, 0, 0, 0.58) 0%,
    transparent 36%,
    rgba(255, 220, 160, 0.14) 50%,
    transparent 68%,
    rgba(0, 0, 0, 0.38) 100%
  );
  pointer-events: none;
  mix-blend-mode: multiply;
}

.viewer-plate {
  position: relative;
}

@media (max-width: 720px) {
  body.page-altar {
    overflow: hidden;
    height: 100svh;
    height: 100dvh;
  }
  .page-altar .chapel-shell {
    height: 100svh;
    height: 100dvh;
    overflow: hidden;
    padding-top: 0;
  }
  .page-altar .altar-piece {
    position: absolute;
    inset: 0;
    max-width: none;
    max-height: none;
    overflow: hidden;
    touch-action: manipulation;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
  }
  .page-altar .altar-fit {
    position: relative;
    max-width: 100%;
    max-height: 100svh;
    max-height: 100dvh;
    width: min(100%, calc(100svh * 1536 / 1024));
    width: min(100%, calc(100dvh * 1536 / 1024));
    aspect-ratio: 1536 / 1024;
    padding: 0;
  }
  .page-altar .altar-fit img#seal {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    object-position: center;
  }
  .page-altar .altar-fit .hotspots {
    position: absolute;
    inset: 0;
  }
  /* Match desktop chrome: keep Icon clear; slim footer on phone */
  .page-altar .litany {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 0.45rem 0.55rem calc(0.55rem + env(safe-area-inset-bottom, 0px));
    background: linear-gradient(180deg, transparent 0%, rgba(12, 2, 3, 0.72) 42%, rgba(12, 2, 3, 0.9) 100%);
  }
  .page-altar .litany .bio {
    font-size: clamp(0.95rem, 4.2vw, 1.25rem);
    letter-spacing: 0.12em;
    margin: 0 0 0.35rem;
  }
  .page-altar .litany .inventory,
  .page-altar .litany .house-foot,
  .page-altar .litany .cite {
    display: none;
  }
  .page-altar .acts {
    gap: 0.35rem;
    flex-wrap: wrap;
    justify-content: center;
  }
  .page-altar .acts a {
    font-size: 0.58rem;
    padding: 0.45rem 0.65rem;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
  }
  .page-altar .masthead {
    top: 0.45rem;
    left: 0.55rem;
    font-size: 0.52rem;
    letter-spacing: 0.28em;
  }
  /* Same corner as desktop — was overlapping footer at bottom */
  .organ {
    top: 2.1rem;
    bottom: auto;
    left: 0.55rem;
  }
  .organ-vol {
    width: 56px;
  }
  .page-altar .latch-door {
    top: 0.5rem;
  }
  .votive {
    width: 48px;
  }
  /* Inner pages: readable column, no horizontal spill */
  body:not(.page-altar) {
    overflow-x: hidden;
  }
  body:not(.page-altar) .chapel-shell {
    padding-left: max(0.75rem, env(safe-area-inset-left));
    padding-right: max(0.75rem, env(safe-area-inset-right));
    box-sizing: border-box;
  }
  .acts a {
    font-size: 0.64rem;
    padding: 0.55rem 0.75rem;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }
}

/* registrar notices */

.notice-slip {
  margin: 1.6rem 0 0;
  max-width: 28rem;
  padding: 1.1rem 1.15rem 1rem;
  border: 1px solid var(--gold-rot);
  background: rgba(58, 6, 8, 0.55);
  box-shadow: inset 0 0 0 1px rgba(197, 160, 89, 0.08);
}

.notice-slip .slip-meta {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: var(--gold-rot);
  margin: 0 0 0.7rem;
}

.notice-slip .slip-title {
  font-family: var(--serif-display);
  font-size: 0.82rem;
  font-weight: 400;
  letter-spacing: 0.14em;
  text-transform: lowercase;
  color: var(--gold);
  margin: 0 0 0.65rem;
}

.notice-slip .slip-body {
  font-family: var(--serif-lore);
  font-size: 1.05rem;
  color: var(--ink);
  margin: 0 0 0.9rem;
}

.notice-slip .slip-foot {
  font-family: var(--serif-display);
  font-size: 0.58rem;
  letter-spacing: 0.16em;
  color: var(--mute);
  margin: 0;
}

/* src directory listing */

.src-room .dir-listing a {
  color: var(--gold);
}

.src-room .dir-listing a:hover {
  color: var(--gold-bright);
}
