/* Palette: mortuary slate, bone paper, dried-blood ink, candle amber. */
:root {
  --slate: #171310;
  --slate-soft: #221c17;
  --bone: #ece0c4;
  --bone-shade: #d8c9a5;
  --ink: #2b241d;
  --blood: #8e2f28;
  --candle: #c98d43;
  --thread: #6b5a44;
  --display: "IM Fell English", "Iowan Old Style", Georgia, serif;
  --type: "Special Elite", "Courier New", monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--slate);
  background-image: radial-gradient(
    ellipse 90% 55% at 50% -5%,
    rgba(201, 141, 67, 0.16),
    transparent 70%
  );
  color: var(--bone);
  font-family: var(--display);
  font-size: 19px;
  line-height: 1.55;
}

main, .masthead, .colophon {
  max-width: 700px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------- masthead ---------- */

.masthead { padding-top: 56px; text-align: center; }

.postmark {
  font-family: var(--type);
  font-size: 0.75rem;
  color: var(--candle);
  margin: 0 0 4px;
}

h1 {
  font-size: clamp(2.6rem, 9vw, 4.2rem);
  font-weight: 400;
  margin: 0 0 12px;
  letter-spacing: 0.01em;
  text-shadow: 0 0 32px rgba(201, 141, 67, 0.35);
}

.lede {
  font-style: italic;
  color: var(--bone-shade);
  max-width: 46ch;
  margin: 0 auto;
}

/* ---------- the locked door ---------- */

.gate {
  margin: 56px auto 24px;
  max-width: 420px;
  text-align: center;
  border: 1px solid rgba(201, 141, 67, 0.3);
  border-radius: 6px;
  background: var(--slate-soft);
  padding: 34px 28px;
}

.gate h2 {
  font-family: var(--display);
  font-weight: 400;
  font-size: 1.9rem;
  margin: 0 0 8px;
  color: var(--bone-shade);
}

.gate p {
  font-family: var(--type);
  font-size: 0.82rem;
  color: var(--candle);
  margin: 0 0 22px;
}

.gate form {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

#gate-code {
  width: 7.5ch;
  font-family: var(--type);
  font-size: 1.6rem;
  letter-spacing: 0.45em;
  text-align: center;
  color: var(--bone);
  background: var(--slate);
  border: 2px solid var(--thread);
  border-radius: 4px;
  padding: 6px 0 6px 0.45em;
}
#gate-code:focus {
  outline: none;
  border-color: var(--candle);
}

.gate button {
  font-family: var(--type);
  font-size: 0.9rem;
  color: var(--slate);
  background: var(--candle);
  border: 0;
  border-radius: 4px;
  padding: 10px 18px;
  cursor: pointer;
}
.gate button:hover { background: var(--bone-shade); }
.gate button:focus-visible,
#gate-code:focus-visible {
  outline: 2px solid var(--candle);
  outline-offset: 2px;
}

.gate .miss { margin-top: 14px; color: #d06a5f; }

/* ---------- ledger line ---------- */

.ledger {
  font-family: var(--type);
  font-size: 0.85rem;
  color: var(--candle);
  text-align: center;
  margin: 44px 0 28px;
  border-top: 1px solid rgba(201, 141, 67, 0.35);
  border-bottom: 1px solid rgba(201, 141, 67, 0.35);
  padding: 8px 0;
}

/* ---------- toe-tags ---------- */

.tags {
  display: flex;
  flex-direction: column;
  gap: 34px;
  padding-bottom: 12px;
}

.tag {
  position: relative;
  background: var(--bone);
  color: var(--ink);
  font-family: var(--type);
  padding: 26px 28px 24px 66px;
  border-radius: 4px 14px 14px 4px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.55);
  transform: rotate(-0.7deg);
}
.tag:nth-child(even) { transform: rotate(0.6deg); }

/* punched hole + string */
.tag::before {
  content: "";
  position: absolute;
  left: 22px;
  top: 50%;
  width: 16px;
  height: 16px;
  margin-top: -8px;
  border-radius: 50%;
  background: var(--slate);
  box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.6), 0 0 0 4px var(--bone-shade);
}
.tag::after {
  content: "";
  position: absolute;
  left: -26px;
  top: 50%;
  width: 40px;
  height: 34px;
  border-left: 2px solid var(--thread);
  border-bottom: 2px solid var(--thread);
  border-radius: 0 0 0 100%;
  transform: translateY(-30px);
  pointer-events: none;
}

.tag-exhibit {
  font-size: 0.7rem;
  color: var(--blood);
  margin: 0;
}

.tag h2 {
  font-family: var(--display);
  font-size: 1.7rem;
  font-weight: 400;
  margin: 2px 0 10px;
  border-bottom: 1px dashed var(--thread);
  padding-bottom: 8px;
}

.tag .riddle {
  font-size: 0.92rem;
  margin: 0 0 18px;
}

.tag form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.tag label {
  flex: 1 1 200px;
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 0.85rem;
}

.tag input {
  flex: 1;
  min-width: 0;
  font-family: var(--type);
  font-size: 1rem;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-bottom: 2px solid var(--thread);
  padding: 2px 4px;
}
.tag input:focus {
  outline: none;
  border-bottom-color: var(--blood);
  background: rgba(142, 47, 40, 0.07);
}

.tag button {
  font-family: var(--type);
  font-size: 0.85rem;
  color: var(--bone);
  background: var(--ink);
  border: 0;
  border-radius: 3px;
  padding: 8px 16px;
  cursor: pointer;
}
.tag button:hover { background: var(--blood); }
.tag button:focus-visible,
.tag input:focus-visible {
  outline: 2px solid var(--blood);
  outline-offset: 2px;
}

.miss {
  width: 100%;
  color: var(--blood);
  font-size: 0.8rem;
  margin: 8px 0 0;
}

/* solved state */
.tag.is-solved .riddle { opacity: 0.55; }

.named {
  font-size: 0.95rem;
  margin: 0;
}
.named b { color: var(--blood); }

.stamp {
  position: absolute;
  right: 18px;
  top: 12px;
  font-family: var(--type);
  font-size: 1.05rem;
  letter-spacing: 0.12em;
  color: var(--blood);
  border: 3px double var(--blood);
  border-radius: 4px;
  padding: 3px 10px;
  transform: rotate(7deg);
  opacity: 0.85;
  mix-blend-mode: multiply;
}

@keyframes stamp-in {
  0% { transform: rotate(7deg) scale(2.4); opacity: 0; }
  70% { transform: rotate(7deg) scale(0.95); opacity: 0.9; }
  100% { transform: rotate(7deg) scale(1); opacity: 0.85; }
}
.tag.just-solved .stamp { animation: stamp-in 0.45s ease-out both; }

/* ---------- the crypt / video ---------- */

.crypt {
  margin: 44px 0 24px;
  border: 1px solid rgba(201, 141, 67, 0.3);
  border-radius: 6px;
  padding: 34px 26px;
  text-align: center;
  background: var(--slate-soft);
}

.crypt h2 {
  font-family: var(--display);
  font-weight: 400;
  font-size: 2rem;
  margin: 0 0 8px;
}

.crypt-locked h2 { color: var(--bone-shade); }
.crypt-locked p {
  font-family: var(--type);
  font-size: 0.85rem;
  color: var(--candle);
  margin: 0;
}

.crypt-open h2 {
  color: var(--candle);
  text-shadow: 0 0 24px rgba(201, 141, 67, 0.5);
}

.crypt-open p {
  font-family: var(--type);
  font-size: 0.85rem;
  color: var(--bone-shade);
  margin: 0 0 20px;
}

#watch {
  font-family: var(--type);
  font-size: 0.95rem;
  color: var(--slate);
  background: var(--candle);
  border: 0;
  border-radius: 4px;
  padding: 12px 22px;
  cursor: pointer;
}
#watch:hover { background: var(--bone-shade); }
#watch:focus-visible {
  outline: 2px solid var(--candle);
  outline-offset: 2px;
}

/* ---------- the awakening (fullscreen film) ---------- */

.awakening {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.5s ease;
}
.awakening[hidden] { display: none; }
.awakening.show { opacity: 1; }

.awakening-title {
  position: absolute;
  margin: 0;
  padding: 0 20px;
  font-family: var(--display);
  font-size: clamp(3rem, 11vw, 5.5rem);
  color: var(--bone);
  text-shadow: 0 0 46px rgba(201, 141, 67, 0.65);
  opacity: 0;
  pointer-events: none;
}
.awakening.show:not(.play) .awakening-title {
  animation: title-burn 2.4s ease forwards;
}
@keyframes title-burn {
  0% { opacity: 0; transform: scale(0.92); letter-spacing: 0.02em; }
  30% { opacity: 1; }
  75% { opacity: 1; transform: scale(1); letter-spacing: 0.06em; }
  100% { opacity: 0; transform: scale(1.03); }
}

.awakening video {
  width: 100vw;
  height: 100vh;
  object-fit: contain;
  background: #000;
  opacity: 0;
  transition: opacity 0.8s ease;
}
.awakening.play video { opacity: 1; }

#press-play {
  position: absolute;
  font-family: var(--type);
  font-size: 1.1rem;
  color: var(--bone);
  background: rgba(23, 19, 16, 0.85);
  border: 2px solid var(--candle);
  border-radius: 6px;
  padding: 16px 30px;
  cursor: pointer;
}
#press-play:hover { background: var(--blood); }

#awakening-close {
  position: absolute;
  top: 10px;
  right: 16px;
  font-size: 2.2rem;
  line-height: 1;
  color: var(--bone-shade);
  background: none;
  border: 0;
  padding: 8px;
  cursor: pointer;
}
#awakening-close:hover { color: var(--bone); }
#press-play:focus-visible,
#awakening-close:focus-visible {
  outline: 2px solid var(--candle);
  outline-offset: 2px;
}

/* the one flicker moment when the fourth tag is stamped */
@keyframes lightning {
  0%, 12%, 24%, 100% { filter: none; }
  6%, 18% { filter: invert(1) brightness(1.6); }
}
body.flicker { animation: lightning 0.9s steps(1) 1; }

/* ---------- colophon ---------- */

.colophon {
  text-align: center;
  font-style: italic;
  color: var(--thread);
  font-size: 0.9rem;
  padding-bottom: 48px;
}

@media (prefers-reduced-motion: reduce) {
  body.flicker { animation: none; }
  .tag.just-solved .stamp { animation: none; }
  .awakening.show:not(.play) .awakening-title { animation: none; }
  .awakening, .awakening video { transition: none; }
}

@media (max-width: 540px) {
  .tag, .tag:nth-child(even) { transform: none; padding-left: 56px; }
  .tag::after { display: none; }
  .tag::before { left: 18px; }
}
