:root {
  color-scheme: light;
  font-family: Georgia, serif;
  background: #f8efdc;
  color: #382e21;
}
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}
main, .explore { height: 100%; min-height: 0; }
.explore { position: relative; }
button { font: inherit; cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 3px solid #226052; outline-offset: 4px; }
.masthead {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #fcf5e6;
  border-bottom: 1px solid #dfd0b6;
}
.masthead-inner {
  max-width: 86rem;
  margin: auto;
  padding: .3rem clamp(.75rem, 3vw, 2.75rem);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
}
.masthead a, nav button { display: inline-flex; align-items: center; min-height: 44px; text-decoration: none; }
.masthead a:hover, nav button:hover { text-decoration: underline; text-underline-offset: .25em; }
.wordmark { font-weight: bold; font-size: clamp(1rem, 2vw, 1.25rem); }
nav { display: flex; gap: clamp(.75rem, 3vw, 1.75rem); color: #385649; }
nav a, nav button { font: 600 .9rem system-ui, sans-serif; }
nav button { color: inherit; background: transparent; border: 0; padding: 0; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}
h2 { margin: 0; }
.scene {
  position: relative;
  height: min(100%, calc(56.5vw - 16px));
  overflow: hidden;
  background: #d8bb79;
  container-type: size;
  touch-action: pinch-zoom;
}
.world {
  position: absolute;
  top: -8px;
  left: 50%;
  width: 104%;
  width: max(104%, min(calc(200cqh + 32px), 113%));
  aspect-ratio: 2;
  transform: translate(calc(-50% + var(--x, 0px)), var(--y, 0px));
}
.landscape, .foreground { position: absolute; width: 100%; height: 100%; inset: 0; user-select: none; pointer-events: none; }
.foreground {
  mask-image: linear-gradient(transparent 83%, black 98%);
  transform: translate(var(--near-x, 0px), var(--near-y, 0px));
}
.hotspot {
  position: absolute;
  z-index: 1;
  width: 48px;
  height: 48px;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 0;
  padding: 0;
  background: transparent;
}
.hotspot:focus-visible { outline-color: #fff8dc; }
.sparkles {
  position: relative;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  pointer-events: none;
}
.sparkles i {
  position: absolute;
  top: 50%;
  left: 50%;
  width: var(--size, 4px);
  height: var(--size, 4px);
  margin: calc(var(--size, 4px) / -2);
  border-radius: 50%;
  background: #fff3bc;
  box-shadow: 0 0 5px 1px #ffbb53;
  opacity: 0;
  animation: scatter var(--cycle, 4.8s) linear infinite;
  animation-delay: calc(var(--phase, 0s) + var(--offset, 0s));
}
.sparkles i:nth-child(1) { --dx: -19px; --dy: -15px; --offset: .09s; }
.sparkles i:nth-child(2) { --dx: -6px; --dy: -26px; --size: 6px; }
.sparkles i:nth-child(3) { --dx: 12px; --dy: -23px; --offset: .16s; }
.sparkles i:nth-child(4) { --dx: 23px; --dy: -5px; --offset: .03s; --size: 3px; }
.sparkles i:nth-child(5) { --dx: 16px; --dy: 12px; --offset: .21s; }
.sparkles i:nth-child(6) { --dx: -19px; --dy: 10px; --offset: .15s; --size: 3px; }
.sparkles i:nth-child(7) { --dx: -30px; --dy: -9px; --offset: .08s; --size: 3px; }
.sparkles i:nth-child(8) { --dx: -23px; --dy: -25px; --offset: .23s; }
.sparkles i:nth-child(9) { --dx: -15px; --dy: -33px; --offset: .04s; --size: 3px; }
.sparkles i:nth-child(10) { --dx: 4px; --dy: -34px; --offset: .13s; }
.sparkles i:nth-child(11) { --dx: 20px; --dy: -30px; --offset: .25s; --size: 3px; }
.sparkles i:nth-child(12) { --dx: 29px; --dy: -18px; --offset: .05s; }
.sparkles i:nth-child(13) { --dx: 33px; --dy: 2px; --offset: .19s; --size: 3px; }
.sparkles i:nth-child(14) { --dx: 24px; --dy: 9px; --offset: .27s; }
.sparkles i:nth-child(15) { --dx: 9px; --dy: 15px; --offset: .12s; --size: 3px; }
.sparkles i:nth-child(16) { --dx: -4px; --dy: 11px; --offset: .21s; }
.sparkles i:nth-child(17) { --dx: -12px; --dy: 17px; --offset: .06s; --size: 3px; }
.sparkles i:nth-child(18) { --dx: -29px; --dy: 5px; --offset: .24s; }
.sparkles i:nth-child(n+19) {
  --size: 2px;
  background: #fff9de;
  box-shadow: 0 0 3px 1px #ffbd69;
}
.sparkles i:nth-child(n+19):nth-child(odd) { --size: 1.25px; }
.sparkles i:nth-child(19) { --dx: -36px; --dy: -18px; --offset: .1s; }
.sparkles i:nth-child(20) { --dx: -32px; --dy: -31px; --offset: .18s; }
.sparkles i:nth-child(21) { --dx: -21px; --dy: -39px; --offset: .03s; }
.sparkles i:nth-child(22) { --dx: -10px; --dy: -37px; --offset: .24s; }
.sparkles i:nth-child(23) { --dx: 2px; --dy: -43px; --offset: .11s; }
.sparkles i:nth-child(24) { --dx: 14px; --dy: -36px; --offset: .28s; }
.sparkles i:nth-child(25) { --dx: 25px; --dy: -34px; --offset: .15s; }
.sparkles i:nth-child(26) { --dx: 35px; --dy: -24px; --offset: .06s; }
.sparkles i:nth-child(27) { --dx: 40px; --dy: -11px; --offset: .2s; }
.sparkles i:nth-child(28) { --dx: 37px; --dy: 11px; --offset: .12s; }
.sparkles i:nth-child(29) { --dx: 23px; --dy: 20px; --offset: .3s; }
.sparkles i:nth-child(30) { --dx: 1px; --dy: 19px; --offset: .17s; }
.sparkles i:nth-child(31) { --dx: -22px; --dy: 19px; --offset: .08s; }
.sparkles i:nth-child(32) { --dx: -39px; --dy: 6px; --offset: .26s; }
.door { left: 12.5%; top: 66%; }
.shutters { left: 90%; top: 62%; --cycle: 6.3s; --phase: -3.1s; }
@keyframes scatter {
  0% {
    opacity: 0;
    transform: translate(0, 0) scale(.55);
    animation-timing-function: ease-out;
  }
  9% {
    opacity: 1;
    transform: translate(calc(var(--dx) * 1.5), calc(var(--dy) * 1.35)) scale(1);
    animation-timing-function: ease-in;
  }
  35%, 100% {
    opacity: 0;
    transform: translate(calc(var(--dx) * 1.75), calc(var(--dy) * 1.35 + 30px)) scale(.35);
  }
}
h2 { font-weight: normal; font-size: clamp(1.75rem, 4vw, 2.5rem); }
.book-list { list-style: none; margin: 0; padding: .25rem 1rem 1rem; }
.book-list li { border-top: 1px solid #cfb98e; padding: .85rem 0; }
dialog {
  padding: 0;
  border: 1px solid #cfb98e;
  border-radius: .9rem;
  background: #fcf5e6;
  color: inherit;
  width: min(92vw, 37rem);
  max-height: 90dvh;
  box-shadow: 0 1rem 4rem #1f1a1a65;
}
dialog[open] { animation: appear .24s ease-out; }
dialog::backdrop { background: #231c14ad; }
@keyframes appear { from { opacity: 0; transform: translateY(8px); } }
.dialog-top { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .7rem 1rem; }
.dialog-top button { background: #385649; color: #fff6dc; border: 0; border-radius: 2rem; padding: .55rem .8rem; min-height: 44px; }
.room-art { display: block; width: 100%; height: auto; max-height: 72dvh; object-fit: cover; }
.neighbor-art { aspect-ratio: 1.6; background: url(assets/mouse-town.jpg) 100% 68% / 490% auto no-repeat; }
.pane-controls, .pane-stop { display: none; }
@media (max-width: 650px) and (orientation: portrait) {
  .explore { --scene-height: min(100%, 125vw); }
  .scene {
    height: var(--scene-height);
    overflow-x: auto;
    scrollbar-width: none;
    scroll-snap-type: x mandatory;
    touch-action: pan-x pinch-zoom;
  }
  .scene::-webkit-scrollbar { display: none; }
  .world {
    top: 0;
    left: 0;
    width: 250%;
    transform: none;
  }
  .foreground { display: none; }
  .pane-stop {
    display: block;
    position: absolute;
    top: 0;
    width: 1px;
    height: 1px;
    pointer-events: none;
  }
  .pane-start { left: 0; scroll-snap-align: start; }
  .pane-middle { left: calc(50% - .5px); scroll-snap-align: center; }
  .pane-end { right: 0; scroll-snap-align: end; }
  .pane-controls {
    position: absolute;
    inset: 0 0 auto;
    height: var(--scene-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-inline: .5rem;
    pointer-events: none;
  }
  .pane-controls button {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    color: #fff6dc;
    background: #382e21df;
    border: 1px solid #fff6dc99;
    border-radius: 50%;
    pointer-events: auto;
  }
  .pane-controls button:disabled { visibility: hidden; }
  .pane-controls button::before {
    content: '';
    width: 11px;
    height: 11px;
    border-block-start: 2px solid;
    border-inline-end: 2px solid;
    transform: translateX(-2px) rotate(45deg);
  }
  .pane-controls button:first-child::before {
    transform: translateX(2px) rotate(-135deg);
  }
}
@media (prefers-reduced-motion: reduce) {
  .sparkles i, dialog[open] { animation: none; }
  .sparkles i:nth-child(-n+6) {
    opacity: .9;
    transform: translate(var(--dx), var(--dy));
  }
}
