@font-face {
  font-family: "Fraunces";
  src: url("/fraunces.woff2?v=7f9d191d9993") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --wall: #E3B5A4;
  --wall-shade: #D7A593;
  --ink: #17352B;
  --trim: #F6EADF;
  --door: #1F6B52;
  --brass: #CFA144;
  --brass-hi: #F6DF9F;
  --brass-lo: #8C6420;
  --floor: #4A2B33;
  --floor-ink: #F6EADF;
  --glow: #FFD98A;
  --serif: "Fraunces", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}

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

html { height: 100%; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  grid-template-rows: 1fr auto;
  background: var(--wall);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1rem;
  line-height: 1.5;
  overflow-x: hidden;
}

button { font: inherit; color: inherit; }

/* ---------- wall ---------- */

.scene {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding: max(1.25rem, env(safe-area-inset-top)) 1rem 0;
  background: linear-gradient(var(--wall) 55%, var(--wall-shade));
}

.say {
  margin: 0 0 1rem;
  min-height: 3.6em;
  max-width: 22ch;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  text-align: center;
  font-size: clamp(1.5rem, 5.4vw, 2.5rem);
  font-weight: 560;
  line-height: 1.18;
  letter-spacing: -0.012em;
  text-wrap: balance;
  opacity: 0;
  transform: translateY(4px);
}
.say.in {
  opacity: 1;
  transform: none;
  transition: opacity .22s ease-out, transform .22s ease-out;
}

.enter {
  margin: -0.25rem 0 1rem;
  padding: .55rem 1.4rem;
  border-radius: 999px;
  background: var(--ink);
  color: var(--trim);
  font-size: 1.125rem;
  font-weight: 600;
  text-decoration: none;
}
.enter:hover { background: #0E221B; }

.wall {
  position: relative;
  line-height: 0;
}

.door {
  display: block;
  height: min(62vh, 640px);
  height: min(62svh, 640px);
  width: auto;
  max-width: 100%;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  overflow: visible;
}

.door [data-act] { cursor: pointer; }
.door .hitbox { fill: transparent; }
.door .focus {
  fill: none;
  stroke: var(--brass-hi);
  stroke-width: 3;
  stroke-dasharray: 7 5;
  visibility: hidden;
}
.door .hit { outline: none; }
.door .hit:focus-visible .focus { visibility: visible; }

.slab, .ring, .flap, .knob-top, .bell-btn {
  transform-box: fill-box;
}

.slab { transform-origin: 0 50%; transition: transform .9s cubic-bezier(.3, .7, .2, 1); }
.slab.shake { animation: shake .16s linear; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  30% { transform: translateX(1.6px); }
  70% { transform: translateX(-1.1px); }
}

.ring { transform-origin: 50% 0; }
.ring.swing { animation: swing .2s ease-in; }
@keyframes swing {
  0% { transform: scaleY(1); }
  35% { transform: translateY(-5px) scaleY(.74); }
  100% { transform: scaleY(1); }
}

.flap { transform-origin: 50% 0; transition: transform .18s ease-out; }
.flap.open { transform: scaleY(.22); }

.knob-top { transform-origin: 50% 50%; }
.knob-top.jiggle { animation: jiggle .3s ease-in-out; }
@keyframes jiggle {
  0%, 100% { transform: rotate(0); }
  25% { transform: rotate(-14deg); }
  75% { transform: rotate(12deg); }
}

.bell-btn { transform-origin: 50% 50%; }
.bell-btn.press { animation: press .18s ease-out; }
@keyframes press {
  40% { transform: scale(.8); }
}

.underlight { opacity: 0; transition: opacity 1.2s; }
.lit .underlight { opacity: 1; }

.ajar .slab { transform: scaleX(.9) skewY(-1.4deg); }
.open .slab { transform: scaleX(.16) skewY(-7deg); }
.ajar .underlight, .open .underlight { opacity: 0; }

/* ---------- sticker ---------- */

.sticker {
  position: absolute;
  top: 9%;
  right: 3%;
  width: clamp(4.25rem, 20%, 6rem);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #F2C230;
  box-shadow: 0 0 0 3px var(--trim), 1px 3px 0 3px rgba(74, 43, 51, .28);
  color: var(--ink);
  font-size: clamp(.7rem, 2.6vw, .95rem);
  font-weight: 700;
  line-height: 1;
  transform: rotate(-11deg);
}
.sticker[hidden] { display: none; }
.sticker.pop { animation: pop .4s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes pop {
  0% { transform: rotate(-30deg) scale(0); }
  100% { transform: rotate(-11deg) scale(1); }
}

/* ---------- floor ---------- */

.floor {
  position: relative;
  background: var(--floor);
  border-top: clamp(10px, 1.8vh, 16px) solid var(--trim);
  color: var(--floor-ink);
  text-align: center;
  padding: 0 1rem max(1rem, env(safe-area-inset-bottom));
}

.glow {
  position: absolute;
  top: 0;
  left: 50%;
  width: min(26rem, 90vw);
  height: 5.5rem;
  transform: translateX(-50%);
  background: radial-gradient(ellipse at 50% 0, rgba(255, 217, 138, .55), rgba(255, 217, 138, 0) 68%);
  opacity: 0;
  transition: opacity 1.2s;
  pointer-events: none;
}
.lit .glow { opacity: 1; }

.stoop {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 3.4rem;
}

.mat {
  position: relative;
  margin-top: .45rem;
  padding: .5rem 1.5rem .55rem;
  border: 0;
  border-radius: 3px;
  background: #B98D58;
  background-image: repeating-linear-gradient(90deg, rgba(90, 61, 30, .16) 0 2px, transparent 2px 5px);
  box-shadow: inset 0 0 0 3px #A07743;
  color: #3F2A12;
  font-size: clamp(.85rem, 3.2vw, 1rem);
  font-weight: 650;
  letter-spacing: .04em;
  cursor: pointer;
  transform: perspective(300px) rotateX(38deg);
  transform-origin: 50% 0;
}

.parcel {
  position: absolute;
  top: -1.9rem;
  left: calc(50% - min(11.5rem, 44vw));
  width: 3.6rem;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  line-height: 0;
}
.parcel[hidden] { display: none; }
.parcel svg { width: 100%; height: auto; filter: drop-shadow(0 3px 0 rgba(0, 0, 0, .25)); }

.note {
  position: absolute;
  top: -.4rem;
  left: 50%;
  z-index: 2;
  width: min(17rem, 78vw);
  padding: .9rem 1rem 1rem;
  border: 0;
  border-radius: 2px;
  background: #FFFDF6;
  box-shadow: 0 6px 0 rgba(0, 0, 0, .22);
  color: var(--ink);
  text-align: center;
  cursor: pointer;
  transform: translateX(-50%) rotate(-2.5deg);
}
.note[hidden] { display: none; }
.note.slide { animation: slide .6s cubic-bezier(.2, .9, .3, 1); }
@keyframes slide {
  0% { transform: translateX(-50%) translateY(-2.6rem) rotate(0) scaleY(.2); opacity: 0; }
  100% { transform: translateX(-50%) rotate(-2.5deg); opacity: 1; }
}
.note-big { display: block; font-size: 1.2rem; font-weight: 650; line-height: 1.25; }
.note-small { display: block; margin-top: .5rem; font-size: .875rem; line-height: 1.4; }
.note-small[hidden] { display: none; }

.tally {
  margin: .9rem auto 0;
  font-size: clamp(.95rem, 3.4vw, 1.0625rem);
  font-variant-numeric: tabular-nums;
}
.tally[hidden] { display: none; }
.tally b { font-weight: 700; color: var(--glow); }

.fine {
  margin: .6rem auto 0;
  max-width: 34rem;
  font-size: .8125rem;
  line-height: 1.5;
  color: rgba(246, 234, 223, .82);
}

.mute {
  margin-left: .35rem;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.floor button:focus-visible,
.enter:focus-visible,
.peek-close:focus-visible,
.slot-dialog button:focus-visible {
  outline: 3px dashed var(--brass-hi);
  outline-offset: 3px;
}

/* ---------- mail slot ---------- */

.slot-dialog {
  width: min(26rem, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  max-height: calc(100svh - 2rem);
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: #FFFDF6;
  color: var(--ink);
  box-shadow: 0 0 0 4px var(--brass), 0 18px 0 rgba(0, 0, 0, .22);
  overflow: auto;
}
.slot-dialog::backdrop { background: rgba(23, 53, 43, .62); }

.slot-dialog form { padding: 1.4rem 1.4rem 1.25rem; }
.slot-dialog h1 { margin: 0; font-size: 1.6rem; font-weight: 650; line-height: 1.15; letter-spacing: -.01em; }
.slot-lede { margin: .35rem 0 1.1rem; font-size: 1rem; }
.slot-dialog label { display: block; margin: .8rem 0 .25rem; font-size: .9375rem; font-weight: 600; }
.slot-dialog input,
.slot-dialog textarea {
  display: block;
  width: 100%;
  padding: .6rem .7rem;
  border: 2px solid var(--ink);
  border-radius: 3px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
}
.slot-dialog textarea { resize: vertical; min-height: 4.5rem; }
.slot-dialog input:focus-visible,
.slot-dialog textarea:focus-visible { outline: 3px solid var(--brass); outline-offset: 1px; }

.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.slot-error {
  margin: .9rem 0 0;
  padding: .55rem .7rem;
  border-left: 4px solid #A6352B;
  background: #FBE9E4;
  font-size: .9375rem;
}
.slot-error[hidden] { display: none; }

.slot-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: .6rem;
  margin-top: 1.2rem;
}
.slot-actions button {
  padding: .65rem 1.1rem;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--ink);
  color: var(--trim);
  font-weight: 600;
  cursor: pointer;
}
.slot-actions button.quiet { background: transparent; color: var(--ink); }
.slot-actions button[disabled] { opacity: .55; cursor: default; }

/* ---------- keyhole ---------- */

.peek {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.1rem;
  padding: 1.25rem;
  background: #0B0F0D;
  color: var(--trim);
  text-align: center;
}
.peek[hidden] { display: none; }

.peek-scene {
  position: relative;
  width: min(64vw, 40vh, 20rem);
  width: min(64vw, 40svh, 20rem);
  aspect-ratio: 2 / 3;
  overflow: hidden;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
  line-height: 1;
  animation: iris .35s ease-out;
}
@keyframes iris {
  0% { transform: scale(.82); opacity: 0; }
  100% { transform: none; opacity: 1; }
}

.peek-scene span { position: absolute; transform: translate(-50%, -50%); white-space: nowrap; }
.peek-scene .tile {
  inset: 0;
  transform: none;
  white-space: normal;
  word-break: break-all;
  text-align: center;
  line-height: 1.12;
  letter-spacing: .06em;
}
.peek-scene .bar { height: 3%; background: #6B4A2C; border-radius: 2px; }
.peek-scene .spot {
  width: 150%;
  height: 80%;
  background: radial-gradient(ellipse at 50% 0, rgba(255, 244, 200, .5), rgba(255, 244, 200, 0) 62%);
}
.peek-scene .hole {
  width: 22%;
  aspect-ratio: 2 / 3;
  background: #F6EADF;
  clip-path: polygon(50% 0, 78% 8%, 92% 30%, 78% 52%, 66% 56%, 84% 100%, 16% 100%, 34% 56%, 22% 52%, 8% 30%, 22% 8%);
}
.peek-scene .bob { animation: bob 1.6s ease-in-out infinite; }
.peek-scene .spin { animation: spin 5s linear infinite; }
.peek-scene .sway { animation: sway 2.4s ease-in-out infinite; }
.peek-scene .crawl { animation: crawl 14s linear infinite; }
@keyframes bob { 50% { margin-top: -5%; } }
@keyframes spin { to { rotate: 360deg; } }
@keyframes sway { 0%, 100% { rotate: -7deg; } 50% { rotate: 7deg; } }
@keyframes crawl { from { margin-left: 28%; } to { margin-left: -28%; } }

.peek-caption {
  margin: 0;
  max-width: 24ch;
  min-height: 3.6em;
  font-family: var(--serif);
  font-size: clamp(1.25rem, 4.6vw, 1.75rem);
  font-weight: 520;
  line-height: 1.22;
  text-wrap: balance;
}

.peek-close {
  padding: .6rem 1.3rem;
  border: 2px solid var(--trim);
  border-radius: 999px;
  background: transparent;
  color: var(--trim);
  font-family: var(--serif);
  font-weight: 600;
  cursor: pointer;
}

.defs { position: absolute; }
.noscript { margin: 0; padding: 1rem; background: var(--floor); color: var(--floor-ink); text-align: center; }

@media (max-height: 560px) {
  .say { min-height: 2.5em; margin-bottom: .5rem; font-size: 1.3rem; }
  .door { height: 56vh; height: 56svh; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* =====================================================================
   Second layer: evening light, more stickers, notes, the ledger.
   ===================================================================== */

.say { color: var(--say, var(--ink)); }
body { transition: background-color 1.5s; }

/* ---------- time of day ---------- */

.door .shade, .door .keyglow { pointer-events: none; opacity: 0; transition: opacity 1.5s; }

body.dusk { --wall: #D8A694; --wall-shade: #C48F82; }
body.dusk .door .shade { opacity: .14; }

body.night { --wall: #7D6068; --wall-shade: #6A4F59; --say: #F6EADF; }
body.night .door .shade { opacity: .4; }
body.night .floor { background: #38202A; border-top-color: #CBBDB4; }
body.night .sticker { filter: brightness(.8); }
body.night .mat, body.night .parcel { filter: brightness(.78); }
body.night .enter { background: var(--trim); color: var(--ink); }

body.night.lit .keyglow, body.dusk.lit .keyglow { opacity: .95; }
body.night.lit .underlight { animation: flicker 23s linear infinite; }
@keyframes flicker {
  0%, 61%, 63.2%, 100% { opacity: 1; }
  62% { opacity: .35; }
  62.6% { opacity: .9; }
  62.9% { opacity: .5; }
}
.underlight.blink { animation: blink .7s ease-in-out 1; }
@keyframes blink { 30% { opacity: .15; } 60% { opacity: 1; } }

/* a knocker that has seen some use hangs a little crooked */
.loose .ring { transform: rotate(4deg); }
.loose .ring.swing { animation: swing-loose .2s ease-in; }
@keyframes swing-loose {
  0% { transform: rotate(4deg) scaleY(1); }
  35% { transform: rotate(-2deg) translateY(-5px) scaleY(.74); }
  100% { transform: rotate(4deg) scaleY(1); }
}

/* ---------- stickers ---------- */

.sticker {
  padding: 0;
  border: 0;
  cursor: pointer;
  font-family: var(--serif);
}
.sticker.s-3 {
  top: 15%;
  right: auto;
  left: 1%;
  width: clamp(3.7rem, 18%, 5.2rem);
  aspect-ratio: 5 / 3;
  border-radius: 6px;
  background: var(--trim);
  box-shadow: 0 0 0 2px var(--ink), 1px 3px 0 3px rgba(74, 43, 51, .28);
  transform: rotate(7deg);
}
.sticker.s-7 {
  top: 33%;
  right: auto;
  left: 2.5%;
  width: clamp(3.5rem, 16.5%, 4.8rem);
  background: var(--floor);
  color: var(--trim);
  transform: rotate(-6deg);
}
.sticker.s-10 {
  top: 28%;
  right: .5%;
  width: clamp(3.9rem, 18.5%, 5.4rem);
  border-radius: 0;
  background: var(--brass);
  box-shadow: none;
  clip-path: polygon(50% 0, 61% 12%, 77% 6%, 80% 23%, 96% 27%, 89% 42%, 100% 55%, 86% 64%, 88% 81%, 71% 81%, 62% 96%, 50% 86%, 38% 96%, 29% 81%, 12% 81%, 14% 64%, 0 55%, 11% 42%, 4% 27%, 20% 23%, 23% 6%, 39% 12%);
  transform: rotate(9deg);
}
.sticker.s-3.pop { animation: pop3 .4s cubic-bezier(.2, 1.6, .4, 1); }
.sticker.s-7.pop { animation: pop7 .4s cubic-bezier(.2, 1.6, .4, 1); }
.sticker.s-10.pop { animation: pop10 .4s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes pop3 { 0% { transform: rotate(30deg) scale(0); } 100% { transform: rotate(7deg) scale(1); } }
@keyframes pop7 { 0% { transform: rotate(-30deg) scale(0); } 100% { transform: rotate(-6deg) scale(1); } }
@keyframes pop10 { 0% { transform: rotate(40deg) scale(0); } 100% { transform: rotate(9deg) scale(1); } }
.sticker:focus-visible { outline: 3px dashed var(--ink); outline-offset: 3px; }
body.night .sticker:focus-visible { outline-color: var(--brass-hi); }

/* ---------- mat ---------- */

.mat.lifted::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  border-style: solid;
  border-width: 0 0 .85rem .85rem;
  border-color: transparent transparent #6E4E28 transparent;
  background: var(--floor);
}
.mat.worn { background-image:
  radial-gradient(ellipse at 50% 60%, rgba(63, 42, 18, .22), transparent 62%),
  repeating-linear-gradient(90deg, rgba(90, 61, 30, .16) 0 2px, transparent 2px 5px); }

/* ---------- notes ---------- */

.note-big { white-space: pre-line; }
.note.plain .note-big { font-size: 1.08rem; font-weight: 560; }
.note.tilt-a { transform: translateX(-50%) rotate(1.8deg); }
.note.tilt-a.slide { animation: slide-a .6s cubic-bezier(.2, .9, .3, 1); }
@keyframes slide-a {
  0% { transform: translateX(-50%) translateY(-2.6rem) rotate(0) scaleY(.2); opacity: 0; }
  100% { transform: translateX(-50%) rotate(1.8deg); opacity: 1; }
}

/* ---------- under the mat ---------- */

.under-mat .paper { padding: 1.4rem 1.4rem 1.25rem; }
.under-mat h2 { margin: 1.3rem 0 .15rem; font-size: 1.15rem; font-weight: 650; line-height: 1.2; }
.under-mat p { margin: .3rem 0 0; }
.under-mat .quiet-line { font-size: .9375rem; color: #45605A; }

.ledger { margin: .7rem 0 0; padding: 0; list-style: none; border-top: 2px solid var(--ink); }
.ledger li {
  display: grid;
  grid-template-columns: 2.1rem 1fr auto;
  gap: .5rem;
  align-items: baseline;
  padding: .38rem 0;
  border-bottom: 1px solid #D9CFC0;
  font-variant-numeric: tabular-nums;
}
.ledger li.you { font-weight: 700; }
.ledger .rank { color: #45605A; }
.ledger .count { text-align: right; }

.kept { margin: .6rem 0 0; padding: 0; list-style: none; }
.kept li {
  margin: 0 0 .5rem;
  padding: .55rem .7rem;
  border-left: 3px solid var(--brass);
  background: #F7F1E4;
  font-size: .9875rem;
  line-height: 1.4;
  white-space: pre-line;
}
